[complement-svn] SF.net SVN: complement: [1415] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-11-27 18:53:51
|
Revision: 1415 http://svn.sourceforge.net/complement/?rev=1415&view=rev Author: complement Date: 2006-11-27 10:53:49 -0800 (Mon, 27 Nov 2006) Log Message: ----------- debugging Modified Paths: -------------- trunk/complement/explore/include/stem/NetTransport.h trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/Names.cc trunk/complement/explore/lib/stem/NetTransport.cc trunk/complement/explore/lib/stem/_EventHandler.cc trunk/complement/explore/test/libstem/unit/Echo.cc trunk/complement/explore/test/libstem/unit/unit_test.cc Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/include/stem/NetTransport.h 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 15:29:19 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 17:22:33 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/lib/stem/EvManager.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/26 21:21:55 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 21:40:35 ptr> /* * @@ -40,6 +40,8 @@ std::string EvManager::inv_key_str( "invalid key" ); +// int EvManager_flags = 0; + __FIT_DECLSPEC EvManager::EvManager() : _low( beglocaddr ), _high( endlocaddr ), @@ -244,6 +246,8 @@ iheap[id] = info; } + cerr << "EvManager:: " << tr.link << " / " << hex << addr.pid << " + " << addr.addr << " - " << id << " = " << getpid() << dec << endl; + return id; } @@ -344,13 +348,19 @@ __FIT_DECLSPEC void EvManager::unsafe_Remove( void *channel ) { + cerr << "Remove channel " << channel << hex << " " << getpid() << dec << endl; pair<tr_uuid_heap_type::iterator,tr_uuid_heap_type::iterator> ch_range = _ch_heap.equal_range( channel ); for (tr_uuid_heap_type::iterator i = ch_range.first; i != ch_range.second; ++i ) { +#if 1 _tr_heap.erase( i->second ); addr_type address = _ui_heap[i->second]; _ex_heap.erase( address ); iheap.erase( address ); _ui_heap.erase( i->second ); +#else + cerr << i->first << "; " << hex << i->second.addr << dec << endl; + cerr << hex << _ui_heap[i->second] << dec << endl; +#endif } _ch_heap.erase( ch_range.first, ch_range.second ); } @@ -383,22 +393,25 @@ if ( e.dest() & extbit ) { // external object try { _lock_xheap.lock(); - ext_uuid_heap_type::iterator i = _ex_heap.find( e.dest() ); + ext_uuid_heap_type::const_iterator i = _ex_heap.find( e.dest() ); if ( i == _ex_heap.end() ) { // destination not found - throw invalid_argument( string("external address unknown") ); + ostringstream s; + s << "external address unknown: " << hex << e.dest() << " from " + << e.src() << ", pid " << getpid() << dec; + throw invalid_argument( s.str() ); } - pair<uuid_tr_heap_type::iterator,uuid_tr_heap_type::iterator> range = _tr_heap.equal_range( i->second ); + pair<uuid_tr_heap_type::const_iterator,uuid_tr_heap_type::const_iterator> range = _tr_heap.equal_range( i->second ); if ( range.first == _tr_heap.end() ) { throw range_error( string( "no transport" ) ); } - detail::transport& tr = min_element( range.first, range.second, tr_compare )->second; + const detail::transport& tr = min_element( range.first, range.second, tr_compare )->second; detail::transport::kind_type k = tr.kind; void *link = tr.link; gaddr_type gaddr_dst( i->second ); gaddr_type gaddr_src; - ext_uuid_heap_type::iterator j = _ex_heap.find( e.src() ); + ext_uuid_heap_type::const_iterator j = _ex_heap.find( e.src() ); if ( j == _ex_heap.end() ) { gaddr_type& _gaddr_src = _ex_heap[e.src()]; _gaddr_src.hid = xmt::hostid(); @@ -429,6 +442,14 @@ break; } } + catch ( std::logic_error& err ) { + cerr << err.what() << endl; + _lock_xheap.unlock(); + } + catch ( std::runtime_error& err ) { + cerr << err.what() << endl; + _lock_xheap.unlock(); + } catch ( ... ) { _lock_xheap.unlock(); } @@ -448,6 +469,14 @@ catch ( ... ) { } } + catch ( std::logic_error& err ) { + cerr << err.what() << endl; + _lock_heap.unlock(); + } + catch ( std::runtime_error& err ) { + cerr << err.what() << endl; + _lock_heap.unlock(); + } catch ( ... ) { _lock_heap.unlock(); } Modified: trunk/complement/explore/lib/stem/Names.cc =================================================================== --- trunk/complement/explore/lib/stem/Names.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/lib/stem/Names.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/26 12:22:27 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 18:45:00 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -77,6 +77,7 @@ void __FIT_DECLSPEC Names::ns_name( const Event& rq ) { + cerr << __FILE__ << ":" << __LINE__ << endl; typedef NameRecords<gaddr_type,string> Seq; Event_base<Seq> rs( EV_STEM_NS_NAME ); Seq::container_type& lst = rs.value().container; @@ -105,6 +106,7 @@ } manager()->_lock_iheap.unlock(); + cerr << __FILE__ << ":" << __LINE__ << endl; rs.dest( rq.src() ); Send( rs ); } Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/26 19:14:58 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 20:24:50 ptr> /* * @@ -230,7 +230,7 @@ manager()->SubscribeRemote( detail::transport( static_cast<NetTransport_base *>(this), detail::transport::socket_tcp, 10 ), src ); } Event ack( EV_STEM_TRANSPORT_ACK ); - push( ack, src, self_glid() ); + push( ack, src, self_glid() ); // the source (second arg) is NetTransport } else { throw runtime_error( "net handshake error" ); } @@ -256,15 +256,21 @@ gaddr_type src; if ( pop( ev, dst, src ) ) { + cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; addr_type xdst = manager()->reflect( dst ); + cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << " " << hex << xdst << dec << endl; if ( xdst == badaddr ) { + cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; return; } + cerr << __FILE__ << ":" << __LINE__ << endl; ev.dest( xdst ); addr_type xsrc = manager()->reflect( src ); if ( xsrc == badaddr ) { + cerr << __FILE__ << ":" << __LINE__ << endl; ev.src( manager()->SubscribeRemote( detail::transport( static_cast<NetTransport_base *>(this), detail::transport::socket_tcp, 10 ), src ) ); } else { + cerr << __FILE__ << ":" << __LINE__ << endl; ev.src( xsrc ); } manager()->push( ev ); @@ -319,9 +325,6 @@ } if ( net->good() ) { - // _net_ns = rar_map( ns_addr, __ns_at + hostname ); - // addr_type zero_object = rar_map( 0, __at + hostname ); - Event ev( EV_STEM_TRANSPORT ); gaddr_type dst; gaddr_type src; @@ -331,9 +334,12 @@ if ( ev.code() == EV_STEM_TRANSPORT_ACK ) { src.addr = ns_addr; xsrc = manager()->reflect( src ); + // indeed src is something like NetTransport, so substitute ns: + src.addr = ns_addr; if ( xsrc == badaddr ) { manager()->SubscribeRemote( detail::transport( static_cast<NetTransport_base *>(this), detail::transport::socket_tcp, 10 ), src ); } + // indeed src is something like NetTransport, so substitute default: src.addr = default_addr; xsrc = manager()->reflect( src ); if ( xsrc == badaddr ) { Modified: trunk/complement/explore/lib/stem/_EventHandler.cc =================================================================== --- trunk/complement/explore/lib/stem/_EventHandler.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/lib/stem/_EventHandler.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/26 12:22:42 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 17:26:35 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -33,10 +33,28 @@ int EventHandler::Init::_count = 0; xmt::MutexRS _init_lock; +#if 0 // depends where fork happens: in the EvManager loop (stack) or not. +extern "C" void __at_fork_prepare() +{ +} + +extern "C" void __at_fork_child() +{ + if ( EventHandler::Init::_count != 0 ) { + // delete EventHandler::_mgr; + EventHandler::_mgr = new( EventHandler::_mgr ) EvManager(); + } +} + +extern "C" void __at_fork_parent() +{ +} +#endif + EventHandler::Init::Init() { MT_REENTRANT_RS( _init_lock, _x ); - if ( _count++ == 0 ) { + if ( _count++ == 0 ) { EventHandler::_mgr = new EvManager(); stem::_ns = new Names( ns_addr, _ns_name ); } Modified: trunk/complement/explore/test/libstem/unit/Echo.cc =================================================================== --- trunk/complement/explore/test/libstem/unit/Echo.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/test/libstem/unit/Echo.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/12 15:12:19 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 18:33:21 ptr> /* * Copyright (c) 2006 @@ -45,6 +45,7 @@ void StEMecho::regme( const stem::Event& ev ) { + cerr << "Echo\n"; manager()->change_announce( ev.src(), ev.value() ); cnd.set( true ); } Modified: trunk/complement/explore/test/libstem/unit/unit_test.cc =================================================================== --- trunk/complement/explore/test/libstem/unit/unit_test.cc 2006-11-27 18:52:47 UTC (rev 1414) +++ trunk/complement/explore/test/libstem/unit/unit_test.cc 2006-11-27 18:53:49 UTC (rev 1415) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 11:15:16 ptr> +// -*- C++ -*- Time-stamp: <06/11/27 18:20:55 ptr> /* * Copyright (c) 2002, 2003, 2006 @@ -35,6 +35,8 @@ using namespace __gnu_cxx; #endif +#include <sys/shm.h> + using namespace std; struct stem_test @@ -281,7 +283,6 @@ } catch ( ... ) { } - // cerr << "Fine\n"; } void stem_test::echo_net() @@ -339,13 +340,28 @@ void stem_test::peer() { - xmt::__Condition<true> fcnd; + cerr << "peer" << endl; + + shmid_ds ds; + int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); + if ( id == -1 ) { + cerr << "Error on shmget" << endl; + } + if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { + cerr << "Error on shmctl" << endl; + } + void *buf = shmat( id, 0, 0 ); + if ( buf == reinterpret_cast<void *>(-1) ) { + cerr << "Error on shmat" << endl; + } + + xmt::__Condition<true>& fcnd = *new( buf ) xmt::__Condition<true>(); fcnd.set( false ); - xmt::__Condition<true> pcnd; + xmt::__Condition<true>& pcnd = *new( (char *)buf + sizeof(xmt::__Condition<true>) ) xmt::__Condition<true>(); pcnd.set( false ); - xmt::__Condition<true> scnd; + xmt::__Condition<true>& scnd = *new( (char *)buf + sizeof(xmt::__Condition<true>) * 2 ) xmt::__Condition<true>(); scnd.set( false ); try { @@ -387,8 +403,10 @@ pcnd.try_wait(); + cerr << "@1\n"; nm.Send( evname ); nm.wait(); + cerr << "@2\n"; Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); @@ -399,13 +417,13 @@ cerr << "1.1\n"; - scnd.set( true ); + scnd.set( true, true ); exit( 0 ); } catch ( xmt::fork_in_parent& ) { } -#if 0 + try { xmt::Thread::fork(); stem::NetTransportMgr mgr; @@ -431,20 +449,28 @@ cerr << "2.1\n"; pcnd.set( true ); + scnd.try_wait(); exit( 0 ); } catch ( xmt::fork_in_parent& ) { } -#endif + sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) cerr << "3\n"; - fcnd.set( true ); + fcnd.set( true, true ); scnd.try_wait(); + (&fcnd)->~__Condition<true>(); + (&pcnd)->~__Condition<true>(); + (&scnd)->~__Condition<true>(); + + shmdt( buf ); + shmctl( id, IPC_RMID, &ds ); + srv.close(); srv.wait(); @@ -569,7 +595,6 @@ test_case *echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo, instance ); test_case *echo_net_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo_net, instance ); test_case *peer_tc = BOOST_CLASS_TEST_CASE( &stem_test::peer, instance ); - basic2_tc->depends_on( basic1_tc ); basic1n_tc->depends_on( basic1_tc ); basic2n_tc->depends_on( basic2_tc ); @@ -590,7 +615,7 @@ add( echo_tc ); add( echo_net_tc ); - // add( peer_tc ); + add( peer_tc ); } test_suite *init_unit_test_suite( int argc, char **argv ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |