mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[11442] Cleanup codestyle in WorldSocketMgr.cpp & WorldSocketMgr.h
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
d0a0479749
commit
d98b9b9670
3 changed files with 97 additions and 114 deletions
|
|
@ -52,7 +52,6 @@
|
||||||
class ReactorRunnable : protected ACE_Task_Base
|
class ReactorRunnable : protected ACE_Task_Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ReactorRunnable() :
|
ReactorRunnable() :
|
||||||
m_Reactor (0),
|
m_Reactor (0),
|
||||||
m_Connections (0),
|
m_Connections (0),
|
||||||
|
|
@ -124,7 +123,6 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void AddNewSockets()
|
void AddNewSockets()
|
||||||
{
|
{
|
||||||
ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock);
|
ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock);
|
||||||
|
|
@ -225,8 +223,7 @@ WorldSocketMgr::~WorldSocketMgr ()
|
||||||
delete m_Acceptor;
|
delete m_Acceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
|
||||||
WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
|
|
||||||
{
|
{
|
||||||
m_UseNoDelay = sConfig.GetBoolDefault ("Network.TcpNodelay", true);
|
m_UseNoDelay = sConfig.GetBoolDefault ("Network.TcpNodelay", true);
|
||||||
|
|
||||||
|
|
@ -272,8 +269,7 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
|
||||||
WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
|
|
||||||
{
|
{
|
||||||
m_addr = address;
|
m_addr = address;
|
||||||
m_port = port;
|
m_port = port;
|
||||||
|
|
@ -287,8 +283,7 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void WorldSocketMgr::StopNetwork()
|
||||||
WorldSocketMgr::StopNetwork ()
|
|
||||||
{
|
{
|
||||||
if (m_Acceptor)
|
if (m_Acceptor)
|
||||||
{
|
{
|
||||||
|
|
@ -307,8 +302,7 @@ WorldSocketMgr::StopNetwork ()
|
||||||
Wait();
|
Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void WorldSocketMgr::Wait()
|
||||||
WorldSocketMgr::Wait ()
|
|
||||||
{
|
{
|
||||||
if (m_NetThreadsCount != 0)
|
if (m_NetThreadsCount != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -317,16 +311,12 @@ WorldSocketMgr::Wait ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int WorldSocketMgr::OnSocketOpen(WorldSocket* sock)
|
||||||
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, (void*)&m_SockOutKBuff, sizeof(int)) == -1 && errno != ENOTSUP)
|
||||||
SO_SNDBUF,
|
|
||||||
(void*) & m_SockOutKBuff,
|
|
||||||
sizeof (int)) == -1 && errno != ENOTSUP)
|
|
||||||
{
|
{
|
||||||
sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF");
|
sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -338,10 +328,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
|
||||||
// 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, (void*)&ndoption, sizeof (int)) == -1)
|
||||||
TCP_NODELAY,
|
|
||||||
(void*)&ndoption,
|
|
||||||
sizeof (int)) == -1)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
@ -362,8 +349,7 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
|
||||||
return m_NetThreads[min].AddSocket (sock);
|
return m_NetThreads[min].AddSocket (sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldSocketMgr*
|
WorldSocketMgr* WorldSocketMgr::Instance()
|
||||||
WorldSocketMgr::Instance ()
|
|
||||||
{
|
{
|
||||||
return ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>::instance();
|
return ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>::instance();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int OnSocketOpen(WorldSocket* sock);
|
int OnSocketOpen(WorldSocket* sock);
|
||||||
|
|
||||||
int StartReactiveIO(ACE_UINT16 port, const char* address);
|
int StartReactiveIO(ACE_UINT16 port, const char* address);
|
||||||
|
|
||||||
private:
|
|
||||||
WorldSocketMgr();
|
WorldSocketMgr();
|
||||||
virtual ~WorldSocketMgr();
|
virtual ~WorldSocketMgr();
|
||||||
|
|
||||||
|
|
@ -81,6 +79,5 @@ private:
|
||||||
|
|
||||||
#define sWorldSocketMgr WorldSocketMgr::Instance()
|
#define sWorldSocketMgr WorldSocketMgr::Instance()
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11441"
|
#define REVISION_NR "11442"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue