mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
* 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:
parent
245f868521
commit
398b5535b7
6 changed files with 343 additions and 350 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -61,20 +61,23 @@ public:
|
|||
ACE_Reactor_Impl* imp = 0;
|
||||
|
||||
#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
|
||||
|
||||
imp = new ACE_TP_Reactor ();
|
||||
imp->max_notify_iterations (128);
|
||||
|
||||
#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);
|
||||
|
||||
|
|
@ -130,8 +125,7 @@ public:
|
|||
|
||||
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");
|
||||
|
||||
|
|
@ -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_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,11 +328,13 @@ 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,
|
||||
|
|
@ -346,6 +343,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue