[complement-svn] SF.net SVN: complement: [1419] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-11-28 10:08:22
|
Revision: 1419 http://svn.sourceforge.net/complement/?rev=1419&view=rev Author: complement Date: 2006-11-28 02:08:16 -0800 (Tue, 28 Nov 2006) Log Message: ----------- method for dump tables of EvManager Modified Paths: -------------- trunk/complement/explore/include/stem/EvManager.h trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/NetTransport.cc trunk/complement/explore/test/libstem/unit/Echo.cc trunk/complement/explore/test/libstem/unit/unit_test.cc Modified: trunk/complement/explore/include/stem/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2006-11-28 10:06:40 UTC (rev 1418) +++ trunk/complement/explore/include/stem/EvManager.h 2006-11-28 10:08:16 UTC (rev 1419) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/26 21:10:31 ptr> +// -*- C++ -*- Time-stamp: <06/11/28 11:06:04 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -29,6 +29,7 @@ #include <stem/Event.h> #include <stem/EventHandler.h> +#include <ostream> namespace stem { @@ -149,6 +150,8 @@ } __FIT_DECLSPEC void Remove( void * ); + __FIT_DECLSPEC std::ostream& dump( std::ostream& ) const; + protected: bool unsafe_is_avail( addr_type id ) const Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2006-11-28 10:06:40 UTC (rev 1418) +++ trunk/complement/explore/lib/stem/EvManager.cc 2006-11-28 10:08:16 UTC (rev 1419) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 21:40:35 ptr> +// -*- C++ -*- Time-stamp: <06/11/28 12:33:34 ptr> /* * @@ -246,7 +246,7 @@ iheap[id] = info; } - cerr << "EvManager:: " << tr.link << " / " << hex << addr.pid << " + " << addr.addr << " - " << id << " = " << getpid() << dec << endl; + // cerr << "EvManager:: " << tr.link << " / " << hex << addr.pid << " + " << addr.addr << " - " << id << " = " << getpid() << dec << endl; return id; } @@ -348,7 +348,7 @@ __FIT_DECLSPEC void EvManager::unsafe_Remove( void *channel ) { - cerr << "Remove channel " << channel << hex << " " << getpid() << dec << endl; + // 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 @@ -500,9 +500,76 @@ if ( ++_x_id > _x_high ) { _x_id = (_x_id - _x_low) % (_x_high - _x_low) + _x_low; } - } while ( heap.find( _x_id ) != heap.end() ); + } while ( _ex_heap.find( _x_id ) != _ex_heap.end() ); return _x_id; } + +std::ostream& operator <<( ostream& s, const gaddr_type& ga ) +{ + s.unsetf( ios_base::showbase ); + s << hex << setfill('0') + << setw(2) << static_cast<unsigned>(ga.hid.u.b[0]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[1]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[2]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[3]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[4]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[5]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[6]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[7]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[8]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[9]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[10]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[11]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[12]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[13]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[14]) + << setw(2) << static_cast<unsigned>(ga.hid.u.b[15]) + << "-" + << dec << ga.pid + << "-" + << setw(8) << setfill( '0' ) << ga.addr; +} + +__FIT_DECLSPEC std::ostream& EvManager::dump( std::ostream& s ) const +{ + s << "Local map:\n"; + + s << hex << showbase; + for ( local_heap_type::const_iterator i = heap.begin(); i != heap.end(); ++i ) { + s << i->first << "\t=> " << i->second << "\n"; + } + + s << "\nInfo map:\n"; + + for ( info_heap_type::const_iterator i = iheap.begin(); i != iheap.end(); ++i ) { + s << i->first << "\t=> '" << i->second << "'\n"; + } + + s << "\nUnique Id map:\n"; + for ( uuid_ext_heap_type::const_iterator i = _ui_heap.begin(); i != _ui_heap.end(); ++i ) { + s << i->first << "\t=> " << hex << showbase << i->second << "\n"; + } + + s << "\nExternal address map:\n"; + for ( ext_uuid_heap_type::const_iterator i = _ex_heap.begin(); i != _ex_heap.end(); ++i ) { + s << hex << showbase << i->first << "\t=> " << i->second << "\n"; + } + + s << "\nUnique Id to transport map:\n"; + for ( uuid_tr_heap_type::const_iterator i = _tr_heap.begin(); i != _tr_heap.end(); ++i ) { + s << i->first << "\t=> " << i->second.link << " " << i->second.metric << "\n"; + } + + s << "\nTransport to Unique Id map:\n"; + for ( tr_uuid_heap_type::const_iterator i = _ch_heap.begin(); i != _ch_heap.end(); ++i ) { + s << i->first << "\t=> " << i->second << "\n"; + } + + s << dec << endl; + + return s; +} + } // namespace stem Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-28 10:06:40 UTC (rev 1418) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-28 10:08:16 UTC (rev 1419) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 20:24:50 ptr> +// -*- C++ -*- Time-stamp: <06/11/28 11:40:21 ptr> /* * @@ -256,21 +256,21 @@ gaddr_type src; if ( pop( ev, dst, src ) ) { - cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; + // cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; addr_type xdst = manager()->reflect( dst ); - cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << " " << hex << xdst << dec << endl; + // cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << " " << hex << xdst << dec << endl; if ( xdst == badaddr ) { - cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; + // cerr << getpid() << "= " << __FILE__ << ":" << __LINE__ << endl; return; } - cerr << __FILE__ << ":" << __LINE__ << endl; + // cerr << __FILE__ << ":" << __LINE__ << endl; ev.dest( xdst ); addr_type xsrc = manager()->reflect( src ); if ( xsrc == badaddr ) { - cerr << __FILE__ << ":" << __LINE__ << endl; + // 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; + // cerr << __FILE__ << ":" << __LINE__ << endl; ev.src( xsrc ); } manager()->push( ev ); Modified: trunk/complement/explore/test/libstem/unit/Echo.cc =================================================================== --- trunk/complement/explore/test/libstem/unit/Echo.cc 2006-11-28 10:06:40 UTC (rev 1418) +++ trunk/complement/explore/test/libstem/unit/Echo.cc 2006-11-28 10:08:16 UTC (rev 1419) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 18:33:21 ptr> +// -*- C++ -*- Time-stamp: <06/11/28 11:49:49 ptr> /* * Copyright (c) 2006 @@ -45,7 +45,7 @@ void StEMecho::regme( const stem::Event& ev ) { - cerr << "Echo\n"; + // 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-28 10:06:40 UTC (rev 1418) +++ trunk/complement/explore/test/libstem/unit/unit_test.cc 2006-11-28 10:08:16 UTC (rev 1419) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/27 18:20:55 ptr> +// -*- C++ -*- Time-stamp: <06/11/28 11:02:56 ptr> /* * Copyright (c) 2002, 2003, 2006 @@ -36,6 +36,7 @@ #endif #include <sys/shm.h> +#include <sys/wait.h> using namespace std; @@ -342,6 +343,8 @@ { cerr << "peer" << endl; + pid_t fpid; + shmid_ds ds; int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); if ( id == -1 ) { @@ -397,6 +400,8 @@ BOOST_CHECK( c1.manager()->reflect( ga ) != stem::badaddr ); + c1.manager()->dump( cerr ); + stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( c1.manager()->reflect( ga ) ); evname.value() = "c2@here"; @@ -420,8 +425,8 @@ scnd.set( true, true ); exit( 0 ); } - catch ( xmt::fork_in_parent& ) { - + catch ( xmt::fork_in_parent& child ) { + fpid = child.pid(); } try { @@ -452,18 +457,23 @@ scnd.try_wait(); exit( 0 ); } - catch ( xmt::fork_in_parent& ) { - - } + catch ( xmt::fork_in_parent& child ) { + 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"; - 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, true ); - fcnd.set( true, true ); + scnd.try_wait(); - scnd.try_wait(); + int stat; + waitpid( child.pid(), &stat, 0 ); + waitpid( fpid, &stat, 0 ); + srv.close(); + srv.wait(); + } + (&fcnd)->~__Condition<true>(); (&pcnd)->~__Condition<true>(); (&scnd)->~__Condition<true>(); @@ -471,9 +481,6 @@ shmdt( buf ); shmctl( id, IPC_RMID, &ds ); - srv.close(); - srv.wait(); - #if 0 /* * Scheme: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |