[complement-svn] SF.net SVN: complement: [1915] branches/complement-sockios/explore/include/ sockio
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-06-26 05:45:46
|
Revision: 1915 http://complement.svn.sourceforge.net/complement/?rev=1915&view=rev Author: complement Date: 2008-06-25 22:45:45 -0700 (Wed, 25 Jun 2008) Log Message: ----------- worker's loop may run after signal: fix end-of-loop var The body of loop may be reached after I send signal and set _in_work to false, so it may turn on _in_work to true again. Fixed. Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/socksrv.cc branches/complement-sockios/explore/include/sockios/socksrv.h branches/complement-sockios/explore/include/sockios/sockstream Modified: branches/complement-sockios/explore/include/sockios/socksrv.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.cc 2008-06-26 05:45:30 UTC (rev 1914) +++ branches/complement-sockios/explore/include/sockios/socksrv.cc 2008-06-26 05:45:45 UTC (rev 1915) @@ -295,7 +295,6 @@ cnd.wait( lk, not_empty ); p = ready_pool.front(); // it may contain p.c == 0, p.s == 0, if !in_work() ready_pool.pop_front(); - // std::cerr << "pop 1\n"; #if 0 if ( p.c == 0 ) { // wake up, but _in_work may be still true here (in processor pipe?), return false; // even I know that _in_work <- false before notification... @@ -312,16 +311,12 @@ template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> void connect_processor<Connect, charT, traits, _Alloc, C>::worker() { - _in_work = true; - processor p; while ( pop_ready( p ) ) { - // std::cerr << "worker 1\n"; if ( p.c != 0 ) { std::cerr << __FILE__ << ":" << __LINE__ << std::endl; (p.c->*C)( *p.s ); - // std::cerr << "worker 2\n"; if ( p.s->rdbuf()->in_avail() ) { std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); ready_pool.push_back( p ); @@ -329,7 +324,6 @@ std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); worker_pool[p.s->rdbuf()->fd()] = p; } - // std::cerr << "worker 3\n"; } else { std::cerr << __FILE__ << ":" << __LINE__ << std::endl; } @@ -346,9 +340,7 @@ if ( ready_pool.empty() ) { ready_pool.push_back( processor() ); // make ready_pool not empty cnd.notify_one(); - std::cerr << __FILE__ << ":" << __LINE__ << std::endl; } - std::cerr << __FILE__ << ":" << __LINE__ << std::endl; } } // namespace std Modified: branches/complement-sockios/explore/include/sockios/socksrv.h =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.h 2008-06-26 05:45:30 UTC (rev 1914) +++ branches/complement-sockios/explore/include/sockios/socksrv.h 2008-06-26 05:45:45 UTC (rev 1915) @@ -180,14 +180,14 @@ public: connect_processor() : not_empty( *this ), - _in_work( false ), + _in_work( true ), ploop( loop, this ) { new( Init_buf ) Init(); /* base_t::_real_stop = &connect_processor::_xstop; */ } explicit connect_processor( int port ) : base_t( port, sock_base::sock_stream ), not_empty( *this ), - _in_work( false ), + _in_work( true ), ploop( loop, this ) { new( Init_buf ) Init(); /* base_t::_real_stop = &connect_processor::_xstop; */ } Modified: branches/complement-sockios/explore/include/sockios/sockstream =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream 2008-06-26 05:45:30 UTC (rev 1914) +++ branches/complement-sockios/explore/include/sockios/sockstream 2008-06-26 05:45:45 UTC (rev 1915) @@ -451,7 +451,6 @@ std::cerr << __FILE__ << ":" << __LINE__ << " " << basic_socket_t::_fd << std::endl; close(); _M_deallocate_block(); - std::cerr << __FILE__ << ":" << __LINE__ << " " << basic_socket_t::_fd << std::endl; } sockbuf_type *open( const char *hostname, int port, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |