Fixed a very nasty bug concerning the sender thread. SOCKETs were assumed to be kind of unique, but Windows tends to return the socket number of a socket which was just closed as new socket number in accept. This led to very strange behavior when the server was flooded with inits, because the sender thread still had entries for this socket number (which were not removed because they should just fail).
No longer use socket as key in maps, instead, use the session id. Only use the session id in the sender thread, "resolve" it to the socket only in the moment when it is needed. Outstanding requests will be detected to have an invalid session id then. Also, as side effect, fixed an issue with two callback classes which were named the same and caused unexpected behavior.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include <net/clientcontext.h>
|
||||
|
||||
ClientContext::ClientContext()
|
||||
: m_sockfd(INVALID_SOCKET), m_protocol(0), m_addrFamily(AF_INET), m_serverPort(0)
|
||||
: m_sockfd(INVALID_SOCKET), m_sessionId(SESSION_ID_GENERIC), m_protocol(0), m_addrFamily(AF_INET), m_serverPort(0)
|
||||
{
|
||||
bzero(&m_clientSockaddr, sizeof(m_clientSockaddr));
|
||||
}
|
||||
@@ -37,13 +37,6 @@ ClientContext::GetSocket() const
|
||||
return m_sockfd;
|
||||
}
|
||||
|
||||
u_int32_t
|
||||
ClientContext::GetId() const
|
||||
{
|
||||
// Id is unused for clients.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ClientContext::SetSocket(SOCKET sockfd)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user