* Remove unused now TcpNoDelay config option. Patch provided by TonyMontana5000.

* Fixed: move includes to prevent fail rebuild WorldSocket.cpp.
 * Apply code style to WorldSocket.* and WorldSocketMgr.cpp
This commit is contained in:
vladimir-mangos 2008-10-17 06:30:08 +04:00
parent 245f868521
commit 398b5535b7
6 changed files with 343 additions and 350 deletions

View file

@ -558,7 +558,6 @@ void World::LoadConfigSettings(bool reload)
else
m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME);
m_configs[CONFIG_TCP_NO_DELAY] = sConfig.GetBoolDefault("TcpNoDelay", false);
m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74);
/// \todo Add MonsterSight and GuarderSight (with meaning) in mangosd.conf or put them as define
m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50);

View file

@ -146,7 +146,6 @@ enum WorldConfigs
CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL,
CONFIG_TALENTS_INSPECTING,
CONFIG_CHAT_FAKE_MESSAGE_PREVENTING,
CONFIG_TCP_NO_DELAY,
CONFIG_CORPSE_DECAY_NORMAL,
CONFIG_CORPSE_DECAY_RARE,
CONFIG_CORPSE_DECAY_ELITE,

View file

@ -16,8 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
#include "WorldSocket.h"
#include <ace/Message_Block.h>
#include <ace/OS_NS_string.h>
#include <ace/OS_NS_unistd.h>
@ -29,6 +27,9 @@
#include <ace/Reactor.h>
#include <ace/Auto_Ptr.h>
#include "WorldSocket.h"
#include "Common.h"
#include "Util.h"
#include "World.h"
#include "WorldPacket.h"

View file

@ -88,7 +88,7 @@ typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> WorldHandler;
*/
class WorldSocket : protected WorldHandler
{
public:
public:
/// Declare some friends
friend class ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR >;
friend class WorldSocketMgr;
@ -124,7 +124,7 @@ public:
/// Remove refference to this object.
long RemoveReference (void);
protected:
protected:
/// things called by ACE framework.
WorldSocket (void);
virtual ~WorldSocket (void);
@ -148,7 +148,7 @@ protected:
/// Called by WorldSocketMgr/ReactorRunnable.
int Update (void);
private:
private:
/// Helper functions for processing incoming data.
int handle_input_header (void);
int handle_input_payload (void);
@ -179,7 +179,7 @@ private:
/// to mark the socket for output ).
bool iFlushPacketQueue ();
private:
private:
/// Time in which the last ping was received
ACE_Time_Value m_LastPingTime;

View file

@ -1,25 +1,25 @@
/*
* Copyright (C) 2005-2008,2007 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
* Copyright (C) 2005-2008,2007 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file WorldSocketMgr.cpp
* \ingroup u2w
* \author Derex <derex101@gmail.com>
*/
* \ingroup u2w
* \author Derex <derex101@gmail.com>
*/
#include "WorldSocketMgr.h"
@ -45,13 +45,13 @@
#include "WorldSocket.h"
/**
* This is a helper class to WorldSocketMgr ,that manages
* network threads, and assigning connections from acceptor thread
* to other network threads
*/
* This is a helper class to WorldSocketMgr ,that manages
* network threads, and assigning connections from acceptor thread
* to other network threads
*/
class ReactorRunnable : protected ACE_Task_Base
{
public:
public:
ReactorRunnable () :
m_ThreadId (-1),
@ -60,21 +60,24 @@ public:
{
ACE_Reactor_Impl* imp = 0;
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
imp = new ACE_Dev_Poll_Reactor ();
imp->max_notify_iterations (128);
imp->restart (1);
#else
#else
imp = new ACE_TP_Reactor ();
imp->max_notify_iterations (128);
#endif
#endif
m_Reactor = new ACE_Reactor (imp, 1);
}
virtual
~ReactorRunnable ()
virtual ~ReactorRunnable ()
{
this->Stop ();
this->Wait ();
@ -83,14 +86,12 @@ public:
delete m_Reactor;
}
void
Stop ()
void Stop ()
{
m_Reactor->end_reactor_event_loop ();
}
int
Start ()
int Start ()
{
if (m_ThreadId != -1)
return -1;
@ -98,20 +99,14 @@ public:
return (m_ThreadId = this->activate ());
}
void
Wait ()
{
ACE_Task_Base::wait ();
}
void Wait () { ACE_Task_Base::wait (); }
long
Connections ()
long Connections ()
{
return static_cast<long> (m_Connections.value ());
}
int
AddSocket (WorldSocket* sock)
int AddSocket (WorldSocket* sock)
{
ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1);
@ -128,10 +123,9 @@ public:
return m_Reactor;
}
protected:
protected:
void
AddNewSockets ()
void AddNewSockets ()
{
ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock);
@ -154,8 +148,7 @@ protected:
m_NewSockets.clear ();
}
virtual int
svc (void)
virtual int svc ()
{
DEBUG_LOG ("Network Thread Starting");
@ -199,7 +192,7 @@ protected:
return 0;
}
private:
private:
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, long> AtomicInt;
typedef std::set<WorldSocket*> SocketSet;
@ -213,15 +206,15 @@ private:
ACE_Thread_Mutex m_NewSockets_Lock;
};
WorldSocketMgr::WorldSocketMgr () :
m_NetThreadsCount (0),
m_NetThreads (0),
m_SockOutKBuff (-1),
m_SockOutUBuff (65536),
m_UseNoDelay (true),
m_Acceptor (0) {}
m_NetThreadsCount (0),
m_NetThreads (0),
m_SockOutKBuff (-1),
m_SockOutUBuff (65536),
m_UseNoDelay (true),
m_Acceptor (0)
{
}
WorldSocketMgr::~WorldSocketMgr ()
{
@ -251,7 +244,8 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
sLog.outBasic ("Max alowed socket connections %d",ACE::max_handles ());
m_SockOutKBuff = sConfig.GetIntDefault ("Network.OutKBuff", -1); // -1 means use default
// -1 means use default
m_SockOutKBuff = sConfig.GetIntDefault ("Network.OutKBuff", -1);
m_SockOutUBuff = sConfig.GetIntDefault ("Network.OutUBuff", 65536);
@ -325,6 +319,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
{
// set some options here
if (m_SockOutKBuff >= 0)
{
if (sock->peer ().set_option (SOL_SOCKET,
SO_SNDBUF,
(void*) & m_SockOutKBuff,
@ -333,19 +328,22 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF");
return -1;
}
}
static const int ndoption = 1;
// Set TCP_NODELAY.
if (m_UseNoDelay)
{
if (sock->peer ().set_option (ACE_IPPROTO_TCP,
TCP_NODELAY,
(void*) & ndoption,
(void*)&ndoption,
sizeof (int)) == -1)
{
sLog.outError ("WorldSocketMgr::OnSocketOpen: peer ().set_option TCP_NODELAY errno = %s", ACE_OS::strerror (errno));
return -1;
}
}
sock->m_OutBufferSize = static_cast<size_t> (m_SockOutUBuff);

View file

@ -70,11 +70,6 @@ BindIP = "0.0.0.0"
# Default: 1 (speed)
# 9 (best compression)
#
# TcpNoDelay
# TCP Nagle algorithm setting
# Default: 0 (enable Nagle algorithm, less traffic, more latency)
# 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency)
#
# PlayerLimit
# Maximum number of players in the world. Excluding Mods, GM's and Admins
# Default: 100
@ -1026,24 +1021,25 @@ Death.CorpseReclaimDelay.PvE = 1
###################################################################################################################
#
# Network config
# NETWORK CONFIG
#
# Threads: Number of threads for network, recommend 1 thread per 1000 connections.
# Network.Threads
# Number of threads for network, recommend 1 thread per 1000 connections.
# Default: 1
#
# OutKBuff: The size of the output kernel buffer used ( SO_SNDBUF socket option, tcp manual ).
# Network.OutKBuff
# The size of the output kernel buffer used ( SO_SNDBUF socket option, tcp manual ).
# Default: -1 (Use system default setting)
#
# OutUBuff: Userspace buffer for output. This is amount of memory reserved per each connection.
# Network.OutUBuff
# Userspace buffer for output. This is amount of memory reserved per each connection.
# Default: 65536
#
# TcpNoDelay:
# Network.TcpNoDelay:
# TCP Nagle algorithm setting
# Default: 0 (enable Nagle algorithm, less traffic, more latency)
# 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency)
#
#
#
###################################################################################################################
Network.Threads = 1