* 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 else
m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 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); 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 /// \todo Add MonsterSight and GuarderSight (with meaning) in mangosd.conf or put them as define
m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50);

View file

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

View file

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

View file

@ -61,20 +61,23 @@ public:
ACE_Reactor_Impl* imp = 0; 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 = new ACE_Dev_Poll_Reactor ();
imp->max_notify_iterations (128); imp->max_notify_iterations (128);
imp->restart (1); imp->restart (1);
#else #else
imp = new ACE_TP_Reactor (); imp = new ACE_TP_Reactor ();
imp->max_notify_iterations (128); imp->max_notify_iterations (128);
#endif #endif
m_Reactor = new ACE_Reactor (imp, 1); m_Reactor = new ACE_Reactor (imp, 1);
} }
virtual virtual ~ReactorRunnable ()
~ReactorRunnable ()
{ {
this->Stop (); this->Stop ();
this->Wait (); this->Wait ();
@ -83,14 +86,12 @@ public:
delete m_Reactor; delete m_Reactor;
} }
void void Stop ()
Stop ()
{ {
m_Reactor->end_reactor_event_loop (); m_Reactor->end_reactor_event_loop ();
} }
int int Start ()
Start ()
{ {
if (m_ThreadId != -1) if (m_ThreadId != -1)
return -1; return -1;
@ -98,20 +99,14 @@ public:
return (m_ThreadId = this->activate ()); return (m_ThreadId = this->activate ());
} }
void void Wait () { ACE_Task_Base::wait (); }
Wait ()
{
ACE_Task_Base::wait ();
}
long long Connections ()
Connections ()
{ {
return static_cast<long> (m_Connections.value ()); return static_cast<long> (m_Connections.value ());
} }
int int AddSocket (WorldSocket* sock)
AddSocket (WorldSocket* sock)
{ {
ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1); ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1);
@ -130,8 +125,7 @@ public:
protected: protected:
void void AddNewSockets ()
AddNewSockets ()
{ {
ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock); ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock);
@ -154,8 +148,7 @@ protected:
m_NewSockets.clear (); m_NewSockets.clear ();
} }
virtual int virtual int svc ()
svc (void)
{ {
DEBUG_LOG ("Network Thread Starting"); DEBUG_LOG ("Network Thread Starting");
@ -213,15 +206,15 @@ private:
ACE_Thread_Mutex m_NewSockets_Lock; ACE_Thread_Mutex m_NewSockets_Lock;
}; };
WorldSocketMgr::WorldSocketMgr () : WorldSocketMgr::WorldSocketMgr () :
m_NetThreadsCount (0), m_NetThreadsCount (0),
m_NetThreads (0), m_NetThreads (0),
m_SockOutKBuff (-1), m_SockOutKBuff (-1),
m_SockOutUBuff (65536), m_SockOutUBuff (65536),
m_UseNoDelay (true), m_UseNoDelay (true),
m_Acceptor (0) {} m_Acceptor (0)
{
}
WorldSocketMgr::~WorldSocketMgr () WorldSocketMgr::~WorldSocketMgr ()
{ {
@ -251,7 +244,8 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
sLog.outBasic ("Max alowed socket connections %d",ACE::max_handles ()); 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); m_SockOutUBuff = sConfig.GetIntDefault ("Network.OutUBuff", 65536);
@ -325,6 +319,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
{ {
// set some options here // set some options here
if (m_SockOutKBuff >= 0) if (m_SockOutKBuff >= 0)
{
if (sock->peer ().set_option (SOL_SOCKET, if (sock->peer ().set_option (SOL_SOCKET,
SO_SNDBUF, SO_SNDBUF,
(void*) & m_SockOutKBuff, (void*) & m_SockOutKBuff,
@ -333,11 +328,13 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF"); sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF");
return -1; return -1;
} }
}
static const int ndoption = 1; static const int ndoption = 1;
// Set TCP_NODELAY. // Set TCP_NODELAY.
if (m_UseNoDelay) if (m_UseNoDelay)
{
if (sock->peer ().set_option (ACE_IPPROTO_TCP, if (sock->peer ().set_option (ACE_IPPROTO_TCP,
TCP_NODELAY, TCP_NODELAY,
(void*)&ndoption, (void*)&ndoption,
@ -346,6 +343,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
sLog.outError ("WorldSocketMgr::OnSocketOpen: peer ().set_option TCP_NODELAY errno = %s", ACE_OS::strerror (errno)); sLog.outError ("WorldSocketMgr::OnSocketOpen: peer ().set_option TCP_NODELAY errno = %s", ACE_OS::strerror (errno));
return -1; return -1;
} }
}
sock->m_OutBufferSize = static_cast<size_t> (m_SockOutUBuff); sock->m_OutBufferSize = static_cast<size_t> (m_SockOutUBuff);

View file

@ -70,11 +70,6 @@ BindIP = "0.0.0.0"
# Default: 1 (speed) # Default: 1 (speed)
# 9 (best compression) # 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 # PlayerLimit
# Maximum number of players in the world. Excluding Mods, GM's and Admins # Maximum number of players in the world. Excluding Mods, GM's and Admins
# Default: 100 # 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 # 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) # 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 # Default: 65536
# #
# TcpNoDelay: # Network.TcpNoDelay:
# TCP Nagle algorithm setting # TCP Nagle algorithm setting
# Default: 0 (enable Nagle algorithm, less traffic, more latency) # Default: 0 (enable Nagle algorithm, less traffic, more latency)
# 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency) # 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency)
# #
#
#
################################################################################################################### ###################################################################################################################
Network.Threads = 1 Network.Threads = 1