[complement-svn] SF.net SVN: complement: [1489] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-01-31 08:03:17
|
Revision: 1489 http://svn.sourceforge.net/complement/?rev=1489&view=rev Author: complement Date: 2007-01-31 00:03:15 -0800 (Wed, 31 Jan 2007) Log Message: ----------- really erase iterators from _conn_pool; remove sockstream from processing, if it was closed during 'connect' processing. Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.cc trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile.inc trunk/complement/explore/test/sockios/sockios_test.cc Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-01-30 15:14:56 UTC (rev 1488) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-01-31 08:03:15 UTC (rev 1489) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <06/12/15 01:27:36 ptr> +// -*- C++ -*- Time-stamp: <07/01/31 09:43:59 ptr> /* - * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Portion Copyright (c) 1999-2001 @@ -100,6 +100,7 @@ // cerr << __FILE__ << ":" << __LINE__ << endl; // } if ( j->revents != 0 ) { + xmt::Locker _l( _c_lock ); // We should distinguish closed socket from income message typename container_type::iterator i = find_if( _M_c.begin(), _M_c.end(), bind2nd( _M_comp, j->fd ) ); @@ -114,7 +115,7 @@ i = _M_c.begin(); while ( (i = find_if( i, _M_c.end(), bind2nd( _M_comp, -1 ) )) != _M_c.end() ) { _dlock.lock(); - std::remove( _conn_pool.begin(), _conn_pool.end(), i ); + _conn_pool.erase( std::remove( _conn_pool.begin(), _conn_pool.end(), i ), _conn_pool.end() ); _dlock.unlock(); _M_c.erase( i++ ); } @@ -124,7 +125,7 @@ _pfd.erase( j ); j = _pfd.begin() + (d - 1); _dlock.lock(); - std::remove( _conn_pool.begin(), _conn_pool.end(), i ); + _conn_pool.erase( std::remove( _conn_pool.begin(), _conn_pool.end(), i ), _conn_pool.end() ); _dlock.unlock(); _M_c.erase( i ); } else { @@ -141,7 +142,7 @@ _pfd.erase( j ); j = _pfd.begin() + (d - 1); _dlock.lock(); - std::remove( _conn_pool.begin(), _conn_pool.end(), i ); + _conn_pool.erase( std::remove( _conn_pool.begin(), _conn_pool.end(), i ), _conn_pool.end() ); _dlock.unlock(); _M_c.erase( i ); } else { // normal data available for reading @@ -216,10 +217,10 @@ } try { - _Connect *cl_new; + xmt::Locker _l( _c_lock ); _M_c.push_back( _Connect() ); _M_c.back().open( _sd, addr.any ); - cl_new = &_M_c.back(); + _Connect *cl_new = &_M_c.back(); if ( cl_new->s.rdbuf()->in_avail() > 0 ) { // this is the case when user read from sockstream // in ctor above; push processing of this stream @@ -418,6 +419,13 @@ sock_base::socket_type rfd = stream.rdbuf()->fd(); ::write( me->_cfd, reinterpret_cast<const char *>(&rfd), sizeof(sock_base::socket_type) ); } + } else { + me->_dlock.lock(); + me->_conn_pool.erase( std::remove( me->_conn_pool.begin(), me->_conn_pool.end(), c ), me->_conn_pool.end() ); + me->_dlock.unlock(); + + xmt::Locker _l( me->_c_lock ); + me->_M_c.erase( c ); } } } Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-01-30 15:14:56 UTC (rev 1488) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-01-31 08:03:15 UTC (rev 1489) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/13 17:38:44 ptr> +// -*- C++ -*- Time-stamp: <07/01/31 08:55:49 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -289,7 +289,7 @@ _Sequence _M_c; _Compare _M_comp; pfd_equal _pfdcomp; - // xmt::Mutex _c_lock; + xmt::Mutex _c_lock; _fd_sequence _pfd; int _cfd; // sock_base::socket_type Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-01-30 15:14:56 UTC (rev 1488) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-01-31 08:03:15 UTC (rev 1489) @@ -1,3 +1,11 @@ +2007-01-31 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h, sockmgr.cc: really erase iterators + from _conn_pool; remove sockstream from processing, + if it was closed during 'connect' processing. + + * libsockios: Version 1.10.2 + 2006-12-13 Petr Ovtchenkov <pt...@is...> * sockmgr.h, sockmgr.cc: container now single owner Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-01-30 15:14:56 UTC (rev 1488) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-01-31 08:03:15 UTC (rev 1489) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <06/11/29 18:47:25 ptr> +# -*- Makefile -*- Time-stamp: <07/01/31 10:07:17 ptr> LIBNAME = sockios MAJOR = 1 MINOR = 10 -PATCH = 1 +PATCH = 2 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ freebsd/ns_parse.c \ Modified: trunk/complement/explore/test/sockios/sockios_test.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.cc 2007-01-30 15:14:56 UTC (rev 1488) +++ trunk/complement/explore/test/sockios/sockios_test.cc 2007-01-31 08:03:15 UTC (rev 1489) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/01/30 11:45:52 ptr> +// -*- C++ -*- Time-stamp: <07/01/31 10:55:45 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -375,23 +375,23 @@ long_msg_processor::long_msg_processor( std::sockstream& ) { - cerr << "long_msg_processor::long_msg_processor" << endl; + // cerr << "long_msg_processor::long_msg_processor" << endl; } void long_msg_processor::connect( std::sockstream& s ) { - cerr << "long_msg_processor::connect" << endl; + // cerr << "long_msg_processor::connect" << endl; string l; getline( s, l ); - cerr << "Is good? " << s.good() << endl; + // cerr << "Is good? " << s.good() << endl; } void long_msg_processor::close() { - cerr << "long_msg_processor::close()" << endl; + // cerr << "long_msg_processor::close()" << endl; cnd->set( true ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |