diff --git a/xwords4/relay/crefmgr.cpp b/xwords4/relay/crefmgr.cpp index 2e5e225a2..9592d869e 100644 --- a/xwords4/relay/crefmgr.cpp +++ b/xwords4/relay/crefmgr.cpp @@ -513,10 +513,10 @@ CRefMgr::AddNew( const char* cookie, const char* connName, CookieID id ) logf( XW_LOGINFO, "making new cref: %d", id ); if ( !!ref ) { - logf( XW_LOGINFO, "using from free list" ); + logf( XW_LOGVERBOSE1, "using from free list" ); ref->ReInit( cookie, connName, id ); } else { - logf( XW_LOGINFO, "calling constructor" ); + logf( XW_LOGVERBOSE1, "calling constructor" ); ref = new CookieRef( cookie, connName, id ); } diff --git a/xwords4/relay/http.cpp b/xwords4/relay/http.cpp index 827ea98aa..8c20da65c 100644 --- a/xwords4/relay/http.cpp +++ b/xwords4/relay/http.cpp @@ -197,14 +197,22 @@ printStats( FILE* fil, const CrefMgrInfo* info, bool isLocal ) fprintf( fil, "" ); } +class HttpInstance { + public: + HttpInstance( int sock, HttpState* state ) { + m_sock = sock; + m_state = state; + } + int m_sock; + HttpState* m_state; +}; + static void* http_thread_main( void* arg ) { - HttpState* state = (HttpState*)arg; - - sockaddr newaddr; - socklen_t siz = sizeof(newaddr); - int sock = accept( state->ctrl_sock, &newaddr, &siz ); + HttpInstance* inst = (HttpInstance*)arg; + HttpState* state = inst->m_state; + int sock = inst->m_sock; char buf[512]; ssize_t totalRead = 0; @@ -275,6 +283,8 @@ http_thread_main( void* arg ) } close( sock ); + delete inst; + return NULL; } /* http_thread_main */ @@ -282,13 +292,18 @@ void run_http_thread( HttpState* state ) { pthread_t thread; - int result = pthread_create( &thread, NULL, - http_thread_main, (void*)state ); + sockaddr newaddr; + socklen_t siz = sizeof(newaddr); + int sock = accept( state->ctrl_sock, &newaddr, &siz ); + + HttpInstance* inst = new HttpInstance( sock, state ); + int result = pthread_create( &thread, NULL, http_thread_main, + (void*)inst ); if ( 0 == result ) { pthread_detach( thread ); } else { - /* logf( XW_LOGERROR, "%s: pthread_create failed: %s", __func__, */ - /* strerror(errno) ); */ + logf( XW_LOGERROR, "%s: pthread_create failed: %s", __func__, + strerror(errno) ); } } /* run_http_thread */ diff --git a/xwords4/relay/tpool.cpp b/xwords4/relay/tpool.cpp index 434cc5dad..0f3055259 100644 --- a/xwords4/relay/tpool.cpp +++ b/xwords4/relay/tpool.cpp @@ -238,7 +238,9 @@ XWThreadPool::real_tpool_main() void XWThreadPool::interrupt_poll() { +#ifdef LOG_POLL logf( XW_LOGINFO, __func__ ); +#endif unsigned char byt = 0; int nSent = write( m_pipeWrite, &byt, 1 ); if ( nSent != 1 ) { @@ -304,7 +306,9 @@ XWThreadPool::real_listener() logf( XW_LOGINFO, "polling %s nmillis=%d", log, nMillis ); #endif int nEvents = poll( fds, nSockets, nMillis ); +#ifdef LOG_POLL logf( XW_LOGINFO, "back from poll: %d", nEvents ); +#endif if ( m_timeToDie ) { break; } @@ -317,7 +321,9 @@ XWThreadPool::real_listener() } if ( fds[0].revents != 0 ) { +#ifdef LOG_POLL logf( XW_LOGINFO, "poll interrupted" ); +#endif assert( fds[0].revents == POLLIN ); unsigned char byt; read( fds[0].fd, &byt, 1 );