complement-svn Mailing List for Complement (Page 10)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2007-10-01 13:06:20
|
Revision: 1753 http://complement.svn.sourceforge.net/complement/?rev=1753&view=rev Author: complement Date: 2007-10-01 06:06:18 -0700 (Mon, 01 Oct 2007) Log Message: ----------- add more trace to NetTransport_base Modified Paths: -------------- trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/NetTransport.cc Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-10-01 09:13:22 UTC (rev 1752) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-10-01 13:06:18 UTC (rev 1753) @@ -3,6 +3,8 @@ * NetTransport.h, NetTransport.cc: comment NetTransportMP, looks it useless; add trace for NetTransport [server part]; + * NetTransport.cc: add more trace to NetTransport_base; + * libstem: library version 4.6.4 2007-09-05 Petr Ovtchenkov <pt...@is...> Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2007-10-01 09:13:22 UTC (rev 1752) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2007-10-01 13:06:18 UTC (rev 1753) @@ -179,6 +179,19 @@ while ( sz-- > 0 ) { str += (char)net->get(); } +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracenet)) ) { + int flags = manager()->_trs->flags(); + *manager()->_trs << "\tMessage from remote " << hex << showbase << _rs.code() << " " + << src << " -> " << dst << endl; + manager()->_trs->flags( flags ); + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE return net->good(); } @@ -187,6 +200,20 @@ __FIT_DECLSPEC bool NetTransport_base::push( const Event& _rs, const gaddr_type& dst, const gaddr_type& src ) { +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracenet)) ) { + int flags = manager()->_trs->flags(); + *manager()->_trs << "\tMessage to remote " << hex << showbase << _rs.code() << " " + << src << " -> " << dst << endl; + manager()->_trs->flags( flags ); + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE + if ( !net->good() ) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-10-01 09:13:24
|
Revision: 1752 http://complement.svn.sourceforge.net/complement/?rev=1752&view=rev Author: complement Date: 2007-10-01 02:13:22 -0700 (Mon, 01 Oct 2007) Log Message: ----------- comment NetTransportMP, looks it useless; add trace for NetTransport [server part]; library version 4.6.4 Modified Paths: -------------- trunk/complement/explore/include/stem/NetTransport.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Makefile.inc trunk/complement/explore/lib/stem/NetTransport.cc Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2007-09-28 11:03:56 UTC (rev 1751) +++ trunk/complement/explore/include/stem/NetTransport.h 2007-10-01 09:13:22 UTC (rev 1752) @@ -112,6 +112,7 @@ std::sockstream _channel; }; +#if 0 class NetTransportMP : public NetTransport_base { @@ -123,6 +124,7 @@ __FIT_DECLSPEC void connect( std::sockstream& ); }; +#endif } // namespace stem Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-09-28 11:03:56 UTC (rev 1751) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-10-01 09:13:22 UTC (rev 1752) @@ -1,3 +1,10 @@ +2007-10-01 Petr Ovtchenkov <pt...@is...> + + * NetTransport.h, NetTransport.cc: comment NetTransportMP, + looks it useless; add trace for NetTransport [server part]; + + * libstem: library version 4.6.4 + 2007-09-05 Petr Ovtchenkov <pt...@is...> * Cron.h, NetTransport.h, EvManager.h: looks like non-POD return Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-09-28 11:03:56 UTC (rev 1751) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-10-01 09:13:22 UTC (rev 1752) @@ -3,7 +3,7 @@ LIBNAME = stem MAJOR = 4 MINOR = 6 -PATCH = 3 +PATCH = 4 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2007-09-28 11:03:56 UTC (rev 1751) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2007-10-01 09:13:22 UTC (rev 1752) @@ -303,8 +303,33 @@ gaddr_type src; if ( pop( ev, dst, src ) ) { +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracenet) ) { + *manager()->_trs << "Pid/ppid: " << xmt::getpid() << "/" << xmt::getppid() << "\n"; + manager()->dump( *manager()->_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE addr_type xdst = manager()->reflect( dst ); if ( xdst == badaddr ) { +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracefault)) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ + << " (" + << xmt::getpid() << "/" << xmt::getppid() << ") " + << "Unknown destination\n"; + manager()->dump( *manager()->_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE return; } ev.dest( xdst ); @@ -314,6 +339,16 @@ } else { ev.src( xsrc ); } +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracenet)) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE manager()->push( ev ); } } @@ -505,6 +540,7 @@ return 0; } +#if 0 __FIT_DECLSPEC void NetTransportMP::connect( sockstream& s ) { @@ -514,8 +550,35 @@ try { if ( pop( ev, dst, src ) ) { +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & E +vManager::tracenet) ) { + *manager()->_trs << "Pid/ppid: " << xmt::getpid() << "/" << xmt::getppid() << +"\n"; + manager()->dump( *manager()->_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE addr_type xdst = manager()->reflect( dst ); if ( xdst == badaddr ) { +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracefault)) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ + << " (" + << xmt::getpid() << "/" << xmt::getppid() << ") " + << "Unknown destination\n"; + manager()->dump( *manager()->_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE return; } ev.dest( xdst ); @@ -526,6 +589,16 @@ } else { ev.src( xsrc ); } +#ifdef __FIT_STEM_TRACE + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & (EvManager::tracenet)) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_STEM_TRACE manager()->push( ev ); } if ( !s.good() ) { @@ -538,4 +611,6 @@ } } +#endif + } // namespace stem This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-28 11:04:00
|
Revision: 1751 http://complement.svn.sourceforge.net/complement/?rev=1751&view=rev Author: complement Date: 2007-09-28 04:03:56 -0700 (Fri, 28 Sep 2007) Log Message: ----------- problem in stack_allocator? Modified Paths: -------------- trunk/complement/explore/inquiry/STLport/merge/test.cc Added Paths: ----------- trunk/complement/explore/inquiry/STLport/merge/stack_allocator.h Added: trunk/complement/explore/inquiry/STLport/merge/stack_allocator.h =================================================================== --- trunk/complement/explore/inquiry/STLport/merge/stack_allocator.h (rev 0) +++ trunk/complement/explore/inquiry/STLport/merge/stack_allocator.h 2007-09-28 11:03:56 UTC (rev 1751) @@ -0,0 +1,205 @@ +#ifndef STLPORT_UNIT_TEST_STACK_ALLOCATOR_H +#define STLPORT_UNIT_TEST_STACK_ALLOCATOR_H + +#include <algorithm> + +#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS) +//For bad_alloc: +# include <new> +#endif + +#if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES) +# define __STD std:: +#else +# define __STD +#endif + +struct State { + char *m_beg, *m_end, *m_cur; + bool m_isOk, m_swaped; + int m_nbAlloc; + + //The following members are shared among all StackAllocator instance created from + //a reference StackAllocator instance: + char **m_sharedCur; + bool *m_sharedOk; + int *m_sharedNbAlloc; + +#if defined (__DMC__) + State(){} +#endif + + State(char *beg, char *end) + : m_beg(beg), m_end(end), m_cur(m_beg), m_isOk(true), m_swaped(false), m_nbAlloc(0), + m_sharedCur(&m_cur), m_sharedOk(&m_isOk), m_sharedNbAlloc(&m_nbAlloc) {} + + State(const State& other) + : m_beg(other.m_beg), m_end(other.m_end), m_cur(0), + m_isOk(true), m_swaped(other.m_swaped), m_nbAlloc(0), + m_sharedCur(other.m_sharedCur), m_sharedOk(other.m_sharedOk), + m_sharedNbAlloc(other.m_sharedNbAlloc) {} +}; + +/* This allocator is not thread safe: + */ +template <class _Tp> +struct StackAllocator +#if defined (STLPORT) && \ + defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + //Special Borland workaround that have problem with function + //overloading when one of the overloaded version is a template + //one. This is the case for the std::swap function. + : public __STD __stlport_class<StackAllocator<_Tp> > +#endif +{ + typedef _Tp value_type; + typedef value_type * pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +#if defined (__DMC__) + StackAllocator(){} +#endif + + StackAllocator(char *beg, char *end) + : m_state(beg, end) {} + + const State& getState() const { return m_state; } +#if !defined (STLPORT) || defined (_STLP_MEMBER_TEMPLATES) + template <class _OtherTp> + StackAllocator(StackAllocator<_OtherTp> const& other) + : m_state(other.getState()) {} +#else + StackAllocator(const State& state) + : m_state(state) {} +#endif + +#if !defined (STLPORT) || defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template <class _Other> + struct rebind { + typedef StackAllocator<_Other> other; + }; +#endif + + _Tp* allocate(size_type n, void* = 0) { + if (n == 0) + return 0; + + ++(*m_state.m_sharedNbAlloc); + + if (*m_state.m_sharedCur + (n * sizeof(_Tp)) < m_state.m_end) { + char *ret = *m_state.m_sharedCur; + *m_state.m_sharedCur += n * sizeof(_Tp); + return reinterpret_cast<_Tp*>(ret); + } +#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS) + throw __STD bad_alloc(); +# if defined (__DMC__) + return 0; +# endif +#else + return 0; +#endif + } + +#if defined (STLPORT) && \ + defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + //Necessary extension to make StackAllocator a real STLport allocator + //implementation: + _Tp* _M_allocate(size_type n, size_type &new_n) { + new_n = n; + return allocate(n); + } +#endif + + void deallocate(pointer p, size_type n) { + if (p == 0) + return; + + --(*m_state.m_sharedNbAlloc); + + if ((char*)p == (*m_state.m_sharedCur - n * sizeof(_Tp))) { + *m_state.m_sharedCur -= n * sizeof(_Tp); + } + + if ((char*)p < m_state.m_beg || (char*)p >= m_state.m_end) { + //An object has been returned to the bad allocator instance: + *m_state.m_sharedOk = false; + } + } + + pointer address(reference __x) const {return &__x;} + const_pointer address(const_reference __x) const { return &__x; } + size_type max_size() const { return m_state.m_end - *m_state.m_sharedCur; } + void construct(pointer __p, const_reference __val) { new(__p) _Tp(__val); } + void destroy(pointer __p) { __p->~_Tp(); } + + bool ok() const { return m_state.m_isOk && (m_state.m_nbAlloc == 0); } + void reset () { + m_state.m_cur = m_state.m_beg; + m_state.m_isOk = true; + m_state.m_swaped = false; + } + bool swaped() const { return m_state.m_swaped; } + void swap(StackAllocator &other) { + __STD swap(m_state, other.m_state); + m_state.m_swaped = true; + other.m_state.m_swaped = true; + } +#if defined (STLPORT) && \ + defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(StackAllocator& __x) { swap(__x); } +#endif + + //2 StackAllocator instance are identical if they are built on top + //of the same buffer. + bool operator == (StackAllocator const& other) const + { return m_state.m_beg == other.m_state.m_beg; } + + bool operator != (StackAllocator const& other) const + { return !(*this == other); } + +private: + State m_state; +}; + +#if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES) +namespace std { +#endif + +# if defined (STLPORT) && (defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) || !defined (_STLP_MEMBER_TEMPLATES)) +template <class _Tp1, class _Tp2> +inline StackAllocator<_Tp2>& +__stl_alloc_rebind(StackAllocator<_Tp1>& __a, const _Tp2*) { return (StackAllocator<_Tp2>&)(__a); } +template <class _Tp1, class _Tp2> +inline StackAllocator<_Tp2> +__stl_alloc_create(const StackAllocator<_Tp1>& __a, const _Tp2*) { return StackAllocator<_Tp2>(__a.getState()); } +# endif + +# if !defined (STLPORT) || defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + template <class _Tp> + inline void swap(StackAllocator<_Tp>& __a, StackAllocator<_Tp>& __b) + { __a.swap(__b); } +# elif !defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) +//The following overloads depends on instanciation, if new unit tests are written +//with new StackAllocator instanciations associated swap overload should also be +//written +inline void swap(StackAllocator<int>& __a, StackAllocator<int>& __b) +{ __a.swap(__b); } +inline void swap(StackAllocator<char>& __a, StackAllocator<char>& __b) +{ __a.swap(__b); } +inline void swap(StackAllocator<pair<const int, int> >& __a, + StackAllocator<pair<const int, int> >& __b) +{ __a.swap(__b); } +# endif + +#if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES) +} +#endif + +#undef __STD + +#endif //STLPORT_UNIT_TEST_STACK_ALLOCATOR_H Modified: trunk/complement/explore/inquiry/STLport/merge/test.cc =================================================================== --- trunk/complement/explore/inquiry/STLport/merge/test.cc 2007-09-28 10:41:29 UTC (rev 1750) +++ trunk/complement/explore/inquiry/STLport/merge/test.cc 2007-09-28 11:03:56 UTC (rev 1751) @@ -1,21 +1,23 @@ #include <list> #include <iostream> +#include "stack_allocator.h" + using namespace std; int main() { - // char buf1[1024]; - // StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1)); + char buf1[1024]; + StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1)); - // char buf2[1024]; - // StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2)); + char buf2[1024]; + StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2)); - // typedef list<int, StackAllocator<int> > ListInt; - typedef list<int> ListInt; + typedef list<int, StackAllocator<int> > ListInt; + // typedef list<int> ListInt; - ListInt lint1(10, 0 /* , stack1 */ ); - ListInt lint2(10, 1 /* , stack2 */ ); + ListInt lint1(10, 0, stack1 ); + ListInt lint2(10, 1, stack2 ); // ListInt lintref(stack2); // lintref.insert(lintref.begin(), 10, 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-28 10:41:40
|
Revision: 1750 http://complement.svn.sourceforge.net/complement/?rev=1750&view=rev Author: complement Date: 2007-09-28 03:41:29 -0700 (Fri, 28 Sep 2007) Log Message: ----------- investigation of merge/size problem with some compilers Added Paths: ----------- trunk/complement/explore/inquiry/STLport/merge/ trunk/complement/explore/inquiry/STLport/merge/Makefile trunk/complement/explore/inquiry/STLport/merge/Makefile.inc trunk/complement/explore/inquiry/STLport/merge/test.cc Property changes on: trunk/complement/explore/inquiry/STLport/merge ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/STLport/merge/Makefile =================================================================== --- trunk/complement/explore/inquiry/STLport/merge/Makefile (rev 0) +++ trunk/complement/explore/inquiry/STLport/merge/Makefile 2007-09-28 10:41:29 UTC (rev 1750) @@ -0,0 +1,14 @@ +# -*- Makefile -*- Time-stamp: <03/07/09 18:08:47 ptr> + +SRCROOT := ../../.. +# COMPILER_NAME := gcc + +STLPORT_DIR := /export/home/ptr/STLport.lab/STLport +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + + +INCLUDES += -I$(SRCROOT)/include + +LDFLAGS += -Wl,-rpath=$(STLPORT_LIB_DIR) + Added: trunk/complement/explore/inquiry/STLport/merge/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/STLport/merge/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/STLport/merge/Makefile.inc 2007-09-28 10:41:29 UTC (rev 1750) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> + +PRGNAME = test +SRC_CC = test.cc Added: trunk/complement/explore/inquiry/STLport/merge/test.cc =================================================================== --- trunk/complement/explore/inquiry/STLport/merge/test.cc (rev 0) +++ trunk/complement/explore/inquiry/STLport/merge/test.cc 2007-09-28 10:41:29 UTC (rev 1750) @@ -0,0 +1,30 @@ +#include <list> +#include <iostream> + +using namespace std; + +int main() +{ + // char buf1[1024]; + // StackAllocator<int> stack1(buf1, buf1 + sizeof(buf1)); + + // char buf2[1024]; + // StackAllocator<int> stack2(buf2, buf2 + sizeof(buf2)); + + // typedef list<int, StackAllocator<int> > ListInt; + typedef list<int> ListInt; + + ListInt lint1(10, 0 /* , stack1 */ ); + ListInt lint2(10, 1 /* , stack2 */ ); + + // ListInt lintref(stack2); + // lintref.insert(lintref.begin(), 10, 1); + // lintref.insert(lintref.begin(), 10, 0); + + lint1.merge(lint2); + cerr << lint1.size() << endl; + // CPPUNIT_ASSERT( lint1 == lintref ); + // CPPUNIT_ASSERT( lint2.empty() ); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-27 13:47:11
|
Revision: 1749 http://complement.svn.sourceforge.net/complement/?rev=1749&view=rev Author: complement Date: 2007-09-27 06:47:07 -0700 (Thu, 27 Sep 2007) Log Message: ----------- add trace and debug printing Modified Paths: -------------- trunk/complement/explore/lib/janus/samples/point1/point1.cc Modified: trunk/complement/explore/lib/janus/samples/point1/point1.cc =================================================================== --- trunk/complement/explore/lib/janus/samples/point1/point1.cc 2007-09-27 13:42:40 UTC (rev 1748) +++ trunk/complement/explore/lib/janus/samples/point1/point1.cc 2007-09-27 13:47:07 UTC (rev 1749) @@ -4,6 +4,8 @@ #include <janus/janus.h> #include <janus/vshostmgr.h> +#include <stem/EvManager.h> + #include <mt/xmt.h> #include <iostream> @@ -56,11 +58,13 @@ void YaSample::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { // VTNewMember_data( ev, "" ); + cerr << "new member" << endl; VTHandler::VSNewMember( ev ); } void YaSample::VSOutMember( const stem::Event_base<VSsync_rq>& ) { + cerr << "member out" << endl; } void YaSample::vs_line( const stem::Event& ev ) @@ -79,6 +83,13 @@ YaSample sample; + sample.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + sample.manager()->settrs( &std::cerr ); + + sample.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + sample.vtdispatcher()->settrs( &std::cerr ); + + sample.JoinGroup( janus::vs_base::first_user_group ); Event ev( VS_LINE ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-27 13:42:53
|
Revision: 1748 http://complement.svn.sourceforge.net/complement/?rev=1748&view=rev Author: complement Date: 2007-09-27 06:42:40 -0700 (Thu, 27 Sep 2007) Log Message: ----------- define __FIT_VS_TRACE macro for debug targets. Modified Paths: -------------- trunk/complement/explore/lib/janus/ChangeLog trunk/complement/explore/lib/janus/Makefile Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-09-27 13:41:12 UTC (rev 1747) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-09-27 13:42:40 UTC (rev 1748) @@ -1,8 +1,10 @@ 2007-09-27 Petr Ovtchenkov <pt...@is...> * vshostmgr.cc, janus.cc, vtime.cc: print trace info before - stem's Send. + stem's Send; + * Makefile: define __FIT_VS_TRACE macro for debug targets. + 2007-09-25 Petr Ovtchenkov <pt...@is...> * vshostmgr.h, vshostmgr.cc: try to connect to well-known hosts Modified: trunk/complement/explore/lib/janus/Makefile =================================================================== --- trunk/complement/explore/lib/janus/Makefile 2007-09-27 13:41:12 UTC (rev 1747) +++ trunk/complement/explore/lib/janus/Makefile 2007-09-27 13:42:40 UTC (rev 1748) @@ -20,6 +20,12 @@ endif dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg +dbg-shared: DEFS += -D__FIT_VS_TRACE + +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + check: all-shared $(MAKE) -C ut (cd ut; ${OUTPUT_DIR}/ut_vtime) || exit 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-27 13:41:21
|
Revision: 1747 http://complement.svn.sourceforge.net/complement/?rev=1747&view=rev Author: complement Date: 2007-09-27 06:41:12 -0700 (Thu, 27 Sep 2007) Log Message: ----------- print trace info before stem's Send Modified Paths: -------------- trunk/complement/explore/lib/janus/ChangeLog trunk/complement/explore/lib/janus/janus.cc trunk/complement/explore/lib/janus/vshostmgr.cc trunk/complement/explore/lib/janus/vtime.cc Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-09-26 10:58:43 UTC (rev 1746) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-09-27 13:41:12 UTC (rev 1747) @@ -1,3 +1,8 @@ +2007-09-27 Petr Ovtchenkov <pt...@is...> + + * vshostmgr.cc, janus.cc, vtime.cc: print trace info before + stem's Send. + 2007-09-25 Petr Ovtchenkov <pt...@is...> * vshostmgr.h, vshostmgr.cc: try to connect to well-known hosts Modified: trunk/complement/explore/lib/janus/janus.cc =================================================================== --- trunk/complement/explore/lib/janus/janus.cc 2007-09-26 10:58:43 UTC (rev 1746) +++ trunk/complement/explore/lib/janus/janus.cc 2007-09-27 13:41:12 UTC (rev 1747) @@ -276,7 +276,6 @@ ev.dest( i->second.stem_addr() ); ev.src( addr ); ev.value().grp = grp; - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -289,6 +288,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); } } @@ -341,7 +341,6 @@ ev.dest( addr ); ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); ev.value().grp = grp; - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -354,6 +353,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); } ++range.first; } @@ -414,7 +414,6 @@ ev.dest( addr ); ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); ev.value().grp = *grp; - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -427,6 +426,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); } ++range.first; } @@ -510,7 +510,6 @@ { if ( ev.value().grp == vshosts_group ) { ev.dest( _hostmgr->self_id() ); - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -523,6 +522,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); gaddr_type ga = manager()->reflect( ev.src() ); addr_type janus_addr = badaddr; @@ -536,7 +536,6 @@ stem::Event_base<VSsync_rq> evr( VS_NEW_MEMBER_RV ); evr.dest( janus_addr ); evr.value().grp = vshosts_group; - Send( evr ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -549,8 +548,22 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - + Send( evr ); } +#ifdef __FIT_VS_TRACE + else { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "Unexpected VS_NEW_MEMBER on Janus: G" << ev.value().grp << " " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } + } +#endif // __FIT_VS_TRACE } void Janus::VSNewRemoteMemberDirect( const stem::Event_base<VSsync_rq>& ev ) @@ -576,7 +589,6 @@ evs.dest( i->second.stem_addr() ); evs.src( addr ); evs.value().grp = grp; - Forward( evs ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -589,11 +601,11 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( evs ); stem::Event_base<VSsync_rq> evr( VS_NEW_MEMBER_RV ); evr.dest( janus_addr ); evr.src( i->second.stem_addr() ); evr.value().grp = grp; - Forward( evr ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -606,6 +618,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( evr ); } } @@ -632,7 +645,6 @@ evs.dest( i->second.stem_addr() ); evs.src( addr ); evs.value().grp = grp; - Forward( evs ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -645,6 +657,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( evs ); } } @@ -698,7 +711,6 @@ // send only to local addresses if ( (addr & stem::extbit) == 0 ) { ev.dest( addr ); - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(_lock_tr); @@ -711,6 +723,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); } } ++range.first; Modified: trunk/complement/explore/lib/janus/vshostmgr.cc =================================================================== --- trunk/complement/explore/lib/janus/vshostmgr.cc 2007-09-26 10:58:43 UTC (rev 1746) +++ trunk/complement/explore/lib/janus/vshostmgr.cc 2007-09-27 13:41:12 UTC (rev 1747) @@ -188,7 +188,6 @@ stem::Event_base<VSsync_rq> ev( VS_NEW_MEMBER ); ev.dest( a ); ev.value().grp = vshosts_group; // special group - Send( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(vtdispatcher()->_lock_tr); @@ -202,6 +201,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Send( ev ); return 0; } #ifdef __FIT_VS_TRACE @@ -263,7 +263,6 @@ if ( ga != *i ) { ev.dest( manager()->reflect( *i ) ); ev.value().grp = grp; - Forward( ev ); #ifdef __FIT_VS_TRACE try { scoped_lock lk(vtdispatcher()->_lock_tr); @@ -276,6 +275,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Forward( ev ); } } } Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-09-26 10:58:43 UTC (rev 1746) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-09-27 13:41:12 UTC (rev 1747) @@ -671,9 +671,6 @@ out_ev.value().grp = ev.value().grp; get_gvtime( ev.value().grp, out_ev.value().gvt.gvt ); out_ev.value().mess = data; - - Send( out_ev ); - #ifdef __FIT_VS_TRACE try { scoped_lock lk(_vtdsp->_lock_tr); @@ -686,6 +683,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + Send( out_ev ); } void VTHandler::get_gvtime( group_type g, gvtime_type& gvt ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-26 10:58:45
|
Revision: 1746 http://complement.svn.sourceforge.net/complement/?rev=1746&view=rev Author: complement Date: 2007-09-26 03:58:43 -0700 (Wed, 26 Sep 2007) Log Message: ----------- use cin for input; send message to group Modified Paths: -------------- trunk/complement/explore/lib/janus/samples/point1/point1.cc Modified: trunk/complement/explore/lib/janus/samples/point1/point1.cc =================================================================== --- trunk/complement/explore/lib/janus/samples/point1/point1.cc 2007-09-25 14:28:38 UTC (rev 1745) +++ trunk/complement/explore/lib/janus/samples/point1/point1.cc 2007-09-26 10:58:43 UTC (rev 1746) @@ -7,10 +7,12 @@ #include <mt/xmt.h> #include <iostream> +#include <string> using namespace janus; using namespace std; using namespace xmt; +using namespace stem; #define VS_LINE 0x1300 @@ -63,7 +65,7 @@ void YaSample::vs_line( const stem::Event& ev ) { - cerr << "Line here" << endl; + cerr << "Line here: '" << ev.value() << "'" << endl; } DEFINE_RESPONSE_TABLE( YaSample ) @@ -77,11 +79,26 @@ YaSample sample; - condition cnd; + sample.JoinGroup( janus::vs_base::first_user_group ); - cnd.set( false ); + Event ev( VS_LINE ); + ev.dest( janus::vs_base::first_user_group ); - cnd.wait(); + string line; + while ( cin.good() ) { + cin >> line; + if ( !cin.fail() ) { + ev.value() = line; + sample.JaSend( ev ); + } + } + + // condition cnd; + + // cnd.set( false ); + + // cnd.wait(); + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-25 14:28:41
|
Revision: 1745 http://complement.svn.sourceforge.net/complement/?rev=1745&view=rev Author: complement Date: 2007-09-25 07:28:38 -0700 (Tue, 25 Sep 2007) Log Message: ----------- trial configuration for virtual synchrony net, initial implementation Modified Paths: -------------- trunk/complement/explore/lib/janus/ChangeLog Added Paths: ----------- trunk/complement/explore/lib/janus/samples/ trunk/complement/explore/lib/janus/samples/point1/ trunk/complement/explore/lib/janus/samples/point1/Makefile trunk/complement/explore/lib/janus/samples/point1/Makefile.inc trunk/complement/explore/lib/janus/samples/point1/point1.cc Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-09-25 14:25:16 UTC (rev 1744) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-09-25 14:28:38 UTC (rev 1745) @@ -8,8 +8,11 @@ * lib/janus/ut/vt_operations.h, lib/janus/ut/vt_remote.cc: ditto; - * libjanus: version 0.4.0. + * libjanus: version 0.4.0; + * lib/janus/samples/point1: trial configuration for virtual + synchrony net, initial implementation; + 2007-08-27 Petr Ovtchenkov <pt...@is...> * janus.h, janus.cc: hide methods, intended for internal Property changes on: trunk/complement/explore/lib/janus/samples/point1 ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/janus/samples/point1/Makefile =================================================================== --- trunk/complement/explore/lib/janus/samples/point1/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/samples/point1/Makefile 2007-09-25 14:28:38 UTC (rev 1745) @@ -0,0 +1,26 @@ +# -*- Makefile -*- Time-stamp: <07/08/08 22:18:48 ptr> + +SRCROOT := ../../../.. +COMPILER_NAME := gcc +# ALL_TAGS := install-release-shared install-dbg-shared +# CoMT_DIR := ../../external/complement/explore + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +# DEFS += -DUNIT_TEST +INCLUDES += -I${CoMT_INCLUDE_DIR} + +release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -ljanus +dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -ljanusg +ifndef WITHOUT_STLPORT +stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -ljanusstlg +endif + +dbg-shared: DEFS += -D__FIT_VS_TRACE +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + +LDLIBS = -L${CoMT_LIB_DIR} -Wl,-rpath=${CoMT_LIB_DIR}:${STLPORT_LIB_DIR} ${PROJECT_LIBS} + Added: trunk/complement/explore/lib/janus/samples/point1/Makefile.inc =================================================================== --- trunk/complement/explore/lib/janus/samples/point1/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/samples/point1/Makefile.inc 2007-09-25 14:28:38 UTC (rev 1745) @@ -0,0 +1,5 @@ +# -*- Makefile -*- + +PRGNAME = point1 + +SRC_CC = point1.cc Added: trunk/complement/explore/lib/janus/samples/point1/point1.cc =================================================================== --- trunk/complement/explore/lib/janus/samples/point1/point1.cc (rev 0) +++ trunk/complement/explore/lib/janus/samples/point1/point1.cc 2007-09-25 14:28:38 UTC (rev 1745) @@ -0,0 +1,87 @@ +// -*- C++ -*- Time-stamp: <07/08/26 12:54:05 ptr> + +#include <janus/vtime.h> +#include <janus/janus.h> +#include <janus/vshostmgr.h> + +#include <mt/xmt.h> + +#include <iostream> + +using namespace janus; +using namespace std; +using namespace xmt; + +#define VS_LINE 0x1300 + +class YaSample : + public janus::VTHandler +{ + public: + YaSample(); + YaSample( stem::addr_type id, const char *info = 0 ); + YaSample( const char *info ); + ~YaSample(); + + private: + void vs_line( const stem::Event& ); + + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + DECLARE_RESPONSE_TABLE( YaSample, janus::VTHandler ); +}; + +YaSample::YaSample() : + janus::VTHandler() +{ +} + +YaSample::YaSample( stem::addr_type id, const char *info ) : + janus::VTHandler( id, info ) +{ +} + +YaSample::YaSample( const char *info ) : + janus::VTHandler( info ) +{ +} + +YaSample::~YaSample() +{ +} + +void YaSample::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); +} + +void YaSample::VSOutMember( const stem::Event_base<VSsync_rq>& ) +{ +} + +void YaSample::vs_line( const stem::Event& ev ) +{ + cerr << "Line here" << endl; +} + +DEFINE_RESPONSE_TABLE( YaSample ) + EV_EDS( ST_NULL, VS_LINE, vs_line ) +END_RESPONSE_TABLE + +int main() +{ + VSHostMgr::add_srvport( 6700 ); + VSHostMgr::add_wellknown( "island.corbina.net:6700" ); + + YaSample sample; + + condition cnd; + + cnd.set( false ); + + cnd.wait(); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-25 14:25:18
|
Revision: 1744 http://complement.svn.sourceforge.net/complement/?rev=1744&view=rev Author: complement Date: 2007-09-25 07:25:16 -0700 (Tue, 25 Sep 2007) Log Message: ----------- try to connect to well-known hosts and/or become a server to establish virtual synchrony net; libjanus: version 0.4.0 Modified Paths: -------------- trunk/complement/explore/include/janus/vshostmgr.h trunk/complement/explore/lib/janus/ChangeLog trunk/complement/explore/lib/janus/Makefile trunk/complement/explore/lib/janus/Makefile.inc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_operations.h trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vshostmgr.cc Modified: trunk/complement/explore/include/janus/vshostmgr.h =================================================================== --- trunk/complement/explore/include/janus/vshostmgr.h 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/include/janus/vshostmgr.h 2007-09-25 14:25:16 UTC (rev 1744) @@ -39,12 +39,15 @@ // typedef std::list<stem::gaddr_type> vshost_container_t; #if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) typedef std::tr1::unordered_set<stem::gaddr_type> vshost_container_t; + typedef std::tr1::unordered_set<std::string> vs_wellknown_hosts_container_t; #endif #ifdef __USE_STD_HASH typedef __gnu_cxx::hash_set<stem::gaddr_type> vshost_container_t; + typedef __gnu_cxx::hash_set<std::string> vs_wellknown_hosts_container_t; #endif #ifdef __USE_STLPORT_HASH typedef std::hash_set<stem::gaddr_type> vshost_container_t; + typedef std::hash_set<std::string> vs_wellknown_hosts_container_t; #endif public: @@ -60,9 +63,15 @@ void VSOutMember( const stem::Event_base<VSsync_rq>& ); void VSsync_time( const stem::Event_base<VSsync>& ev ); - void connect( const char *, int ); - void serve( int ); + static void add_wellknown( const char *nm ); + static void add_wellknown( const std::string& nm ); + static void rm_wellknown( const char *nm ); + static void rm_wellknown( const std::string& nm ); + static void add_srvport( int ); + int connect( const char *, int ); + int serve( int ); + size_type vs_known_processes() const { xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -102,6 +111,10 @@ Finalizer finalizer; + static xmt::mutex _wknh_lock; + static vs_wellknown_hosts_container_t _wknhosts; + static int _srvport; + // DECLARE_RESPONSE_TABLE( VSHostMgr, janus::VTHandler ); }; Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-09-25 14:25:16 UTC (rev 1744) @@ -1,3 +1,15 @@ +2007-09-25 Petr Ovtchenkov <pt...@is...> + + * vshostmgr.h, vshostmgr.cc: try to connect to well-known hosts + and/or become a server to establish virtual synchrony net; + + * ut/unit_test.cc: test for well-known hosts [nodes of virtual + synchrony net]; + + * lib/janus/ut/vt_operations.h, lib/janus/ut/vt_remote.cc: ditto; + + * libjanus: version 0.4.0. + 2007-08-27 Petr Ovtchenkov <pt...@is...> * janus.h, janus.cc: hide methods, intended for internal Modified: trunk/complement/explore/lib/janus/Makefile =================================================================== --- trunk/complement/explore/lib/janus/Makefile 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/Makefile 2007-09-25 14:25:16 UTC (rev 1744) @@ -21,11 +21,11 @@ dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg check: all-shared - $(MAKE) -C test - (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 - (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 + $(MAKE) -C ut + (cd ut; ${OUTPUT_DIR}/ut_vtime) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 ifndef WITHOUT_STLPORT - (cd test; ${OUTPUT_DIR_STLDBG}/ut_vt) || exit 1 + (cd ut; ${OUTPUT_DIR_STLDBG}/ut_vt) || exit 1 endif check-release-shared: release-shared @@ -43,7 +43,7 @@ endif depend:: - $(MAKE) -C test depend + $(MAKE) -C ut depend # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/lib/janus/Makefile.inc =================================================================== --- trunk/complement/explore/lib/janus/Makefile.inc 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/Makefile.inc 2007-09-25 14:25:16 UTC (rev 1744) @@ -2,6 +2,6 @@ LIBNAME = janus MAJOR = 0 -MINOR = 3 +MINOR = 4 PATCH = 0 SRC_CC = vtime.cc janus.cc vshostmgr.cc Modified: trunk/complement/explore/lib/janus/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-09-25 14:25:16 UTC (rev 1744) @@ -8,7 +8,7 @@ { using namespace janus; - exam::test_suite::test_case_type tc[3]; + exam::test_suite::test_case_type tc[4]; exam::test_suite t( "virtual time operations" ); @@ -23,7 +23,7 @@ tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); t.add( &vtime_operations::mgroups, vt_oper, "mgroups", - t.add( &vtime_operations::remote, vt_oper, "remote", + tc[3] = t.add( &vtime_operations::remote, vt_oper, "remote", t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", @@ -34,6 +34,8 @@ t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))) ); + t.add( &vtime_operations::wellknownhost, vt_oper, "well-known host", tc[3] ); + return t.girdle(); } Modified: trunk/complement/explore/lib/janus/ut/vt_operations.h =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-09-25 14:25:16 UTC (rev 1744) @@ -33,6 +33,7 @@ int EXAM_DECL(remote); int EXAM_DECL(mgroups); + int EXAM_DECL(wellknownhost); }; } // namespace janus Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-09-25 14:25:16 UTC (rev 1744) @@ -430,4 +430,92 @@ return EXAM_RESULT; } +int EXAM_IMPL(vtime_operations::wellknownhost) +{ + const char fname[] = "/tmp/yanus_test.shm"; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; + + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); + + VSHostMgr::add_wellknown( "localhost:6980" ); + VSHostMgr::add_srvport( 6980 ); + + try { + xmt::fork(); + + long res_flag = 0; + + b.wait(); + + { + YaRemote obj1( "obj client" ); + + obj1.JoinGroup( janus::vs_base::first_user_group ); + + obj1.wait_greeting(); + } + + exit( res_flag ); + } + catch ( xmt::fork_in_parent& child ) { + YaRemote obj1( "obj srv" ); + + // obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + // obj1.vtdispatcher()->settrs( &std::cerr ); + + // obj1.vtdispatcher()->serve( 6980 ); + + obj1.JoinGroup( janus::vs_base::first_user_group ); + + b.wait(); + + // while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { + // xmt::delay( xmt::timespec( 0, 1000000 ) ); + // } + + obj1.wait_greeting(); + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( janus::vs_base::first_user_group ); + ev.value() = "hello"; + + obj1.JaSend( ev ); + + EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); + EXAM_CHECK( obj1.count == 1 ); + + // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // obj1.manager()->settrs( &std::cerr ); + + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } + + EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1 ); + + EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); + // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; + } + + (&b)->~__barrier<true>(); + shm_b.deallocate( &b, 1 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + EXAM_ERROR( err.what() ); + } + + seg.deallocate(); + unlink( fname ); + + return EXAM_RESULT; +} + } // namespace janus Modified: trunk/complement/explore/lib/janus/vshostmgr.cc =================================================================== --- trunk/complement/explore/lib/janus/vshostmgr.cc 2007-09-24 19:06:03 UTC (rev 1743) +++ trunk/complement/explore/lib/janus/vshostmgr.cc 2007-09-25 14:25:16 UTC (rev 1744) @@ -48,6 +48,30 @@ vshost.insert( gaddr_type( stem::janus_addr ) ); JoinGroup( vshosts_group ); + + bool is_connected = false; + + xmt::scoped_lock lk( _wknh_lock ); + for ( vs_wellknown_hosts_container_t::const_iterator i = _wknhosts.begin(); i != _wknhosts.end(); ++i ) { + string s( *i ); + string::size_type p = s.find( ':' ); + if ( p != string::npos ) { + s.replace( p, 1, 1, ' ' ); + stringstream ss( s ); + int port = 0; + ss >> s >> port; + if ( !ss.fail() ) { + if ( connect( s.c_str(), port ) != 0 ) { + continue; + } + is_connected = true; + break; + } + } + } + if ( !is_connected && _srvport != 0 ) { + serve( _srvport ); + } } VSHostMgr::~VSHostMgr() @@ -141,12 +165,19 @@ VTHandler::VSsync_time(ev); } -void VSHostMgr::connect( const char *host, int port ) +int VSHostMgr::connect( const char *host, int port ) { - _clients.push_back( new NetTransportMgr() ); + NetTransportMgr *mgr = new NetTransportMgr(); - addr_type zero = _clients.back()->open( host, port ); + addr_type zero = mgr->open( host, port ); + if ( zero == stem::badaddr ) { + delete mgr; + return -1; + } + + _clients.push_back( mgr ); + gaddr_type ga = manager()->reflect( zero ); if ( ga != gaddr_type() ) { ga.addr = stem::janus_addr; @@ -171,6 +202,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE + return 0; } #ifdef __FIT_VS_TRACE else { @@ -184,27 +216,40 @@ } } #endif // __FIT_VS_TRACE + + delete _clients.back(); + _clients.pop_back(); + return -2; } -void VSHostMgr::serve( int port ) +int VSHostMgr::serve( int port ) { - _servers.push_back( new sockmgr_stream_MP<NetTransport>( port ) ); + sockmgr_stream_MP<NetTransport> *mgr = new sockmgr_stream_MP<NetTransport>( port ); + #ifdef __FIT_VS_TRACE try { scoped_lock lk(vtdispatcher()->_lock_tr); if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { *vtdispatcher()->_trs << "serve " << port - << (_servers.back()->good() ? " ok" : " fail" ) - << endl; + << (mgr->good() ? " ok" : " fail" ) << endl; } } catch ( ... ) { } #endif // __FIT_VS_TRACE + if ( !mgr->good() ) { + delete mgr; + return -2; + } + _servers.push_back( mgr ); + return 0; } void VSHostMgr::Subscribe( stem::addr_type addr, group_type grp ) { + if ( vshost.empty() ) { + return; + } try { manager()->transport( addr ); } @@ -226,16 +271,56 @@ *vtdispatcher()->_trs << " -> VS_NEW_REMOTE_MEMBER G" << grp << " " << hex << showbase << ev.src() << " -> " << ev.dest() << dec << endl; - } - } - catch ( ... ) { - } + } + } + catch ( ... ) { + } #endif // __FIT_VS_TRACE } } } } +xmt::mutex VSHostMgr::_wknh_lock; +VSHostMgr::vs_wellknown_hosts_container_t VSHostMgr::_wknhosts; +int VSHostMgr::_srvport = 0; + +void VSHostMgr::add_wellknown( const char *nm ) +{ + xmt::scoped_lock lk( _wknh_lock ); + _wknhosts.insert( string(nm) ); +} + +void VSHostMgr::add_wellknown( const std::string& nm ) +{ + xmt::scoped_lock lk( _wknh_lock ); + _wknhosts.insert( nm ); +} + +void VSHostMgr::rm_wellknown( const char *nm ) +{ + xmt::scoped_lock lk( _wknh_lock ); + vs_wellknown_hosts_container_t::iterator i = _wknhosts.find( string(nm) ); + if ( i != _wknhosts.end() ) { + _wknhosts.erase( i ); + } +} + +void VSHostMgr::rm_wellknown( const std::string& nm ) +{ + xmt::scoped_lock lk( _wknh_lock ); + vs_wellknown_hosts_container_t::iterator i = _wknhosts.find( nm ); + if ( i != _wknhosts.end() ) { + _wknhosts.erase( i ); + } +} + +void VSHostMgr::add_srvport( int p ) +{ + xmt::scoped_lock lk( _wknh_lock ); + _srvport = p; +} + // DEFINE_RESPONSE_TABLE( VSHostMgr ) // EV_Event_base_T_( ST_NULL, VS_NEW_REMOTE_MEMBER, VSNewRemoteMemberDirect, VSsync_rq ) // EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER_RV, VSNewRemoteMemberRevert, VSsync_rq ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-24 19:06:08
|
Revision: 1743 http://complement.svn.sourceforge.net/complement/?rev=1743&view=rev Author: complement Date: 2007-09-24 12:06:03 -0700 (Mon, 24 Sep 2007) Log Message: ----------- rewrite performance tests; still problem with write/read test Modified Paths: -------------- trunk/complement/explore/lib/sockios/perf/perf.cc trunk/complement/explore/lib/sockios/perf/sockios_perf.cc trunk/complement/explore/lib/sockios/perf/sockios_perf.h trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h Modified: trunk/complement/explore/lib/sockios/perf/perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/perf.cc 2007-09-24 19:04:25 UTC (rev 1742) +++ trunk/complement/explore/lib/sockios/perf/perf.cc 2007-09-24 19:06:03 UTC (rev 1743) @@ -13,5 +13,11 @@ int main( int, char ** ) { - return sockios_perf_suite(0); + int flag = 0; + + flag += sockios_perf_suite_b(0); + flag += sockios_perf_suite_c(0); + flag += sockios_perf_suite_d(0); + + return flag; } Modified: trunk/complement/explore/lib/sockios/perf/sockios_perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.cc 2007-09-24 19:04:25 UTC (rev 1742) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.cc 2007-09-24 19:06:03 UTC (rev 1743) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/06 11:17:21 ptr> +// -*- C++ -*- Time-stamp: <07/09/10 22:39:41 ptr> /* * @@ -22,25 +22,7 @@ using namespace std; -sockios_perf::sockios_perf() // : -// fname( "/tmp/sockios_perf.shm" ) -{ -// try { -// seg.allocate( fname.c_str(), 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); -// } -// catch ( const xmt::shm_bad_alloc& err ) { -// EXAM_ERROR_ASYNC( err.what() ); -// } -} - -sockios_perf::~sockios_perf() -{ -// seg.deallocate(); -// unlink( fname.c_str() ); -} - -/* ************************************************************ */ - +template <int N, int S> class SrvR { public: @@ -52,7 +34,7 @@ void connect( sockstream& s ) { - s.read( buf, 1024*8 ); + s.read( buf, S ); EXAM_CHECK_ASYNC( s.good() ); } @@ -60,17 +42,142 @@ { } private: - char buf[10240]; + char buf[S]; }; +sockmgr_stream_MP<SrvR<32,1638400> > *srv0; +sockmgr_stream_MP<SrvR<1024,51200> > *srv1; +sockmgr_stream_MP<SrvR<4096,12800> > *srv2; +sockmgr_stream_MP<SrvR<6400,8192> > *srv3; +sockmgr_stream_MP<SrvR<12800,4096> > *srv4; +sockmgr_stream_MP<SrvR<25600,2048> > *srv5; +sockmgr_stream_MP<SrvR<51200,1024> > *srv6; +sockmgr_stream_MP<SrvR<102400,512> > *srv7; +sockmgr_stream_MP<SrvR<204800,256> > *srv8; +sockmgr_stream_MP<SrvR<409600,128> > *srv9; +sockmgr_stream_MP<SrvR<819200,64> > *srv10; + +sockios_perf_SrvR::sockios_perf_SrvR() +{ + srv0 = new sockmgr_stream_MP<SrvR<32,1638400> >( 6480 ); + srv1 = new sockmgr_stream_MP<SrvR<1024,51200> >( 6481 ); + srv2 = new sockmgr_stream_MP<SrvR<4096,12800> >( 6482 ); + srv3 = new sockmgr_stream_MP<SrvR<6400,8192> >( 6483 ); + srv4 = new sockmgr_stream_MP<SrvR<12800,4096> >( 6484 ); + srv5 = new sockmgr_stream_MP<SrvR<25600,2048> >( 6485 ); + srv6 = new sockmgr_stream_MP<SrvR<51200,1024> >( 6486 ); + srv7 = new sockmgr_stream_MP<SrvR<102400,512> >( 6487 ); + srv8 = new sockmgr_stream_MP<SrvR<204800,256> >( 6488 ); + srv9 = new sockmgr_stream_MP<SrvR<409600,128> >( 6489 ); + srv10 = new sockmgr_stream_MP<SrvR<819200,64> >( 6490 ); +} + +sockios_perf_SrvR::~sockios_perf_SrvR() +{ + srv0->close(); srv0->wait(); + delete srv0; + srv1->close(); srv1->wait(); + delete srv1; + srv2->close(); srv2->wait(); + delete srv2; + srv3->close(); srv3->wait(); + delete srv3; + srv4->close(); srv4->wait(); + delete srv4; + srv5->close(); srv5->wait(); + delete srv5; + srv6->close(); srv6->wait(); + delete srv6; + srv7->close(); srv7->wait(); + delete srv7; + srv8->close(); srv8->wait(); + delete srv8; + srv9->close(); srv9->wait(); + delete srv9; + srv10->close(); srv10->wait(); + delete srv10; +} + +template <class SRV, int N, int S, int P> +int block_write( SRV& srv ) +{ + int flag = 0; + + EXAM_CHECK_ASYNC_F( srv.good() && srv.is_open(), flag ); + sockstream s( "localhost", P ); + char buf[S]; + // fill( buf, buf + S, ' ' ); + for ( int i = 0; i < N; ++i ) { + s.write( buf, S ).flush(); + EXAM_CHECK_ASYNC_F( s.good(), flag ); + } + + return flag; +} + +int EXAM_IMPL(sockios_perf_SrvR::r1) +{ + return block_write<sockmgr_stream_MP<SrvR<32,1638400> >, 32, 1638400, 6480>( *srv0 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r2) +{ + return block_write<sockmgr_stream_MP<SrvR<1024,51200> >, 1024, 51200, 6481>( *srv1 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r3) +{ + return block_write<sockmgr_stream_MP<SrvR<4096,12800> >, 4096, 12800, 6482>( *srv2 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r4) +{ + return block_write<sockmgr_stream_MP<SrvR<6400,8192> >, 6400, 8192, 6483>( *srv3 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r5) +{ + return block_write<sockmgr_stream_MP<SrvR<12800,4096> >, 12800, 4096, 6484>( *srv4 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r6) +{ + return block_write<sockmgr_stream_MP<SrvR<25600,2048> >, 25600, 2048, 6485>( *srv5 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r7) +{ + return block_write<sockmgr_stream_MP<SrvR<51200,1024> >, 51200, 1024, 6486>( *srv6 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r8) +{ + return block_write<sockmgr_stream_MP<SrvR<102400,512> >, 102400, 512, 6487>( *srv7 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r9) +{ + return block_write<sockmgr_stream_MP<SrvR<204800,256> >, 204800, 256, 6488>( *srv8 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r10) +{ + return block_write<sockmgr_stream_MP<SrvR<409600,128> >, 409600, 128, 6489>( *srv9 ); +} + +int EXAM_IMPL(sockios_perf_SrvR::r11) +{ + return block_write<sockmgr_stream_MP<SrvR<819200,64> >, 819200, 64, 6490>( *srv10 ); +} + +template <int N, int S> class SrvW { public: SrvW( sockstream& s ) { - fill( buf, buf + 10240, ' ' ); - for ( int i = 0; i < 10; ++i ) { - s.write( buf, 1024*8 ); + for ( int i = 0; i < N; ++i ) { + s.write( buf, S ).flush(); EXAM_CHECK_ASYNC( s.good() ); } } @@ -85,9 +192,135 @@ { } private: - char buf[10240]; + char buf[S]; }; +sockmgr_stream_MP<SrvW<32,1638400> > *srvW0; +sockmgr_stream_MP<SrvW<1024,51200> > *srvW1; +sockmgr_stream_MP<SrvW<4096,12800> > *srvW2; +sockmgr_stream_MP<SrvW<6400,8192> > *srvW3; +sockmgr_stream_MP<SrvW<12800,4096> > *srvW4; +sockmgr_stream_MP<SrvW<25600,2048> > *srvW5; +sockmgr_stream_MP<SrvW<51200,1024> > *srvW6; +sockmgr_stream_MP<SrvW<102400,512> > *srvW7; +sockmgr_stream_MP<SrvW<204800,256> > *srvW8; +sockmgr_stream_MP<SrvW<409600,128> > *srvW9; +sockmgr_stream_MP<SrvW<819200,64> > *srvW10; + +sockios_perf_SrvW::sockios_perf_SrvW() +{ + srvW0 = new sockmgr_stream_MP<SrvW<32,1638400> >( 6480 ); + srvW1 = new sockmgr_stream_MP<SrvW<1024,51200> >( 6481 ); + srvW2 = new sockmgr_stream_MP<SrvW<4096,12800> >( 6482 ); + srvW3 = new sockmgr_stream_MP<SrvW<6400,8192> >( 6483 ); + srvW4 = new sockmgr_stream_MP<SrvW<12800,4096> >( 6484 ); + srvW5 = new sockmgr_stream_MP<SrvW<25600,2048> >( 6485 ); + srvW6 = new sockmgr_stream_MP<SrvW<51200,1024> >( 6486 ); + srvW7 = new sockmgr_stream_MP<SrvW<102400,512> >( 6487 ); + srvW8 = new sockmgr_stream_MP<SrvW<204800,256> >( 6488 ); + srvW9 = new sockmgr_stream_MP<SrvW<409600,128> >( 6489 ); + srvW10 = new sockmgr_stream_MP<SrvW<819200,64> >( 6490 ); +} + +sockios_perf_SrvW::~sockios_perf_SrvW() +{ + srvW0->close(); srvW0->wait(); + delete srvW0; + srvW1->close(); srvW1->wait(); + delete srvW1; + srvW2->close(); srvW2->wait(); + delete srvW2; + srvW3->close(); srvW3->wait(); + delete srvW3; + srvW4->close(); srvW4->wait(); + delete srvW4; + srvW5->close(); srvW5->wait(); + delete srvW5; + srvW6->close(); srvW6->wait(); + delete srvW6; + srvW7->close(); srvW7->wait(); + delete srvW7; + srvW8->close(); srvW8->wait(); + delete srvW8; + srvW9->close(); srvW9->wait(); + delete srvW9; + srvW10->close(); srvW10->wait(); + delete srvW10; +} + +template <class SRV, int N, int S, int P> +int block_read( SRV& srv ) +{ + int flag = 0; + + EXAM_CHECK_ASYNC_F( srv.good() && srv.is_open(), flag ); + sockstream s( "localhost", P ); + char buf[S]; + // fill( buf, buf + S, ' ' ); + for ( int i = 0; i < N; ++i ) { + s.read( buf, S ); + EXAM_CHECK_ASYNC_F( s.good(), flag ); + } + + return flag; +} + +int EXAM_IMPL(sockios_perf_SrvW::r1) +{ + return block_read<sockmgr_stream_MP<SrvW<32,1638400> >, 32, 1638400, 6480>( *srvW0 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r2) +{ + return block_read<sockmgr_stream_MP<SrvW<1024,51200> >, 1024, 51200, 6481>( *srvW1 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r3) +{ + return block_read<sockmgr_stream_MP<SrvW<4096,12800> >, 4096, 12800, 6482>( *srvW2 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r4) +{ + return block_read<sockmgr_stream_MP<SrvW<6400,8192> >, 6400, 8192, 6483>( *srvW3 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r5) +{ + return block_read<sockmgr_stream_MP<SrvW<12800,4096> >, 12800, 4096, 6484>( *srvW4 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r6) +{ + return block_read<sockmgr_stream_MP<SrvW<25600,2048> >, 25600, 2048, 6485>( *srvW5 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r7) +{ + return block_read<sockmgr_stream_MP<SrvW<51200,1024> >, 51200, 1024, 6486>( *srvW6 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r8) +{ + return block_read<sockmgr_stream_MP<SrvW<102400,512> >, 102400, 512, 6487>( *srvW7 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r9) +{ + return block_read<sockmgr_stream_MP<SrvW<204800,256> >, 204800, 256, 6488>( *srvW8 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r10) +{ + return block_read<sockmgr_stream_MP<SrvW<409600,128> >, 409600, 128, 6489>( *srvW9 ); +} + +int EXAM_IMPL(sockios_perf_SrvW::r11) +{ + return block_read<sockmgr_stream_MP<SrvW<819200,64> >, 819200, 64, 6490>( *srvW10 ); +} + +template <int N, int S> class SrvRW { public: @@ -99,9 +332,9 @@ void connect( sockstream& s ) { - s.read( buf, 1024*8 ); + s.read( buf, S ); EXAM_CHECK_ASYNC( s.good() ); - s.write( buf, 1024*8 ).flush(); + s.write( buf, S ).flush(); EXAM_CHECK_ASYNC( s.good() ); } @@ -109,80 +342,132 @@ { } private: - char buf[10240]; + char buf[S]; }; -int EXAM_IMPL(sockios_perf::exchange1) +sockmgr_stream_MP<SrvRW<32,1638400> > *srvRW0; +sockmgr_stream_MP<SrvRW<1024,51200> > *srvRW1; +sockmgr_stream_MP<SrvRW<4096,12800> > *srvRW2; +sockmgr_stream_MP<SrvRW<6400,8192> > *srvRW3; +sockmgr_stream_MP<SrvRW<12800,4096> > *srvRW4; +sockmgr_stream_MP<SrvRW<25600,2048> > *srvRW5; +sockmgr_stream_MP<SrvRW<51200,1024> > *srvRW6; +sockmgr_stream_MP<SrvRW<102400,512> > *srvRW7; +sockmgr_stream_MP<SrvRW<204800,256> > *srvRW8; +sockmgr_stream_MP<SrvRW<409600,128> > *srvRW9; +sockmgr_stream_MP<SrvRW<819200,64> > *srvRW10; + +sockios_perf_SrvRW::sockios_perf_SrvRW() { - sockmgr_stream_MP<SrvR> srv( 6480 ); - - { - EXAM_REQUIRE( srv.good() && srv.is_open() ); + srvRW0 = new sockmgr_stream_MP<SrvRW<32,1638400> >( 6480 ); + srvRW1 = new sockmgr_stream_MP<SrvRW<1024,51200> >( 6481 ); + srvRW2 = new sockmgr_stream_MP<SrvRW<4096,12800> >( 6482 ); + srvRW3 = new sockmgr_stream_MP<SrvRW<6400,8192> >( 6483 ); + srvRW4 = new sockmgr_stream_MP<SrvRW<12800,4096> >( 6484 ); + srvRW5 = new sockmgr_stream_MP<SrvRW<25600,2048> >( 6485 ); + srvRW6 = new sockmgr_stream_MP<SrvRW<51200,1024> >( 6486 ); + srvRW7 = new sockmgr_stream_MP<SrvRW<102400,512> >( 6487 ); + srvRW8 = new sockmgr_stream_MP<SrvRW<204800,256> >( 6488 ); + srvRW9 = new sockmgr_stream_MP<SrvRW<409600,128> >( 6489 ); + srvRW10 = new sockmgr_stream_MP<SrvRW<819200,64> >( 6490 ); +} - sockstream s1( "localhost", 6480 ); - char buf[10240]; +sockios_perf_SrvRW::~sockios_perf_SrvRW() +{ + srvRW0->close(); srvRW0->wait(); + delete srvRW0; + srvRW1->close(); srvRW1->wait(); + delete srvRW1; + srvRW2->close(); srvRW2->wait(); + delete srvRW2; + srvRW3->close(); srvRW3->wait(); + delete srvRW3; + srvRW4->close(); srvRW4->wait(); + delete srvRW4; + srvRW5->close(); srvRW5->wait(); + delete srvRW5; + srvRW6->close(); srvRW6->wait(); + delete srvRW6; + srvRW7->close(); srvRW7->wait(); + delete srvRW7; + srvRW8->close(); srvRW8->wait(); + delete srvRW8; + srvRW9->close(); srvRW9->wait(); + delete srvRW9; + srvRW10->close(); srvRW10->wait(); + delete srvRW10; +} - fill( buf, buf + 10240, ' ' ); +template <class SRV, int N, int S, int P> +int block_write_read( SRV& srv ) +{ + int flag = 0; - for ( int i = 0; i < 10; ++i ) { - s1.write( buf, 1024 * 8 ); - EXAM_CHECK_ASYNC( s1.good() ); - } + EXAM_CHECK_ASYNC_F( srv.good() && srv.is_open(), flag ); + sockstream s( "localhost", P ); + char buf[S]; + // fill( buf, buf + S, ' ' ); + for ( int i = 0; i < N; ++i ) { + s.write( buf, S ).flush(); + EXAM_CHECK_ASYNC_F( s.good(), flag ); + s.read( buf, S ); + EXAM_CHECK_ASYNC_F( s.good(), flag ); } - srv.close(); - srv.wait(); + return flag; +} - return EXAM_RESULT; +int EXAM_IMPL(sockios_perf_SrvRW::r1) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<32,1638400> >, 32, 1638400, 6480>( *srvRW0 ); } -int EXAM_IMPL(sockios_perf::exchange2) +int EXAM_IMPL(sockios_perf_SrvRW::r2) { - sockmgr_stream_MP<SrvW> srv( 6480 ); - - { - EXAM_REQUIRE( srv.good() && srv.is_open() ); + return block_write_read<sockmgr_stream_MP<SrvRW<1024,51200> >, 1024, 51200, 6481>( *srvRW1 ); +} - sockstream s1( "localhost", 6480 ); - char buf[10240]; +int EXAM_IMPL(sockios_perf_SrvRW::r3) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<4096,12800> >, 4096, 12800, 6482>( *srvRW2 ); +} - for ( int i = 0; i < 10; ++i ) { - s1.read( buf, 1024 * 8 ); - EXAM_CHECK_ASYNC( s1.good() ); - } - } +int EXAM_IMPL(sockios_perf_SrvRW::r4) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<6400,8192> >, 6400, 8192, 6483>( *srvRW3 ); +} - srv.close(); - srv.wait(); +int EXAM_IMPL(sockios_perf_SrvRW::r5) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<12800,4096> >, 12800, 4096, 6484>( *srvRW4 ); +} - return EXAM_RESULT; +int EXAM_IMPL(sockios_perf_SrvRW::r6) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<25600,2048> >, 25600, 2048, 6485>( *srvRW5 ); } -int EXAM_IMPL(sockios_perf::exchange3) +int EXAM_IMPL(sockios_perf_SrvRW::r7) { - sockmgr_stream_MP<SrvRW> srv( 6480 ); - - { - EXAM_REQUIRE( srv.good() && srv.is_open() ); + return block_write_read<sockmgr_stream_MP<SrvRW<51200,1024> >, 51200, 1024, 6486>( *srvRW6 ); +} - sockstream s1( "localhost", 6480 ); - char buf[10240]; +int EXAM_IMPL(sockios_perf_SrvRW::r8) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<102400,512> >, 102400, 512, 6487>( *srvRW7 ); +} - for ( int i = 0; i < 10; ++i ) { - s1.write( buf, 1024 * 8 ).flush(); - EXAM_CHECK_ASYNC( s1.good() ); - s1.read( buf, 1024 * 8 ); - EXAM_CHECK_ASYNC( s1.good() ); - } - } +int EXAM_IMPL(sockios_perf_SrvRW::r9) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<204800,256> >, 204800, 256, 6488>( *srvRW8 ); +} - srv.close(); - srv.wait(); - - return EXAM_RESULT; +int EXAM_IMPL(sockios_perf_SrvRW::r10) +{ + return block_write_read<sockmgr_stream_MP<SrvRW<409600,128> >, 409600, 128, 6489>( *srvRW9 ); } -xmt::Thread::ret_t client_thr( void *p ) +int EXAM_IMPL(sockios_perf_SrvRW::r11) { - return 0; + return block_write_read<sockmgr_stream_MP<SrvRW<819200,64> >, 819200, 64, 6490>( *srvRW10 ); } Modified: trunk/complement/explore/lib/sockios/perf/sockios_perf.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.h 2007-09-24 19:04:25 UTC (rev 1742) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.h 2007-09-24 19:06:03 UTC (rev 1743) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/06 11:12:29 ptr> +// -*- C++ -*- Time-stamp: <07/09/12 22:57:45 ptr> /* * @@ -16,21 +16,61 @@ #include <string> #include <mt/shm.h> -class sockios_perf +class sockios_perf_SrvR { public: - sockios_perf(); - ~sockios_perf(); + sockios_perf_SrvR(); + ~sockios_perf_SrvR(); - int EXAM_DECL(exchange1); - int EXAM_DECL(exchange2); - int EXAM_DECL(exchange3); + int EXAM_DECL(r1); + int EXAM_DECL(r2); + int EXAM_DECL(r3); + int EXAM_DECL(r4); + int EXAM_DECL(r5); + int EXAM_DECL(r6); + int EXAM_DECL(r7); + int EXAM_DECL(r8); + int EXAM_DECL(r9); + int EXAM_DECL(r10); + int EXAM_DECL(r11); +}; - private: - // const std::string fname; - // xmt::shm_alloc<0> seg; - // xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; - // xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; +class sockios_perf_SrvW +{ + public: + sockios_perf_SrvW(); + ~sockios_perf_SrvW(); + + int EXAM_DECL(r1); + int EXAM_DECL(r2); + int EXAM_DECL(r3); + int EXAM_DECL(r4); + int EXAM_DECL(r5); + int EXAM_DECL(r6); + int EXAM_DECL(r7); + int EXAM_DECL(r8); + int EXAM_DECL(r9); + int EXAM_DECL(r10); + int EXAM_DECL(r11); }; +class sockios_perf_SrvRW +{ + public: + sockios_perf_SrvRW(); + ~sockios_perf_SrvRW(); + + int EXAM_DECL(r1); + int EXAM_DECL(r2); + int EXAM_DECL(r3); + int EXAM_DECL(r4); + int EXAM_DECL(r5); + int EXAM_DECL(r6); + int EXAM_DECL(r7); + int EXAM_DECL(r8); + int EXAM_DECL(r9); + int EXAM_DECL(r10); + int EXAM_DECL(r11); +}; + #endif // __sockios_perf_h Modified: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc 2007-09-24 19:04:25 UTC (rev 1742) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc 2007-09-24 19:06:03 UTC (rev 1743) @@ -17,17 +17,68 @@ using namespace std; -int EXAM_IMPL(sockios_perf_suite) +int EXAM_IMPL(sockios_perf_suite_b) { exam::trivial_time_logger tlogger( std::cout ); - exam::test_suite t( "libsockios performance test suite", 10 ); + exam::test_suite t( "libsockios performance test suite 0", 10 ); t.set_logger( &tlogger ); - sockios_perf p; + sockios_perf_SrvR p; + t.add( &sockios_perf_SrvR::r1, p, "client write 32 1638400 bytes blocks" ); + t.add( &sockios_perf_SrvR::r2, p, "client write 1024 51200 bytes blocks" ); + t.add( &sockios_perf_SrvR::r3, p, "client write 4096 12800 bytes blocks" ); + t.add( &sockios_perf_SrvR::r4, p, "client write 6400 8192 bytes blocks" ); + t.add( &sockios_perf_SrvR::r5, p, "client write 12800 4096 bytes blocks" ); + t.add( &sockios_perf_SrvR::r6, p, "client write 25600 2048 bytes blocks" ); + t.add( &sockios_perf_SrvR::r7, p, "client write 51200 1024 bytes blocks" ); + t.add( &sockios_perf_SrvR::r8, p, "client write 102400 512 bytes blocks" ); + t.add( &sockios_perf_SrvR::r9, p, "client write 204800 256 bytes blocks" ); + t.add( &sockios_perf_SrvR::r10, p, "client write 409600 128 bytes blocks" ); + t.add( &sockios_perf_SrvR::r11, p, "client write 819200 64 bytes blocks" ); - t.add( &sockios_perf::exchange1, p, "client write 8K blocks" ); - t.add( &sockios_perf::exchange2, p, "client read 8K blocks" ); - t.add( &sockios_perf::exchange3, p, "client write/read 8K blocks" ); + return t.girdle(); +} +int EXAM_IMPL(sockios_perf_suite_c) +{ + exam::trivial_time_logger tlogger( std::cout ); + exam::test_suite t( "libsockios performance test suite 1", 10 ); + t.set_logger( &tlogger ); + + sockios_perf_SrvW p; + t.add( &sockios_perf_SrvW::r1, p, "client read 32 1638400 bytes blocks" ); + t.add( &sockios_perf_SrvW::r2, p, "client read 1024 51200 bytes blocks" ); + t.add( &sockios_perf_SrvW::r3, p, "client read 4096 12800 bytes blocks" ); + t.add( &sockios_perf_SrvW::r4, p, "client read 6400 8192 bytes blocks" ); + t.add( &sockios_perf_SrvW::r5, p, "client read 12800 4096 bytes blocks" ); + t.add( &sockios_perf_SrvW::r6, p, "client read 25600 2048 bytes blocks" ); + t.add( &sockios_perf_SrvW::r7, p, "client read 51200 1024 bytes blocks" ); + t.add( &sockios_perf_SrvW::r8, p, "client read 102400 512 bytes blocks" ); + t.add( &sockios_perf_SrvW::r9, p, "client read 204800 256 bytes blocks" ); + t.add( &sockios_perf_SrvW::r10, p, "client read 409600 128 bytes blocks" ); + t.add( &sockios_perf_SrvW::r11, p, "client read 819200 64 bytes blocks" ); + return t.girdle(); } + +int EXAM_IMPL(sockios_perf_suite_d) +{ + exam::trivial_time_logger tlogger( std::cout ); + exam::test_suite t( "libsockios performance test suite 2", 10 ); + t.set_logger( &tlogger ); + + sockios_perf_SrvRW p; + t.add( &sockios_perf_SrvRW::r1, p, "client write/read 32 1638400 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r2, p, "client write/read 1024 51200 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r3, p, "client write/read 4096 12800 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r4, p, "client write/read 6400 8192 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r5, p, "client write/read 12800 4096 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r6, p, "client write/read 25600 2048 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r7, p, "client write/read 51200 1024 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r8, p, "client write/read 102400 512 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r9, p, "client write/read 204800 256 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r10, p, "client write/read 409600 128 bytes blocks" ); + t.add( &sockios_perf_SrvRW::r11, p, "client write/read 819200 64 bytes blocks" ); + + return t.girdle(); +} Modified: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h 2007-09-24 19:04:25 UTC (rev 1742) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h 2007-09-24 19:06:03 UTC (rev 1743) @@ -14,6 +14,8 @@ #include <exam/suite.h> -int EXAM_DECL(sockios_perf_suite); +int EXAM_DECL(sockios_perf_suite_b); +int EXAM_DECL(sockios_perf_suite_c); +int EXAM_DECL(sockios_perf_suite_d); #endif // __sockios_perf_suite_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-24 19:04:29
|
Revision: 1742 http://complement.svn.sourceforge.net/complement/?rev=1742&view=rev Author: complement Date: 2007-09-24 12:04:25 -0700 (Mon, 24 Sep 2007) Log Message: ----------- rename loop_id to loop_thr, for correct interpretation; clean main loop of connection_processor; initialize buffer; reduce number of iterations for test; libsockios: Version 1.13.0. 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/lib/sockios/ut/sockios_test.cc trunk/complement/explore/lib/sockios/ut/sockios_test_suite.cc Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-24 19:04:25 UTC (rev 1742) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/13 23:10:08 ptr> +// -*- C++ -*- Time-stamp: <07/09/19 11:43:21 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -63,7 +63,7 @@ } _loop_cnd.set( false ); - loop_id.launch( loop, this, 0, PTHREAD_STACK_MIN * 2 ); + loop_thr.launch( loop, this, 0, PTHREAD_STACK_MIN * 2 ); _loop_cnd.try_wait(); } } @@ -376,7 +376,7 @@ xmt::Thread::ret_t sockmgr_stream_MP<Connect,C,T>::loop( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); - me->loop_id.pword( _idx ) = me; // push pointer to self for signal processing + me->loop_thr.pword( _idx ) = me; // push pointer to self for signal processing xmt::Thread::ret_t rtc = 0; xmt::Thread::ret_t rtc_observer = 0; @@ -387,7 +387,7 @@ me->_follow = true; - while ( (me->*me->_accept)() ) { + while ( (me->*me->_accept)() /* && me->_is_follow() */ ) { if ( thr_observer.bad() ) { if ( thr_observer.is_join_req() ) { rtc_observer = thr_observer.join(); @@ -421,6 +421,7 @@ // me->_c_lock.unlock(); rtc_observer = thr_observer.join(); + xmt::scoped_lock _l( me->_c_lock ); me->_M_c.clear(); // FIN still may not come yet; force close if ( rtc_observer != 0 && rtc == 0 ) { rtc = reinterpret_cast<xmt::Thread::ret_t>(-2); // there was connect_processor that was killed @@ -436,75 +437,74 @@ try { timespec idle( me->_idle ); + typename _Sequence::iterator c; - me->_dlock.lock(); - typename _Sequence::iterator c; - bool _non_empty = false; - if ( me->_conn_pool.size() != 0 ) { + { + xmt::scoped_lock lk(me->_dlock); + if ( me->_conn_pool.empty() ) { + me->_pool_cnd.set( false ); + me->_observer_cnd.set( false ); + return 0; + } c = me->_conn_pool.front(); me->_conn_pool.pop_front(); - _non_empty = true; xmt::gettime( &me->_tpop ); } - me->_dlock.unlock(); do { - if ( _non_empty ) { - sockstream& stream = c->s; - if ( stream.is_open() ) { - (c->_proc->*C)( stream ); - if ( stream.is_open() && stream.good() ) { - if ( stream.rdbuf()->in_avail() > 0 ) { - // socket has buffered data, push it back to queue - xmt::scoped_lock lk(me->_dlock); - me->_conn_pool.push_back( c ); - me->_observer_cnd.set( true ); - me->_pool_cnd.set( true ); - if ( !me->_follow ) { - break; - } - c = me->_conn_pool.front(); - me->_conn_pool.pop_front(); - xmt::gettime( &me->_tpop ); - // xmt::Thread::gettime( &me->_tpush ); - continue; - } else { // no buffered data, return socket to poll - sock_base::socket_type rfd = stream.rdbuf()->fd(); - ::write( me->_cfd, reinterpret_cast<const char *>(&rfd), sizeof(sock_base::socket_type) ); + sockstream& stream = c->s; + if ( stream.is_open() ) { + (c->_proc->*C)( stream ); + if ( stream.is_open() && stream.good() ) { + if ( stream.rdbuf()->in_avail() > 0 ) { + // socket has buffered data, push it back to queue + xmt::scoped_lock lk(me->_dlock); + me->_conn_pool.push_back( c ); + me->_observer_cnd.set( true ); + me->_pool_cnd.set( true ); + if ( !me->_follow ) { + break; } - } 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(); + c = me->_conn_pool.front(); + me->_conn_pool.pop_front(); + xmt::gettime( &me->_tpop ); + // xmt::Thread::gettime( &me->_tpush ); + continue; + } else { // no buffered data, return socket to poll + 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::scoped_lock _l( me->_c_lock ); - me->_M_c.erase( c ); - } + xmt::scoped_lock _l( me->_c_lock ); + me->_M_c.erase( c ); } } - _non_empty = false; - - if ( me->_pool_cnd.try_wait_delay( &idle ) == 0 ) { + { xmt::scoped_lock lk(me->_dlock); - if ( !me->_follow ) { - return 0; + if ( me->_conn_pool.empty() ) { + lk.unlock(); + if ( me->_pool_cnd.try_wait_delay( &idle ) != 0 ) { + lk.lock(); + me->_pool_cnd.set( false ); + me->_observer_cnd.set( false ); + return 0; + } + if ( !me->_is_follow() ) { // before _conn_pool.front() + return 0; + } + lk.lock(); + if ( me->_conn_pool.empty() ) { + return 0; + } } - if ( me->_conn_pool.size() != 0 ) { - c = me->_conn_pool.front(); - me->_conn_pool.pop_front(); - _non_empty = true; - xmt::gettime( &me->_tpop ); - } else { - me->_pool_cnd.set( false ); - me->_observer_cnd.set( false ); - return 0; - } - } else { - xmt::scoped_lock lk(me->_dlock); - me->_pool_cnd.set( false ); - me->_observer_cnd.set( false ); - return 0; + c = me->_conn_pool.front(); + me->_conn_pool.pop_front(); + xmt::gettime( &me->_tpop ); } } while ( me->_is_follow() ); } @@ -610,7 +610,7 @@ FD_SET( fd_unsafe(), &_pfde ); _fdmax = fd_unsafe(); - loop_id.launch( loop, this, 0, PTHREAD_STACK_MIN * 2 ); + loop_thr.launch( loop, this, 0, PTHREAD_STACK_MIN * 2 ); } } Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-09-24 19:04:25 UTC (rev 1742) @@ -192,7 +192,7 @@ } ~sockmgr_stream_MP() - { loop_id.join(); } + { loop_thr.join(); } private: sockmgr_stream_MP( const sockmgr_stream_MP<Connect,C,T>& ); @@ -207,7 +207,7 @@ { basic_sockmgr::close(); } void wait() - { loop_id.join(); } + { loop_thr.join(); } void detach( sockstream& ) // remove sockstream from polling in manager { } @@ -237,7 +237,7 @@ { } ~_Connect() - { if ( _proc ) { s.close(); (_proc->*T)(); } delete _proc; } + { if ( _proc ) { s.close(); (_proc->*T)(); delete _proc; _proc = 0; } } void open( sock_base::socket_type st, const sockaddr& addr, sock_base::stype t = sock_base::sock_stream ) { s.open( st, addr, t ); _proc = new Connect( s ); } @@ -289,7 +289,7 @@ bool accept_udp(); private: - xmt::Thread loop_id; + xmt::Thread loop_thr; protected: typedef sockmgr_stream_MP<Connect,C,T> _Self_type; Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-24 19:04:25 UTC (rev 1742) @@ -1,3 +1,13 @@ +2007-09-24 Petr Ovtchenkov <pt...@is...> + + * sockios/sockmgr.h, sockios/sockmgr.cc: rename loop_id to loop_thr, + for correct interpretation; clean main loop of connection_processor; + + * ut/sockios_test.cc: initialize buffer; reduce number of iterations + for test; + + * libsockios: Version 1.13.0. + 2007-09-07 Petr Ovtchenkov <pt...@is...> * sockstream, sockstream.cc: prepare for __FIT_NONBLOCK_SOCKETS. Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-09-24 19:04:25 UTC (rev 1742) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <07/07/12 00:53:38 ptr> +# -*- Makefile -*- Time-stamp: <07/09/24 22:52:43 ptr> LIBNAME = sockios MAJOR = 1 -MINOR = 12 -PATCH = 1 +MINOR = 13 +PATCH = 0 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ freebsd/ns_parse.c \ Modified: trunk/complement/explore/lib/sockios/ut/sockios_test.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-24 19:04:25 UTC (rev 1742) @@ -664,7 +664,7 @@ char buf[1024]; int count = 0; - for ( int i = 0; i < 1024 * 1024; ++i ) { + for ( int i = 0; i < 128 * 1024; ++i ) { s.read( buf, 1024 ); } cnd.set( true ); @@ -693,7 +693,9 @@ char buf[1024]; - for ( int i = 0; i < 1024 * 1024; ++i ) { + fill( buf, buf + 1024, ' ' ); + + for ( int i = 0; i < 128 * 1024; ++i ) { s.write( buf, 1024 ); } s.flush(); Modified: trunk/complement/explore/lib/sockios/ut/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/sockios_test_suite.cc 2007-09-24 18:50:50 UTC (rev 1741) +++ trunk/complement/explore/lib/sockios/ut/sockios_test_suite.cc 2007-09-24 19:04:25 UTC (rev 1742) @@ -36,6 +36,8 @@ exam::test_suite t( "libsockios test" ); + // t.flags( t.flags() | exam::base_logger::trace ); + trivial_sockios_test trivial_test; tc[0] = t.add( &trivial_sockios_test::simple, trivial_test, "trivial_sockios_test::simple" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-24 18:50:53
|
Revision: 1741 http://complement.svn.sourceforge.net/complement/?rev=1741&view=rev Author: complement Date: 2007-09-24 11:50:50 -0700 (Mon, 24 Sep 2007) Log Message: ----------- macro for demangle, used for call stack printing Modified Paths: -------------- trunk/complement/explore/include/config/_gcc.h Modified: trunk/complement/explore/include/config/_gcc.h =================================================================== --- trunk/complement/explore/include/config/_gcc.h 2007-09-24 18:49:09 UTC (rev 1740) +++ trunk/complement/explore/include/config/_gcc.h 2007-09-24 18:50:50 UTC (rev 1741) @@ -27,4 +27,6 @@ # define __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION #endif +#define __FIT_CPP_DEMANGLE + #endif /* __config__gcc_h */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-24 18:49:16
|
Revision: 1740 http://complement.svn.sourceforge.net/complement/?rev=1740&view=rev Author: complement Date: 2007-09-24 11:49:09 -0700 (Mon, 24 Sep 2007) Log Message: ----------- print call stack to ostream, initial implementation; store call stack when thread created; useful for debugging; macro to force store call stack when thread created; recompilation required when changed; bfd library required for call stack printing; initial test for call stack output; libxmt: version 1.14.0 Modified Paths: -------------- trunk/complement/explore/include/config/feature.h trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/ut/mt_test.cc trunk/complement/explore/lib/mt/ut/mt_test.h trunk/complement/explore/lib/mt/ut/mt_test_suite.cc trunk/complement/explore/lib/mt/xmt.cc Added Paths: ----------- trunk/complement/explore/include/mt/callstack.h trunk/complement/explore/lib/mt/callstack.cc Modified: trunk/complement/explore/include/config/feature.h =================================================================== --- trunk/complement/explore/include/config/feature.h 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/include/config/feature.h 2007-09-24 18:49:09 UTC (rev 1740) @@ -112,4 +112,11 @@ # define __FIT_TYPENAME_ARG #endif /* __FIT_NEED_TYPENAME_IN_ARGS_BUG */ +/* + Store information about stack before create thread in xmt::Thread; + useful for debugging. +*/ + +#define __FIT_CREATE_THREAD_STACK_INFO + #endif /* __config_feature_h */ Added: trunk/complement/explore/include/mt/callstack.h =================================================================== --- trunk/complement/explore/include/mt/callstack.h (rev 0) +++ trunk/complement/explore/include/mt/callstack.h 2007-09-24 18:49:09 UTC (rev 1740) @@ -0,0 +1,22 @@ +// -*- C++ -*- Time-stamp: <07/08/03 09:47:53 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __mt_callstack_h +#define __mt_callstack_h + +#include <ostream> + +namespace xmt { + +void callstack( std::ostream& ); + +} // namespace xmt + +#endif Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/include/mt/xmt.h 2007-09-24 18:49:09 UTC (rev 1740) @@ -1538,7 +1538,9 @@ size_t _param_sz; unsigned _flags; size_t _stack_sz; // stack size, if not 0 - // mutex _llock; +#ifdef __FIT_CREATE_THREAD_STACK_INFO + std::string _stack_on_create; +#endif friend class Init; // extern "C", wrap for thread_create // #ifdef __unix Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-09-24 18:49:09 UTC (rev 1740) @@ -1,3 +1,21 @@ +2007-09-24 Petr Ovtchenkov <pt...@is...> + + * callstack.h, callstack.cc: print call stack to ostream, initial + implementation; + + * xmt.h, xmt.cc: store call stack when thread created; useful for + debugging; + + * config/feature.h: macro to force store call stack when thread + created; recompilation required when changed; + + * Makefile: bfd library required for call stack printing; + + * ut/mt_test.cc, ut/mt_test.h, ut/mt_test_suite.cc: initial test for + call stack output. + + * libxmt: version 1.14.0 + 2007-09-18 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: removed intermediate _xcall, use direct call of _call Modified: trunk/complement/explore/lib/mt/Makefile =================================================================== --- trunk/complement/explore/lib/mt/Makefile 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/Makefile 2007-09-24 18:49:09 UTC (rev 1740) @@ -8,6 +8,8 @@ INCLUDES += -I$(SRCROOT)/include HEADERS_BASE = $(SRCROOT)/include/mt $(SRCROOT)/include/config $(SRCROOT)/include/misc +LDLIBS += -ldl -lbfd + check: all-shared $(MAKE) -C ut all-shared (cd ut; ${OUTPUT_DIR}/mt_ut) || exit 1 Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-09-24 18:49:09 UTC (rev 1740) @@ -2,7 +2,7 @@ LIBNAME = xmt MAJOR = 1 -MINOR = 13 +MINOR = 14 PATCH = 0 -SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc +SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc callstack.cc SRC_C = fl.c Added: trunk/complement/explore/lib/mt/callstack.cc =================================================================== --- trunk/complement/explore/lib/mt/callstack.cc (rev 0) +++ trunk/complement/explore/lib/mt/callstack.cc 2007-09-24 18:49:09 UTC (rev 1740) @@ -0,0 +1,304 @@ +// -*- C++ -*- Time-stamp: <07/09/21 22:45:51 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +/** + * Derived from: + * http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV + * + * This code is in the public domain. Use it as you see fit, some credit + * would be appreciated, but is not a prerequisite for usage. Feedback + * on it's use would encourage further development and maintenance. + * + * Author: Jaco Kroon <ja...@kr...> + * + * Copyright (C) 2005 - 2006 Jaco Kroon + */ + +#include <config/feature.h> + +// #define _GNU_SOURCE +// #include <memory.h> +// #include <stdlib.h> +// #include <stdio.h> + +#include <bfd.h> +#include <signal.h> +#include <ucontext.h> +#include <dlfcn.h> +#include <execinfo.h> + +#ifdef __FIT_CPP_DEMANGLE +# include <cxxabi.h> +#endif + +#if 1 +#if defined(REG_RIP) +# define SIGSEGV_STACK_IA64 +// # define REGFORMAT "%016lx" +#elif defined(REG_EIP) +# define SIGSEGV_STACK_X86 +// # define REGFORMAT "%08x" +#else +# define SIGSEGV_STACK_GENERIC +// # define REGFORMAT "%x" +#endif +#endif + +#include <cstring> + +#include <mt/callstack.h> +#include <iomanip> +#include <string> +#include <sstream> + +namespace xmt { + +using namespace std; + +class BFD_Init +{ + public: + BFD_Init() + { + bfd_init(); + bfd_set_default_target( "i686-pc-linux-gnu" ); + } +}; + +BFD_Init init; + +struct params_collect +{ + bfd_boolean found; + bfd_vma pc; + asymbol **syms; + const char *fname; + const char *funcname; + unsigned line; +}; + +void find_address_in_section( bfd *abfd, asection *section, void *data ) +{ + bfd_boolean& found = static_cast<params_collect *>(data)->found; + + if ( found ) { + return; + } + + if ( (bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0 ) { + return; + } + + bfd_vma vma = bfd_get_section_vma( abfd, section ); + bfd_vma& pc = static_cast<params_collect *>(data)->pc; + if ( pc < vma ) { + return; + } + + bfd_size_type size = bfd_get_section_size( section ); + if ( pc >= vma + size ) { + return; + } + + found = bfd_find_nearest_line( abfd, section, + static_cast<params_collect *>(data)->syms, pc - vma, + &static_cast<params_collect *>(data)->fname, + &static_cast<params_collect *>(data)->funcname, + &static_cast<params_collect *>(data)->line ); +} + +int extract_info( const char *fname, void *addr, string& file, unsigned& line ) +{ + bfd *abfd = bfd_openr( fname, 0 ); + if ( abfd == 0 ) { + return -1; + } + + char **matching; + if ( !bfd_check_format_matches( abfd, bfd_object, &matching ) ) { + // free (matching); + return -2; + } + + // slurp_symtab (abfd); + asymbol **syms = 0; // Symbol table + + if ( ( bfd_get_file_flags(abfd) & HAS_SYMS ) != 0 ) { + long symcount; + unsigned int size; + + symcount = bfd_read_minisymbols( abfd, 0, (void **)&syms, &size ); + if ( symcount == 0 ) { + symcount = bfd_read_minisymbols( abfd, 1, (void **)&syms, &size ); + } + + if ( symcount < 0 ) { + if ( syms != 0 ) { + free( syms ); + } + bfd_close( abfd ); + return -3; + } + } + + params_collect pars; + pars.found = 0; + pars.syms = syms; + + // translate_addresses (abfd, 0); + + // for ( ; ; ) { + pars.pc = reinterpret_cast<bfd_vma>(addr); + bfd_map_over_sections( abfd, find_address_in_section, reinterpret_cast<void *>(&pars) ); + if ( pars.found == 0 ) { + if ( syms != 0 ) { + free( syms ); + } + bfd_close( abfd ); + return -4; + } + + file = pars.fname; + line = pars.line; + + // } + if ( syms != 0 ) { + free( syms ); + } + + bfd_close( abfd ); + + return 0; +} + +void callstack( std::ostream& s ) +{ + // s.clear(); + +#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64) + ucontext_t ucontext; + + getcontext( &ucontext ); + + int f = 0; + Dl_info dlinfo; + void **bp = 0; + void *ip = 0; +# if defined(SIGSEGV_STACK_IA64) + ip = (void*)ucontext.uc_mcontext.gregs[REG_RIP]; + bp = (void**)ucontext.uc_mcontext.gregs[REG_RBP]; +# elif defined(SIGSEGV_STACK_X86) + ip = (void*)ucontext.uc_mcontext.gregs[REG_EIP]; + bp = (void**)ucontext.uc_mcontext.gregs[REG_EBP]; +# endif + string file; + unsigned line; + + while ( bp && ip ) { + if ( !dladdr( ip, &dlinfo ) ) { + break; + } + + const char *symname = dlinfo.dli_sname; +#ifdef __FIT_CPP_DEMANGLE + int status = 0; + char *tmp = symname == 0 ? 0 : __cxxabiv1::__cxa_demangle( symname, 0, 0, &status ); + + if ( status == 0 && tmp != 0 ) { + symname = tmp; + } +#endif + + // int res; + + // if ( string( "obj/gcc/so_g/mt_ut" ) == dlinfo.dli_fname ) { + if ( /* (res = extract_info( dlinfo.dli_fname, ip, file, line )) != 0 */ false ) { + file = "??"; + line = 0; + // s << "*** " << res << " " << dlinfo.dli_fname << endl; + } else { + file = "??"; + line = 0; + } + // } else { + // file = "??"; + // line = 0; + // } + + s << '#' << setw(2) << setiosflags(ios_base::left) << f++ << " " << ip + << " in " << (symname == 0 ? "?" : symname ) + << " at " << /* "...\n" */ file << ":" << line << '\n'; + // << "+" << (static_cast<char *>(ip) - static_cast<char *>(dlinfo.dli_saddr)) + // << "> (" << dlinfo.dli_fname << ")\n"; +#ifdef __FIT_CPP_DEMANGLE + if ( tmp ) { + free(tmp); + } +#endif + + if ( dlinfo.dli_sname && !strcmp( dlinfo.dli_sname, "main" ) ) { + break; + } + + ip = bp[1]; + bp = (void**)bp[0]; + } +#else + const int btsz = 50; + void *bt[btsz]; + + size_t sz = backtrace( bt, btsz ); + char **line = backtrace_symbols( bt, sz ); + + Dl_info dlinfo; + // string file; + // unsigned line; + + for ( int i = 0; i < sz; ++i ) { + stringstream ss( line[i] ); + // s << line[i] << '\n'; + string nm; + void *addr; + char c; + ss >> nm >> c >> hex >> addr; + + if ( !dladdr( addr, &dlinfo ) ) { + continue; + } + + const char *symname = dlinfo.dli_sname; +#ifdef __FIT_CPP_DEMANGLE + int status = 0; + char *tmp = symname == 0 ? 0 : __cxxabiv1::__cxa_demangle( symname, 0, 0, &status ); + + if ( status == 0 && tmp != 0 ) { + symname = tmp; + } +#endif + + // int res = extract_info(); + + s << '#' << setw(2) << setiosflags(ios_base::left) << i << " " << addr + << " in " << (symname == 0 ? "..." : symname) + << " at " << "...\n"; + // s << "== " << nm << " / '" << c << "' " << addr << "\n"; +#ifdef __FIT_CPP_DEMANGLE + if ( tmp ) { + free(tmp); + } +#endif + } + + free( line ); +#endif +} + +} // namespace xmt + Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-24 18:49:09 UTC (rev 1740) @@ -13,6 +13,7 @@ #include <mt/xmt.h> #include <mt/shm.h> #include <mt/thr_mgr.h> +#include <mt/callstack.h> #include <sys/shm.h> #include <sys/wait.h> @@ -27,6 +28,13 @@ using namespace std; namespace fs = boost::filesystem; +int EXAM_IMPL(mt_test::callstack) +{ + xmt::callstack( cerr ); + + return EXAM_RESULT; +} + /* ****************************************************** * Degenerate case: check that one thread pass throw * own barrier. Modified: trunk/complement/explore/lib/mt/ut/mt_test.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.h 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/ut/mt_test.h 2007-09-24 18:49:09 UTC (rev 1740) @@ -19,6 +19,7 @@ class mt_test { public: + int EXAM_DECL(callstack); int EXAM_DECL(barrier); int EXAM_DECL(join_test); int EXAM_DECL(barrier2); Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2007-09-24 18:49:09 UTC (rev 1740) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/05 00:29:06 ptr> +// -*- C++ -*- Time-stamp: <07/09/21 22:41:08 ptr> /* * Copyright (c) 2006, 2007 @@ -27,6 +27,7 @@ exam::test_suite t( "libxmt test" ); mt_test test; +#if 0 t.add( timespec_diff, "timespec_diff" ); t.add( signal_1_test, "signal_1_test" ); // You can't throw exception from signal handler @@ -34,9 +35,12 @@ // by this reason next test is commented: // t.add( signal_2_test, "signal_2_test" ); t.add( signal_3_test, "signal_3_test" ); +#endif exam::test_suite::test_case_type tc[3]; + // t.add( &mt_test::callstack, test, "callstack" ); + tc[0] = t.add( &mt_test::barrier, test, "mt_test::barrier" ); tc[1] = t.add( &mt_test::join_test, test, "mt_test::join_test" ); tc[2] = t.add( &mt_test::yield, test, "mt_test::yield", Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2007-09-18 09:31:26 UTC (rev 1739) +++ trunk/complement/explore/lib/mt/xmt.cc 2007-09-24 18:49:09 UTC (rev 1740) @@ -20,6 +20,7 @@ #include <fcntl.h> #include <mt/xmt.h> +#include <mt/callstack.h> #include <cstring> #ifndef _WIN32 @@ -359,7 +360,13 @@ if ( (_flags & (daemon | detached)) != 0 ) { // not joinable // Locker lk( _llock ); if ( _id != bad_thread_id ) { // still run? - cerr << "Crash on daemon thread exit expected, threas id " << _id << endl; + cerr << "Suspected crash of daemon thread, threas id " << _id << endl; +#ifdef __FIT_CREATE_THREAD_STACK_INFO + cerr << "Stack when thread was created:\n" << _stack_on_create << endl; +#endif + std::stringstream s; + callstack( s ); + cerr << "Current stack is:\n" << s.str() << endl; } } @@ -701,6 +708,15 @@ _param_sz = psz; int err = 0; +#ifdef __FIT_CREATE_THREAD_STACK_INFO + // _stack_on_create + { + std::stringstream s; + callstack( s ); + _stack_on_create = s.str(); + } +#endif + #ifdef _PTHREADS pthread_attr_t attr; if ( _flags != 0 || _stack_sz != 0 ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-18 09:31:47
|
Revision: 1739 http://complement.svn.sourceforge.net/complement/?rev=1739&view=rev Author: complement Date: 2007-09-18 02:31:26 -0700 (Tue, 18 Sep 2007) Log Message: ----------- test require sync with main thread, otherwise join may happens BEFORE thread call indeed (!!!) and _rip_id will be bad_thread_id and not joined (hmm, really bug of pthread_create in glibc 2.3.6?). Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/ut/mt_test.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:22:32 UTC (rev 1738) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:31:26 UTC (rev 1739) @@ -8,6 +8,10 @@ * libxmt: version 1.13.0 + * ut/mt_test.cc: test require sync with main thread, otherwise join may + happens BEFORE thread call indeed (!!!) and _rip_id will be bad_thread_id + and not joined (hmm, really bug of pthread_create in glibc 2.3.6?). + 2007-09-05 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: looks like non-POD return from thread is unstable, Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-18 09:22:32 UTC (rev 1738) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-18 09:31:26 UTC (rev 1739) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/05 00:31:04 ptr> +// -*- C++ -*- Time-stamp: <07/09/14 22:10:35 ptr> /* * Copyright (c) 2006, 2007 @@ -46,10 +46,15 @@ static int x = 0; -xmt::Thread::ret_t thread_entry_call( void * ) +xmt::Thread::ret_t thread_entry_call( void *p ) { + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); + b.wait(); + x = 1; + // cerr << "XXX" << endl; + return reinterpret_cast<xmt::Thread::ret_t>(2); } @@ -57,10 +62,19 @@ { EXAM_CHECK( x == 0 ); - xmt::Thread t( thread_entry_call ); + xmt::barrier b; - EXAM_CHECK( reinterpret_cast<int>(t.join()) == 2 ); + xmt::Thread t( thread_entry_call, &b ); + // cerr << t.good() << " " << t.is_join_req() << endl; + + // void *r = t.join(); + + // cerr << r << endl; + b.wait(); + + EXAM_CHECK( reinterpret_cast<int>( t.join() ) == 2 ); + EXAM_CHECK( x == 1 ); return EXAM_RESULT; @@ -83,10 +97,12 @@ xmt::barrier b; xmt::Thread t1( thread2_entry_call, &b ); - xmt::Thread t2( thread2_entry_call, &b ); + // xmt::Thread t2( thread2_entry_call, &b ); - EXAM_CHECK( reinterpret_cast<int>(t2.join()) == 1 ); + // EXAM_CHECK( reinterpret_cast<int>(t2.join()) == 1 ); // std::cerr << t2.join() << std::endl; + b.wait(); + EXAM_CHECK( reinterpret_cast<int>(t1.join()) == 1 ); return EXAM_RESULT; @@ -112,9 +128,10 @@ { xmt::barrier b; - xmt::Thread t1( thread2_entry_call, &b ); + // xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread3_entry_call, &b ); // .join()'s are in Thread's destructors + b.wait(); } return EXAM_RESULT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-18 09:22:38
|
Revision: 1738 http://complement.svn.sourceforge.net/complement/?rev=1738&view=rev Author: complement Date: 2007-09-18 02:22:32 -0700 (Tue, 18 Sep 2007) Log Message: ----------- libxmt 1.13.0 Modified Paths: -------------- trunk/complement/explore/lib/mt/Makefile.inc Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-09-18 09:21:45 UTC (rev 1737) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-09-18 09:22:32 UTC (rev 1738) @@ -2,7 +2,7 @@ LIBNAME = xmt MAJOR = 1 -MINOR = 12 +MINOR = 13 PATCH = 0 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-18 09:21:47
|
Revision: 1737 http://complement.svn.sourceforge.net/complement/?rev=1737&view=rev Author: complement Date: 2007-09-18 02:21:45 -0700 (Tue, 18 Sep 2007) Log Message: ----------- removed intermediate _xcall, use direct call of _call as thread function; add locker for _rip_id---it may be changed from different threads in case of fast termination of thread; libxmt: version 1.13.0 Modified Paths: -------------- trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/xmt.cc Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-09-14 10:08:15 UTC (rev 1736) +++ trunk/complement/explore/include/mt/xmt.h 2007-09-18 09:21:45 UTC (rev 1737) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 09:47:08 ptr> +// -*- C++ -*- Time-stamp: <07/09/15 10:03:40 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -144,12 +144,12 @@ // extern __FIT_DECLSPEC void signal_throw( int sig ) throw( int ); // extern __FIT_DECLSPEC void signal_thread_exit( int sig ); -#ifdef __unix -extern "C" void *_xcall( void * ); // forward declaration -#endif -#ifdef WIN32 -extern "C" unsigned long __stdcall _xcall( void *p ); // forward declaration -#endif +// #ifdef __unix +// extern "C" void *_xcall( void * ); // forward declaration +// #endif +// #ifdef WIN32 +// extern "C" unsigned long __stdcall _xcall( void *p ); // forward declaration +// #endif #ifndef WIN32 // using std::size_t; @@ -1463,7 +1463,7 @@ bool bad() const { /* Locker lk( _llock ); */ return (_id == bad_thread_id); } bool is_join_req() const // if true, you can (and should) use join() - { /* Locker lk( _llock ); */ return (_rip_id != bad_thread_id) && ((_flags & (daemon | detached)) == 0); } + { scoped_lock lk( _rip_id_lock ); return (_rip_id != bad_thread_id) && ((_flags & (daemon | detached)) == 0); } __FIT_DECLSPEC bool is_self(); @@ -1494,7 +1494,11 @@ bool _not_run() const { /* Locker lk( _llock ); */ return _id == bad_thread_id; } void _create( const void *p, size_t psz ) throw( std::runtime_error); + static void *_call( void *p ); +#ifdef WIN32 + statuc unsigned long __stdcall _call( void *p ); +#endif static void unexpected(); static void terminate(); @@ -1518,6 +1522,7 @@ thread_id_type _id; thread_id_type _rip_id; + mutex _rip_id_lock; #ifdef _PTHREADS # ifndef __hpux // sorry, POSIX threads don't have suspend/resume calls, so it should @@ -1536,12 +1541,12 @@ // mutex _llock; friend class Init; // extern "C", wrap for thread_create -#ifdef __unix - friend void *_xcall( void * ); -#endif -#ifdef __FIT_WIN32THREADS - friend unsigned long __stdcall _xcall( void *p ); -#endif +// #ifdef __unix +// friend void *_xcall( void * ); +// #endif +// #ifdef __FIT_WIN32THREADS +// friend unsigned long __stdcall _xcall( void *p ); +// #endif }; template <bool SCOPE> Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-09-14 10:08:15 UTC (rev 1736) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:21:45 UTC (rev 1737) @@ -1,3 +1,13 @@ +2007-09-18 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc: removed intermediate _xcall, use direct call of _call + as thread function; + + * xmt.h, xmt.cc: add locker for _rip_id---it may be changed from different + threads in case of fast termination of thread; + + * libxmt: version 1.13.0 + 2007-09-05 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: looks like non-POD return from thread is unstable, Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2007-09-14 10:08:15 UTC (rev 1736) +++ trunk/complement/explore/lib/mt/xmt.cc 2007-09-18 09:21:45 UTC (rev 1737) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/06/14 10:10:54 ptr> +// -*- C++ -*- Time-stamp: <07/09/15 10:16:39 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -419,6 +419,7 @@ thr_join( _rip_id, 0, &rt ); # endif // Locker lk( _llock ); + scoped_lock lk( _rip_id_lock ); _rip_id = bad_thread_id; } #endif // __FIT_UITHREADS || PTHREADS @@ -544,7 +545,7 @@ // follow part of _call if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected - // Locker lk( me->_llock ); // !!!!??? in the signal handler? + // scoped_lock lk( _rip_id_lock ); // !!!!??? in the signal handler? me->_rip_id = me->_id = bad_thread_id; } else { me->_id = bad_thread_id; @@ -718,21 +719,23 @@ // pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); // pthread_attr_setschedpolicy(&attr,SCHED_OTHER); } - err = pthread_create( &_id, _flags != 0 || _stack_sz != 0 ? &attr : 0, _xcall, this ); + scoped_lock lk( _rip_id_lock ); + err = pthread_create( &_id, _flags != 0 || _stack_sz != 0 ? &attr : 0, _call, this ); if ( err != 0 ) { _rip_id = _id = bad_thread_id; } else { _rip_id = _id; } + lk.unlock(); if ( _flags != 0 || _stack_sz != 0 ) { pthread_attr_destroy( &attr ); } #endif #ifdef __FIT_UITHREADS - err = thr_create( 0, 0, _xcall, this, _flags, &_id ); + err = thr_create( 0, 0, _call, this, _flags, &_id ); #endif #ifdef __FIT_WIN32THREADS - _rip_id = _id = CreateThread( 0, 0, _xcall, this, (_flags & suspended), &_thr_id ); + _rip_id = _id = CreateThread( 0, 0, _call, this, (_flags & suspended), &_thr_id ); err = GetLastError(); #endif @@ -750,28 +753,12 @@ #pragma warning( disable : 4101 ) #endif -extern "C" { #ifdef __unix - void *_xcall( void *p ) - { - return Thread::_call( p ); - } +void *Thread::_call( void *p ) #endif #ifdef WIN32 - unsigned long __stdcall _xcall( void *p ) - { - return (unsigned long)Thread::_call( p ); - } +unsigned long __stdcall Thread::_call( void *p ) #endif -#ifdef __FIT_NETWARE - void _xcall( void *p ) - { - Thread::_call( p ); - } -#endif -} // extern "C" - -void *Thread::_call( void *p ) { Thread *me = static_cast<Thread *>(p); @@ -816,6 +803,7 @@ #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif + scoped_lock lk( me->_rip_id_lock ); me->_id = bad_thread_id; me->_rip_id = bad_thread_id; } else { @@ -830,6 +818,7 @@ #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif + scoped_lock lk( me->_rip_id_lock ); me->_id = bad_thread_id; me->_rip_id = bad_thread_id; } else { @@ -848,6 +837,7 @@ #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif + scoped_lock lk( me->_rip_id_lock ); me->_id = bad_thread_id; me->_rip_id = bad_thread_id; } else { @@ -868,6 +858,7 @@ #ifdef __FIT_WIN32THREADS CloseHandle( me->_id ); #endif + scoped_lock lk( me->_rip_id_lock ); me->_id = bad_thread_id; me->_rip_id = bad_thread_id; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-14 10:08:20
|
Revision: 1736 http://complement.svn.sourceforge.net/complement/?rev=1736&view=rev Author: complement Date: 2007-09-14 03:08:15 -0700 (Fri, 14 Sep 2007) Log Message: ----------- simplify and clean exit from connection_processor thread, including delay from exit when thread idle Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.cc Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-10 10:11:10 UTC (rev 1735) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-14 10:08:15 UTC (rev 1736) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/06 21:32:15 ptr> +// -*- C++ -*- Time-stamp: <07/09/13 23:10:08 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -433,11 +433,9 @@ xmt::Thread::ret_t sockmgr_stream_MP<Connect,C,T>::connect_processor( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); - xmt::Thread::ret_t rtc = 0; try { timespec idle( me->_idle ); - int idle_count = 0; me->_dlock.lock(); typename _Sequence::iterator c; @@ -451,7 +449,7 @@ me->_dlock.unlock(); do { - if (_non_empty ) { + if ( _non_empty ) { sockstream& stream = c->s; if ( stream.is_open() ) { (c->_proc->*C)( stream ); @@ -462,7 +460,14 @@ me->_conn_pool.push_back( c ); me->_observer_cnd.set( true ); me->_pool_cnd.set( true ); + if ( !me->_follow ) { + break; + } + c = me->_conn_pool.front(); + me->_conn_pool.pop_front(); + xmt::gettime( &me->_tpop ); // xmt::Thread::gettime( &me->_tpush ); + continue; } else { // no buffered data, return socket to poll sock_base::socket_type rfd = stream.rdbuf()->fd(); ::write( me->_cfd, reinterpret_cast<const char *>(&rfd), sizeof(sock_base::socket_type) ); @@ -480,33 +485,34 @@ _non_empty = false; - for ( idle_count = 0; idle_count < 2; ++idle_count ) { - { - xmt::scoped_lock lk(me->_dlock); - if ( !me->_follow ) { - break; - } - if ( me->_conn_pool.size() != 0 ) { - c = me->_conn_pool.front(); - me->_conn_pool.pop_front(); - _non_empty = true; - xmt::gettime( &me->_tpop ); - break; - } + if ( me->_pool_cnd.try_wait_delay( &idle ) == 0 ) { + xmt::scoped_lock lk(me->_dlock); + if ( !me->_follow ) { + return 0; + } + if ( me->_conn_pool.size() != 0 ) { + c = me->_conn_pool.front(); + me->_conn_pool.pop_front(); + _non_empty = true; + xmt::gettime( &me->_tpop ); + } else { me->_pool_cnd.set( false ); me->_observer_cnd.set( false ); + return 0; } - if ( me->_pool_cnd.try_wait_delay( &idle ) != 0 ) { - idle_count = 2; - } + } else { + xmt::scoped_lock lk(me->_dlock); + me->_pool_cnd.set( false ); + me->_observer_cnd.set( false ); + return 0; } - } while ( me->_is_follow() && idle_count < 2 ); + } while ( me->_is_follow() ); } catch ( ... ) { - rtc = reinterpret_cast<xmt::Thread::ret_t>(-1); + return reinterpret_cast<xmt::Thread::ret_t>(-1); } - return rtc; + return 0; } template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 10:11:16
|
Revision: 1735 http://complement.svn.sourceforge.net/complement/?rev=1735&view=rev Author: complement Date: 2007-09-10 03:11:10 -0700 (Mon, 10 Sep 2007) Log Message: ----------- propagate check results from child process to parent Modified Paths: -------------- trunk/complement/explore/lib/janus/ut/vt_remote.cc Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-09-10 09:47:10 UTC (rev 1734) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-09-10 10:11:10 UTC (rev 1735) @@ -198,6 +198,8 @@ try { xmt::fork(); + long res_flag = 0; + b.wait(); { @@ -212,7 +214,7 @@ // obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); // obj1.vtdispatcher()->settrs( &std::cerr ); - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); + EXAM_CHECK_ASYNC_F( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1, res_flag ); obj1.vtdispatcher()->connect( "localhost", 6980 ); @@ -237,15 +239,15 @@ // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2 ); + EXAM_CHECK_ASYNC_F( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2, res_flag ); // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; obj1.JoinGroup( janus::vs_base::first_user_group ); obj1.wait_greeting(); - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); - EXAM_CHECK_ASYNC( obj1.count == 1 ); + EXAM_CHECK_ASYNC_F( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2, res_flag ); + EXAM_CHECK_ASYNC_F( obj1.count == 1, res_flag ); // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; obj1.wait(); @@ -254,10 +256,10 @@ } // obj1 here away, but in another process (remote) still exist object in // first_user_group, that's why 1 here: - EXAM_CHECK_ASYNC( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1); + EXAM_CHECK_ASYNC_F( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1, res_flag ); } - exit(0); + exit( res_flag ); } catch ( xmt::fork_in_parent& child ) { YaRemote obj1( "obj srv" ); @@ -289,8 +291,13 @@ // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); // obj1.manager()->settrs( &std::cerr ); - int stat; + int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1 ); @@ -325,6 +332,8 @@ try { xmt::fork(); + long res_flag = 0; + b.wait(); { @@ -346,9 +355,9 @@ obj1.wait_greeting(); obj1.wait_greeting2(); - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 2 ); - EXAM_CHECK_ASYNC( obj1.count == 2 ); + EXAM_CHECK_ASYNC_F( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2, res_flag ); + EXAM_CHECK_ASYNC_F( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 2, res_flag ); + EXAM_CHECK_ASYNC_F( obj1.count == 2, res_flag ); stem::Event ev( VS_DUMMY_MESS2 ); ev.dest( janus::vs_base::first_user_group + 1 ); @@ -362,11 +371,11 @@ // obj1.manager()->settrs( &std::cerr ); } - EXAM_CHECK_ASYNC( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1); - EXAM_CHECK_ASYNC( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 1); + EXAM_CHECK_ASYNC_F( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1, res_flag ); + EXAM_CHECK_ASYNC_F( obj0.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 1, res_flag ); } - exit(0); + exit( res_flag ); } catch ( xmt::fork_in_parent& child ) { YaRemote obj1( "obj srv" ); @@ -393,8 +402,13 @@ obj1.wait2(); - int stat; + int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 1 ); EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 1 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:47:12
|
Revision: 1734 http://complement.svn.sourceforge.net/complement/?rev=1734&view=rev Author: complement Date: 2007-09-10 02:47:10 -0700 (Mon, 10 Sep 2007) Log Message: ----------- trial non-block sockets Modified Paths: -------------- trunk/complement/explore/include/config/_linux.h Modified: trunk/complement/explore/include/config/_linux.h =================================================================== --- trunk/complement/explore/include/config/_linux.h 2007-09-10 09:46:15 UTC (rev 1733) +++ trunk/complement/explore/include/config/_linux.h 2007-09-10 09:47:10 UTC (rev 1734) @@ -71,11 +71,9 @@ /* * use algorithms that based on non-block sockets technique */ - /* #define __FIT_NONBLOCK_SOCKETS */ - /* * use epoll syscall instead of poll */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:46:16
|
Revision: 1733 http://complement.svn.sourceforge.net/complement/?rev=1733&view=rev Author: complement Date: 2007-09-10 02:46:15 -0700 (Mon, 10 Sep 2007) Log Message: ----------- compile fix, related to non-block sockets Modified Paths: -------------- trunk/complement/explore/include/sockios/sockstream.cc Modified: trunk/complement/explore/include/sockios/sockstream.cc =================================================================== --- trunk/complement/explore/include/sockios/sockstream.cc 2007-09-10 09:44:41 UTC (rev 1732) +++ trunk/complement/explore/include/sockios/sockstream.cc 2007-09-10 09:46:15 UTC (rev 1733) @@ -19,6 +19,9 @@ # include <stropts.h> // for ioctl() call #endif +#ifdef __FIT_NONBLOCK_SOCKETS +# include <fcntl.h> +#endif #ifdef STLPORT _STLP_BEGIN_NAMESPACE @@ -575,8 +578,8 @@ } if ( offset < count ) { // MUST BE: (offset % sizeof(char_traits)) == 0 ! - offset /= sizeof(char_traits); - count /= sizeof(char_traits); + offset /= sizeof(charT); + count /= sizeof(charT); traits::move( this->pbase(), this->pbase() + offset, count - offset ); // std::copy_backword( this->pbase() + offset, this->pbase() + count, this->pbase() ); setp( this->pbase(), this->epptr() ); // require: set pptr This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:44:45
|
Revision: 1732 http://complement.svn.sourceforge.net/complement/?rev=1732&view=rev Author: complement Date: 2007-09-10 02:44:41 -0700 (Mon, 10 Sep 2007) Log Message: ----------- propagate check results from child process to parent Modified Paths: -------------- trunk/complement/explore/lib/stem/ut/unit_test.cc Modified: trunk/complement/explore/lib/stem/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/unit_test.cc 2007-09-10 09:43:55 UTC (rev 1731) +++ trunk/complement/explore/lib/stem/ut/unit_test.cc 2007-09-10 09:44:41 UTC (rev 1732) @@ -334,6 +334,8 @@ try { xmt::fork(); + int eflag = 0; + try { stem::NetTransportMgr mgr; @@ -341,8 +343,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery + EXAM_CHECK_ASYNC_F( zero != stem::badaddr, eflag ); + EXAM_CHECK_ASYNC_F( zero != 0, eflag ); // NetTransportMgr should detect external delivery EchoClient node; @@ -361,7 +363,7 @@ catch ( ... ) { } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { try { @@ -371,8 +373,13 @@ fcnd.set( true ); - int stat; + int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } srv.close(); srv.wait(); @@ -402,6 +409,7 @@ try { xmt::fork(); + int eflag = 0; // server part { std::sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); @@ -410,7 +418,7 @@ // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); // echo.manager()->settrs( &std::cerr ); - EXAM_CHECK_ASYNC( srv.good() ); + EXAM_CHECK_ASYNC_F( srv.good(), eflag ); c.set( true ); // ok, server listen b.wait(); // server may go away @@ -419,7 +427,7 @@ srv.wait(); } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { // client part @@ -449,8 +457,13 @@ b.wait(); // server may go away - int stat; + int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } } (&c)->~__condition<true>(); @@ -520,6 +533,8 @@ sigaction( SIGALRM, &action, &old_action ); #endif + int eflag = 0; + try { stem::NetTransportMgr mgr; @@ -531,9 +546,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC_F( zero != stem::badaddr, eflag ); + EXAM_CHECK_ASYNC_F( zero != 0, eflag ); + EXAM_CHECK_ASYNC_F( zero & stem::extbit, eflag ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -543,13 +558,13 @@ stem::gaddr_type ga( c1.manager()->reflect( zero ) ); - EXAM_CHECK_ASYNC( ga.addr == 0 ); - EXAM_CHECK_ASYNC( ga.pid != -1 ); + EXAM_CHECK_ASYNC_F( ga.addr == 0, eflag ); + EXAM_CHECK_ASYNC_F( ga.pid != -1, eflag ); ga.addr = stem::ns_addr; // this will be global address of ns of the same process // as zero - EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); + EXAM_CHECK_ASYNC_F( c1.manager()->reflect( ga ) != stem::badaddr, eflag ); stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( c1.manager()->reflect( ga ) ); @@ -567,8 +582,8 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); } while ( i == nm.lst.end() ); - EXAM_CHECK_ASYNC( i != nm.lst.end() ); - EXAM_CHECK_ASYNC( i->second == "c2@here" ); + EXAM_CHECK_ASYNC_F( i != nm.lst.end(), eflag ); + EXAM_CHECK_ASYNC_F( i->second == "c2@here", eflag ); stem::addr_type pa = c1.manager()->reflect( i->first ); if ( pa == stem::badaddr ) { // unknown yet @@ -579,7 +594,7 @@ } } - EXAM_CHECK_ASYNC( pa != stem::badaddr ); + EXAM_CHECK_ASYNC_F( pa != stem::badaddr, eflag ); if ( pa != stem::badaddr ) { stem::Event pe( NODE_EV_ECHO ); @@ -595,9 +610,10 @@ mgr.join(); } catch ( ... ) { + eflag = 2; } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { fpid = child.pid(); @@ -622,6 +638,8 @@ sigaction( SIGALRM, &action, &old_action ); #endif + int eflag = 0; + try { stem::NetTransportMgr mgr; // ^ @@ -631,9 +649,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC_F( zero != stem::badaddr, eflag ); + EXAM_CHECK_ASYNC_F( zero != 0, eflag ); + EXAM_CHECK_ASYNC_F( zero & stem::extbit, eflag ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -651,9 +669,10 @@ mgr.join(); } catch ( ... ) { + eflag = 2; } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' @@ -661,9 +680,20 @@ fcnd.set( true, true ); - int stat; - waitpid( child.pid(), &stat, 0 ); - waitpid( fpid, &stat, 0 ); + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } + stat = -1; + EXAM_CHECK( waitpid( fpid, &stat, 0 ) == fpid ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } srv.close(); srv.wait(); @@ -687,6 +717,9 @@ try { // Client xmt::fork(); + + int eflag = 0; + try { fcnd.try_wait(); @@ -699,6 +732,7 @@ for ( int j = 1; j < n; ++j ) { mgr[j] = new stem::NetTransportMgr; stem::addr_type a = mgr[j]->open( "localhost", 6995 ); + EXAM_CHECK_ASYNC_F( a != stem::badaddr, eflag ); mgr[j]->close(); mgr[j]->join(); delete mgr[j]; @@ -709,8 +743,9 @@ } } catch ( ... ) { + eflag = 2; } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' @@ -718,8 +753,13 @@ fcnd.set( true, true ); - int stat; - waitpid( child.pid(), &stat, 0 ); + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } srv.close(); srv.wait(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:43:56
|
Revision: 1731 http://complement.svn.sourceforge.net/complement/?rev=1731&view=rev Author: complement Date: 2007-09-10 02:43:55 -0700 (Mon, 10 Sep 2007) Log Message: ----------- add close() to NetTransport, due to changes in sockmgr (functions as template parameters) Modified Paths: -------------- trunk/complement/explore/include/stem/NetTransport.h Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2007-09-10 09:41:19 UTC (rev 1730) +++ trunk/complement/explore/include/stem/NetTransport.h 2007-09-10 09:43:55 UTC (rev 1731) @@ -78,6 +78,9 @@ __FIT_DECLSPEC void connect( std::sockstream& ); + + virtual void close() + { NetTransport_base::close(); } }; class NetTransportMgr : This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:41:21
|
Revision: 1730 http://complement.svn.sourceforge.net/complement/?rev=1730&view=rev Author: complement Date: 2007-09-10 02:41:19 -0700 (Mon, 10 Sep 2007) Log Message: ----------- fix thread return type Modified Paths: -------------- trunk/complement/explore/include/DB/PgSQL.h trunk/complement/explore/lib/DB/PgSQL/PgSQL.cc Modified: trunk/complement/explore/include/DB/PgSQL.h =================================================================== --- trunk/complement/explore/include/DB/PgSQL.h 2007-09-10 09:14:38 UTC (rev 1729) +++ trunk/complement/explore/include/DB/PgSQL.h 2007-09-10 09:41:19 UTC (rev 1730) @@ -68,7 +68,7 @@ virtual std::string IS_NOT_NULL() const; private: - static xmt::Thread::ret_code conn_proc( void * ); + static xmt::Thread::ret_t conn_proc( void * ); DBconn *_conn; xmt::Thread thr; Modified: trunk/complement/explore/lib/DB/PgSQL/PgSQL.cc =================================================================== --- trunk/complement/explore/lib/DB/PgSQL/PgSQL.cc 2007-09-10 09:14:38 UTC (rev 1729) +++ trunk/complement/explore/lib/DB/PgSQL/PgSQL.cc 2007-09-10 09:41:19 UTC (rev 1730) @@ -77,11 +77,9 @@ //} } -xmt::Thread::ret_code DataBase::conn_proc( void *p ) +xmt::Thread::ret_t DataBase::conn_proc( void *p ) { DataBase *me = reinterpret_cast<DataBase *>(p); - xmt::Thread::ret_code ret; - ret.iword = 0; me->_conn = PQsetdbLogin( me->_dbhost.length() > 0 ? me->_dbhost.c_str() : 0, 0 /* _dbport */, me->_dbopt.length() > 0 ? me->_dbopt.c_str() : 0, @@ -100,7 +98,7 @@ } me->con_cond.set( true ); - return ret; + return 0; } void DataBase::reconnect() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-10 09:14:40
|
Revision: 1729 http://complement.svn.sourceforge.net/complement/?rev=1729&view=rev Author: complement Date: 2007-09-10 02:14:38 -0700 (Mon, 10 Sep 2007) Log Message: ----------- propagate check results from child process to parent Modified Paths: -------------- trunk/complement/explore/lib/sockios/ut/sockios_test.cc Modified: trunk/complement/explore/lib/sockios/ut/sockios_test.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-07 12:48:58 UTC (rev 1728) +++ trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-10 09:14:38 UTC (rev 1729) @@ -241,9 +241,9 @@ tcnd.set( true ); - th1->join(); + th1->join(); // Will be interrupted! - exit( 0 ); + exit( 0 ); // will be killed! } catch ( ... ) { } @@ -259,8 +259,14 @@ kill( child.pid(), SIGTERM ); - int stat; - waitpid( child.pid(), &stat, 0 ); + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + // EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + EXAM_ERROR( "child should be interrupted" ); + } else { + EXAM_MESSAGE( "child interrupted" ); + } srv.close(); srv.wait(); @@ -332,11 +338,14 @@ try { xmt::fork(); + long res_flag = 0; fcnd.try_wait(); { sockstream s( "localhost", port ); + EXAM_CHECK_ASYNC_F( s.is_open() && s.good(), res_flag ); + s << "POST /test.php HTTP/1.1\r\n" << "xmlrequest=<?xml version=\"1.0\"?>\ <RWRequest><REQUEST domain=\"network\" service=\"ComplexReport\" nocache=\"n\" \ @@ -353,8 +362,9 @@ ref=\"network_gross_profit_ecpm\"/></COLUMNS><FILTERS><FILTER ref=\"time\" \ macro=\"yesterday\"/></FILTERS></REQUEST></RWRequest>"; s.flush(); + EXAM_CHECK_ASYNC_F( s.good(), res_flag ); } - exit( 0 ); + exit( res_flag ); } catch ( xmt::fork_in_parent& child ) { sockmgr_stream_MP<long_msg_processor> srv( port ); @@ -362,6 +372,14 @@ srv_cnd.try_wait(); + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } + srv.close(); srv.wait(); @@ -464,13 +482,15 @@ int buff = 0; // cerr << "thread_entry" << endl; cnd.set( true ); + + int r = 0; // Note: due to this is another process then main, boost can report // about errors here, but don't count error it in summary, if it occur! - EXAM_CHECK_ASYNC( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line - EXAM_CHECK_ASYNC( buff == 1 ); + EXAM_CHECK_ASYNC_F( sock.read( (char *)&buff, sizeof(int) ).good(), r ); // <---- key line + EXAM_CHECK_ASYNC_F( buff == 1, r ); // cerr << "Read pass" << endl; - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(r); } int EXAM_IMPL(sockios_test::read0) @@ -501,9 +521,8 @@ b.wait(); - thr.join(); // cerr << "exit child" << endl; - exit( 0 ); + exit( reinterpret_cast<int>(thr.join()) ); } catch ( xmt::fork_in_parent& child ) { // cerr << "** 3" << endl; @@ -511,8 +530,14 @@ fcnd.set( true ); - int stat; - waitpid( child.pid(), &stat, 0 ); + int stat = -1; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + if ( WIFEXITED(stat) ) { + EXAM_CHECK( WEXITSTATUS(stat) == 0 ); + } else { + EXAM_ERROR( "child interrupted" ); + } + srv.close(); srv.wait(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |