From 3a0fc4a71ef4fab76cebc4bd154811d48700c3a5 Mon Sep 17 00:00:00 2001 From: lotodore Date: Wed, 31 Oct 2007 22:33:52 +0000 Subject: [PATCH] Also disable avatar retrieval on server. Fixed nasty send "wrong return value" (Linux only). --- src/net/common/clientstate.cpp | 2 +- src/net/common/receiverhelper.cpp | 2 +- src/net/common/senderthread.cpp | 4 +-- src/net/common/serverlobbythread.cpp | 6 ++-- src/net/socket_helper.h | 51 ++++++++++++++-------------- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index a1d6b856..1a195520 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -248,7 +248,7 @@ ClientStateStartConnect::Process(ClientThread &client) else { int errCode = SOCKET_ERRNO(); - if (errCode == SOCKET_ERR_WOULDBLOCK) + if (IS_SOCKET_ERR_WOULDBLOCK(errCode)) { boost::timers::portable::microsec_timer connectTimer; ClientStateConnecting::Instance().SetTimer(connectTimer); diff --git a/src/net/common/receiverhelper.cpp b/src/net/common/receiverhelper.cpp index 09dd990c..ffe4a928 100644 --- a/src/net/common/receiverhelper.cpp +++ b/src/net/common/receiverhelper.cpp @@ -66,7 +66,7 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf) if (!IS_VALID_RECV(bytesRecvd)) { int errCode = SOCKET_ERRNO(); - if (errCode != SOCKET_ERR_WOULDBLOCK) + if (!IS_SOCKET_ERR_WOULDBLOCK(errCode)) throw NetException(__FILE__, __LINE__, ERR_SOCK_RECV_FAILED, SOCKET_ERRNO()); } else if (bytesRecvd == 0) diff --git a/src/net/common/senderthread.cpp b/src/net/common/senderthread.cpp index f1ebe44d..4d71572f 100644 --- a/src/net/common/senderthread.cpp +++ b/src/net/common/senderthread.cpp @@ -178,7 +178,7 @@ SenderThread::Main() { // Never assume that this is a fatal error. int errCode = SOCKET_ERRNO(); - if (errCode == SOCKET_ERR_WOULDBLOCK) + if (IS_SOCKET_ERR_WOULDBLOCK(errCode)) { fd_set writeSet; struct timeval timeout; @@ -193,7 +193,7 @@ SenderThread::Main() { // Never assume that this is a fatal error. int errCode = SOCKET_ERRNO(); - if (errCode != SOCKET_ERR_WOULDBLOCK) + if (!IS_SOCKET_ERR_WOULDBLOCK(errCode)) { // Skip this packet - this is bad, and is therefore reported. // Ignore invalid or not connected sockets. diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 0b614ce0..1225b723 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -387,9 +387,9 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const NetPacketIn m_sessionManager.SetSessionPlayerData(session.sessionData->GetId(), tmpPlayerData); session.playerData = tmpPlayerData; - if (initData.showAvatar && !GetAvatarManager().HasAvatar(initData.avatar)) - RequestPlayerAvatar(session); - else +// if (initData.showAvatar && !GetAvatarManager().HasAvatar(initData.avatar)) +// RequestPlayerAvatar(session); +// else EstablishSession(session); } diff --git a/src/net/socket_helper.h b/src/net/socket_helper.h index 613942c6..25b95b0e 100644 --- a/src/net/socket_helper.h +++ b/src/net/socket_helper.h @@ -28,42 +28,43 @@ #endif #ifdef _WIN32 -#define CLOSESOCKET closesocket -#define IOCTLSOCKET ioctlsocket -#define SOCKET_ERRNO() WSAGetLastError() -#define SOCKET_ERR_WOULDBLOCK WSAEWOULDBLOCK -#define SOCKET_ERR_NOTCONN WSAENOTCONN -#define SOCKET_ERR_NOTSOCK WSAENOTSOCK -#define SOCKET_SEND_FLAGS 0 +#define CLOSESOCKET closesocket +#define IOCTLSOCKET ioctlsocket +#define SOCKET_ERRNO() WSAGetLastError() +#define IS_SOCKET_ERR_WOULDBLOCK(_e) ((_e) == WSAEWOULDBLOCK) +#define SOCKET_ERR_NOTCONN WSAENOTCONN +#define SOCKET_ERR_NOTSOCK WSAENOTSOCK +#define SOCKET_SEND_FLAGS 0 #ifndef IPV6_V6ONLY - #define IPV6_V6ONLY 27 + #define IPV6_V6ONLY 27 #endif #ifdef __GNUC__ /* mingw provides stdint.h */ #include - typedef uint16_t u_int16_t; - typedef uint32_t u_int32_t; + typedef uint16_t u_int16_t; + typedef uint32_t u_int32_t; #else - typedef unsigned __int16 u_int16_t; - typedef unsigned __int32 u_int32_t; - typedef __int16 int16_t; - typedef __int32 int32_t; + typedef unsigned __int16 u_int16_t; + typedef unsigned __int32 u_int32_t; + typedef __int16 int16_t; + typedef __int32 int32_t; #endif -typedef unsigned char u_char; +typedef unsigned char u_char; #else -#define SOCKET int -#define SOCKET_ERROR -1 -#define INVALID_SOCKET -1 -#define CLOSESOCKET close -#define SOCKET_ERRNO() errno -#define IOCTLSOCKET ioctl -#define SOCKET_ERR_WOULDBLOCK EINPROGRESS -#define SOCKET_ERR_NOTCONN ENOTCONN -#define SOCKET_ERR_NOTSOCK ENOTSOCK -#define SOCKET_SEND_FLAGS MSG_NOSIGNAL +#define SOCKET int +#define SOCKET_ERROR -1 +#define INVALID_SOCKET -1 +#define CLOSESOCKET close +#define SOCKET_ERRNO() errno +#define IOCTLSOCKET ioctl +#define SOCKET_ERR_NOTCONN ENOTCONN +#define SOCKET_ERR_NOTSOCK ENOTSOCK +#define SOCKET_SEND_FLAGS MSG_NOSIGNAL + +#define IS_SOCKET_ERR_WOULDBLOCK(_e) ((_e) == EINPROGRESS || (_e) == EAGAIN) #endif