From 8e5abb189b9b2b978c92e8102e650372f8866cd0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 15 Jul 2010 18:14:44 -0700 Subject: [PATCH] add mutex for reconns too; log socket and ip addr connecting on it --- xwords4/relay/xwrelay.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index 6637b0f64..8f9ebac40 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -363,6 +363,9 @@ processReconnect( unsigned char* bufp, int bufLen, int socket ) && getNetShort( &bufp, end, &gameSeed ) && readStr( &bufp, end, connName, sizeof(connName) ) ) { + static pthread_mutex_t s_newCookieLock = PTHREAD_MUTEX_INITIALIZER; + MutexLock ml( &s_newCookieLock ); + SafeCref scr( cookie[0]? cookie : NULL, connName[0]? connName : NULL, srcID, socket, nPlayersH, @@ -903,8 +906,9 @@ main( int argc, char** argv ) int newSock = accept( listener, (sockaddr*)&newaddr, &siz ); - logf( XW_LOGINFO, "accepting connection from %s", - inet_ntoa(newaddr.sin_addr) ); + logf( XW_LOGINFO, + "accepting connection from %s on socket %d", + inet_ntoa(newaddr.sin_addr), newSock ); tPool->AddSocket( newSock ); --retval;