complement-svn Mailing List for Complement (Page 11)
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-09-07 12:49:01
|
Revision: 1728 http://complement.svn.sourceforge.net/complement/?rev=1728&view=rev Author: complement Date: 2007-09-07 05:48:58 -0700 (Fri, 07 Sep 2007) Log Message: ----------- prepare for __FIT_NONBLOCK_SOCKETS Modified Paths: -------------- trunk/complement/explore/include/sockios/sockstream trunk/complement/explore/include/sockios/sockstream.cc trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockstream =================================================================== --- trunk/complement/explore/include/sockios/sockstream 2007-09-07 11:07:26 UTC (rev 1727) +++ trunk/complement/explore/include/sockios/sockstream 2007-09-07 12:48:58 UTC (rev 1728) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/31 09:49:58 ptr> +// -*- C++ -*- Time-stamp: <07/09/06 23:42:19 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -18,6 +18,10 @@ #include <config/feature.h> #endif +#if !defined(__sun) && !defined(_WIN32) // i.e. __linux and __hpux +#include <sys/poll.h> // pollfd +#endif + #ifndef __XMT_H #include <mt/xmt.h> #endif @@ -538,23 +542,7 @@ return this; } - virtual int sync() - { - if ( !is_open() ) { - return -1; - } - - long count = this->pptr() - this->pbase(); - if ( count ) { - // _STLP_ASSERT( this->pbase() != 0 ); - if ( (this->*_xwrite)( this->pbase(), sizeof(charT) * count ) != count * sizeof(charT) ) - return -1; - setp( this->pbase(), this->epptr() ); // require: set pptr - } - - return 0; - } - + virtual int sync(); virtual streamsize xsputn(const char_type *s, streamsize n); public: @@ -565,9 +553,11 @@ charT* _ebuf; bool _allocated; // true, if _bbuf should be deallocated #ifdef __FIT_POLL + pollfd pfd; int _timeout; // milliseconds #endif #ifdef __FIT_SELECT + fd_set pfd; struct timeval _timeout; struct timeval *_timeout_ref; #endif Modified: trunk/complement/explore/include/sockios/sockstream.cc =================================================================== --- trunk/complement/explore/include/sockios/sockstream.cc 2007-09-07 11:07:26 UTC (rev 1727) +++ trunk/complement/explore/include/sockios/sockstream.cc 2007-09-07 12:48:58 UTC (rev 1728) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/08/21 23:58:48 ptr> +// -*- C++ -*- Time-stamp: <07/09/06 23:48:33 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -15,10 +15,6 @@ extern "C" int nanosleep(const struct timespec *, struct timespec *); #endif -#if !defined(__sun) && !defined(_WIN32) // i.e. __linux and __hpux -#include <sys/poll.h> // pollfd -#endif - #if defined(__unix) && !defined(__UCLIBC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) # include <stropts.h> // for ioctl() call #endif @@ -103,6 +99,15 @@ throw std::length_error( "can't allocate block" ); } +#ifdef __FIT_NONBLOCK_SOCKETS + if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { + throw std::runtime_error( "can't establish nonblock mode" ); + } +#endif +#ifdef __FIT_POLL + pfd.fd = _fd; + pfd.events = POLLIN | POLLHUP | POLLRDNORM; +#endif setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); @@ -217,6 +222,15 @@ throw std::length_error( "can't allocate block" ); } +#ifdef __FIT_NONBLOCK_SOCKETS + if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { + throw std::runtime_error( "can't establish nonblock mode" ); + } +#endif +#ifdef __FIT_POLL + pfd.fd = _fd; + pfd.events = POLLIN | POLLHUP | POLLRDNORM; +#endif setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); @@ -334,6 +348,15 @@ return 0; } +#ifdef __FIT_NONBLOCK_SOCKETS + if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { + throw std::runtime_error( "can't establish nonblock mode" ); + } +#endif +#ifdef __FIT_POLL + pfd.fd = _fd; + pfd.events = POLLIN | POLLHUP | POLLRDNORM; +#endif setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); @@ -424,8 +447,8 @@ if ( this->gptr() < this->egptr() ) return traits::to_int_type(*this->gptr()); -#ifdef __FIT_SELECT - fd_set pfd; +#ifndef __FIT_NONBLOCK_SOCKETS +# ifdef __FIT_SELECT FD_ZERO( &pfd ); FD_SET( fd(), &pfd ); @@ -436,16 +459,10 @@ } return traits::eof(); } -#endif // __FIT_SELECT -#ifdef __FIT_POLL - pollfd pfd; - pfd.fd = fd(); - pfd.events = POLLIN | POLLHUP | POLLRDNORM; +# endif // __FIT_SELECT +# ifdef __FIT_POLL pfd.revents = 0; - if ( !is_open() /* || (_state != ios_base::goodbit) */ ) { - return traits::eof(); - } while ( poll( &pfd, 1, _timeout ) <= 0 ) { // wait infinite if ( errno == EINTR ) { // may be interrupted, check and ignore errno = 0; @@ -457,17 +474,52 @@ // _state |= ios_base::failbit; return traits::eof(); } -#endif // __FIT_POLL +# endif // __FIT_POLL +#endif // !__FIT_NONBLOCK_SOCKETS + long offset = (this->*_xread)( this->eback(), sizeof(char_type) * (_ebuf - this->eback()) ); +#ifdef __FIT_NONBLOCK_SOCKETS + if ( offset < 0 && errno == EAGAIN ) { + errno = 0; +# ifdef __FIT_SELECT + FD_ZERO( &pfd ); + FD_SET( fd(), &pfd ); - // _STLP_ASSERT( this->eback() != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); + while ( select( fd() + 1, &pfd, 0, 0, _timeout_ref ) <= 0 ) { + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return traits::eof(); + } +# endif // __FIT_SELECT +# ifdef __FIT_POLL + pfd.revents = 0; - long offset = (this->*_xread)( this->eback(), sizeof(char_type) * (_ebuf - this->eback()) ); - // don't allow message of zero length: - // in conjunction with POLLIN in revent of poll above this designate that - // we receive FIN packet. - if ( offset <= 0 ) + while ( poll( &pfd, 1, _timeout ) <= 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return traits::eof(); + } + if ( (pfd.revents & POLLERR) != 0 ) { + // _state |= ios_base::failbit; + return traits::eof(); + } +# endif // __FIT_POLL + offset = (this->*_xread)( this->eback(), sizeof(char_type) * (_ebuf - this->eback()) ); + } +#endif // __FIT_NONBLOCK_SOCKETS + // Without __FIT_NONBLOCK_SOCKETS: + // don't allow message of zero length: + // in conjunction with POLLIN in revent of poll above this designate that + // we receive FIN packet. + // With __FIT_NONBLOCK_SOCKETS: + // 0 is eof, < 0 --- second read also return < 0, but shouldn't + if ( offset <= 0 ) { return traits::eof(); + } + offset /= sizeof(charT); setg( this->eback(), this->eback(), this->eback() + offset ); @@ -490,8 +542,52 @@ long count = this->pptr() - this->pbase(); if ( count ) { - if ( (this->*_xwrite)( this->pbase(), sizeof(charT) * count ) != count * sizeof(charT) ) + count *= sizeof(charT); +#ifndef __FIT_NONBLOCK_SOCKETS + if ( (this->*_xwrite)( this->pbase(), count ) != count ) { return traits::eof(); + } +#else + long offset = (this->*_xwrite)( this->pbase(), count ); + if ( offset < 0 ) { + if ( errno == EAGAIN ) { + pollfd wpfd; + wpfd.fd = _fd; + wpfd.events = POLLOUT | POLLHUP | POLLWRNORM; + wpfd.revents = 0; + while ( poll( &wpfd, 1, _timeout ) <= 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return traits::eof(); + } + if ( (wpfd.revents & POLLERR) != 0 ) { + return traits::eof(); + } + offset = (this->*_xwrite)( this->pbase(), count ); + if ( offset < 0 ) { + return traits::eof(); + } + } else { + return traits::eof(); + } + } + if ( offset < count ) { + // MUST BE: (offset % sizeof(char_traits)) == 0 ! + offset /= sizeof(char_traits); + count /= sizeof(char_traits); + 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->pbump( count - offset ); + if( !traits::eq_int_type(c,traits::eof()) ) { + sputc( traits::to_char_type(c) ); + } + + return traits::not_eof(c); + } +#endif } setp( this->pbase(), this->epptr() ); // require: set pptr @@ -503,6 +599,59 @@ } template<class charT, class traits, class _Alloc> +int basic_sockbuf<charT, traits, _Alloc>::sync() +{ + if ( !is_open() ) { + return -1; + } + + long count = this->pptr() - this->pbase(); + if ( count ) { + // _STLP_ASSERT( this->pbase() != 0 ); + count *= sizeof(charT); +#ifndef __FIT_NONBLOCK_SOCKETS + if ( (this->*_xwrite)( this->pbase(), count ) != count ) { + return -1; + } +#else + long start = 0; + while ( count > 0 ) { + long offset = (this->*_xwrite)( this->pbase() + start, count ); + if ( offset < 0 ) { + if ( errno == EAGAIN ) { + pollfd wpfd; + wpfd.fd = _fd; + wpfd.events = POLLOUT | POLLHUP | POLLWRNORM; + wpfd.revents = 0; + while ( poll( &wpfd, 1, _timeout ) <= 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return -1; + } + if ( (wpfd.revents & POLLERR) != 0 ) { + return -1; + } + offset = (this->*_xwrite)( this->pbase() + start, count ); + if ( offset < 0 ) { + return -1; + } + } else { + return -1; + } + } + count -= offset; + start += offset; + } +#endif + setp( this->pbase(), this->epptr() ); // require: set pptr + } + + return 0; +} + +template<class charT, class traits, class _Alloc> streamsize basic_sockbuf<charT, traits, _Alloc>:: xsputn( const char_type *s, streamsize n ) { Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-07 11:07:26 UTC (rev 1727) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-07 12:48:58 UTC (rev 1728) @@ -1,3 +1,7 @@ +2007-09-07 Petr Ovtchenkov <pt...@is...> + + * sockstream, sockstream.cc: prepare for __FIT_NONBLOCK_SOCKETS. + 2007-09-06 Petr Ovtchenkov <pt...@is...> * sockmgr.h, sockmgr.cc: allow any name of functions for 'connect' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-07 11:07:27
|
Revision: 1727 http://complement.svn.sourceforge.net/complement/?rev=1727&view=rev Author: complement Date: 2007-09-07 04:07:26 -0700 (Fri, 07 Sep 2007) Log Message: ----------- performance measure for sockios: client read 8K blocks, client write 8K blocks, cleint write/read 8K blocks Added Paths: ----------- trunk/complement/explore/lib/sockios/perf/ trunk/complement/explore/lib/sockios/perf/Makefile trunk/complement/explore/lib/sockios/perf/Makefile.inc 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 Property changes on: trunk/complement/explore/lib/sockios/perf ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/sockios/perf/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/perf/Makefile (rev 0) +++ trunk/complement/explore/lib/sockios/perf/Makefile 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,32 @@ +# -*- Makefile -*- Time-stamp: <07/09/05 22:48:46 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + + +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif +DEFS += -D__FIT_EXAM + +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework + +ifeq ($(OSNAME),linux) +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +endif + +release-shared : LDLIBS = -lxmt -lsockios -lexam +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +endif +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Added: trunk/complement/explore/lib/sockios/perf/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/perf/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/Makefile.inc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <07/09/05 22:48:36 ptr> + +PRGNAME = sockios_perf +SRC_CC = perf.cc sockios_perf.cc sockios_perf_suite.cc Added: trunk/complement/explore/lib/sockios/perf/perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/perf.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/perf.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,17 @@ +// -*- C++ -*- Time-stamp: <07/09/05 22:46:17 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf_suite.h" + +int main( int, char ** ) +{ + return sockios_perf_suite(0); +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,188 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:17:21 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf.h" +#include <exam/suite.h> + +#include <sockios/sockstream> +#include <sockios/sockmgr.h> + +#include <mt/shm.h> +#include <sys/wait.h> +#include <signal.h> +#include <algorithm> + +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() ); +} + +/* ************************************************************ */ + +class SrvR +{ + public: + SrvR( sockstream& ) + { } + + ~SrvR() + { } + + void connect( sockstream& s ) + { + s.read( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + } + + void close() + { } + + private: + char buf[10240]; +}; + +class SrvW +{ + public: + SrvW( sockstream& s ) + { + fill( buf, buf + 10240, ' ' ); + for ( int i = 0; i < 10; ++i ) { + s.write( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + } + } + + ~SrvW() + { } + + void connect( sockstream& ) + { } + + void close() + { } + + private: + char buf[10240]; +}; + +class SrvRW +{ + public: + SrvRW( sockstream& ) + { } + + ~SrvRW() + { } + + void connect( sockstream& s ) + { + s.read( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + s.write( buf, 1024*8 ).flush(); + EXAM_CHECK_ASYNC( s.good() ); + } + + void close() + { } + + private: + char buf[10240]; +}; + +int EXAM_IMPL(sockios_perf::exchange1) +{ + sockmgr_stream_MP<SrvR> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + fill( buf, buf + 10240, ' ' ); + + for ( int i = 0; i < 10; ++i ) { + s1.write( buf, 1024 * 8 ); + EXAM_CHECK_ASYNC( s1.good() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +int EXAM_IMPL(sockios_perf::exchange2) +{ + sockmgr_stream_MP<SrvW> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + for ( int i = 0; i < 10; ++i ) { + s1.read( buf, 1024 * 8 ); + EXAM_CHECK_ASYNC( s1.good() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +int EXAM_IMPL(sockios_perf::exchange3) +{ + sockmgr_stream_MP<SrvRW> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + 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() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +xmt::Thread::ret_t client_thr( void *p ) +{ + return 0; +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.h (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.h 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,36 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:12:29 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __sockios_perf_h +#define __sockios_perf_h + +#include <exam/suite.h> +#include <string> +#include <mt/shm.h> + +class sockios_perf +{ + public: + sockios_perf(); + ~sockios_perf(); + + int EXAM_DECL(exchange1); + int EXAM_DECL(exchange2); + int EXAM_DECL(exchange3); + + 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; +}; + +#endif // __sockios_perf_h Added: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,33 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:11:58 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf_suite.h" +#include "sockios_perf.h" + +#include <exam/suite.h> +#include <iostream> + +using namespace std; + +int EXAM_IMPL(sockios_perf_suite) +{ + exam::trivial_time_logger tlogger( std::cout ); + exam::test_suite t( "libsockios performance test suite", 10 ); + t.set_logger( &tlogger ); + + sockios_perf p; + + 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(); +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,19 @@ +// -*- C++ -*- Time-stamp: <07/09/05 22:47:06 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __sockios_perf_suite_h +#define __sockios_perf_suite_h + +#include <exam/suite.h> + +int EXAM_DECL(sockios_perf_suite); + +#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-07 11:03:35
|
Revision: 1726 http://complement.svn.sourceforge.net/complement/?rev=1726&view=rev Author: complement Date: 2007-09-07 04:03:24 -0700 (Fri, 07 Sep 2007) Log Message: ----------- added macro EXAM_CHECK_ASYNC_F, EXAM_ERROR_ASYNC_F Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/mt/ut/mt_test.cc trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-09-07 10:54:55 UTC (rev 1725) +++ trunk/complement/explore/include/exam/suite.h 2007-09-07 11:03:24 UTC (rev 1726) @@ -324,24 +324,28 @@ # define EXAM_RESULT __exam_counter # define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) # define EXAM_CHECK_ASYNC(C) if ( !(C) ) { exam::test_suite::report_async( __FILE__, __LINE__, false, #C ); } else exam::test_suite::report_async( __FILE__, __LINE__, true, #C ) +# define EXAM_CHECK_ASYNC_F(C,V) if ( !(C) ) { exam::test_suite::report_async( __FILE__, __LINE__, false, #C ); V |= 1; } else exam::test_suite::report_async( __FILE__, __LINE__, true, #C ) # define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) # define EXAM_MESSAGE_ASYNC(M) exam::test_suite::report_async( __FILE__, __LINE__, true, M ) # define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) # define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 # define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 # define EXAM_ERROR_ASYNC(M) exam::test_suite::report_async( __FILE__, __LINE__, false, M ) +# define EXAM_ERROR_ASYNC_F(M,V) exam::test_suite::report_async( __FILE__, __LINE__, false, M ); V |= 1 #else # define EXAM_IMPL(F) F( exam::test_suite *, int ) # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT 0 # define EXAM_CHECK(C) (C) # define EXAM_CHECK_ASYNC(C) (C) +# define EXAM_CHECK_ASYNC_F(C,V) (C) # define EXAM_MESSAGE(M) # define EXAM_MESSAGE_ASYNC(M) # define EXAM_REQUIRE(C) (C) # define EXAM_FAIL(M) # define EXAM_ERROR(M) # define EXAM_ERROR_ASYNC(M) +# define EXAM_ERROR_ASYNC_F(M,V) #endif Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-09-07 10:54:55 UTC (rev 1725) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-09-07 11:03:24 UTC (rev 1726) @@ -1,3 +1,10 @@ +2007-09-07 Petr Ovtchenkov <pt...@is...> + + * suite.h: added macro EXAM_CHECK_ASYNC_F, EXAM_ERROR_ASYNC_F + that useful to set passed value to non-zero; useful for non-zero + exit status after fork or thread [may be checked in parent process + or thread]. + 2007-09-04 Petr Ovtchenkov <pt...@is...> * logger.h, logger.cc: added trivial_time_logger for performance Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-07 10:54:55 UTC (rev 1725) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-07 11:03:24 UTC (rev 1726) @@ -99,11 +99,12 @@ xmt::Thread::ret_t thread3_entry_call( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); - EXAM_CHECK_ASYNC( xmt::Thread::yield() == 0 ); + EXAM_CHECK_ASYNC_F( xmt::Thread::yield() == 0, flag ); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } int EXAM_IMPL(mt_test::yield) @@ -133,24 +134,27 @@ xmt::Thread::ret_t thr1( void *p ) { + int flag = 0; + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); m1.lock(); - EXAM_CHECK_ASYNC( x == 0 ); + EXAM_CHECK_ASYNC_F( x == 0, flag ); xmt::Thread::yield(); - EXAM_CHECK_ASYNC( x == 0 ); + EXAM_CHECK_ASYNC_F( x == 0, flag ); x = 1; m1.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } xmt::Thread::ret_t thr2( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); for ( int i = 0; i < 128; ++i ) { @@ -158,11 +162,11 @@ } m1.lock(); - EXAM_CHECK_ASYNC( x == 1 ); + EXAM_CHECK_ASYNC_F( x == 1, flag ); x = 2; m1.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } int EXAM_IMPL(mt_test::mutex_test) @@ -173,8 +177,8 @@ xmt::Thread t1( thr1, &b ); xmt::Thread t2( thr2, &b ); - t1.join(); - t2.join(); + EXAM_CHECK( t1.join() == 0 ); + EXAM_CHECK( t2.join() == 0 ); EXAM_CHECK( x == 2 ); @@ -196,24 +200,26 @@ xmt::Thread::ret_t thr1s( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); sl1.lock(); - EXAM_CHECK_ASYNC( x == 0 ); + EXAM_CHECK_ASYNC_F( x == 0, flag ); xmt::Thread::yield(); - EXAM_CHECK_ASYNC( x == 0 ); + EXAM_CHECK_ASYNC_F( x == 0, flag ); x = 1; sl1.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } xmt::Thread::ret_t thr2s( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); for ( int i = 0; i < 128; ++i ) { @@ -221,11 +227,11 @@ } sl1.lock(); - EXAM_CHECK_ASYNC( x == 1 ); + EXAM_CHECK_ASYNC_F( x == 1, flag ); x = 2; sl1.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } #endif @@ -239,8 +245,8 @@ xmt::Thread t1( thr1s, &b ); xmt::Thread t2( thr2s, &b ); - t1.join(); - t2.join(); + EXAM_CHECK( t1.join() == 0 ); + EXAM_CHECK( t2.join() == 0 ); EXAM_CHECK( x == 2 ); #endif @@ -291,26 +297,28 @@ xmt::Thread::ret_t thr1r( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); m2.lock(); - EXAM_CHECK_ASYNC( x == 0 ); + EXAM_CHECK_ASYNC_F( x == 0, flag ); x = 1; xmt::Thread::yield(); - EXAM_CHECK_ASYNC( x == 1 ); + EXAM_CHECK_ASYNC_F( x == 1, flag ); recursive(); - EXAM_CHECK_ASYNC( x == 2 ); + EXAM_CHECK_ASYNC_F( x == 2, flag ); x = 3; m2.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } xmt::Thread::ret_t thr2r( void *p ) { + int flag = 0; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -320,14 +328,14 @@ m2.lock(); - EXAM_CHECK_ASYNC( x == 3 ); + EXAM_CHECK_ASYNC_F( x == 3, flag ); xmt::Thread::yield(); recursive(); - EXAM_CHECK_ASYNC( x == 2 ); + EXAM_CHECK_ASYNC_F( x == 2, flag ); m2.unlock(); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(flag); } int EXAM_IMPL(mt_test::recursive_mutex_test) @@ -338,8 +346,8 @@ xmt::Thread t1( thr1r, &b ); xmt::Thread t2( thr2r, &b ); - t1.join(); - t2.join(); + EXAM_CHECK( t1.join() == 0 ); + EXAM_CHECK( t2.join() == 0 ); EXAM_CHECK( x == 2 ); @@ -388,8 +396,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" ); + } } catch ( ... ) { } @@ -432,10 +445,12 @@ try { xmt::fork(); + int flag = 0; + try { // Child code - EXAM_CHECK_ASYNC( my_pid == xmt::getppid() ); + EXAM_CHECK_ASYNC_F( my_pid == xmt::getppid(), flag ); *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) = xmt::getpid(); fcnd.set( true ); @@ -444,7 +459,7 @@ catch ( ... ) { } - exit( 0 ); + exit( flag ); } catch ( xmt::fork_in_parent& child ) { try { @@ -454,8 +469,13 @@ EXAM_CHECK( *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) == child.pid() ); - 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" ); + } } catch ( ... ) { } @@ -656,8 +676,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" ); + } } catch ( ... ) { } @@ -701,6 +726,8 @@ try { xmt::fork(); + int eflag = 0; + try { // Child code @@ -719,16 +746,16 @@ fcnd_ch.set( true ); } catch ( const xmt::shm_bad_alloc& err ) { - EXAM_ERROR_ASYNC( err.what() ); + EXAM_ERROR_ASYNC_F( err.what(), eflag ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR_ASYNC( err.what() ); + EXAM_ERROR_ASYNC_F( err.what(), eflag ); } catch ( ... ) { - EXAM_ERROR_ASYNC( "Fail in child" ); + EXAM_ERROR_ASYNC_F( "Fail in child", eflag ); } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { try { @@ -736,8 +763,13 @@ fcnd.try_wait(); - 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" ); + } } catch ( ... ) { EXAM_ERROR( "Fail in parent" ); @@ -802,6 +834,8 @@ try { xmt::fork(); + int eflag = 0; + try { xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); xmt::allocator_shm<xmt::__condition<true>,1> shm_ch; @@ -810,14 +844,19 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR_ASYNC( err.what() ); + EXAM_ERROR_ASYNC_F( err.what(), eflag ); } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { fcnd.try_wait(); - 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" ); + } } nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here @@ -828,6 +867,8 @@ try { xmt::fork(); + int eflag = 0; + try { xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); xmt::allocator_shm<xmt::__condition<true>,1> shm_ch; @@ -836,15 +877,20 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR_ASYNC( err.what() ); + EXAM_ERROR_ASYNC_F( err.what(), eflag ); } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { fcnd1.try_wait(); - 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" ); + } } nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here @@ -856,6 +902,7 @@ try { xmt::fork(); + int eflag = 0; try { xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); xmt::allocator_shm<xmt::__barrier<true>,1> shm_ch; @@ -864,15 +911,20 @@ nm_ch.release<xmt::__barrier<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR_ASYNC( err.what() ); + EXAM_ERROR_ASYNC_F( err.what(), eflag ); } - exit( 0 ); + exit( eflag ); } catch ( xmt::fork_in_parent& child ) { b.wait(); - 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" ); + } } nm.release<xmt::__barrier<true> >( ObjName ); // barrier should be destroyed here } Modified: trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc 2007-09-07 10:54:55 UTC (rev 1725) +++ trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc 2007-09-07 11:03:24 UTC (rev 1726) @@ -393,9 +393,7 @@ ::srv_p = &srv; - if ( !srv.is_open() || !srv.good() ) { - ++rt; - } + EXAM_CHECK_ASYNC_F( srv.is_open() && srv.good(), rt ); cnd.set( true ); @@ -417,11 +415,9 @@ getline( sock, buf ); - if ( !sock.is_open() || !sock.good() ) { - ++rt; - } + EXAM_CHECK_ASYNC_F( sock.is_open() && sock.good(), rt ); - EXAM_CHECK_ASYNC( buf == "hello" ); + EXAM_CHECK_ASYNC_F( buf == "hello", rt ); // xmt::delay( xmt::timespec( 5, 0 ) ); @@ -437,7 +433,7 @@ char a; sock.read( &a, 1 ); - EXAM_CHECK_ASYNC( !sock.good() ); + EXAM_CHECK_ASYNC_F( !sock.good(), rt ); srv_p->close(); @@ -519,19 +515,20 @@ Thread::ret_t thread_entry_call( void * ) { + int eflag = 0; cnd.set( true ); EXAM_MESSAGE_ASYNC( "Client start" ); - EXAM_CHECK_ASYNC( psock->good() ); + EXAM_CHECK_ASYNC_F( psock->good(), eflag ); char c = '0'; psock->read( &c, 1 ); - EXAM_CHECK_ASYNC( c == '1' ); + EXAM_CHECK_ASYNC_F( c == '1', eflag ); cnd_close.set( true ); psock->read( &c, 1 ); - return 0; + return reinterpret_cast<xmt::Thread::ret_t>(eflag); } int EXAM_IMPL(trivial_sockios_test::client_close_socket) @@ -555,7 +552,7 @@ // but call shutdown is what you want here: psock->rdbuf()->shutdown( sock_base::stop_in | sock_base::stop_out ); psock->close(); - thr.join(); + EXAM_CHECK( thr.join() == 0 ); delete psock; srv.close(); // close server, so we don't wait server termination on next line This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-07 10:54:56
|
Revision: 1725 http://complement.svn.sourceforge.net/complement/?rev=1725&view=rev Author: complement Date: 2007-09-07 03:54:55 -0700 (Fri, 07 Sep 2007) Log Message: ----------- prepare for EPOLL and NONBLOCK Modified Paths: -------------- trunk/complement/explore/include/config/_linux.h trunk/complement/explore/include/config/feature.h Modified: trunk/complement/explore/include/config/_linux.h =================================================================== --- trunk/complement/explore/include/config/_linux.h 2007-09-07 10:53:27 UTC (rev 1724) +++ trunk/complement/explore/include/config/_linux.h 2007-09-07 10:54:55 UTC (rev 1725) @@ -68,4 +68,20 @@ #define __FIT_NO_SELECT +/* + * use algorithms that based on non-block sockets technique + */ + +/* +#define __FIT_NONBLOCK_SOCKETS +*/ + +/* + * use epoll syscall instead of poll + */ + +/* +#define __FIT_EPOLL +*/ + #endif /* __config__linux_h */ Modified: trunk/complement/explore/include/config/feature.h =================================================================== --- trunk/complement/explore/include/config/feature.h 2007-09-07 10:53:27 UTC (rev 1724) +++ trunk/complement/explore/include/config/feature.h 2007-09-07 10:54:55 UTC (rev 1725) @@ -82,7 +82,7 @@ * has poll (HP-UX 10.xx, old Linuxes may not). * We can use either poll or select. */ -#ifndef __FIT_NO_POLL +#if !defined(__FIT_NO_POLL) /* && !defined(__FIT_EPOLL) */ # define __FIT_POLL /* use poll system call */ #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-07 10:53:31
|
Revision: 1724 http://complement.svn.sourceforge.net/complement/?rev=1724&view=rev Author: complement Date: 2007-09-07 03:53:27 -0700 (Fri, 07 Sep 2007) Log Message: ----------- allow any name of functions for 'connect' and 'close' procedures in template parametric class Connect Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.cc trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-07 10:52:21 UTC (rev 1723) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-07 10:53:27 UTC (rev 1724) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/05 00:54:04 ptr> +// -*- C++ -*- Time-stamp: <07/09/06 21:32:15 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -26,8 +26,8 @@ #ifndef __FIT_NO_POLL -template <class Connect> -void sockmgr_stream_MP<Connect>::_open( sock_base::stype t ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +void sockmgr_stream_MP<Connect,C,T>::_open( sock_base::stype t ) { xmt::scoped_lock lk(_fd_lck); if ( is_open_unsafe() ) { @@ -68,29 +68,29 @@ } } -template <class Connect> -void sockmgr_stream_MP<Connect>::open( const in_addr& addr, int port, sock_base::stype t ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +void sockmgr_stream_MP<Connect,C,T>::open( const in_addr& addr, int port, sock_base::stype t ) { basic_sockmgr::open( addr, port, t, sock_base::inet ); - sockmgr_stream_MP<Connect>::_open( t ); + sockmgr_stream_MP<Connect,C,T>::_open( t ); } -template <class Connect> -void sockmgr_stream_MP<Connect>::open( unsigned long addr, int port, sock_base::stype t ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +void sockmgr_stream_MP<Connect,C,T>::open( unsigned long addr, int port, sock_base::stype t ) { basic_sockmgr::open( addr, port, t, sock_base::inet ); - sockmgr_stream_MP<Connect>::_open( t ); + sockmgr_stream_MP<Connect,C,T>::_open( t ); } -template <class Connect> -void sockmgr_stream_MP<Connect>::open( int port, sock_base::stype t ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +void sockmgr_stream_MP<Connect,C,T>::open( int port, sock_base::stype t ) { basic_sockmgr::open( port, t, sock_base::inet ); - sockmgr_stream_MP<Connect>::_open( t ); + sockmgr_stream_MP<Connect,C,T>::_open( t ); } -template <class Connect> -bool sockmgr_stream_MP<Connect>::_shift_fd() +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +bool sockmgr_stream_MP<Connect,C,T>::_shift_fd() { bool ret = false; typename iterator_traits<typename _fd_sequence::iterator>::difference_type d; @@ -173,8 +173,8 @@ return ret; } -template <class Connect> -bool sockmgr_stream_MP<Connect>::accept_tcp() +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +bool sockmgr_stream_MP<Connect,C,T>::accept_tcp() { if ( !is_open() ) { return false; @@ -255,8 +255,8 @@ return true; // something was pushed in connection queue (by _shift_fd) } -template <class Connect> -bool sockmgr_stream_MP<Connect>::accept_udp() +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +bool sockmgr_stream_MP<Connect,C,T>::accept_udp() { if ( !is_open() ) { return false; @@ -359,8 +359,8 @@ return true /* cl */; } -template <class Connect> -void sockmgr_stream_MP<Connect>::_close_by_signal( int ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +void sockmgr_stream_MP<Connect,C,T>::_close_by_signal( int ) { #ifdef _PTHREADS void *_uw_save = *((void **)pthread_getspecific( xmt::Thread::mtkey() ) + _idx ); @@ -372,8 +372,8 @@ #endif } -template <class Connect> -xmt::Thread::ret_t sockmgr_stream_MP<Connect>::loop( void *p ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +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 @@ -429,8 +429,8 @@ return rtc; } -template <class Connect> -xmt::Thread::ret_t sockmgr_stream_MP<Connect>::connect_processor( void *p ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +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; @@ -454,7 +454,7 @@ if (_non_empty ) { sockstream& stream = c->s; if ( stream.is_open() ) { - c->_proc->connect( stream ); + (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 @@ -509,8 +509,8 @@ return rtc; } -template <class Connect> -xmt::Thread::ret_t sockmgr_stream_MP<Connect>::observer( void *p ) +template <class Connect, void (Connect::*C)( std::sockstream& ), void (Connect::*T)() > +xmt::Thread::ret_t sockmgr_stream_MP<Connect,C,T>::observer( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); xmt::Thread::ret_t rtc = 0; Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-09-07 10:52:21 UTC (rev 1723) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-09-07 10:53:27 UTC (rev 1724) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/05 00:45:19 ptr> +// -*- C++ -*- Time-stamp: <07/09/06 21:23:52 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -135,7 +135,7 @@ #ifndef __FIT_NO_POLL -template <class Connect> +template <class Connect, void (Connect::*C)( std::sockstream& ) = &Connect::connect, void (Connect::*T)() = &Connect::close > class sockmgr_stream_MP : public basic_sockmgr { @@ -195,8 +195,8 @@ { loop_id.join(); } private: - sockmgr_stream_MP( const sockmgr_stream_MP<Connect>& ); - sockmgr_stream_MP<Connect>& operator =( const sockmgr_stream_MP<Connect>& ); + sockmgr_stream_MP( const sockmgr_stream_MP<Connect,C,T>& ); + sockmgr_stream_MP<Connect,C,T>& operator =( const sockmgr_stream_MP<Connect,C,T>& ); public: void open( const in_addr& addr, int port, sock_base::stype t = sock_base::sock_stream ); @@ -237,7 +237,7 @@ { } ~_Connect() - { if ( _proc ) { s.close(); _proc->close(); } delete _proc; } + { if ( _proc ) { s.close(); (_proc->*T)(); } delete _proc; } 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 ); } @@ -276,7 +276,7 @@ { return __x.fd == __y; } }; - typedef bool (sockmgr_stream_MP<Connect>::*accept_type)(); + typedef bool (sockmgr_stream_MP<Connect,C,T>::*accept_type)(); #if 0 accept_type _accept; @@ -292,7 +292,7 @@ xmt::Thread loop_id; protected: - typedef sockmgr_stream_MP<Connect> _Self_type; + typedef sockmgr_stream_MP<Connect,C,T> _Self_type; typedef fd_equal _Compare; typedef iaddr_equal _Compare_inet; typedef typename _Sequence::value_type value_type; Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-07 10:52:21 UTC (rev 1723) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-07 10:53:27 UTC (rev 1724) @@ -1,3 +1,8 @@ +2007-09-06 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h, sockmgr.cc: allow any name of functions for 'connect' + and 'close' procedures in template parametric class Connect. + 2007-09-05 Petr Ovtchenkov <pt...@is...> * sockmgr.h, sockmgr.cc: looks like non-POD return from thread is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-07 10:52:23
|
Revision: 1723 http://complement.svn.sourceforge.net/complement/?rev=1723&view=rev Author: complement Date: 2007-09-07 03:52:21 -0700 (Fri, 07 Sep 2007) Log Message: ----------- fix dirname, options Modified Paths: -------------- trunk/complement/explore/lib/janus/Makefile trunk/complement/explore/lib/janus/ut/Makefile Modified: trunk/complement/explore/lib/janus/Makefile =================================================================== --- trunk/complement/explore/lib/janus/Makefile 2007-09-05 11:10:42 UTC (rev 1722) +++ trunk/complement/explore/lib/janus/Makefile 2007-09-07 10:52:21 UTC (rev 1723) @@ -29,17 +29,17 @@ endif check-release-shared: release-shared - $(MAKE) -C test release-shared - (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/ut_vtime) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C test dbg-shared - (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C test stldbg-shared - (cd test; ${OUTPUT_DIR_STLDBG}/ut_vtime) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/ut_vtime) || exit 1 endif depend:: Modified: trunk/complement/explore/lib/janus/ut/Makefile =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile 2007-09-05 11:10:42 UTC (rev 1722) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-09-07 10:52:21 UTC (rev 1723) @@ -12,13 +12,23 @@ INCLUDES += -I${CoMT_INCLUDE_DIR} -I.. DEFS += -D__FIT_EXAM -LDFLAGS += -L${INSTALL_LIB_DIR} -ifdef WITHOUT_STLPORT -LDFLAGS += -Wl,-rpath=${INSTALL_LIB_DIR} -else -LDFLAGS += -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +LIBXMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCKIOS_DIR = ${CoMT_DIR}/lib/sockios +LIBSTEM_DIR = ${CoMT_DIR}/lib/stem + +ifeq ($(OSNAME),linux) + +release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR} -L$(LIBSTEM_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif +endif + release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg ifndef WITHOUT_STLPORT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-05 11:10:45
|
Revision: 1722 http://complement.svn.sourceforge.net/complement/?rev=1722&view=rev Author: complement Date: 2007-09-05 04:10:42 -0700 (Wed, 05 Sep 2007) Log Message: ----------- looks like non-POD return from thread is unstable, and should be avoided; replace union rec_code by void * or long, depends upon operation environment Modified Paths: -------------- trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/include/sockios/sockmgr.cc trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/include/stem/Cron.h trunk/complement/explore/include/stem/EvManager.h trunk/complement/explore/include/stem/NetTransport.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/ut/flck.cc trunk/complement/explore/lib/mt/ut/lfs.cc 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/ut/signal-1.cc trunk/complement/explore/lib/mt/ut/signal-2.cc trunk/complement/explore/lib/mt/ut/signal-3.cc trunk/complement/explore/lib/mt/xmt.cc trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc trunk/complement/explore/lib/sockios/ut/sockios_test.cc trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Cron.cc trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/NetTransport.cc trunk/complement/explore/lib/stem/ut/unit_test.cc Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/mt/xmt.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1377,13 +1377,14 @@ class Thread { public: - union ret_code - { - void *pword; - long iword; - }; +#ifdef _PTHREADS + typedef void * ret_t; +#endif +#ifdef __FIT_WIN32THREADS + typedef long ret_t; +#endif - typedef ret_code (*entrance_type)( void * ); + typedef ret_t (*entrance_type)( void * ); #ifdef __FIT_WIN32THREADS typedef unsigned long thread_key_type; typedef HANDLE thread_id_type; @@ -1444,7 +1445,7 @@ __FIT_DECLSPEC void launch( entrance_type entrance, const void *p = 0, size_t psz = 0, size_t stack_sz = 0 ); - __FIT_DECLSPEC ret_code join(); + __FIT_DECLSPEC ret_t join(); __FIT_DECLSPEC int suspend(); __FIT_DECLSPEC int resume(); __FIT_DECLSPEC int kill( int sig ); Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:14:42 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:54:04 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -258,14 +258,71 @@ template <class Connect> bool sockmgr_stream_MP<Connect>::accept_udp() { -#if 0 if ( !is_open() ) { return false; } + _xsockaddr addr; socklen_t sz = sizeof( sockaddr_in ); - _xsockaddr addr; + bool _in_buf; + do { + _in_buf = false; + _pfd[0].revents = 0; + _pfd[1].revents = 0; + while ( poll( &_pfd[0], /* _pfd.size() */ 1, -1 ) < 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return false; // poll wait infinite, so it can't return 0 (timeout), so it return -1. + } + + // New connction open before data read from opened sockets. + // This policy may be worth to revise. + + if ( (_pfd[0].revents & POLLERR) != 0 /* || (_pfd[1].revents & POLLERR) != 0 */ ) { + return false; // return 0 only for binded socket, or control socket + } + + if ( _pfd[0].revents != 0 ) { + xmt::scoped_lock lk(_fd_lck); + if ( !is_open_unsafe() ) { // may be already closed + return false; + } + // poll found event on binded socket + // get address of caller only + char buff[65535]; + ::recvfrom( fd(), buff, 65535, MSG_PEEK, &addr.any, &sz ); + try { + xmt::scoped_lock _l( _c_lock ); + // if addr.any pesent in _M_c + typename container_type::iterator i = + find_if( _M_c.begin(), _M_c.end(), bind2nd( _M_comp_inet, addr.any ) ); + if ( i == _M_c.end() ) { + _M_c.push_back( _Connect() ); + _M_c.back().open( fd(), addr.any, sock_base::sock_dgram ); + _Connect *cl_new = &_M_c.back(); + } + // + // ... + // + } + catch ( ... ) { + } + } +#if 0 + if ( _pfd[1].revents != 0 ) { // fd come back for poll + pollfd rfd; + ::read( _pfd[1].fd, reinterpret_cast<char *>(&rfd.fd), sizeof(sock_base::socket_type) ); + rfd.events = POLLIN; + rfd.revents = 0; + _pfd.push_back( rfd ); + } +#endif + } while ( /* !_shift_fd() && */ !_in_buf ); + +#if 0 if ( poll( &_pfd[0], 1, -1 ) < 0 ) { // wait infinite return false; // poll wait infinite, so it can't return 0 (timeout), so it return -1. } @@ -316,14 +373,12 @@ } template <class Connect> -xmt::Thread::ret_code sockmgr_stream_MP<Connect>::loop( void *p ) +xmt::Thread::ret_t sockmgr_stream_MP<Connect>::loop( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); me->loop_id.pword( _idx ) = me; // push pointer to self for signal processing - xmt::Thread::ret_code rtc; - xmt::Thread::ret_code rtc_observer; - rtc.iword = 0; - rtc_observer.iword = 0; + xmt::Thread::ret_t rtc = 0; + xmt::Thread::ret_t rtc_observer = 0; xmt::Thread thr_observer; @@ -336,8 +391,8 @@ if ( thr_observer.bad() ) { if ( thr_observer.is_join_req() ) { rtc_observer = thr_observer.join(); - if ( rtc_observer.iword != 0 ) { - rtc.iword = -2; // there was connect_processor that was killed + if ( rtc_observer != 0 ) { + rtc = reinterpret_cast<xmt::Thread::ret_t>(-2); // there was connect_processor that was killed } } thr_observer.launch( observer, me, 0, PTHREAD_STACK_MIN * 2 ); @@ -345,7 +400,7 @@ } } catch ( ... ) { - rtc.iword = -1; + rtc = reinterpret_cast<xmt::Thread::ret_t>(-1); } xmt::block_signal( SIGINT ); @@ -367,19 +422,18 @@ rtc_observer = thr_observer.join(); me->_M_c.clear(); // FIN still may not come yet; force close - if ( rtc_observer.iword != 0 && rtc.iword == 0 ) { - rtc.iword = -2; // there was connect_processor that was killed + if ( rtc_observer != 0 && rtc == 0 ) { + rtc = reinterpret_cast<xmt::Thread::ret_t>(-2); // there was connect_processor that was killed } return rtc; } template <class Connect> -xmt::Thread::ret_code sockmgr_stream_MP<Connect>::connect_processor( void *p ) +xmt::Thread::ret_t sockmgr_stream_MP<Connect>::connect_processor( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); - xmt::Thread::ret_code rtc; - rtc.iword = 0; + xmt::Thread::ret_t rtc = 0; try { timespec idle( me->_idle ); @@ -449,18 +503,17 @@ } while ( me->_is_follow() && idle_count < 2 ); } catch ( ... ) { - rtc.iword = -1; + rtc = reinterpret_cast<xmt::Thread::ret_t>(-1); } return rtc; } template <class Connect> -xmt::Thread::ret_code sockmgr_stream_MP<Connect>::observer( void *p ) +xmt::Thread::ret_t sockmgr_stream_MP<Connect>::observer( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); - xmt::Thread::ret_code rtc; - rtc.iword = 0; + xmt::Thread::ret_t rtc = 0; int pool_size[3]; // size_t thr_pool_size[3]; timespec tpop; @@ -518,11 +571,11 @@ } if ( mgr.size() > 0 ) { mgr.signal( SIGTERM ); - rtc.iword = -1; + rtc = reinterpret_cast<xmt::Thread::ret_t>(-1); } } catch ( ... ) { - rtc.iword = -1; + rtc = reinterpret_cast<xmt::Thread::ret_t>(-1); } return rtc; @@ -802,14 +855,11 @@ } template <class Connect> -xmt::Thread::ret_code sockmgr_stream_MP_SELECT<Connect>::loop( void *p ) +xmt::Thread::ret_t sockmgr_stream_MP_SELECT<Connect>::loop( void *p ) { _Self_type *me = static_cast<_Self_type *>(p); me->loop_id.pword( _idx ) = me; // push pointer to self for signal processing - xmt::Thread::ret_code rtc; - rtc.iword = 0; - try { _Connect *s; unsigned _sfd; @@ -843,8 +893,8 @@ } me->close(); me->_c_lock.unlock(); - rtc.iword = -1; - return rtc; + + return reinterpret_cast<xmt::Thread::ret_t>(-1); // throw; } @@ -863,7 +913,7 @@ me->close(); me->_c_lock.unlock(); - return rtc; + return 0; } #endif // !__FIT_NO_SELECT Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/31 09:55:36 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:45:19 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -251,9 +251,9 @@ typedef std::deque<typename _Sequence::iterator> _connect_pool_sequence; void _open( sock_base::stype t = sock_base::sock_stream ); - static xmt::Thread::ret_code loop( void * ); - static xmt::Thread::ret_code connect_processor( void * ); - static xmt::Thread::ret_code observer( void * ); + static xmt::Thread::ret_t loop( void * ); + static xmt::Thread::ret_t connect_processor( void * ); + static xmt::Thread::ret_t observer( void * ); struct fd_equal : public std::binary_function<_Connect,int,bool> @@ -391,7 +391,7 @@ protected: void _open( sock_base::stype t = sock_base::sock_stream ); - static xmt::Thread::ret_code loop( void * ); + static xmt::Thread::ret_t loop( void * ); struct _Connect { sockstream *s; Modified: trunk/complement/explore/include/stem/Cron.h =================================================================== --- trunk/complement/explore/include/stem/Cron.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/stem/Cron.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:20:12 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:08:54 ptr> /* * Copyright (c) 1998, 2002, 2003, 2005, 2007 @@ -152,7 +152,7 @@ __FIT_DECLSPEC void EmptyStop(); private: - static xmt::Thread::ret_code _loop( void * ); + static xmt::Thread::ret_t _loop( void * ); xmt::Thread _thr; xmt::condition cond; Modified: trunk/complement/explore/include/stem/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/stem/EvManager.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:17:27 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:09:05 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -239,7 +239,7 @@ const addr_type _x_high; addr_type _x_id; - static xmt::Thread::ret_code _Dispatch( void * ); + static xmt::Thread::ret_t _Dispatch( void * ); bool not_finished(); Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/include/stem/NetTransport.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/13 13:22:52 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:10:17 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -97,14 +97,14 @@ virtual __FIT_DECLSPEC void close(); int join() - { return _thr.join().iword; } + { return reinterpret_cast<int>(_thr.join()); } private: NetTransportMgr( const NetTransportMgr& ); NetTransportMgr& operator =( const NetTransportMgr& ); protected: - static xmt::Thread::ret_code _loop( void * ); + static xmt::Thread::ret_t _loop( void * ); xmt::Thread _thr; std::sockstream _channel; }; Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,3 +1,17 @@ +2007-09-05 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc: looks like non-POD return from thread is unstable, + and should be avoided; replace union rec_code by void * or long, + depends upon operation environment; + + * ut/signal-1.cc, ut/signal-2.cc, ut/signal-3.cc: ditto; + + * ut/flck.cc, ut/mt_test.cc, ut/mt_test.h: ditto; + + * ut/lfs.cc, ut/mt_test_suite.cc: ditto; + + * libxmt: version 1.12.0 + 2007-08-27 Petr Ovtchenkov <pt...@is...> * shm.h: use namespace std for max. Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-09-05 11:10:42 UTC (rev 1722) @@ -2,7 +2,7 @@ LIBNAME = xmt MAJOR = 1 -MINOR = 11 +MINOR = 12 PATCH = 0 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/ut/flck.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/flck.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/flck.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 21:34:09 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:00:06 ptr> /* * Copyright (c) 2004, 2006, 2007 @@ -30,11 +30,8 @@ static mutex b; static int cnt = 0; -static Thread::ret_code thread_func( void * ) +static Thread::ret_t thread_func( void * ) { - Thread::ret_code rt; - rt.iword = 0; - try { for ( int count = 0; count < 10; ++count ) { int fd = open( fname, O_RDWR | O_CREAT | O_APPEND, 00666 ); @@ -83,17 +80,14 @@ b.lock(); BOOST_MESSAGE( "* The error returned: " << check << ", errno " << errno ); b.unlock(); - rt.iword = -1; + return reinterpret_cast<Thread::ret_t>(-1); } - return rt; + return 0; } -static Thread::ret_code thread_func_r( void * ) +static Thread::ret_t thread_func_r( void * ) { - Thread::ret_code rt; - rt.iword = 0; - char buf[64]; // buf[14] = 0; int ln = 0; @@ -200,10 +194,10 @@ b.lock(); BOOST_MESSAGE( "* The error returned: " << check << ", errno " << errno << ' ' << buf ); b.unlock(); - rt.iword = -1; + return reinterpret_cast<Thread::ret_t>(-1); } - return rt; + return 0; } int EXAM_IMPL(flock_test) Modified: trunk/complement/explore/lib/mt/ut/lfs.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/lfs.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/lfs.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 21:33:58 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:01:28 ptr> /* * Copyright (c) 2004, 2006, 2007 @@ -31,11 +31,8 @@ static int cnt = 0; static condition cnd; -static Thread::ret_code thread_func( void * ) +static Thread::ret_t thread_func( void * ) { - Thread::ret_code rt; - rt.iword = 0; - try { for ( int count = 0; count < 10; ++count ) { olfstream s( fname, ios_base::out | ios_base::app ); @@ -75,17 +72,14 @@ } catch ( ... ) { BOOST_REQUIRE( false ); - rt.iword = -1; + return reinterpret_cast<Thread::ret_t>(-1); } - return rt; + return 0; } -static Thread::ret_code thread_func_r( void * ) +static Thread::ret_t thread_func_r( void * ) { - Thread::ret_code rt; - rt.iword = 0; - try { string buf; int ln = 0; @@ -141,17 +135,14 @@ b.lock(); BOOST_REQUIRE( false ); b.unlock(); - rt.iword = -1; + return reinterpret_cast<Thread::ret_t>(-1); } - return rt; + return 0; } -static Thread::ret_code thread_func_manip( void * ) +static Thread::ret_t thread_func_manip( void * ) { - Thread::ret_code rt; - rt.iword = 0; - for ( int count = 0; count < 10; ++count ) { olfstream s( fname, ios_base::out | ios_base::app ); @@ -183,14 +174,11 @@ s.close(); } - return rt; + return 0; } -static Thread::ret_code thread_func_manip_r( void * ) +static Thread::ret_t thread_func_manip_r( void * ) { - Thread::ret_code rt; - rt.iword = 0; - string buf; cnd.try_wait(); @@ -232,7 +220,7 @@ s.close(); } - return rt; + return 0; } int EXAM_IMPL(lfs_test) Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/06 10:03:33 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:31:04 ptr> /* * Copyright (c) 2006, 2007 @@ -46,14 +46,11 @@ static int x = 0; -xmt::Thread::ret_code thread_entry_call( void * ) +xmt::Thread::ret_t thread_entry_call( void * ) { x = 1; - xmt::Thread::ret_code rt; - rt.iword = 2; - - return rt; + return reinterpret_cast<xmt::Thread::ret_t>(2); } int EXAM_IMPL(mt_test::join_test) @@ -62,7 +59,7 @@ xmt::Thread t( thread_entry_call ); - EXAM_CHECK( t.join().iword == 2 ); + EXAM_CHECK( reinterpret_cast<int>(t.join()) == 2 ); EXAM_CHECK( x == 1 ); @@ -73,15 +70,12 @@ * Start two threads, align ones on barrier, join. */ -xmt::Thread::ret_code thread2_entry_call( void *p ) +xmt::Thread::ret_t thread2_entry_call( void *p ) { - xmt::Thread::ret_code rt; - rt.iword = 1; - xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); - return rt; + return reinterpret_cast<xmt::Thread::ret_t>(1); } int EXAM_IMPL(mt_test::barrier2) @@ -91,8 +85,9 @@ xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread2_entry_call, &b ); - EXAM_CHECK( t2.join().iword == 1 ); - EXAM_CHECK( t1.join().iword == 1 ); + EXAM_CHECK( reinterpret_cast<int>(t2.join()) == 1 ); + // std::cerr << t2.join() << std::endl; + EXAM_CHECK( reinterpret_cast<int>(t1.join()) == 1 ); return EXAM_RESULT; } @@ -102,16 +97,13 @@ * relinquish control to other; join (within Thread dtors) */ -xmt::Thread::ret_code thread3_entry_call( void *p ) +xmt::Thread::ret_t thread3_entry_call( void *p ) { - xmt::Thread::ret_code rt; - rt.iword = 0; - xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); EXAM_CHECK_ASYNC( xmt::Thread::yield() == 0 ); - return rt; + return 0; } int EXAM_IMPL(mt_test::yield) @@ -139,7 +131,7 @@ static xmt::mutex m1; -xmt::Thread::ret_code thr1( void *p ) +xmt::Thread::ret_t thr1( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -154,13 +146,10 @@ m1.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } -xmt::Thread::ret_code thr2( void *p ) +xmt::Thread::ret_t thr2( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -173,10 +162,7 @@ x = 2; m1.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } int EXAM_IMPL(mt_test::mutex_test) @@ -208,7 +194,7 @@ #ifdef __FIT_PTHREAD_SPINLOCK static xmt::spinlock sl1; -xmt::Thread::ret_code thr1s( void *p ) +xmt::Thread::ret_t thr1s( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -223,13 +209,10 @@ sl1.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } -xmt::Thread::ret_code thr2s( void *p ) +xmt::Thread::ret_t thr2s( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -242,10 +225,7 @@ x = 2; sl1.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } #endif @@ -309,7 +289,7 @@ m2.unlock(); } -xmt::Thread::ret_code thr1r( void *p ) +xmt::Thread::ret_t thr1r( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -326,14 +306,10 @@ m2.unlock(); - xmt::Thread::ret_code rt; - - rt.iword = 0; - - return rt; + return 0; } -xmt::Thread::ret_code thr2r( void *p ) +xmt::Thread::ret_t thr2r( void *p ) { xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -351,11 +327,7 @@ m2.unlock(); - xmt::Thread::ret_code rt; - - rt.iword = 0; - - return rt; + return 0; } int EXAM_IMPL(mt_test::recursive_mutex_test) @@ -926,21 +898,18 @@ static int my_thr_scnt = 0; static xmt::mutex lock; -xmt::Thread::ret_code thread_mgr_entry_call( void * ) +xmt::Thread::ret_t thread_mgr_entry_call( void * ) { lock.lock(); ++my_thr_cnt; ++my_thr_scnt; lock.unlock(); - xmt::Thread::ret_code rt; - rt.iword = 0; - lock.lock(); --my_thr_cnt; lock.unlock(); - return rt; + return 0; } int EXAM_IMPL(mt_test::thr_mgr) Modified: trunk/complement/explore/lib/mt/ut/mt_test.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.h 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/mt_test.h 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 21:01:43 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:02:19 ptr> /* * Copyright (c) 2006, 2007 @@ -32,7 +32,7 @@ int EXAM_DECL(thr_mgr); private: - // static xmt::Thread::ret_code thread_entry_call( void * ); + // static xmt::Thread::ret_t thread_entry_call( void * ); // static int x; }; Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 10:20:08 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:29:06 ptr> /* * Copyright (c) 2006, 2007 @@ -62,28 +62,5 @@ t.add( &shm_test::shm_segment, shmtest, "mt_test::shm_segment" ) ) ) ) ); - // add( barrier_tc, 0, 2 ); - // add( join_tc ); - // add( barrier2_tc, 0, 3 ); - // add( yield_tc, 0, 3 ); - // add( mutex_test_tc, 0, 3 ); -#ifdef __FIT_PTHREAD_SPINLOCK - // add( spinlock_test_tc, 0, 3 ); -#endif - // add( recursive_mutex_test_tc, 0, 3 ); - - // add( fork_tc ); - // add( pid_tc ); - // add( shm_segment_tc ); - // add( shm_alloc_tc ); - // add( fork_shm_tc, 0, 5 ); - // add( shm_nm_obj_tc, 0, 5 ); - - // add( thr_mgr_tc ); - - // add( shm_init_tc ); - // add( shm_nm_obj_more_tc ); - // add( shm_finit_tc ); - return t.girdle(); }; Modified: trunk/complement/explore/lib/mt/ut/signal-1.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/signal-1.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/signal-1.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 09:49:18 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:03:41 ptr> /* * Copyright (c) 2003, 2006, 2007 @@ -23,8 +23,8 @@ * handler (within thread 1): v == 1?; v = 4 */ -static Thread::ret_code thread_one( void * ); -static Thread::ret_code thread_two( void * ); +static Thread::ret_t thread_one( void * ); +static Thread::ret_t thread_two( void * ); static Thread *th_one = 0; static Thread *th_two = 0; @@ -54,7 +54,7 @@ } } -Thread::ret_code thread_one( void * ) +Thread::ret_t thread_one( void * ) { xmt::unblock_signal( SIGINT ); // we wait this signal // Default handler make exit() call: @@ -68,13 +68,10 @@ th_one->kill( SIGINT ); // send signal SIGINT to self - Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } -Thread::ret_code thread_two( void * ) +Thread::ret_t thread_two( void * ) { cnd.set( false ); @@ -89,10 +86,7 @@ EXAM_CHECK_ASYNC( v == 4 ); - Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } int EXAM_IMPL(signal_1_test) Modified: trunk/complement/explore/lib/mt/ut/signal-2.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/signal-2.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/signal-2.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 21:34:49 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:04:38 ptr> /* * Copyright (c) 2003, 2006, 2007 @@ -17,8 +17,8 @@ using namespace std; using namespace xmt; -static Thread::ret_code thread_one( void * ); -static Thread::ret_code thread_two( void * ); +static Thread::ret_t thread_one( void * ); +static Thread::ret_t thread_two( void * ); static Thread *th_one = 0; static Thread *th_two = 0; @@ -40,11 +40,8 @@ } } -Thread::ret_code thread_one( void * ) +Thread::ret_t thread_one( void * ) { - Thread::ret_code rt; - rt.iword = 0; - try { xmt::unblock_signal( SIGINT ); // we wait this signal // I set own handler, that throw signal: @@ -77,10 +74,10 @@ v = 5; } - return rt; + return 0; } -Thread::ret_code thread_two( void * ) +Thread::ret_t thread_two( void * ) { try { // pm.lock(); @@ -108,10 +105,7 @@ // v = 5; } - Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } int EXAM_IMPL(signal_2_test) Modified: trunk/complement/explore/lib/mt/ut/signal-3.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/signal-3.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/ut/signal-3.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 09:50:35 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:05:31 ptr> /* * Copyright (c) 2003, 2006, 2007 @@ -28,8 +28,8 @@ * */ -static Thread::ret_code thread_one( void * ); -static Thread::ret_code thread_two( void * ); +static Thread::ret_t thread_one( void * ); +static Thread::ret_t thread_two( void * ); static Thread *th_one = 0; static Thread *th_two = 0; @@ -59,7 +59,7 @@ } } -Thread::ret_code thread_one( void * ) +Thread::ret_t thread_one( void * ) { EXAM_CHECK_ASYNC( v == 1 ); @@ -67,13 +67,10 @@ th_two->kill( SIGINT ); // send signal SIGINT to self - Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } -Thread::ret_code thread_two( void * ) +Thread::ret_t thread_two( void * ) { xmt::signal_handler( SIGINT, handler ); xmt::block_signal( SIGINT ); // block signal @@ -90,10 +87,7 @@ EXAM_CHECK_ASYNC( v == 4 ); - Thread::ret_code rt; - rt.iword = 0; - - return rt; + return 0; } int EXAM_IMPL(signal_3_test) Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/mt/xmt.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -397,28 +397,26 @@ } __FIT_DECLSPEC -Thread::ret_code Thread::join() +Thread::ret_t Thread::join() { - ret_code rt; + ret_t rt = 0; #ifdef __FIT_WIN32THREADS - rt.iword = 0; if ( !_not_run() ) { WaitForSingleObject( _id, -1 ); - GetExitCodeThread( _id, &rt.iword ); + GetExitCodeThread( _id, &rt ); CloseHandle( _id ); // Locker lk( _llock ); _id = bad_thread_id; } #endif // __FIT_WIN32THREADS #if defined(__FIT_UITHREADS) || defined(_PTHREADS) - rt.pword = 0; if ( is_join_req() ) { # ifdef _PTHREADS - pthread_join( _rip_id, &rt.pword ); + pthread_join( _rip_id, &rt ); # endif # ifdef __FIT_UITHREADS - thr_join( _rip_id, 0, &rt.pword ); + thr_join( _rip_id, 0, &rt ); # endif // Locker lk( _llock ); _rip_id = bad_thread_id; @@ -509,14 +507,10 @@ void Thread::_exit( int code ) { #ifdef _PTHREADS - ret_code v; - v.iword = code; - pthread_exit( v.pword ); + pthread_exit( reinterpret_cast<ret_t>(code) ); #endif #ifdef __FIT_UITHREADS - ret_code v; - v.iword = code; - thr_exit( v.pword ); + thr_exit( reinterpret_cast<ret_t>(code) ); #endif #ifdef __FIT_WIN32THREADS ExitThread( code ); @@ -786,7 +780,7 @@ // of me->_entrance!!! void *_param = me->_param; size_t _param_sz = me->_param_sz; - ret_code ret; + ret_t ret = 0; //#ifdef _PTHREADS //# ifndef __hpux @@ -846,7 +840,7 @@ #ifndef _WIN32 cerr << e.what() << endl; #endif - ret.iword = -1; + ret = reinterpret_cast<ret_t>(-1); } catch ( int sig ) { if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected @@ -866,7 +860,7 @@ #ifndef _WIN32 cerr << "\n--- Thread: signal " << sig /* (_sig_ ? _sig_ : "unknown") */ << " detected ---" << endl; #endif - ret.iword = sig; + ret = reinterpret_cast<ret_t>(sig); } catch ( ... ) { if ( (me->_flags & (daemon | detached)) != 0 ) { // otherwise join expected @@ -884,7 +878,7 @@ #ifndef _WIN32 cerr << "\n--- Thread: unknown exception occur ---" << endl; #endif - ret.iword = -1; + ret = reinterpret_cast<ret_t>(-1); } try { @@ -895,14 +889,14 @@ } } catch ( ... ) { - ret.iword = -1; + ret = reinterpret_cast<ret_t>(-1); } #if defined( __SUNPRO_CC ) && defined( __i386 ) - Thread::_exit( ret.iword ); + Thread::_exit( ret ); #endif - return ret.pword; + return ret; } #ifdef _WIN32 #pragma warning( default : 4101 ) Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,3 +1,11 @@ +2007-09-05 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h, sockmgr.cc: looks like non-POD return from thread is + unstable, and should be avoided; replace union rec_code by void * + or long, depends upon operation environment; + + * ut/ConnectionProcessor.cc, ut/sockios_test.cc: ditto. + 2007-09-01 Petr Ovtchenkov <pt...@is...> * sockstream: clean; add inet_sockaddr() method, that return Modified: trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/sockios/ut/ConnectionProcessor.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/18 23:10:22 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:39:10 ptr> /* * @@ -384,10 +384,9 @@ static srv_type *srv_p; condition cnd; -Thread::ret_code server_proc( void * ) +Thread::ret_t server_proc( void * ) { - Thread::ret_code rt; - rt.iword = 0; + unsigned rt = 0; cnd.set( false ); srv_type srv( port ); // start server @@ -395,20 +394,19 @@ ::srv_p = &srv; if ( !srv.is_open() || !srv.good() ) { - ++rt.iword; + ++rt; } cnd.set( true ); srv.wait(); - return rt; + return reinterpret_cast<Thread::ret_t>(rt); } -Thread::ret_code client_proc( void * ) +Thread::ret_t client_proc( void * ) { - Thread::ret_code rt; - rt.iword = 0; + unsigned rt = 0; cnd.try_wait(); @@ -420,7 +418,7 @@ getline( sock, buf ); if ( !sock.is_open() || !sock.good() ) { - ++rt.iword; + ++rt; } EXAM_CHECK_ASYNC( buf == "hello" ); @@ -445,7 +443,7 @@ EXAM_MESSAGE_ASYNC( "Client end" ); - return rt; + return reinterpret_cast<Thread::ret_t>(rt); } int EXAM_IMPL(trivial_sockios_test::srv_close_connection) @@ -454,8 +452,8 @@ cnd_close.set( false ); Thread client( client_proc ); - EXAM_CHECK( client.join().iword == 0 ); - EXAM_CHECK( srv.join().iword == 0 ); + EXAM_CHECK( client.join() == 0 ); + EXAM_CHECK( srv.join() == 0 ); return EXAM_RESULT; } @@ -519,11 +517,8 @@ std::sockstream *psock = 0; -Thread::ret_code thread_entry_call( void * ) +Thread::ret_t thread_entry_call( void * ) { - Thread::ret_code rt; - rt.iword = 0; - cnd.set( true ); EXAM_MESSAGE_ASYNC( "Client start" ); @@ -536,7 +531,7 @@ cnd_close.set( true ); psock->read( &c, 1 ); - return rt; + return 0; } int EXAM_IMPL(trivial_sockios_test::client_close_socket) Modified: trunk/complement/explore/lib/sockios/ut/sockios_test.cc =================================================================== --- trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/sockios/ut/sockios_test.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/18 09:22:46 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 00:44:02 ptr> /* * @@ -177,12 +177,8 @@ { } -xmt::Thread::ret_code client_thr( void *p ) +xmt::Thread::ret_t client_thr( void *p ) { - xmt::Thread::ret_code ret; - - ret.iword = 0; - sockstream s( "localhost", port ); char buf[1024]; @@ -200,7 +196,7 @@ xmt::Thread::yield(); } - return ret; + return 0; } void sigpipe_handler( int sig, siginfo_t *si, void * ) @@ -459,9 +455,8 @@ // pr_lock.unlock(); } -xmt::Thread::ret_code thread_entry( void *par ) +xmt::Thread::ret_t thread_entry( void *par ) { - xmt::Thread::ret_code rt; xmt::condition& cnd = *reinterpret_cast<xmt::condition *>(par); // sem.wait(); // wait server for listen us @@ -475,8 +470,7 @@ EXAM_CHECK_ASYNC( buff == 1 ); // cerr << "Read pass" << endl; - rt.iword = 0; - return rt; + return 0; } int EXAM_IMPL(sockios_test::read0) @@ -531,6 +525,8 @@ catch ( xmt::shm_bad_alloc& err ) { EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ */ Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,3 +1,11 @@ +2007-09-05 Petr Ovtchenkov <pt...@is...> + + * Cron.h, NetTransport.h, EvManager.h: looks like non-POD return + from thread is unstable, and should be avoided; replace union + rec_code by void * or long, depends upon operation environment; + + * Cron.cc, NetTransport.cc, EvManager.cc, ut/unit_test.cc: idem. + 2007-08-25 Petr Ovtchenkov <pt...@is...> * EvManager.h, NetTransport.cc: use ostream and trace flags Modified: trunk/complement/explore/lib/stem/Cron.cc =================================================================== --- trunk/complement/explore/lib/stem/Cron.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/stem/Cron.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/12/15 03:12:28 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:04:08 ptr> /* * Copyright (c) 1998, 2002, 2003, 2005, 2006 @@ -172,7 +172,7 @@ // do nothing } -xmt::Thread::ret_code Cron::_loop( void *p ) +xmt::Thread::ret_t Cron::_loop( void *p ) { // After creation cron loop (one per every Cron object), // this loop should exit in following cases: @@ -182,9 +182,6 @@ // after Add (Cron entry) event. Cron& me = *reinterpret_cast<Cron *>(p); - xmt::Thread::ret_code rt; - rt.iword = 0; - me.PushState( CRON_ST_STARTED ); timespec abstime; @@ -235,7 +232,7 @@ } } - return rt; + return 0; } Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 22:22:13 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:04:58 ptr> /* * @@ -75,11 +75,9 @@ return !_dispatch_stop; } -xmt::Thread::ret_code EvManager::_Dispatch( void *p ) +xmt::Thread::ret_t EvManager::_Dispatch( void *p ) { EvManager& me = *reinterpret_cast<EvManager *>(p); - xmt::Thread::ret_code rt; - rt.iword = 0; xmt::mutex& lq = me._lock_queue; queue_type& in_ev_queue = me.in_ev_queue; queue_type& out_ev_queue = me.out_ev_queue; @@ -102,7 +100,7 @@ } } - return rt; + return 0; } __FIT_DECLSPEC Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 17:25:23 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:06:19 ptr> /* * @@ -437,12 +437,10 @@ join(); } -xmt::Thread::ret_code NetTransportMgr::_loop( void *p ) +xmt::Thread::ret_t NetTransportMgr::_loop( void *p ) { NetTransportMgr& me = *reinterpret_cast<NetTransportMgr *>(p); Event ev; - xmt::Thread::ret_code rt; - rt.iword = 0; gaddr_type dst; gaddr_type src; @@ -501,10 +499,10 @@ catch ( ... ) { me.NetTransport_base::close(); // throw; - rt.iword = -1; + return reinterpret_cast<xmt::Thread::ret_t>(-1); } - return rt; + return 0; } __FIT_DECLSPEC Modified: trunk/complement/explore/lib/stem/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/unit_test.cc 2007-09-04 07:29:28 UTC (rev 1721) +++ trunk/complement/explore/lib/stem/ut/unit_test.cc 2007-09-05 11:10:42 UTC (rev 1722) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:21:37 ptr> +// -*- C++ -*- Time-stamp: <07/09/05 01:08:18 ptr> /* * Copyright (c) 2002, 2003, 2006, 2007 @@ -62,8 +62,8 @@ int EXAM_DECL(boring_manager); int EXAM_DECL(convert); - static xmt::Thread::ret_code thr1( void * ); - static xmt::Thread::ret_code thr1new( void * ); + static xmt::Thread::ret_t thr1( void * ); + static xmt::Thread::ret_t thr1new( void * ); private: }; @@ -89,7 +89,7 @@ xmt::Thread t1( thr1 ); - EXAM_CHECK( t1.join().iword == 0 ); + EXAM_CHECK( t1.join() == 0 ); node.wait(); @@ -98,11 +98,8 @@ return EXAM_RESULT; } -xmt::Thread::ret_code stem_test::thr1( void * ) +xmt::Thread::ret_t stem_test::thr1( void * ) { - xmt::Thread::ret_code rt; - rt.iword = 0; - Node node( 2001 ); EDS::Event ev( NODE_EV1 ); @@ -110,7 +107,7 @@ ev.dest( 2000 ); node.Send( ev ); - return rt; + return 0; } int EXAM_IMPL(stem_test::basic1new) @@ -145,11 +142,8 @@ return EXAM_RESULT; } -xmt::Thread::ret_code stem_test::thr1new( void * ) +xmt::Thread::ret_t stem_test::thr1new( void * ) { - xmt::Thread::ret_code rt; - rt.iword = 0; - NewNode *node = new NewNode( 2001 ); EDS::Event ev( NODE_EV1 ); @@ -159,7 +153,7 @@ delete node; - return rt; + return 0; } int EXAM_IMPL(stem_test::dl) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-04 07:29:30
|
Revision: 1721 http://complement.svn.sourceforge.net/complement/?rev=1721&view=rev Author: complement Date: 2007-09-04 00:29:28 -0700 (Tue, 04 Sep 2007) Log Message: ----------- performance measure feature; libexam version 0.3.0 Modified Paths: -------------- trunk/complement/explore/include/exam/logger.h trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/Makefile.inc trunk/complement/explore/lib/exam/logger.cc trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/dummy_test.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.h Modified: trunk/complement/explore/include/exam/logger.h =================================================================== --- trunk/complement/explore/include/exam/logger.h 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/include/exam/logger.h 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:08:25 ptr> +// -*- C++ -*- Time-stamp: <07/09/04 10:38:27 ptr> /* * Copyright (c) 2007 @@ -13,6 +13,8 @@ #include <string> #include <cstdio> #include <ostream> +#include <mt/time.h> +#include <list> namespace exam { @@ -64,6 +66,9 @@ virtual void begin_ts() = 0; virtual void end_ts() = 0; virtual void result( const base_logger::stat&, const std::string& suite_name ) = 0; + virtual void tc_pre() = 0; + virtual void tc_post() = 0; + virtual void tc_break() = 0; virtual void tc( tc_result, const std::string& ) = 0; protected: @@ -89,13 +94,41 @@ virtual void begin_ts(); virtual void end_ts(); virtual void result( const base_logger::stat&, const std::string& ); + virtual void tc_pre() + { } + virtual void tc_post() + { } + virtual void tc_break() + { } virtual void tc( base_logger::tc_result, const std::string& ); - private: + protected: std::ostream *s; FILE *f; }; +class trivial_time_logger : + public trivial_logger +{ + public: + explicit trivial_time_logger( std::ostream& str ) : + trivial_logger( str ) + { } + + explicit trivial_time_logger( FILE *fs ) : + trivial_logger( fs ) + { } + + virtual void tc_pre(); + virtual void tc_post(); + virtual void tc_break(); + virtual void tc( base_logger::tc_result, const std::string& ); + + private: + typedef std::list<xmt::timespec> time_container_t; + time_container_t tst; +}; + } // namespace exam #endif // __logger_h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/include/exam/suite.h 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:07:43 ptr> +// -*- C++ -*- Time-stamp: <07/09/04 11:08:48 ptr> /* * Copyright (c) 2007 @@ -168,8 +168,8 @@ typedef int (*func_type)( test_suite *, int ); typedef vertex_t test_case_type; - test_suite( const std::string& name ); - test_suite( const char *name ); + test_suite( const std::string& name, unsigned n = 1 ); + test_suite( const char *name, unsigned n = 1 ); ~test_suite(); test_case_type add( func_type, const std::string& name ); @@ -227,8 +227,9 @@ test_case_map_type _test; base_logger::stat _stat; std::string _suite_name; + unsigned _iterations; - void run_test_case( vertex_t v ); + void run_test_case( vertex_t v, unsigned n = 1 ); static bool vertices_compare( weight_t, weight_t ); static int _root_func( test_suite *, int = 0 ); Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,3 +1,18 @@ +2007-09-04 Petr Ovtchenkov <pt...@is...> + + * logger.h, logger.cc: added trivial_time_logger for performance + measure; added methods tc_pre, tc_post and tc_break for run before + test case, after test case, or after exception within test case; + + * suite.h, suite.cc: add iterations number for each test-case; + this test suite -wide parameter, because mainly intended for + performance measure [statistic] and not useful for problem + detection and tracking; + + * ut/exam_test_suite.cc, ut/dummy_test.cc: test; + + * libexam: version 0.3.0. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * suite.h: remove private keyword for dummy, to make gcc 3.3.6 happy. Modified: trunk/complement/explore/lib/exam/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/Makefile.inc 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/Makefile.inc 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,7 +1,7 @@ -# -*- Makefile -*- Time-stamp: <07/07/21 09:21:58 ptr> +# -*- Makefile -*- Time-stamp: <07/09/04 11:12:48 ptr> LIBNAME = exam MAJOR = 0 -MINOR = 2 +MINOR = 3 PATCH = 0 SRC_CC = logger.cc suite.cc Modified: trunk/complement/explore/lib/exam/logger.cc =================================================================== --- trunk/complement/explore/lib/exam/logger.cc 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/logger.cc 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:09:27 ptr> +// -*- C++ -*- Time-stamp: <07/09/04 10:47:22 ptr> /* * Copyright (c) 2007 @@ -115,4 +115,51 @@ } } +void trivial_time_logger::tc_pre() +{ + tst.push_back( xmt::timespec( xmt::timespec::now ) ); +} + +void trivial_time_logger::tc_post() +{ + tst.back() = xmt::timespec( xmt::timespec::now ) - tst.back(); +} + +void trivial_time_logger::tc_break() +{ + tst.pop_back(); +} + +void trivial_time_logger::tc( base_logger::tc_result r, const std::string& name ) +{ + if ( r == pass ) { + // here tst.size() > 0, if test case not throw excepion + time_container_t::const_iterator a = tst.begin(); + if ( a != tst.end() ) { + unsigned n = 1; + double sum(*a); + double sum_sq = sum * sum; + ++a; + for ( ; a != tst.end(); ++a ) { + double v(*a); + sum += v; + sum_sq += v * v; + // mean = ((n + 1) * mean + static_cast<double>(*a)) / (n + 2); + ++n; + } + sum_sq -= sum * sum / n; + sum_sq = max( 0.0, sum_sq ); // clear epsilon (round error) + sum_sq /= n * n; // dispersion + sum /= n; // mean + if ( s != 0 ) { + *s << " " << sum << " " << sum_sq << " " << name << endl; + } else { + fprintf( f, " %f %f %s\n", sum, sum_sq, name.c_str() ); + } + } + } + tst.clear(); + trivial_logger::tc( r, name ); +} + } //namespace exam Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/suite.cc 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:09:43 ptr> +// -*- C++ -*- Time-stamp: <07/09/04 11:10:58 ptr> /* * Copyright (c) 2007 @@ -29,11 +29,12 @@ return -1; } -test_suite::test_suite( const string& name ) : +test_suite::test_suite( const string& name, unsigned n ) : _count(0), _last_state( 0 ), _suite_name( name ), - local_logger( logger ) + local_logger( logger ), + _iterations( n ) { _vertices.push_back( std::make_pair( 0, 0 ) ); _test[0].tc = detail::make_test_case( detail::call( _root_func ) ); @@ -43,11 +44,12 @@ _stack.push( this ); } -test_suite::test_suite( const char *name ) : +test_suite::test_suite( const char *name, unsigned n ) : _count(0), _last_state( 0 ), _suite_name( name ), - local_logger( logger ) + local_logger( logger ), + _iterations( n ) { _vertices.push_back( std::make_pair( 0, 0 ) ); _test[0].tc = detail::make_test_case( detail::call( _root_func ) ); @@ -97,7 +99,7 @@ _test[j->second].state = skip; } } - run_test_case( i->first ); + run_test_case( i->first, _iterations ); } local_logger->end_ts(); @@ -203,12 +205,22 @@ _stack.top()->report( file, line, cnd, expr ); } -void test_suite::run_test_case( test_suite::vertex_t v ) +void test_suite::run_test_case( test_suite::vertex_t v, unsigned n ) { try { ++_stat.total; if ( _test[v].state == 0 ) { - if ( (*_test[v].tc)( this, 0 ) == 0 ) { + int res = 0; + while ( (res == 0) && (n-- > 0) ) { + _lock_ll.lock(); + local_logger->tc_pre(); + _lock_ll.unlock(); + res = (*_test[v].tc)( this, 0 ); + _lock_ll.lock(); + local_logger->tc_post(); + _lock_ll.unlock(); + } + if ( res == 0 ) { if ( _last_state == 0 ) { ++_stat.passed; scoped_lock lk( _lock_ll ); @@ -234,12 +246,16 @@ } } catch ( init_exception& ) { + _lock_ll.lock(); + local_logger->tc_break(); + _lock_ll.unlock(); --_stat.total; } catch ( ... ) { ++_stat.failed; _test[v].state = fail; scoped_lock lk( _lock_ll ); + local_logger->tc_break(); local_logger->tc( base_logger::fail, _test[v].name ); } } Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 22:53:39 ptr> +# -*- Makefile -*- Time-stamp: <07/09/03 22:27:45 ptr> SRCROOT := ../../.. @@ -9,23 +9,24 @@ DEFS += -D__FIT_EXAM LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +LIBXMT_DIR = ${CoMT_DIR}/lib/mt LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif -release-shared : LDLIBS = -lexam -dbg-shared : LDLIBS = -lexamg +release-shared : LDLIBS = -lexam -lxmt +dbg-shared : LDLIBS = -lexamg -lxmtg ifndef WITHOUT_STLPORT -stldbg-shared : LDLIBS = -lexamstlg +stldbg-shared : LDLIBS = -lexamstlg -lxmtstlg endif Modified: trunk/complement/explore/lib/exam/ut/dummy_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:10:32 ptr> +// -*- C++ -*- Time-stamp: <07/09/03 22:22:09 ptr> /* * Copyright (c) 2007 @@ -57,3 +57,14 @@ return EXAM_RESULT; } + +int EXAM_IMPL(loop) +{ + int j = 0; + for ( int i = 0; i < 100000; ++i ) { + j += 2; + } + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:10:55 ptr> +// -*- C++ -*- Time-stamp: <07/09/04 11:11:41 ptr> /* * Copyright (c) 2007 @@ -8,6 +8,7 @@ */ #include "exam_test_suite.h" +#include <iostream> #include "dummy_test.cc" @@ -243,6 +244,40 @@ return EXAM_RESULT; } +int EXAM_IMPL(exam_basic_test::perf) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, time profile", 20 ); + t.set_logger( &tlogger ); + + t.add( loop, "timer" ); + + t.girdle(); + + double mean = -1.0; + double disp = -1.0; + std::string nm; + + buff >> mean >> disp; // >> nm; + + EXAM_CHECK( mean >= 0.0 ); + EXAM_CHECK( disp >= 0.0 ); + + std::getline( buff, nm ); + + EXAM_CHECK( nm == " timer" ); + + std::getline( buff, nm ); + + EXAM_CHECK( nm == "*** PASS exam self test, time profile (+1-0~0/1) ***" ); + + // std::cerr << buff.str() << std::endl; + + return EXAM_RESULT; +} + const std::string exam_basic_test::r0 = "\ *** PASS exam self test, good function (+2-0~0/2) ***\n"; @@ -325,5 +360,7 @@ exam::test_suite::test_case_type d2 = t.add( &exam_basic_test::multiple_dep, exam_basic, "multiple dependencies", d ); t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); + t.add( &exam_basic_test::perf, exam_basic, "performance timer test", d0 ); + return t.girdle(); } Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.h =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-09-03 14:02:41 UTC (rev 1720) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-09-04 07:29:28 UTC (rev 1721) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/01 09:11:13 ptr> +// -*- C++ -*- Time-stamp: <07/09/03 22:21:36 ptr> /* * Copyright (c) 2007 @@ -16,34 +16,38 @@ class exam_basic_test { - public: - exam_basic_test() : - buff(), - logger( buff ) - { } + public: + exam_basic_test() : + buff(), + logger( buff ), + tlogger( buff ) + { } - int EXAM_DECL(function_good); - int EXAM_DECL(function); - int EXAM_DECL(dep); - int EXAM_DECL(trace); - int EXAM_DECL(dep_test_suite); - int EXAM_DECL(multiple_dep); - int EXAM_DECL(multiple_dep_complex); + int EXAM_DECL(function_good); + int EXAM_DECL(function); + int EXAM_DECL(dep); + int EXAM_DECL(trace); + int EXAM_DECL(dep_test_suite); + int EXAM_DECL(multiple_dep); + int EXAM_DECL(multiple_dep_complex); + int EXAM_DECL(perf); private: - std::stringstream buff; - exam::trivial_logger logger; + std::stringstream buff; + exam::trivial_logger logger; + exam::trivial_time_logger tlogger; + - static const std::string r0; - static const std::string r1; - static const std::string r2; - static const std::string r3; - static const std::string r4; - static const std::string r5; - static const std::string r6; - static const std::string r7; - static const std::string r8; - static const std::string r9; + static const std::string r0; + static const std::string r1; + static const std::string r2; + static const std::string r3; + static const std::string r4; + static const std::string r5; + static const std::string r6; + static const std::string r7; + static const std::string r8; + static const std::string r9; }; int EXAM_DECL(exam_self_test); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-03 14:02:44
|
Revision: 1720 http://complement.svn.sourceforge.net/complement/?rev=1720&view=rev Author: complement Date: 2007-09-03 07:02:41 -0700 (Mon, 03 Sep 2007) Log Message: ----------- fix line numbers, due to copyright notes in dummy_test.cc Modified Paths: -------------- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-09-01 05:46:34 UTC (rev 1719) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-09-03 14:02:41 UTC (rev 1720) @@ -48,12 +48,15 @@ t.girdle(); - EXAM_REQUIRE( buff.str() == r1 ); - // std::cerr << "%%%\n"; // std::cerr << buff.str() << std::endl; // std::cerr << "%%%\n"; + // std::cerr << "^^^\n"; + // std::cerr << r1 << std::endl; + // std::cerr << "^^^\n"; + EXAM_REQUIRE( buff.str() == r1 ); + return EXAM_RESULT; } @@ -244,21 +247,21 @@ *** PASS exam self test, good function (+2-0~0/2) ***\n"; const std::string exam_basic_test::r1 = "\ -dummy_test.cc:5: fail: false\n\ +dummy_test.cc:14: fail: false\n\ FAIL function\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function\n\ *** FAIL exam self test, fail function (+0-2~0/2) ***\n"; const std::string exam_basic_test::r2 = "\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ SKIP function fail\n\ *** FAIL exam self test, fail function (+2-1~1/4) ***\n"; const std::string exam_basic_test::r3 = "\ == Begin test suite\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ SKIP function fail\n\ == End test suite\n\ @@ -268,18 +271,18 @@ *** FAIL exam self test, fail function (+2-1~1/4) ***\n"; const std::string exam_basic_test::r5 = "\ -dummy_test.cc:24: pass: true\n\ -dummy_test.cc:25: pass: true\n\ -dummy_test.cc:16: fail: false\n\ -dummy_test.cc:17: pass: true\n\ +dummy_test.cc:33: pass: true\n\ +dummy_test.cc:34: pass: true\n\ +dummy_test.cc:25: fail: false\n\ +dummy_test.cc:26: pass: true\n\ FAIL member function fail\n\ -dummy_test.cc:33: pass: true\n\ +dummy_test.cc:42: pass: true\n\ SKIP function fail\n\ *** FAIL exam self test, fail function (+2-1~1/4) ***\n"; const std::string exam_basic_test::r6 = "\ PASS member function good\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ PASS function good\n\ SKIP function fail\n\ @@ -287,7 +290,7 @@ const std::string exam_basic_test::r7 = "\ *** PASS exam self test, test suite master (+2-0~0/2) ***\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ SKIP function fail\n\ *** FAIL exam self test, test suite slave (+2-1~1/4) ***\n\ @@ -295,16 +298,16 @@ *** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; const std::string exam_basic_test::r8 = "\ -dummy_test.cc:5: fail: false\n\ +dummy_test.cc:14: fail: false\n\ FAIL function fail\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ *** FAIL exam self test, fail function (+3-2~0/5) ***\n"; const std::string exam_basic_test::r9 = "\ -dummy_test.cc:5: fail: false\n\ +dummy_test.cc:14: fail: false\n\ FAIL function fail\n\ -dummy_test.cc:16: fail: false\n\ +dummy_test.cc:25: fail: false\n\ FAIL member function fail\n\ SKIP function 3 good\n\ *** FAIL exam self test, fail function (+3-2~1/6) ***\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-01 05:46:37
|
Revision: 1719 http://complement.svn.sourceforge.net/complement/?rev=1719&view=rev Author: complement Date: 2007-08-31 22:46:34 -0700 (Fri, 31 Aug 2007) Log Message: ----------- add search by sockaddr_in in connections container; this useful for non-streamed connections, like UDP Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-09-01 05:45:11 UTC (rev 1718) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-09-01 05:46:34 UTC (rev 1719) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 20:57:31 ptr> +// -*- C++ -*- Time-stamp: <07/08/31 09:55:36 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -239,8 +239,8 @@ ~_Connect() { if ( _proc ) { s.close(); _proc->close(); } delete _proc; } - void open( sock_base::socket_type st, const sockaddr& addr ) - { s.open( st, addr ); _proc = new Connect( s ); } + 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 ); } sockstream s; Connect *_proc; @@ -262,6 +262,13 @@ { return __x.s.rdbuf()->fd() == __y; } }; + struct iaddr_equal : + public std::binary_function<_Connect,sockaddr,bool> + { + bool operator()(const _Connect& __x, const sockaddr& __y) const + { return memcmp( &(__x.s.rdbuf()->inet_sockaddr()), reinterpret_cast<const sockaddr_in *>(&__y), sizeof(sockaddr_in) ) == 0; } + }; + struct pfd_equal : public std::binary_function<typename _fd_sequence::value_type,int,bool> { @@ -287,6 +294,7 @@ protected: typedef sockmgr_stream_MP<Connect> _Self_type; typedef fd_equal _Compare; + typedef iaddr_equal _Compare_inet; typedef typename _Sequence::value_type value_type; typedef typename _Sequence::size_type size_type; typedef _Sequence container_type; @@ -296,6 +304,7 @@ _Sequence _M_c; _Compare _M_comp; + _Compare_inet _M_comp_inet; pfd_equal _pfdcomp; xmt::mutex _c_lock; Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-01 05:45:11 UTC (rev 1718) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-01 05:46:34 UTC (rev 1719) @@ -6,6 +6,9 @@ * sockstream.cc: clean; replace sleep by yield in recvfrom, but function not really in use now; + * sockmgr.h: add search by sockaddr_in in connections container; + this useful for non-streamed connections, like UDP. + 2007-08-23 Petr Ovtchenkov <pt...@is...> * sockmgr.h: explicitly inhibit copy of basic_sockmgr and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-01 05:45:14
|
Revision: 1718 http://complement.svn.sourceforge.net/complement/?rev=1718&view=rev Author: complement Date: 2007-08-31 22:45:11 -0700 (Fri, 31 Aug 2007) Log Message: ----------- add inet_sockaddr() method, that return sockaddr_in in whole; replace sleep by yield in recvfrom, but function not really in use now Modified Paths: -------------- trunk/complement/explore/include/sockios/sockstream trunk/complement/explore/include/sockios/sockstream.cc trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockstream =================================================================== --- trunk/complement/explore/include/sockios/sockstream 2007-09-01 05:33:23 UTC (rev 1717) +++ trunk/complement/explore/include/sockios/sockstream 2007-09-01 05:45:11 UTC (rev 1718) @@ -1,22 +1,14 @@ -// -*- C++ -*- Time-stamp: <06/07/11 12:28:37 ptr> +// -*- C++ -*- Time-stamp: <07/08/31 09:49:58 ptr> /* - * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Portion Copyright (c) 1999-2001 * Parallel Graphics Ltd. * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __SOCKSTREAM__ @@ -494,6 +486,14 @@ { return /* is_open() && */ _address.any.sa_family == AF_INET ? _address.inet.sin_addr.s_addr : 0; } + const sockaddr_in& inet_sockaddr() const throw( std::domain_error ) + { + if ( _address.any.sa_family != AF_INET ) { + throw domain_error( "socket not belongs to inet type" ); + } + return /* is_open() && */ _address.inet; + } + sock_base::stype stype() const { return _type; } @@ -613,7 +613,6 @@ private: typedef basic_sockbuf<charT,traits,_Alloc> _Self_type; - // int __rdsync(); int (basic_sockbuf<charT,traits,_Alloc>::*_xwrite)( const void *, size_t ); int (basic_sockbuf<charT,traits,_Alloc>::*_xread)( void *, size_t ); int write( const void *buf, size_t n ) @@ -651,7 +650,7 @@ void __hostname(); sock_base::socket_type _fd; - union { + union sockaddr_t { sockaddr_in inet; sockaddr any; } _address; @@ -660,9 +659,6 @@ int _errno; sock_base::stype _type; // bool _doclose; - // if open, and connected, other side hostname, - // otherwise undefined: - // string _hostname; }; template <class charT, class traits, class _Alloc> Modified: trunk/complement/explore/include/sockios/sockstream.cc =================================================================== --- trunk/complement/explore/include/sockios/sockstream.cc 2007-09-01 05:33:23 UTC (rev 1717) +++ trunk/complement/explore/include/sockios/sockstream.cc 2007-09-01 05:45:11 UTC (rev 1718) @@ -1,22 +1,14 @@ // -*- C++ -*- Time-stamp: <06/08/21 23:58:48 ptr> /* - * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Portion Copyright (c) 1999-2001 * Parallel Graphics Ltd. * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifdef __unix @@ -106,7 +98,7 @@ throw std::invalid_argument( "protocol not implemented" ); } if ( _bbuf == 0 ) - _M_allocate_block( 0xb00 ); // max 1460 (dec) [0x5b4] --- single segment + _M_allocate_block( type == sock_base::sock_stream ? 0xb00 : 0xffff ); // max 1460 (dec) [0x5b4] --- single segment if ( _bbuf == 0 ) { throw std::length_error( "can't allocate block" ); } @@ -114,21 +106,7 @@ setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); - // _STLP_ASSERT( this->pbase() != 0 ); - // _STLP_ASSERT( this->pptr() != 0 ); - // _STLP_ASSERT( this->epptr() != 0 ); - // _STLP_ASSERT( this->eback() != 0 ); - // _STLP_ASSERT( this->gptr() != 0 ); - // _STLP_ASSERT( this->egptr() != 0 ); - // _STLP_ASSERT( _bbuf != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); - _errno = 0; // if any - // __hostname(); - -// in_port_t ppp = 0x5000; -// cerr << hex << _address.inet.sin_port << " " << ppp << endl; -// cerr << hex << _address.inet.sin_addr.s_addr << endl; } catch ( std::domain_error& ) { #ifdef WIN32 @@ -234,7 +212,7 @@ throw std::invalid_argument( "protocol not implemented" ); } if ( _bbuf == 0 ) - _M_allocate_block( 0xb00 ); // max 1460 (dec) [0x5b4] --- single segment + _M_allocate_block( type == sock_base::sock_stream ? 0xb00 : 0xffff ); // max 1460 (dec) [0x5b4] --- single segment if ( _bbuf == 0 ) { throw std::length_error( "can't allocate block" ); } @@ -242,21 +220,7 @@ setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); - // _STLP_ASSERT( this->pbase() != 0 ); - // _STLP_ASSERT( this->pptr() != 0 ); - // _STLP_ASSERT( this->epptr() != 0 ); - // _STLP_ASSERT( this->eback() != 0 ); - // _STLP_ASSERT( this->gptr() != 0 ); - // _STLP_ASSERT( this->egptr() != 0 ); - // _STLP_ASSERT( _bbuf != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); - _errno = 0; // if any - // __hostname(); - -// in_port_t ppp = 0x5000; -// cerr << hex << _address.inet.sin_port << " " << ppp << endl; -// cerr << hex << _address.inet.sin_addr.s_addr << endl; } catch ( std::domain_error& ) { #ifdef WIN32 @@ -357,7 +321,7 @@ } if ( _bbuf == 0 ) { - _M_allocate_block( 0xb00 ); + _M_allocate_block( t == sock_base::sock_stream ? 0xb00 : 0xffff ); } if ( _bbuf == 0 ) { @@ -373,28 +337,8 @@ setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); setg( this->epptr(), this->epptr(), this->epptr() ); - // _STLP_ASSERT( this->pbase() != 0 ); - // _STLP_ASSERT( this->pptr() != 0 ); - // _STLP_ASSERT( this->epptr() != 0 ); - // _STLP_ASSERT( this->eback() != 0 ); - // _STLP_ASSERT( this->gptr() != 0 ); - // _STLP_ASSERT( this->egptr() != 0 ); - // _STLP_ASSERT( _bbuf != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); - _errno = 0; // if any - // __hostname(); -// in_port_t ppp = 0x5000; -// cerr << hex << _address.inet.sin_port << " " << ppp << endl; -// cerr << hex << _address.inet.sin_addr.s_addr << endl; -// sockaddr_in xxx; -// int len = sizeof( xxx ); - -// getpeername( fd(), (sockaddr *)&xxx, &len ); -// cerr << hex << xxx.sin_port << endl; -// cerr << hex << xxx.sin_addr.s_addr << endl; - return this; } @@ -546,16 +490,6 @@ long count = this->pptr() - this->pbase(); if ( count ) { - // _STLP_ASSERT( this->pbase() != 0 ); - - // Never do this: read and and write in basic_sockbuf are independent, - // so reading here lead to lost message if reading and writing occur - // simultaneously from different threads - -// if ( __rdsync() != 0 ) { // I should read something, if other side write -// return traits::eof(); // otherwise I can't write without pipe broken -// } - if ( (this->*_xwrite)( this->pbase(), sizeof(charT) * count ) != count * sizeof(charT) ) return traits::eof(); } @@ -576,12 +510,6 @@ return 0; } - // _STLP_ASSERT( this->pbase() != 0 ); - // _STLP_ASSERT( this->pptr() != 0 ); - // _STLP_ASSERT( this->epptr() != 0 ); - // _STLP_ASSERT( _bbuf != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); - if ( this->epptr() - this->pptr() > n ) { traits::copy( this->pptr(), s, n ); this->pbump( n ); @@ -605,52 +533,7 @@ return n; } -#if 0 // No needs: the sockets are essential bi-direction entities template<class charT, class traits, class _Alloc> -int basic_sockbuf<charT, traits, _Alloc>::__rdsync() -{ -#ifdef WIN32 - unsigned long nlen = 0; - int nmsg = ioctlsocket( fd(), FIONREAD, &nlen ); -#else - long nlen = 0; - int nmsg = ioctl( fd(), I_NREAD, &nlen ); // shouldn't work, as I understand... -#endif - if ( nmsg > 0 && nlen > 0 ) { - // _STLP_ASSERT( _bbuf != 0 ); - // _STLP_ASSERT( _ebuf != 0 ); - // _STLP_ASSERT( this->gptr() != 0 ); - // _STLP_ASSERT( this->egptr() != 0 ); - - bool shift_req = this->gptr() == this->eback() ? false : (_ebuf - this->gptr()) > nlen ? false : true; - if ( shift_req ) { - // _STLP_ASSERT( this->gptr() > this->eback() ); - // _STLP_ASSERT( this->gptr() <= this->egptr() ); - traits::move( this->eback(), this->gptr(), this->egptr() - this->gptr() ); - setg( this->eback(), this->eback(), this->eback() + (this->egptr() - this->gptr()) ); - } - if ( this->gptr() == _ebuf ) { // I should read something, if other side write - return -1; // otherwise I can't write without pipe broken - } - long offset = (this->*_xread)( this->egptr(), sizeof(char_type) * (_ebuf - this->egptr()) ); - if ( offset < 0 ) // allow message of zero length - return -1; - offset /= sizeof(charT); - setg( this->eback(), this->gptr(), this->egptr() + offset ); - } - - return 0; -} -#endif // 0 - -#if defined(__HP_aCC) && (__HP_aCC == 1) - union basic_sockbuf_sockaddr { - sockaddr_in inet; - sockaddr any; - }; -#endif - -template<class charT, class traits, class _Alloc> int basic_sockbuf<charT, traits, _Alloc>::recvfrom( void *buf, size_t n ) { #if defined(_WIN32) || (defined(__hpux) && !defined(_INCLUDE_POSIX1C_SOURCE)) @@ -659,20 +542,9 @@ socklen_t sz = sizeof( sockaddr_in ); #endif -#if defined(__HP_aCC) && (__HP_aCC == 1) - basic_sockbuf_sockaddr addr; -#else - union { - sockaddr_in inet; - sockaddr any; - } addr; -#endif -#ifdef __FIT_POLL - timespec t; + sockaddr_t addr; - t.tv_sec = 0; - t.tv_nsec = 10000; - +#ifdef __FIT_POLL pollfd pfd; pfd.fd = _fd; pfd.events = POLLIN; @@ -704,23 +576,14 @@ return 0; // poll wait infinite, so it can't return 0 (timeout), so it return -1. } #endif // __FIT_POLL - if ( port() == addr.inet.sin_port && inet_addr() == addr.inet.sin_addr.s_addr ) { -// if ( memcmp( (void *)&_address.any, (const void *)&addr, sizeof(sockaddr) ) == 0 ) { + if ( memcmp( &_address.inet, &addr.inet, sizeof(sockaddr_in) ) == 0 ) { #ifdef WIN32 return ::recvfrom( _fd, (char *)buf, n, 0, &_address.any, &sz ); #else return ::recvfrom( _fd, buf, n, 0, &_address.any, &sz ); #endif } -#ifdef __unix -// cerr << "Sleeping in sockstream: " -// << port() << "/" << addr.inet.sin_port << ", " -// << inet_addr() << "/" << addr.inet.sin_addr.s_addr << endl; - nanosleep( &t, 0 ); -#endif -#ifdef WIN32 - Sleep( t ); -#endif + xmt::Thread::yield(); } while ( true ); return 0; // never Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-09-01 05:33:23 UTC (rev 1717) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-09-01 05:45:11 UTC (rev 1718) @@ -1,3 +1,11 @@ +2007-09-01 Petr Ovtchenkov <pt...@is...> + + * sockstream: clean; add inet_sockaddr() method, that return + sockaddr_in in whole; + + * sockstream.cc: clean; replace sleep by yield in recvfrom, + but function not really in use now; + 2007-08-23 Petr Ovtchenkov <pt...@is...> * sockmgr.h: explicitly inhibit copy of basic_sockmgr and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-09-01 05:33:26
|
Revision: 1717 http://complement.svn.sourceforge.net/complement/?rev=1717&view=rev Author: complement Date: 2007-08-31 22:33:23 -0700 (Fri, 31 Aug 2007) Log Message: ----------- copyright info added Modified Paths: -------------- trunk/complement/explore/include/exam/logger.h trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/logger.cc trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/dummy_test.cc trunk/complement/explore/lib/exam/ut/exam_self_test.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.h Modified: trunk/complement/explore/include/exam/logger.h =================================================================== --- trunk/complement/explore/include/exam/logger.h 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/include/exam/logger.h 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/13 11:01:52 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:08:25 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #ifndef __logger_h #define __logger_h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/include/exam/suite.h 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/21 09:06:00 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:07:43 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #ifndef __suite_h #define __suite_h Modified: trunk/complement/explore/lib/exam/logger.cc =================================================================== --- trunk/complement/explore/lib/exam/logger.cc 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/logger.cc 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/13 10:53:32 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:09:27 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #include <exam/logger.h> #include <iostream> Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/suite.cc 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/21 09:13:17 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:09:43 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #include <exam/suite.h> #include <stack> Modified: trunk/complement/explore/lib/exam/ut/dummy_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,3 +1,12 @@ +// -*- C++ -*- Time-stamp: <07/09/01 09:10:32 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #include <exam/suite.h> int EXAM_IMPL(func) Modified: trunk/complement/explore/lib/exam/ut/exam_self_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:10:26 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #include "exam_test_suite.h" int main( int, char ** ) Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/21 09:01:26 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:10:55 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #include "exam_test_suite.h" #include "dummy_test.cc" Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.h =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-08-30 15:44:47 UTC (rev 1716) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-09-01 05:33:23 UTC (rev 1717) @@ -1,5 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/16 23:40:09 ptr> +// -*- C++ -*- Time-stamp: <07/09/01 09:11:13 ptr> +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + */ + #ifndef __exam_test_suite_h #define __exam_test_suite_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 15:44:49
|
Revision: 1716 http://complement.svn.sourceforge.net/complement/?rev=1716&view=rev Author: complement Date: 2007-08-30 08:44:47 -0700 (Thu, 30 Aug 2007) Log Message: ----------- fix environment variables traits; add env vars description to help message Modified Paths: -------------- trunk/complement/explore/configure Modified: trunk/complement/explore/configure =================================================================== --- trunk/complement/explore/configure 2007-08-30 14:35:47 UTC (rev 1715) +++ trunk/complement/explore/configure 2007-08-30 15:44:47 UTC (rev 1716) @@ -59,6 +59,14 @@ --enable-static build static --disable-shared don't build shared +Environment variables: + + \$CXX C++ compiler name (use --target= for cross-compilation) + \$CC C compiler name (use --target= for cross-compilation) + \$CXXFLAGS pass extra options to C++ compiler + + Options has preference over environment variables. + EOF } @@ -195,13 +203,12 @@ done if [ "$CXX" != "" ]; then - if [ "$target_set" != "" ]; then - echo "For cross-compilation with gcc use --target option only" - else - write_option "$CXX" _FORCE_CXX - fi if [ "$cxx_set" != "" ]; then echo "Both --with-cxx and \$CXX set, using the first" + elif [ "$target_set" = "" ]; then + write_option "$CXX" _FORCE_CXX + else + echo "For cross-compilation with gcc use --target option only" fi if [ "$CC" = "" ] && [ "$cc_set" = "" ]; then echo "\$CXX set, but I don't see \$CC!" @@ -211,6 +218,8 @@ if [ "$CC" != "" ]; then if [ "$cxx_set" != "" ]; then echo "Both --with-cc and \$CC set, using the first" + else + write_option "$CC" _FORCE_CC fi fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 14:35:49
|
Revision: 1715 http://complement.svn.sourceforge.net/complement/?rev=1715&view=rev Author: complement Date: 2007-08-30 07:35:47 -0700 (Thu, 30 Aug 2007) Log Message: ----------- $(AUX_DIR) for things like archive repack Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/lib/clean.mak trunk/complement/explore/Makefiles/gmake/targetdirs.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2007-08-30 14:34:12 UTC (rev 1714) +++ trunk/complement/explore/Makefiles/ChangeLog 2007-08-30 14:35:47 UTC (rev 1715) @@ -1,3 +1,13 @@ +2007-08-30 Petr Ovtchenkov <pt...@is...> + + * gmake/sysid.mak, gmake/app/gcc.mak, gmake/lib/gcc.mak: + MacOS X 10.4 with gcc; + + * gmake/gcc.mak: use STLport's experience for MinGW; + + * gmake/targetdirs.mak, gmake/lib/clean.mak: $(AUX_DIR) for things + like archive repack; + 2007-08-29 Petr Ovtchenkov <pt...@is...> * gmake/targetdirs.mak: default installation path is /usr/local Modified: trunk/complement/explore/Makefiles/gmake/lib/clean.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/clean.mak 2007-08-30 14:34:12 UTC (rev 1714) +++ trunk/complement/explore/Makefiles/gmake/lib/clean.mak 2007-08-30 14:35:47 UTC (rev 1715) @@ -1,6 +1,6 @@ # -*- makefile -*- Time-stamp: <07/05/30 23:55:47 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -85,7 +85,7 @@ distclean:: @-rm -f $(DEPENDS_COLLECTION) - @-rmdir -p ${OUTPUT_DIR} ${OUTPUT_DIR_DBG} ${OUTPUT_DIR_STLDBG} 2>/dev/null + @-rmdir -p $(AUX_DIR) ${OUTPUT_DIR} ${OUTPUT_DIR_DBG} ${OUTPUT_DIR_STLDBG} 2>/dev/null uninstall:: ifdef LIBNAME Modified: trunk/complement/explore/Makefiles/gmake/targetdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2007-08-30 14:34:12 UTC (rev 1714) +++ trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2007-08-30 14:35:47 UTC (rev 1715) @@ -1,6 +1,6 @@ # Time-stamp: <06/11/03 18:47:05 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -26,6 +26,9 @@ # file to store generated dependencies for make: DEPENDS_COLLECTION := $(PRE_OUTPUT_DIR)/.make.depend +# catalog for auxilary files, if any +AUX_DIR := $(PRE_OUTPUT_DIR)/.auxdir + # I use the same catalog, as for shared: OUTPUT_DIR_A := $(OUTPUT_DIR) OUTPUT_DIR_A_DBG := $(OUTPUT_DIR_DBG) @@ -74,7 +77,7 @@ INSTALL_BIN_DIRS := $(sort $(INSTALL_BIN_DIRS)) INSTALL_DIRS := $(sort $(INSTALL_LIB_DIRS) $(INSTALL_BIN_DIRS)) -PHONY += $(OUTPUT_DIRS) $(INSTALL_DIRS) +PHONY += $(OUTPUT_DIRS) $(INSTALL_DIRS) $(AUX_DIR) define createdirs @for d in $@ ; do \ @@ -93,3 +96,5 @@ $(INSTALL_DIRS): $(createdirs) +$(AUX_DIR): + $(createdirs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 14:34:14
|
Revision: 1714 http://complement.svn.sourceforge.net/complement/?rev=1714&view=rev Author: complement Date: 2007-08-30 07:34:12 -0700 (Thu, 30 Aug 2007) Log Message: ----------- use STLport's experience for MinGW Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/gcc.mak Modified: trunk/complement/explore/Makefiles/gmake/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-08-30 14:33:25 UTC (rev 1713) +++ trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-08-30 14:34:12 UTC (rev 1714) @@ -90,22 +90,15 @@ CFLAGS += $(OPT) CXXFLAGS += $(OPT) COMPILE.rc = $(RC) $(RCFLAGS) - -#Add Windows target. -ifdef STLP_BUILD_WINDOWS_95 -WINVER=0x0400 -else -WINVER=0x0410 +release-static : DEFS += -D_STLP_USE_STATIC_LIB +dbg-static : DEFS += -D_STLP_USE_STATIC_LIB +stldbg-static : DEFS += -D_STLP_USE_STATIC_LIB +ifeq ($(OSREALNAME), mingw) +dbg-shared : DEFS += -D_DEBUG +stldbg-shared : DEFS += -D_DEBUG +dbg-static : DEFS += -D_DEBUG +stldbg-static : DEFS += -D_DEBUG endif - -release-static : DEFS += -D_STLP_USE_STATIC_LIB -DWINVER=$(WINVER) -dbg-static : DEFS += -D_DEBUG -D_STLP_USE_STATIC_LIB -DWINVER=$(WINVER) -stldbg-static : DEFS += -D_DEBUG -D_STLP_USE_STATIC_LIB -DWINVER=$(WINVER) - -release-shared: DEFS += -DWINVER=$(WINVER) -dbg-shared : DEFS += -D_DEBUG -DWINVER=$(WINVER) -stldbg-shared : DEFS += -D_DEBUG -DWINVER=$(WINVER) - endif ifeq ($(OSNAME),sunos) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 14:33:37
|
Revision: 1713 http://complement.svn.sourceforge.net/complement/?rev=1713&view=rev Author: complement Date: 2007-08-30 07:33:25 -0700 (Thu, 30 Aug 2007) Log Message: ----------- update date Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak Modified: trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak 2007-08-30 14:32:49 UTC (rev 1712) +++ trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak 2007-08-30 14:33:25 UTC (rev 1713) @@ -1,6 +1,6 @@ # -*- makefile -*- Time-stamp: <07/02/07 14:58:53 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 14:32:59
|
Revision: 1712 http://complement.svn.sourceforge.net/complement/?rev=1712&view=rev Author: complement Date: 2007-08-30 07:32:49 -0700 (Thu, 30 Aug 2007) Log Message: ----------- MacOS X 10.4 with gcc Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/app/gcc.mak trunk/complement/explore/Makefiles/gmake/lib/gcc.mak trunk/complement/explore/Makefiles/gmake/sysid.mak Modified: trunk/complement/explore/Makefiles/gmake/app/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2007-08-30 14:20:07 UTC (rev 1711) +++ trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2007-08-30 14:32:49 UTC (rev 1712) @@ -96,9 +96,25 @@ else # otherwise, exceptions support is in libgcc_s.so _LGCC_EH := +ifneq ($(OSNAME),darwin) _LGCC_S := -lgcc_s +else +ifdef GCC_APPLE_CC +ifeq ($(MACOSX_TEN_FIVE),true) +_LGCC_S := -lgcc_s.10.5 +else +_LGCC_S := -lgcc_s.10.4 endif +else +_LGCC_S := -lgcc_s +# end of GCC_APPLE_CC endif +# end of Darwin +endif +# end of !USE_STATIC_LIBGCC +endif +# end of present libgcc_eh.a +endif # ifeq ($(CXX_VERSION_MAJOR),3) ifeq ($(OSNAME),linux) @@ -129,9 +145,28 @@ STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),darwin) -START_OBJ := -lcrt1.o -lcrt2.o +# sometimes crt3.o will required: it has __cxa_at_exit, but the same defined in libc.dyn +# at least in Mac OS X 10.4.10 (8R2218) +ifeq ($(CXX_VERSION_MAJOR),3) +# i.e. gcc 3.3 +START_OBJ := $(shell for o in crt1.o crt2.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +else +ifndef USE_STATIC_LIBGCC +# MacOS X, shared-libgcc +ifeq ($(MACOSX_TEN_FIVE),true) +# MacOS X >= 10.5 +START_OBJ := -lcrt1.o +else +# MacOS X < 10.5 +START_OBJ := -lcrt1.o +endif +else +# MacOS X, not shared-libgcc +START_OBJ := -lcrt1.o +endif +endif END_OBJ := -STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lc -lm -lsupc++ +STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm -lsupc++ ${_LGCC_EH} #LDFLAGS += -dynamic endif LDFLAGS += -nostdlib Modified: trunk/complement/explore/Makefiles/gmake/lib/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-30 14:20:07 UTC (rev 1711) +++ trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-30 14:32:49 UTC (rev 1712) @@ -106,10 +106,34 @@ else # otherwise, exceptions support is in libgcc_s.so _LGCC_EH := +ifneq ($(OSNAME),darwin) _LGCC_S := -lgcc_s +else +ifeq ($(MACOSX_TEN_FIVE),true) +_LGCC_S := -lgcc_s.10.5 +else +_LGCC_S := -lgcc_s.10.4 endif +# end of Darwin endif +# end of !USE_STATIC_LIBGCC +endif +# end of present libgcc_eh.a +endif +_LSUPCPP := $(shell ${CXX} ${CXXFLAGS} -print-file-name=libsupc++.a) +ifeq (${OSNAME},darwin) +ifdef GCC_APPLE_CC +_LSUPCPP := $(shell lipo ${_LSUPCPP} -thin ${M_ARCH} -output $(PRE_OUTPUT_DIR)/libsupc++.a && echo $(PRE_OUTPUT_DIR)/libsupc++.a) +endif +endif +ifneq (${_LSUPCPP},libsupc++.a) +_LSUPCPP_OBJ := $(shell $(AR) t ${_LSUPCPP}) +_LSUPCPP_AUX_OBJ := $(addprefix $(AUX_DIR)/,${_LSUPCPP_OBJ}) +_LSUPCPP_TSMP := .supc++ +_LSUPCPP_AUX_TSMP:= $(AUX_DIR)/$(_LSUPCPP_TSMP) +endif + # ifeq ($(CXX_VERSION_MAJOR),3) # Include whole language support archive (libsupc++.a) into libstlport: # all C++ issues are in libstlport now. @@ -142,10 +166,22 @@ STDLIBS := ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm -lrt endif ifeq ($(OSNAME),darwin) +ifndef USE_STATIC_LIBGCC +# MacOS X, shared-libgcc +ifeq ($(MACOSX_TEN_FIVE),true) +# MacOS X >= 10.5 START_OBJ := +else +# MacOS X < 10.5 +START_OBJ := +endif +else +# MacOS X, not shared-libgcc +START_OBJ := +endif END_OBJ := ifdef GCC_APPLE_CC -STDLIBS := ${STLPORT_LIB} -lgcc -lc -lm +STDLIBS := ${STLPORT_LIB} ${_LGCC_S} -lc -lm else LDFLAGS += -single_module STDLIBS := ${STLPORT_LIB} ${_LGCC_S} -lc -lm Modified: trunk/complement/explore/Makefiles/gmake/sysid.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/sysid.mak 2007-08-30 14:20:07 UTC (rev 1711) +++ trunk/complement/explore/Makefiles/gmake/sysid.mak 2007-08-30 14:32:49 UTC (rev 1712) @@ -14,6 +14,10 @@ ifndef TARGET_OS OSNAME := $(shell uname -s | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',-') +ifeq ($(OSNAME),darwin) +OSREALNAME := $(shell sw_vers -productName | tr '[A-Z]' '[a-z]' | tr -d ', /\\()"') +endif + # RedHat use nonstandard options for uname at least in cygwin, # macro should be overwritten: ifeq (cygwin,$(findstring cygwin,$(OSNAME))) @@ -27,6 +31,9 @@ endif OSREL := $(shell uname -r | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',-') +ifeq ($(OSNAME),darwin) +OSREL := $(shell sw_vers -productVersion | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',-') +endif M_ARCH := $(shell uname -m | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',-') ifeq ($(OSNAME),hp-ux) P_ARCH := unknown @@ -51,6 +58,12 @@ OSREL_MINOR := $(shell echo ${OSREL} | tr '.-' ' ' | awk '{print $$2;}') endif +ifeq ($(OSNAME),darwin) +OSREL_MAJOR := $(shell echo ${OSREL} | tr '.-' ' ' | awk '{print $$1;}') +OSREL_MINOR := $(shell echo ${OSREL} | tr '.-' ' ' | awk '{print $$2;}') +MACOSX_TEN_FIVE := $(shell if [ ${OSREL_MAJOR} -lt 10 ]; then echo false; else if [ ${OSREL_MAJOR} -gt 10 ] ; then echo true; else if [ ${OSREL_MINOR} -lt 5 ]; then echo false; else echo true; fi; fi; fi) +endif + # OS_VER := $(shell uname -s | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',_') BUILD_SYSTEM := $(shell echo `uname -n` `uname -s` `uname -r` `uname -v` `uname -m` $$USER) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-30 14:20:09
|
Revision: 1711 http://complement.svn.sourceforge.net/complement/?rev=1711&view=rev Author: complement Date: 2007-08-30 07:20:07 -0700 (Thu, 30 Aug 2007) Log Message: ----------- fix src files Modified Paths: -------------- trunk/complement/explore/Makefiles/ut/app2-mult/Makefile.inc Modified: trunk/complement/explore/Makefiles/ut/app2-mult/Makefile.inc =================================================================== --- trunk/complement/explore/Makefiles/ut/app2-mult/Makefile.inc 2007-08-29 12:15:22 UTC (rev 1710) +++ trunk/complement/explore/Makefiles/ut/app2-mult/Makefile.inc 2007-08-30 14:20:07 UTC (rev 1711) @@ -1,7 +1,5 @@ # -*- makefile -*- Time-stamp: <04/01/12 15:37:40 ptr> PRGNAMES = test2 test3 -#SRC_C = test.c -SRC_CC = test.cc test2_SRC_CC = test2.cc test3_SRC_CC = test3.cc test31.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-29 12:15:27
|
Revision: 1710 http://complement.svn.sourceforge.net/complement/?rev=1710&view=rev Author: complement Date: 2007-08-29 05:15:22 -0700 (Wed, 29 Aug 2007) Log Message: ----------- gmake/targetdirs.mak: default installation path is /usr/local now; BASE_INSTALL_*_DIR now free from TARGET_NAME prefix, TARGET_NAME prefix appear in INSTALL_*_DIR* as prefix for lib, bin, etc.; gmake/linux/sys.mak: add INSTALL_D for directory creation during installation and INSTALL_F for installing plain file, like header; configure: process --prefix --bindir, --libdir, --includedir (paths for installation); configure may run not only from same dir; gmake/unix/rules-install-so.mak: installation of headers, dummy yet. lib/mt/Makefile: experiments with installation of headers. Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/linux/sys.mak trunk/complement/explore/Makefiles/gmake/targetdirs.mak trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak trunk/complement/explore/configure trunk/complement/explore/lib/mt/Makefile Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/Makefiles/ChangeLog 2007-08-29 12:15:22 UTC (rev 1710) @@ -1,3 +1,16 @@ +2007-08-29 Petr Ovtchenkov <pt...@is...> + + * gmake/targetdirs.mak: default installation path is /usr/local + now; BASE_INSTALL_*_DIR now free from TARGET_NAME prefix, + TARGET_NAME prefix appear in INSTALL_*_DIR* as prefix for lib, + bin, etc.; + + * gmake/linux/sys.mak: add INSTALL_D for directory creation during + installation and INSTALL_F for installing plain file, like header; + + * gmake/unix/rules-install-so.mak: installation of headers, + dummy yet. + 2007-08-17 Petr Ovtchenkov <pt...@is...> * gmake/app/gcc.mak, gmake/lib/gcc.mak: use ${CXXFLAGS} when Modified: trunk/complement/explore/Makefiles/gmake/linux/sys.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/linux/sys.mak 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/Makefiles/gmake/linux/sys.mak 2007-08-29 12:15:22 UTC (rev 1710) @@ -1,6 +1,6 @@ # Time-stamp: <06/11/10 23:43:27 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -20,6 +20,8 @@ INSTALL_SO := ${INSTALL} -c -m 0755 ${_INSTALL_STRIP_OPTION} INSTALL_A := ${INSTALL} -c -m 0644 INSTALL_EXE := ${INSTALL} -c -m 0755 +INSTALL_D := ${INSTALL} -d -m 0755 +INSTALL_F := ${INSTALL} -c -p -m 0644 # bash's built-in test is like extern # EXT_TEST := /usr/bin/test Modified: trunk/complement/explore/Makefiles/gmake/targetdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2007-08-29 12:15:22 UTC (rev 1710) @@ -33,21 +33,24 @@ OUTPUT_DIR_A_STLDBG := $(OUTPUT_DIR_STLDBG) endif -BASE_INSTALL_DIR ?= ${SRCROOT}/build/$(TARGET_NAME) +# BASE_INSTALL_DIR ?= ${SRCROOT}/build/$(TARGET_NAME) +BASE_INSTALL_DIR ?= /usr/local BASE_INSTALL_LIB_DIR ?= ${BASE_INSTALL_DIR} BASE_INSTALL_BIN_DIR ?= ${BASE_INSTALL_DIR} +BASE_INSTALL_HDR_DIR ?= ${BASE_INSTALL_DIR} -INSTALL_LIB_DIR ?= ${BASE_INSTALL_LIB_DIR}lib -INSTALL_LIB_DIR_DBG ?= ${BASE_INSTALL_LIB_DIR}lib +INSTALL_LIB_DIR ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib +INSTALL_LIB_DIR_DBG ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib ifndef WITHOUT_STLPORT -INSTALL_LIB_DIR_STLDBG ?= ${BASE_INSTALL_LIB_DIR}lib +INSTALL_LIB_DIR_STLDBG ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib endif -INSTALL_BIN_DIR ?= ${BASE_INSTALL_BIN_DIR}bin +INSTALL_BIN_DIR ?= ${BASE_INSTALL_BIN_DIR}/${TARGET_NAME}bin INSTALL_BIN_DIR_DBG ?= ${INSTALL_BIN_DIR}_g ifndef WITHOUT_STLPORT INSTALL_BIN_DIR_STLDBG ?= ${INSTALL_BIN_DIR}_stlg endif +INSTALL_HDR_DIR ?= ${BASE_INSTALL_DIR}/include ifndef WITHOUT_STLPORT OUTPUT_DIRS := $(OUTPUT_DIR) $(OUTPUT_DIR_DBG) $(OUTPUT_DIR_STLDBG) \ Modified: trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/Makefiles/gmake/unix/rules-install-so.mak 2007-08-29 12:15:22 UTC (rev 1710) @@ -79,7 +79,7 @@ endif -PHONY += install install-strip $(INSTALL_TAGS) $(INSTALL_STRIP_TAGS) +PHONY += install install-strip install-headers $(INSTALL_TAGS) $(INSTALL_STRIP_TAGS) install: $(INSTALL_TAGS) @@ -139,3 +139,34 @@ install-stldbg-shared: stldbg-shared $(INSTALL_LIB_DIR_STLDBG) $(INSTALL_LIB_DIR_STLDBG)/${SO_NAME_STLDBGxxx} ${POST_INSTALL_STLDBG} endif + +define do_install_headers +if [ ! -d $(INSTALL_HDR_DIR) ]; then \ + echo $(INSTALL_D) $(INSTALL_HDR_DIR); \ +fi; \ +for dd in $(HEADERS_BASE); do \ + d=`dirname $$dd`; \ + h=`basename $$dd`; \ + f=`cd $$d; find $$h \( -type d \( -wholename "*/.svn" -o -prune \) \) -print`; \ + for ddd in $$f; do \ + if [ ! -d $(INSTALL_HDR_DIR)/$$ddd ]; then \ + echo $(INSTALL_D) $(INSTALL_HDR_DIR)/$$ddd; \ + fi; \ + done; \ + f=`find $$dd \( -type f \( \! \( -wholename "*/.svn/*" -o -name "*~" -o -name "*.bak" \) \) \) -print`; \ + for ff in $$f; do \ + h=`echo $$ff | sed -e "s|$$d|$(INSTALL_HDR_DIR)|"`; \ + echo $(INSTALL_F) $$ff $$h; \ + done; \ +done; \ +for f in $(HEADERS); do \ + h=`basename $$f`; \ + echo $(INSTALL_F) $$f $(INSTALL_HDR_DIR)/$$h; \ +done +endef + +# _HEADERS_FROM = $(shell for dd in $(HEADERS_BASE); do find $$dd \( -type f \( \! \( -wholename "*/.svn/*" -o -name "*~" -o -name "*.bak" \) \) \) -print ; done ) +# _HEADERS_TO = $(foreach d,$(HEADERS_BASE),$(patsubst $(d)/%,$(BASE_INSTALL_DIR)include/%,$(_HEADERS_FROM))) + +install-headers: + @$(do_install_headers) Modified: trunk/complement/explore/configure =================================================================== --- trunk/complement/explore/configure 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/configure 2007-08-29 12:15:22 UTC (rev 1710) @@ -1,10 +1,10 @@ #!/bin/sh -# Time-stamp: <07/06/08 23:24:03 ptr> +# Time-stamp: <07/08/29 11:36:31 ptr> -configmak=Makefiles/gmake/config.mak +base=`dirname $0` -# rm -f ${configmak} +configmak=$base/Makefiles/gmake/config.mak # echo "# STLPORT_DIR := /export/home/windows/guest/STLlab/STLport" >> ${configmak} # echo "# MSVC_DIR := c:/Program Files/Microsoft Visual Studio/VC98" >> ${configmak} @@ -25,8 +25,15 @@ Available options: + --prefix=<dir> base install path (/usr/local/) + --bindir=<dir> install path for executables (PREFIX/bin) + --libdir=<dir> install path for libraries (PREFIX/lib) + --includedir=<dir> install path for headers (PREFIX/include) + --target=<target> target platform (cross-compiling) + --help print this help message and exit + --with-stlport=<dir> use STLport in catalog <dir> --without-stlport compile without STLport (default) --with-boost=<dir> use boost headers in catalog <dir> @@ -68,6 +75,9 @@ if [ "$compiler_family_set" = "" ]; then write_option gcc COMPILER_NAME fi + # if [ "$prefix_set" = "" ]; then + # write_option "/usr/local" BASE_INSTALL_DIR + # fi } case $# in @@ -168,6 +178,19 @@ esac compiler_family_set=y ;; + --prefix=*) + write_option "$option" BASE_INSTALL_DIR + # prefix_set=y + ;; + --bindir=*) + write_option "$option" INSTALL_BIN_DIR + ;; + --libdir=*) + write_option "$option" INSTALL_LIB_DIR + ;; + --includedir=*) + write_option "$option" INSTALL_HDR_DIR + ;; esac done Modified: trunk/complement/explore/lib/mt/Makefile =================================================================== --- trunk/complement/explore/lib/mt/Makefile 2007-08-29 05:27:04 UTC (rev 1709) +++ trunk/complement/explore/lib/mt/Makefile 2007-08-29 12:15:22 UTC (rev 1710) @@ -6,6 +6,7 @@ include ${SRCROOT}/Makefiles/gmake/top.mak INCLUDES += -I$(SRCROOT)/include +HEADERS_BASE = $(SRCROOT)/include/mt $(SRCROOT)/include/config $(SRCROOT)/include/misc check: all-shared $(MAKE) -C ut all-shared This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-29 05:27:23
|
Revision: 1709 http://complement.svn.sourceforge.net/complement/?rev=1709&view=rev Author: complement Date: 2007-08-28 22:27:04 -0700 (Tue, 28 Aug 2007) Log Message: ----------- autoconf 2.61, fixes Added Paths: ----------- trunk/complement/explore/inquiry/shades/autotools/ChangeLog Property Changed: ---------------- trunk/complement/explore/inquiry/shades/autotools/ Property changes on: trunk/complement/explore/inquiry/shades/autotools ___________________________________________________________________ Name: svn:ignore - configure config.log config.status a.out autom4te.cache cxxtest.gcc Makefile Makefile.in depcomp ChangeLog stamp-h1 config.guess config.h ltmain.sh config.sub autoscan.log config.h.in missing aclocal.m4 install-sh + configure config.log config.status a.out autom4te.cache cxxtest.gcc Makefile Makefile.in depcomp stamp-h1 config.guess config.h ltmain.sh config.sub autoscan.log config.h.in missing aclocal.m4 install-sh .deps Added: trunk/complement/explore/inquiry/shades/autotools/ChangeLog =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-29 05:25:07
|
Revision: 1708 http://complement.svn.sourceforge.net/complement/?rev=1708&view=rev Author: complement Date: 2007-08-28 22:24:59 -0700 (Tue, 28 Aug 2007) Log Message: ----------- autoconf 2.61 Modified Paths: -------------- trunk/complement/explore/inquiry/shades/autotools/configure.ac Removed Paths: ------------- trunk/complement/explore/inquiry/shades/autotools/ext/ Property Changed: ---------------- trunk/complement/explore/inquiry/shades/autotools/ Property changes on: trunk/complement/explore/inquiry/shades/autotools ___________________________________________________________________ Name: svn:ignore - configure config.log config.status a.out autom4te.cache cxxtest.gcc Makefile + configure config.log config.status a.out autom4te.cache cxxtest.gcc Makefile Makefile.in depcomp ChangeLog stamp-h1 config.guess config.h ltmain.sh config.sub autoscan.log config.h.in missing aclocal.m4 install-sh Modified: trunk/complement/explore/inquiry/shades/autotools/configure.ac =================================================================== --- trunk/complement/explore/inquiry/shades/autotools/configure.ac 2007-08-27 15:32:34 UTC (rev 1707) +++ trunk/complement/explore/inquiry/shades/autotools/configure.ac 2007-08-29 05:24:59 UTC (rev 1708) @@ -1,22 +1,25 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. -dnl Process this file with autoconf to produce a configure script -AC_INIT([Test Autotools],[1],[no...@no...],[cxxtest]) -AC_PREREQ(2.60a) -AC_CONFIG_AUX_DIR(ext) +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) +AC_CONFIG_SRCDIR([main.cc]) +AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE -AC_COPYRIGHT(All portions of this software are copylefted (c)) -# AC_LANG([C++]) +# Checks for programs. AC_PROG_CXX -AC_PROG_RANLIB -AC_LIBTOOL_DLOPEN -AC_PROG_LIBTOOL - -AC_CONFIG_SRCDIR([main.cc]) -AC_CONFIG_HEADER([config.h]) -AC_CONFIG_FILES([Makefile]) - -ACX_PTHREAD - -AC_OUTPUT +AC_PROG_CC + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lstlport': +# AC_CHECK_LIB([stlport], [main]) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-27 15:32:41
|
Revision: 1707 http://complement.svn.sourceforge.net/complement/?rev=1707&view=rev Author: complement Date: 2007-08-27 08:32:34 -0700 (Mon, 27 Aug 2007) Log Message: ----------- janus.h, janus.cc: hide methods, intended for internal protocol usage only; vtime.h, vtime.cc: LeaveGroup added; vshostmgr.h, vshostmgr.cc: trick with finalizer---event after that message queue free from VS_OUT_MEMBER events; ut/unit_test.cc, ut/vt_object.cc, ut/vt_handler.cc, ut/VTmess_core.cc, ut/vt_operations.cc, ut/vt_operations.h, ut/vt_dispatch.cc, ut/vt_remote.cc: move test suite to janus namespace; ut/unit_test.cc, ut/vt_remote.cc: test two groups and interprocess virtual synchrony; Modified Paths: -------------- trunk/complement/explore/include/janus/janus.h trunk/complement/explore/include/janus/vshostmgr.h trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ChangeLog trunk/complement/explore/lib/janus/janus.cc trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_object.cc trunk/complement/explore/lib/janus/ut/vt_operations.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 trunk/complement/explore/lib/janus/vtime.cc Modified: trunk/complement/explore/include/janus/janus.h =================================================================== --- trunk/complement/explore/include/janus/janus.h 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/include/janus/janus.h 2007-08-27 15:32:34 UTC (rev 1707) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/23 12:36:32 ptr> +// -*- C++ -*- Time-stamp: <07/08/25 01:40:20 ptr> #ifndef __janus_h #define __janus_h @@ -41,14 +41,17 @@ #ifdef __USE_STLPORT_HASH typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; + typedef std::hash_set<stem::addr_type> addr_cache_t; #endif #ifdef __USE_STD_HASH typedef __gnu_cxx::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef __gnu_cxx::hash_multimap<group_type, oid_type> gid_map_type; + typedef __gnu_cxx::hash_set<stem::addr_type> addr_cache_t; #endif #if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) typedef std::tr1::unordered_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::tr1::unordered_multimap<group_type, oid_type> gid_map_type; + typedef std::tr1::unordered_set<stem::addr_type> addr_cache_t; #endif public: @@ -92,18 +95,7 @@ ~Janus(); - void JaDispatch( const stem::Event_base<VSmess>& ); - - void VSNewMember( const stem::Event_base<VSsync_rq>& e ); - void VSNewRemoteMemberDirect( const stem::Event_base<VSsync_rq>& e ); - void VSNewRemoteMemberRevert( const stem::Event_base<VSsync_rq>& e ); - void JaSend( const stem::Event& e, group_type ); - void Subscribe( stem::addr_type, oid_type, group_type ); - void Unsubscribe( oid_type, group_type ); - void Unsubscribe( oid_type ); - void get_gvtime( group_type, stem::addr_type, gvtime_type& ); - void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); void settrf( unsigned f ); void unsettrf( unsigned f ); @@ -119,6 +111,12 @@ difference_type group_size( group_type ) const; private: + void Subscribe( stem::addr_type, const oid_type&, group_type ); + void Unsubscribe( const oid_type&, group_type ); + void Unsubscribe( const oid_type& ); + + void get_gvtime( group_type, stem::addr_type, gvtime_type& ); + void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); void check_and_send_delayed( detail::vtime_obj_rec& ); @@ -137,8 +135,18 @@ friend class VTHandler; friend class VSHostMgr; +#ifdef __FIT_EXAM + friend class vtime_operations; +#endif + private: + void JaDispatch( const stem::Event_base<VSmess>& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& e ); + void VSNewRemoteMemberDirect( const stem::Event_base<VSsync_rq>& e ); + void VSNewRemoteMemberRevert( const stem::Event_base<VSsync_rq>& e ); + void VSOutMember( const stem::Event_base<VSsync_rq>& e ); + DECLARE_RESPONSE_TABLE( Janus, stem::EventHandler ); }; Modified: trunk/complement/explore/include/janus/vshostmgr.h =================================================================== --- trunk/complement/explore/include/janus/vshostmgr.h 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/include/janus/vshostmgr.h 2007-08-27 15:32:34 UTC (rev 1707) @@ -37,9 +37,15 @@ { private: // typedef std::list<stem::gaddr_type> vshost_container_t; -#ifdef __USE_STLPORT_TR1 +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) typedef std::tr1::unordered_set<stem::gaddr_type> vshost_container_t; #endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_set<stem::gaddr_type> vshost_container_t; +#endif +#ifdef __USE_STLPORT_HASH + typedef std::hash_set<stem::gaddr_type> vshost_container_t; +#endif public: typedef vshost_container_t::size_type size_type; @@ -64,7 +70,7 @@ return tmp; } - void Subscribe( stem::addr_type, oid_type, group_type ); + void Subscribe( stem::addr_type, group_type ); private: typedef std::list<stem::NetTransportMgr *> nmgr_container_t; @@ -74,6 +80,28 @@ nmgr_container_t _clients; srv_container_t _servers; + class Finalizer : + public stem::EventHandler + { + public: + Finalizer( const char *info ) : + EventHandler( info ) + { cnd.set( false ); } + + void wait() + { cnd.try_wait(); } + + private: + void final() + { cnd.set( true ); } + + xmt::condition cnd; + + DECLARE_RESPONSE_TABLE( Finalizer, stem::EventHandler ); + }; + + Finalizer finalizer; + // DECLARE_RESPONSE_TABLE( VSHostMgr, janus::VTHandler ); }; Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-27 15:32:34 UTC (rev 1707) @@ -367,6 +367,7 @@ void JaSend( const stem::Event& e ); void JoinGroup( group_type grp ); + void LeaveGroup( group_type grp ); virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); @@ -381,6 +382,7 @@ { return _vtdsp; } protected: + void Unsubscribe(); void VSNewMember_data( const stem::Event_base<VSsync_rq>&, const std::string& data ); void get_gvtime( group_type g, gvtime_type& gvt ); @@ -398,6 +400,7 @@ #define VS_SYNC_TIME 0x303 #define VS_NEW_REMOTE_MEMBER 0x304 #define VS_NEW_MEMBER_RV 0x305 +#define VS_HOST_MGR_FINAL 0x306 #ifdef __USE_STLPORT_HASH # undef __USE_STLPORT_HASH Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-08-27 15:32:34 UTC (rev 1707) @@ -1,3 +1,26 @@ +2007-08-27 Petr Ovtchenkov <pt...@is...> + + * janus.h, janus.cc: hide methods, intended for internal + protocol usage only; + + * vtime.h, vtime.cc: LeaveGroup added; + + * vshostmgr.h, vshostmgr.cc: trick with finalizer---event after + that message queue free from VS_OUT_MEMBER events; + + * ut/unit_test.cc: move test suite to janus namespace; + + * ut/vt_object.cc, ut/vt_handler.cc, ut/VTmess_core.cc: + idem; + + * ut/vt_operations.cc, ut/vt_operations.h, ut/vt_dispatch.cc: + idem; + + * ut/vt_remote.cc: idem; + + * ut/unit_test.cc, ut/vt_remote.cc: test two groups and + interprocess virtual synchrony; + 2007-08-23 Petr Ovtchenkov <pt...@is...> * janus.h, janus.cc: Janus code moved from vtime.h, vtime.cc; Modified: trunk/complement/explore/lib/janus/janus.cc =================================================================== --- trunk/complement/explore/lib/janus/janus.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/janus.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/23 12:36:32 ptr> +// -*- C++ -*- Time-stamp: <07/08/26 12:44:25 ptr> #include <janus/janus.h> #include <janus/vshostmgr.h> @@ -261,7 +261,7 @@ throw domain_error( "VT object not member of group" ); // Error: not group member } -void Janus::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +void Janus::Subscribe( stem::addr_type addr, const oid_type& oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -298,11 +298,11 @@ // cerr << "**** " << grp << " " << xmt::getpid() << endl; if ( /* (grp != vshosts_group) && */ (_hostmgr != 0) ) { - _hostmgr->Subscribe( addr, oid, grp ); + _hostmgr->Subscribe( addr, grp ); } } -void Janus::Unsubscribe( oid_type oid, group_type grp ) +void Janus::Unsubscribe( const oid_type& oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -311,6 +311,8 @@ grmap.equal_range( grp ); vt_map_type::iterator i = vtmap.find( oid ); + addr_cache_t addr_cache; + while ( range.first != range.second ) { if ( range.first->second == oid ) { grmap.erase( range.first++ ); @@ -318,9 +320,28 @@ vt_map_type::iterator j = vtmap.find( range.first->second ); if ( j != vtmap.end() ) { stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); - ev.dest( j->second.stem_addr() ); + stem::addr_type addr = j->second.stem_addr(); + + // if address is foreign, send VS_OUT_MEMBER to foreign janus + if ( (addr & stem::extbit) != 0 ) { + gaddr_type ga = manager()->reflect( addr ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + } + addr = manager()->reflect( ga ); + // send only once, foreign janus will resend to other group members + // in the same process: + if ( addr_cache.find(addr) != addr_cache.end() ) { + ++range.first; + continue; + } else { + addr_cache.insert( addr ); + } + } + 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); @@ -333,8 +354,6 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - - Forward( ev ); } ++range.first; } @@ -346,11 +365,12 @@ } } - if ( grp != vshosts_group ) { - } + // if ( /* (grp != vshosts_group) && */ (_hostmgr != 0) ) { + // _hostmgr->Unsubscribe( oid, grp ); + // } } -void Janus::Unsubscribe( oid_type oid ) +void Janus::Unsubscribe( const oid_type& oid ) { // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -364,6 +384,8 @@ pair<gid_map_type::iterator,gid_map_type::iterator> range = grmap.equal_range( *grp ); + addr_cache_t addr_cache; + while ( range.first != range.second ) { if ( range.first->second == oid ) { grmap.erase( range.first++ ); @@ -371,9 +393,28 @@ vt_map_type::iterator j = vtmap.find( range.first->second ); if ( j != vtmap.end() ) { stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); - ev.dest( j->second.stem_addr() ); + stem::addr_type addr = j->second.stem_addr(); + + // if address is foreign, send VS_OUT_MEMBER to foreign janus + if ( (addr & stem::extbit) != 0 ) { + gaddr_type ga = manager()->reflect( addr ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + } + addr = manager()->reflect( ga ); + // send only once, foreign janus will resend to other group members + // in the same process: + if ( addr_cache.find(addr) != addr_cache.end() ) { + ++range.first; + continue; + } else { + addr_cache.insert( addr ); + } + } + 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); @@ -386,8 +427,6 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - - Forward( ev ); } ++range.first; } @@ -504,7 +543,7 @@ if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { *_trs << " -> VS_NEW_MEMBER_RV G" << vshosts_group << " " << hex << showbase - << evr.src() << " -> " << evr.dest() << dec << endl; + << self_id() << " -> " << evr.dest() << dec << endl; } } catch ( ... ) { @@ -520,8 +559,7 @@ group_type grp = ev.value().grp; pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); if ( range.first != range.second ) { // we have local? member within this group - gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr - addr_type addr = ev.src(); + const addr_type addr = ev.src(); gaddr_type ga = manager()->reflect( addr ); addr_type janus_addr = badaddr; if ( ga != gaddr_type() ) { @@ -571,6 +609,8 @@ } } + const gaddr_type oid = manager()->reflect( addr ); // ???? oid == gaddr + vtmap[oid].add( addr, grp ); grmap.insert( make_pair(grp,oid) ); // cerr << "**** " << grp << " " << xmt::getpid() << endl; @@ -584,8 +624,7 @@ group_type grp = ev.value().grp; pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); if ( range.first != range.second ) { // we have local? member within this group - gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr - addr_type addr = ev.src(); + const addr_type addr = ev.src(); for ( ; range.first != range.second; ++range.first ) { vt_map_type::iterator i = vtmap.find( range.first->second ); if ( i != vtmap.end() && ((i->second.stem_addr() & stem::extbit) == 0 )) { @@ -609,13 +648,14 @@ } } + const gaddr_type oid = manager()->reflect( addr ); // ???? oid == gaddr vtmap[oid].add( addr, grp ); grmap.insert( make_pair(grp,oid) ); // cerr << "**** " << grp << " " << xmt::getpid() << endl; } } else { - gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr - addr_type addr = ev.src(); + const addr_type addr = ev.src(); + const gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr vtmap[oid].add( addr, vshosts_group ); grmap.insert( make_pair(static_cast<group_type>(vshosts_group),oid) ); @@ -623,6 +663,67 @@ } } +void Janus::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "<- VS_OUT_MEMBER G" << ev.value().grp + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + const gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr + const group_type grp = ev.value().grp; + + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + + vt_map_type::iterator i = vtmap.find( oid ); + + while ( range.first != range.second ) { + if ( range.first->second == oid ) { + grmap.erase( range.first++ ); + } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::addr_type addr = j->second.stem_addr(); + + // 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); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_OUT_MEMBER " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } + } + ++range.first; + } + } + + if ( i != vtmap.end() ) { + if ( i->second.rm_group( grp ) ) { // no groups more + vtmap.erase( i ); + } + } +} + void Janus::connect( const char *host, int port ) { _hostmgr->connect( host, port ); @@ -653,6 +754,7 @@ EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER, VSNewMember, VSsync_rq ) 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 ) + EV_Event_base_T_( ST_NULL, VS_OUT_MEMBER, VSOutMember, VSsync_rq ) END_RESPONSE_TABLE } // namespace janus Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -5,7 +5,8 @@ #include <iostream> #include <janus/vtime.h> -using namespace janus; +namespace janus { + using namespace std; class VTM_handler : @@ -146,3 +147,6 @@ return EXAM_RESULT; } + +} // namespace janus + Modified: trunk/complement/explore/lib/janus/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -6,11 +6,13 @@ int EXAM_IMPL(vtime_test_suite) { + using namespace janus; + exam::test_suite::test_case_type tc[3]; exam::test_suite t( "virtual time operations" ); - vtime_operations vt_oper; + janus::vtime_operations vt_oper; t.add( &vtime_operations::vt_max, vt_oper, "Max", tc[1] = t.add( &vtime_operations::vt_add, vt_oper, "Additions", @@ -20,16 +22,17 @@ t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - 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", - t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))); + t.add( &vtime_operations::mgroups, vt_oper, "mgroups", + 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", + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))) ); return t.girdle(); } Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -7,7 +7,8 @@ #include <janus/vtime.h> #include <janus/janus.h> -using namespace janus; +namespace janus { + using namespace std; class Dummy : @@ -129,3 +130,6 @@ return EXAM_RESULT; } + +} // namespace janus + Modified: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -7,7 +7,8 @@ #include <stem/EvManager.h> -using namespace janus; +namespace janus { + using namespace std; class VTDummy : @@ -353,3 +354,5 @@ return EXAM_RESULT; } + +} // namespace janus Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -5,7 +5,8 @@ #include <iostream> #include <janus/vtime.h> -using namespace janus; +namespace janus { + using namespace std; int EXAM_IMPL(vtime_operations::vt_object) @@ -186,3 +187,5 @@ return EXAM_RESULT; } + +} // namespace janus Modified: trunk/complement/explore/lib/janus/ut/vt_operations.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -5,7 +5,8 @@ #include <iostream> #include <janus/vtime.h> -using namespace janus; +namespace janus { + using namespace std; int EXAM_IMPL(vtime_operations::vt_compare) @@ -319,3 +320,5 @@ return EXAM_RESULT; } + +} // namespace janus Modified: trunk/complement/explore/lib/janus/ut/vt_operations.h =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-27 15:32:34 UTC (rev 1707) @@ -5,6 +5,8 @@ #include <exam/suite.h> +namespace janus { + struct vtime_operations { int EXAM_DECL(vt_compare); @@ -30,6 +32,9 @@ int EXAM_DECL(VTEntryIntoGroup3); int EXAM_DECL(remote); + int EXAM_DECL(mgroups); }; +} // namespace janus + #endif // __vt_operations_h Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/23 21:31:56 ptr> +// -*- C++ -*- Time-stamp: <07/08/26 12:54:05 ptr> #include "vt_operations.h" @@ -21,13 +21,16 @@ #include <list> #include <sstream> +namespace janus { + using namespace std; using namespace stem; using namespace xmt; -using namespace janus; -#define VS_DUMMY_MESS 0x1203 -#define VS_DUMMY_GREETING 0x1204 +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 +#define VS_DUMMY_GREETING2 0x1205 +#define VS_DUMMY_MESS2 0x1206 class YaRemote : public janus::VTHandler @@ -39,12 +42,16 @@ ~YaRemote(); void handler( const stem::Event& ); + void handler2( const stem::Event& ); void VSNewMember( const stem::Event_base<VSsync_rq>& ); void VSOutMember( const stem::Event_base<VSsync_rq>& ); void greeting(); + void greeting2(); void wait(); + void wait2(); + std::string msg; int count; int ocount; @@ -55,9 +62,17 @@ gr.set( false ); } + void wait_greeting2() + { + gr2.try_wait(); + gr2.set( false ); + } + private: xmt::condition cnd; + xmt::condition cnd2; xmt::condition gr; + xmt::condition gr2; DECLARE_RESPONSE_TABLE( YaRemote, janus::VTHandler ); }; @@ -68,7 +83,9 @@ ocount(0) { cnd.set( false ); + cnd2.set( false ); gr.set( false ); + gr2.set( false ); } YaRemote::YaRemote( stem::addr_type id, const char *info ) : @@ -77,7 +94,9 @@ ocount(0) { cnd.set( false ); + cnd2.set( false ); gr.set( false ); + gr2.set( false ); } YaRemote::YaRemote( const char *info ) : @@ -86,7 +105,9 @@ ocount(0) { cnd.set( false ); + cnd2.set( false ); gr.set( false ); + gr2.set( false ); } YaRemote::~YaRemote() @@ -101,6 +122,13 @@ cnd.set( true ); } +void YaRemote::handler2( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd2.set( true ); +} + void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { // cerr << "Hello " << xmt::getpid() << endl; @@ -109,14 +137,19 @@ // VTNewMember_data( ev, "" ); VTHandler::VSNewMember( ev ); - stem::EventVoid gr_ev( VS_DUMMY_GREETING ); - gr_ev.dest( ev.src() ); - Send( gr_ev ); + if ( ev.value().grp == janus::vs_base::first_user_group ) { + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); + } else if ( ev.value().grp == (janus::vs_base::first_user_group + 1) ) { + stem::EventVoid gr_ev( VS_DUMMY_GREETING2 ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); + } } void YaRemote::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) { - cerr << "VSOutMember" << endl; ++ocount; } @@ -127,14 +160,28 @@ cnd.set( false ); } +void YaRemote::wait2() +{ + cnd2.try_wait(); + + cnd2.set( false ); +} + void YaRemote::greeting() { gr.set( true ); } +void YaRemote::greeting2() +{ + gr2.set( true ); +} + DEFINE_RESPONSE_TABLE( YaRemote ) EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_EDS( ST_NULL, VS_DUMMY_MESS2, handler2 ) EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING2, greeting2 ) END_RESPONSE_TABLE int EXAM_IMPL(vtime_operations::remote) @@ -154,50 +201,60 @@ b.wait(); { - YaRemote obj1( "obj client" ); + VTHandler obj0; // this need to keep VSHostMgr after YaRemote exit + // to check exit from group with another process + { + YaRemote obj1( "obj client" ); - // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); - // obj1.manager()->settrs( &std::cerr ); + // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // obj1.manager()->settrs( &std::cerr ); - // 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()->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( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); - obj1.vtdispatcher()->connect( "localhost", 6980 ); + obj1.vtdispatcher()->connect( "localhost", 6980 ); - // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; - while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { - xmt::Thread::yield(); - xmt::delay( xmt::timespec( 0, 1000000 ) ); - } + while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 1000000 ) ); + } - /*******************************************************************\ - * This variant is wrong, because of group_size don't guarantee - * that information in the object is relevant (i.e. VSsync happens); - * for example, in case below group_size already 2, but no janus string - * stored yet. + /*******************************************************************\ + * This variant is wrong, because of group_size don't guarantee + * that information in the object is relevant (i.e. VSsync happens); + * for example, in case below group_size already 2, but no janus string + * stored yet. - while ( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) < 2 ) { - xmt::Thread::yield(); - xmt::delay( xmt::timespec( 0, 1000000 ) ); - } - \********************************************************************/ + while ( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) < 2 ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 1000000 ) ); + } + \********************************************************************/ - // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; + // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2 ); - // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2 ); + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; - obj1.JoinGroup( janus::vs_base::first_user_group ); + obj1.JoinGroup( janus::vs_base::first_user_group ); - obj1.wait_greeting(); + obj1.wait_greeting(); - EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); - EXAM_CHECK_ASYNC( obj1.count == 1 ); - // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; - obj1.wait(); + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); + EXAM_CHECK_ASYNC( obj1.count == 1 ); + // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; + obj1.wait(); + + // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // obj1.manager()->settrs( &std::cerr ); + } + // 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); } exit(0); @@ -226,15 +283,19 @@ obj1.JaSend( ev ); - EXAM_CHECK( obj1.count == 1 ); + 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; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; - // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + 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; - // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; } (&b)->~__barrier<true>(); @@ -250,3 +311,109 @@ return EXAM_RESULT; } +int EXAM_IMPL(vtime_operations::mgroups) +{ + 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>(); + + try { + xmt::fork(); + + b.wait(); + + { + VTHandler obj0; // this need to keep VSHostMgr after YaRemote exit + // to check exit from group with another process + { + YaRemote obj1( "obj client" ); + + obj1.vtdispatcher()->connect( "localhost", 6980 ); + + while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 1000000 ) ); + } + + obj1.JoinGroup( janus::vs_base::first_user_group ); + obj1.JoinGroup( janus::vs_base::first_user_group + 1); + + 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 ); + + stem::Event ev( VS_DUMMY_MESS2 ); + ev.dest( janus::vs_base::first_user_group + 1 ); + ev.value() = "hello"; + + obj1.JaSend( ev ); + + obj1.wait(); + + // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // 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); + } + + exit(0); + } + catch ( xmt::fork_in_parent& child ) { + YaRemote obj1( "obj srv" ); + + obj1.vtdispatcher()->serve( 6980 ); + + obj1.JoinGroup( janus::vs_base::first_user_group ); + obj1.JoinGroup( janus::vs_base::first_user_group + 1); + + b.wait(); + + obj1.wait_greeting(); + obj1.wait_greeting2(); + + 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.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) == 2 ); + EXAM_CHECK( obj1.count == 2 ); + + obj1.wait2(); + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + 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 ); + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group + 1) << endl; + + EXAM_CHECK( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); + } + + (&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-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/vshostmgr.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/23 11:24:18 ptr> +// -*- C++ -*- Time-stamp: <07/08/26 12:56:20 ptr> #include <janus/vshostmgr.h> @@ -25,21 +25,24 @@ using namespace janus; VSHostMgr::VSHostMgr() : - VTHandler() + VTHandler(), + finalizer( "vshostmgr aux" ) { vshost.insert( gaddr_type( stem::janus_addr ) ); JoinGroup( vshosts_group ); } VSHostMgr::VSHostMgr( stem::addr_type id, const char *info ) : - VTHandler( id, info ) + VTHandler( id, info ), + finalizer( "vshostmgr aux" ) { vshost.insert( gaddr_type( stem::janus_addr ) ); JoinGroup( vshosts_group ); } VSHostMgr::VSHostMgr( const char *info ) : - VTHandler( info ) + VTHandler( info ), + finalizer( "vshostmgr aux" ) { // vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); @@ -49,18 +52,38 @@ VSHostMgr::~VSHostMgr() { - while ( !_clients.empty() ) { - _clients.front()->close(); - _clients.front()->join(); - delete _clients.front(); - _clients.pop_front(); + if ( !_clients.empty() || !_servers.empty() ) { + VTHandler::Unsubscribe(); // before channels closed! + + stem::EventVoid ev( VS_HOST_MGR_FINAL ); + + ev.dest( finalizer.self_id() ); + Send( ev ); + + finalizer.wait(); + + // give the chance to deliver VS_OUT_MEMBER message to remotes... + // Do you know better solution, because this one is ugly? + for ( int i = 0; i < 5; ++i ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 100000 ) ); + } + + // shutdown clients... + while ( !_clients.empty() ) { + _clients.front()->close(); + _clients.front()->join(); + delete _clients.front(); + _clients.pop_front(); + } + // ... and servers + while ( !_servers.empty() ) { + _servers.front()->close(); + _servers.front()->wait(); + delete _servers.front(); + _servers.pop_front(); + } } - while ( !_servers.empty() ) { - _servers.front()->close(); - _servers.front()->wait(); - delete _servers.front(); - _servers.pop_front(); - } } void VSHostMgr::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) @@ -180,7 +203,7 @@ #endif // __FIT_VS_TRACE } -void VSHostMgr::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +void VSHostMgr::Subscribe( stem::addr_type addr, group_type grp ) { try { manager()->transport( addr ); @@ -199,7 +222,7 @@ #ifdef __FIT_VS_TRACE try { scoped_lock lk(vtdispatcher()->_lock_tr); - if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { + if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracegroup) ) { *vtdispatcher()->_trs << " -> VS_NEW_REMOTE_MEMBER G" << grp << " " << hex << showbase << ev.src() << " -> " << ev.dest() << dec << endl; @@ -218,5 +241,9 @@ // EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER_RV, VSNewRemoteMemberRevert, VSsync_rq ) // END_RESPONSE_TABLE +DEFINE_RESPONSE_TABLE( VSHostMgr::Finalizer ) + EV_VOID( ST_NULL, VS_HOST_MGR_FINAL, final ) +END_RESPONSE_TABLE + } // namespace janus Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-27 15:10:53 UTC (rev 1706) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-27 15:32:34 UTC (rev 1707) @@ -621,16 +621,25 @@ VTHandler::~VTHandler() { - _vtdsp->Unsubscribe( oid_type( self_id() ) ); + Unsubscribe(); ((Init *)Init_buf)->~Init(); } +void VTHandler::Unsubscribe() +{ + _vtdsp->Unsubscribe( oid_type( self_id() ) ); +} + void VTHandler::JoinGroup( group_type grp ) { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } +void VTHandler::LeaveGroup( group_type grp ) +{ + _vtdsp->Unsubscribe( oid_type( self_id() ), grp ); +} void VTHandler::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-27 15:11:00
|
Revision: 1706 http://complement.svn.sourceforge.net/complement/?rev=1706&view=rev Author: complement Date: 2007-08-27 08:10:53 -0700 (Mon, 27 Aug 2007) Log Message: ----------- use namespace std for max Modified Paths: -------------- trunk/complement/explore/include/mt/shm.h trunk/complement/explore/lib/mt/ChangeLog Modified: trunk/complement/explore/include/mt/shm.h =================================================================== --- trunk/complement/explore/include/mt/shm.h 2007-08-25 05:59:33 UTC (rev 1705) +++ trunk/complement/explore/include/mt/shm.h 2007-08-27 15:10:53 UTC (rev 1706) @@ -536,7 +536,7 @@ template <int _Inst> void shm_alloc<_Inst>::deallocate( pointer p, size_type n ) { - n = max( n + (__align - n % __align) % __align, sizeof(_fheader) ); + n = std::max( n + (__align - n % __align) % __align, sizeof(_fheader) ); _master *m = reinterpret_cast<_master *>( _seg.address() ); if ( m != reinterpret_cast<_master *>(-1) && (reinterpret_cast<char *>(p) - reinterpret_cast<char *>(_seg.address())) < (_seg.max_size() + sizeof(_master) + sizeof(_aheader) ) ) { xmt::basic_lock<xmt::__mutex<false,true> > lk( m->_lock ); @@ -597,7 +597,7 @@ template <int _Inst> void *shm_alloc<_Inst>::_traverse( size_type *_prev, size_type n ) { - n = max( n + (__align - n % __align) % __align, sizeof(_fheader) ); + n = std::max( n + (__align - n % __align) % __align, sizeof(_fheader) ); for ( _fheader *h = reinterpret_cast<_fheader *>(reinterpret_cast<char *>(_seg.address()) + *_prev); *_prev != 0; _prev = &h->_next, h = reinterpret_cast<_fheader *>(reinterpret_cast<char *>(_seg.address()) + *_prev)) { if ( h->_sz >= (n + sizeof( _fheader )) ) { // reduce this free block, write new free header Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-25 05:59:33 UTC (rev 1705) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-27 15:10:53 UTC (rev 1706) @@ -1,3 +1,7 @@ +2007-08-27 Petr Ovtchenkov <pt...@is...> + + * shm.h: use namespace std for max. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * test/mt/Makefile: let's try don't include boost's -I if macro This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-26 12:07:52
|
Revision: 1705 http://complement.svn.sourceforge.net/complement/?rev=1705&view=rev Author: complement Date: 2007-08-24 22:59:33 -0700 (Fri, 24 Aug 2007) Log Message: ----------- use ostream and trace flags from EvManager for error reports instead of cerr; library version 4.6.3 Modified Paths: -------------- trunk/complement/explore/include/stem/EvManager.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/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2007-08-23 17:34:23 UTC (rev 1704) +++ trunk/complement/explore/include/stem/EvManager.h 2007-08-25 05:59:33 UTC (rev 1705) @@ -262,6 +262,8 @@ friend class Names; friend class NetTransportMgr; + friend class NetTransport_base; + friend class NetTransport; }; } // namespace stem Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-23 17:34:23 UTC (rev 1704) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-25 05:59:33 UTC (rev 1705) @@ -1,3 +1,10 @@ +2007-08-25 Petr Ovtchenkov <pt...@is...> + + * EvManager.h, NetTransport.cc: use ostream and trace flags + from EvManager for error reports instead of cerr; + + * libstem: library version 4.6.3 + 2007-08-23 Petr Ovtchenkov <pt...@is...> * NetTransport.h: inhibit copy of NetTransportMgr explicitly; Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-08-23 17:34:23 UTC (rev 1704) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-08-25 05:59:33 UTC (rev 1705) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <07/07/12 00:52:43 ptr> +# -*- Makefile -*- Time-stamp: <07/08/25 09:58:31 ptr> LIBNAME = stem MAJOR = 4 MINOR = 6 -PATCH = 2 +PATCH = 3 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-08-23 17:34:23 UTC (rev 1704) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2007-08-25 05:59:33 UTC (rev 1705) @@ -2,7 +2,7 @@ /* * - * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -115,7 +115,17 @@ } if ( buf[0] != EDS_MAGIC ) { - cerr << "EDS Magic fail" << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " StEM Magic fail (" + << net->rdbuf()->inet_addr() << ":" << net->rdbuf()->port() << ")" + << endl; + } + } + catch ( ... ) { + } + NetTransport_base::close(); return false; } @@ -131,14 +141,33 @@ uint32_t sz = from_net( buf[18] ); if ( sz >= EDS_MSG_LIMIT ) { - cerr << "EDS Message size too big: " << sz << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " StEM Message size too big: " << sz + << " (" << net->rdbuf()->inet_addr() << ":" << net->rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } NetTransport_base::close(); return false; } adler32_type adler = adler32( (unsigned char *)buf, sizeof(uint32_t) * 19 ); if ( adler != from_net( buf[19] ) ) { - cerr << "EDS Adler-32 fail" << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " StEM Adler-32 fail" + << " (" << net->rdbuf()->inet_addr() << ":" << net->rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } + NetTransport_base::close(); return false; } @@ -169,7 +198,6 @@ dst._xnet_pack( reinterpret_cast<char *>(buf + 2) ); src._xnet_pack( reinterpret_cast<char *>(buf + 9) ); - // MT_IO_REENTRANT_W( *net ) MT_IO_LOCK_W( *net ) buf[16] = to_net( ++_count ); @@ -237,10 +265,31 @@ } } catch ( runtime_error& err ) { + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " " << err.what() + << " (" << s.rdbuf()->inet_addr() << ":" << s.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } + s.close(); - cerr << err.what() << endl; } catch ( ... ) { + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " unknown exception" + << " (" << s.rdbuf()->inet_addr() << ":" << s.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } + s.close(); } } @@ -269,9 +318,29 @@ } } catch ( ios_base::failure& ex ) { - cerr << ex.what() << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " " << ex.what() + << " (" << s.rdbuf()->inet_addr() << ":" << s.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } } catch ( ... ) { + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " unknown exception" + << " (" << s.rdbuf()->inet_addr() << ":" << s.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } + s.close(); } } @@ -332,10 +401,28 @@ } } catch ( runtime_error& err ) { - cerr << err.what() << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " " << err.what() + << " (" << _channel.rdbuf()->inet_addr() << ":" << _channel.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } } catch ( ... ) { - // cerr << __FILE__ << ":" << __LINE__ << endl; + try { + xmt::scoped_lock lk(manager()->_lock_tr); + if ( manager()->_trs != 0 && manager()->_trs->good() && (manager()->_trflags & EvManager::tracefault) ) { + *manager()->_trs << __FILE__ << ":" << __LINE__ << " unknown exception" + << " (" << _channel.rdbuf()->inet_addr() << ":" << _channel.rdbuf()->port() + << ")" << endl; + } + } + catch ( ... ) { + } } return badaddr; } @@ -344,6 +431,7 @@ void NetTransportMgr::close() { _channel.rdbuf()->shutdown( sock_base::stop_in | sock_base::stop_out ); + // _channel.rdbuf()->shutdown( sock_base::stop_in ); NetTransport_base::close(); // _channel.close(); join(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 17:34:24
|
Revision: 1704 http://complement.svn.sourceforge.net/complement/?rev=1704&view=rev Author: complement Date: 2007-08-23 10:34:23 -0700 (Thu, 23 Aug 2007) Log Message: ----------- clean test 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-08-23 13:57:49 UTC (rev 1703) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-23 17:34:23 UTC (rev 1704) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/23 12:43:15 ptr> +// -*- C++ -*- Time-stamp: <07/08/23 21:31:56 ptr> #include "vt_operations.h" @@ -129,9 +129,7 @@ void YaRemote::greeting() { - if ( count > 0 ) { - gr.set( true ); - } + gr.set( true ); } DEFINE_RESPONSE_TABLE( YaRemote ) @@ -175,16 +173,17 @@ xmt::delay( xmt::timespec( 0, 1000000 ) ); } - /* ****************************************************************************** - This variant is wrong, because of group_size don't guarantee that information - in the object is relevant (i.e. VSsync happens); for example, in case below - group_size already 2, but no janus string stored yet. + /*******************************************************************\ + * This variant is wrong, because of group_size don't guarantee + * that information in the object is relevant (i.e. VSsync happens); + * for example, in case below group_size already 2, but no janus string + * stored yet. while ( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) < 2 ) { xmt::Thread::yield(); xmt::delay( xmt::timespec( 0, 1000000 ) ); } - * ****************************************************************************** */ + \********************************************************************/ // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; @@ -196,7 +195,7 @@ obj1.wait_greeting(); EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); - + EXAM_CHECK_ASYNC( obj1.count == 1 ); // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; obj1.wait(); } @@ -227,6 +226,8 @@ obj1.JaSend( ev ); + EXAM_CHECK( obj1.count == 1 ); + int stat; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |