X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnntp%2Fnntplistener.cpp;h=01fa442c8a4c5d6a1c5be07d2a9ed9fdffb8d737;hb=63376b2a82c3f6cdf2df56b1f134bd7df0aaab3a;hp=26f68bc035b169f7c841d16f6024ee22629a5723;hpb=c7fcb4c4bc5012a584add81a9509fc1f84c3c688;p=fms.git diff --git a/src/nntp/nntplistener.cpp b/src/nntp/nntplistener.cpp index 26f68bc..01fa442 100644 --- a/src/nntp/nntplistener.cpp +++ b/src/nntp/nntplistener.cpp @@ -75,11 +75,12 @@ void NNTPListener::Run() newsock=accept((*listeni),(struct sockaddr *)&addr,&addrlen); LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_INFO,"NNTPListener::run NNTP client connected"); //m_connections.execute(new NNTPConnection(newsock)); - m_connectionthreads.push_back(new PThread::Thread(new NNTPConnection(newsock))); + //m_connectionthreads.push_back(new PThread::Thread(new NNTPConnection(newsock))); + m_connections.Execute(new NNTPConnection(newsock)); } } } - +/* // check for any non-running connection threads that we can delete for(std::vector::iterator i=m_connectionthreads.begin(); i!=m_connectionthreads.end(); ) { @@ -93,6 +94,7 @@ void NNTPListener::Run() i++; } } +*/ //}while(!ZThread::Thread::interrupted() && m_listensockets.size()>0); }while(!IsCancelled() && m_listensockets.size()>0); @@ -116,6 +118,7 @@ void NNTPListener::Run() } } */ + /* for(std::vector::iterator i=m_connectionthreads.begin(); i!=m_connectionthreads.end(); i++) { if((*i)->IsRunning()) @@ -126,6 +129,9 @@ void NNTPListener::Run() } delete (*i); } + */ + m_connections.Cancel(); + m_connections.Join(); for(listeni=m_listensockets.begin(); listeni!=m_listensockets.end(); listeni++) { @@ -137,6 +143,8 @@ void NNTPListener::Run() } m_listensockets.clear(); + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"NNTPListener::run thread exiting."); + } void NNTPListener::StartListen() @@ -176,6 +184,10 @@ void NNTPListener::StartListen() sock=socket(current->ai_family,current->ai_socktype,current->ai_protocol); if(sock!=INVALID_SOCKET) { + #ifndef _WIN32 + const char optval='1'; + setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&optval,1); + #endif if(bind(sock,current->ai_addr,current->ai_addrlen)==0) { if(listen(sock,10)==0)