[complement-svn] SF.net SVN: complement: [1909] branches/complement-sockios/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-06-26 05:43:49
|
Revision: 1909 http://complement.svn.sourceforge.net/complement/?rev=1909&view=rev Author: complement Date: 2008-06-25 22:43:48 -0700 (Wed, 25 Jun 2008) Log Message: ----------- final method may lead to deadlock: process close via sockmgr When server closed, all sockets (connections) should be closed, but via sockmgr/epoll (via descriptors); this done with sock_buf::shutdown; but I'm not sure that all connections really closed/destroyed at connection_processor dtor, but this is MUST (otherwise call of unexistent object happens) Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/socksrv.cc branches/complement-sockios/explore/include/sockios/socksrv.h branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc Modified: branches/complement-sockios/explore/include/sockios/socksrv.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.cc 2008-06-26 05:43:27 UTC (rev 1908) +++ branches/complement-sockios/explore/include/sockios/socksrv.cc 2008-06-26 05:43:48 UTC (rev 1909) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/16 10:45:56 ptr> +// -*- C++ -*- Time-stamp: <08/06/16 20:25:28 yeti> /* * Copyright (c) 2008 @@ -198,12 +198,6 @@ // std::cerr << "=== " << ready_pool.size() << std::endl; cnd.notify_one(); } - - basic_socket<charT,traits,_Alloc>::mgr->final( *this ); - - if ( ploop.joinable() ) { - ploop.join(); - } } template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> Modified: branches/complement-sockios/explore/include/sockios/socksrv.h =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.h 2008-06-26 05:43:27 UTC (rev 1908) +++ branches/complement-sockios/explore/include/sockios/socksrv.h 2008-06-26 05:43:48 UTC (rev 1909) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/15 23:29:23 ptr> +// -*- C++ -*- Time-stamp: <08/06/16 22:07:54 yeti> /* * Copyright (c) 2008 @@ -175,6 +175,22 @@ { connect_processor::close(); + if ( ploop.joinable() ) { + ploop.join(); + } + + basic_socket<charT,traits,_Alloc>::mgr->final( *this ); + + { + std::tr2::lock_guard<std::tr2::mutex> lk2( rdlock ); + cerr << __FILE__ << ":" << __LINE__ << " " << ready_pool.size() << endl; + } + + { + std::tr2::lock_guard<std::tr2::mutex> lk2( wklock ); + cerr << __FILE__ << ":" << __LINE__ << " " << worker_pool.size() << endl; + } + ((Init *)Init_buf)->~Init(); } Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-26 05:43:27 UTC (rev 1908) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-26 05:43:48 UTC (rev 1909) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/16 11:05:56 ptr> +// -*- C++ -*- Time-stamp: <08/06/16 20:24:51 yeti> /* * Copyright (c) 2008 @@ -140,6 +140,11 @@ if ( ifd->second.p != 0 ) { ifd->second.p->close(); + for ( typename fd_container_type::iterator i = descr.begin(); i != descr.end(); ++i ) { + if ( (i->second.p == ifd->second.p) && (i->second.b != 0) ) { + i->second.b->shutdown( sock_base::stop_in | sock_base::stop_out ); + } + } } descr.erase( ifd ); @@ -194,6 +199,11 @@ if ( ifd->second.p != 0 ) { ifd->second.p->close(); + for ( typename fd_container_type::iterator i = descr.begin(); i != descr.end(); ++i ) { + if ( (i->second.p == ifd->second.p) && (i->second.b != 0) ) { + i->second.b->shutdown( sock_base::stop_in | sock_base::stop_out ); + } + } } descr.erase( ifd ); @@ -388,6 +398,7 @@ template<class charT, class traits, class _Alloc> void sockmgr<charT,traits,_Alloc>::final( sockmgr<charT,traits,_Alloc>::socks_processor_t& p ) { +#if 0 std::tr2::lock_guard<std::tr2::mutex> lk_descr( dll ); for ( typename fd_container_type::iterator ifd = descr.begin(); ifd != descr.end(); ) { @@ -403,6 +414,7 @@ ++ifd; } } +#endif std::tr2::lock_guard<std::tr2::mutex> lk( cll ); Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-26 05:43:27 UTC (rev 1908) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-26 05:43:48 UTC (rev 1909) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/15 21:52:52 ptr> +// -*- C++ -*- Time-stamp: <08/06/16 20:35:30 yeti> /* * @@ -393,8 +393,8 @@ } } - EXAM_CHECK( worker::line == "" ); + EXAM_CHECK( worker::rd == 0 ); // check after sockstream2 was closed, i.e. ensure, that all data available read before close { @@ -413,9 +413,9 @@ } unique_lock<mutex> lk( worker::lock ); - worker::cnd.timed_wait( lk, milliseconds( 500 ), rd_counter1 ); + worker::cnd.timed_wait( lk, milliseconds( 100 ), rd_counter1 ); - // cerr << worker::line << endl; + cerr << worker::line << endl; EXAM_CHECK( worker::line == "Hello, world!" ); worker::line = ""; worker::rd = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |