[complement-svn] SF.net SVN: complement: [1886] branches/complement-sockios/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-06-05 08:57:46
|
Revision: 1886 http://complement.svn.sourceforge.net/complement/?rev=1886&view=rev Author: complement Date: 2008-06-05 01:57:35 -0700 (Thu, 05 Jun 2008) Log Message: ----------- fix compilation; shouldn't work indeed, review required Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sockstream2 branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc Modified: branches/complement-sockios/explore/include/sockios/sockstream2 =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream2 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sockstream2 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/09 13:02:18 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:53:21 yeti> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 @@ -190,6 +190,9 @@ template <class charT, class traits, class _Alloc> class sockmgr; } // namespace detail +template <class charT, class traits, class _Alloc> +class sock_processor_base; + template<class charT, class traits, class _Alloc> class basic_socket { @@ -617,6 +620,7 @@ std::tr2::condition_variable ucnd; friend class detail::sockmgr<charT,traits,_Alloc>; + friend class sock_processor_base<charT,traits,_Alloc>; }; template <class charT, class traits, class _Alloc> @@ -768,7 +772,7 @@ typedef basic_sockbuf2<char,char_traits<char>,allocator<char> > sockbuf2; // typedef basic_sockbuf2<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockbuf; -typedef basic_sockstream2<char,char_traits<char>,allocator<char> > sockstream2; +typedef basic_sockstream2<char,std::char_traits<char>,std::allocator<char> > sockstream2; // typedef basic_sockstream<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockstream; #ifdef STLPORT Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/11 21:52:28 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:55:59 yeti> /* * Copyright (c) 2008 @@ -199,19 +199,19 @@ } template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream2<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::adopt_new_t& ) +void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const sockaddr& addr ) { - typename base_t::sockstream_t* s = base_t::create_stream( fd ); + typename base_t::sockstream_t* s = base_t::create_stream( fd, addr ); - Connect* c = new Connect( s ); // bad point! I can't read from s in ctor indeed! + Connect* c = new Connect( *s ); // bad point! I can't read from s in ctor indeed! - if ( s.rdbuf()->in_avail() ) { + if ( s->rdbuf()->in_avail() ) { std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - ready_pool.push_back( processor( c, &s ) ); + ready_pool.push_back( processor( c, s ) ); cnd.notify_one(); } else { std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool.insert( std::make_pair( &s, c ) ); + worker_pool.insert( std::make_pair( fd, processor( c, s ) ) ); } } @@ -306,7 +306,7 @@ ready_pool.push_back( p ); } else { std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool[p.s] = p.c; + worker_pool[p.s->rdbuf()->fd()] = p; } // std::cerr << "worker 3\n"; } @@ -497,7 +497,7 @@ try { std::cerr << __FILE__ << ":" << __LINE__ << " new sockstream_t" << std::endl; - (*info.p)( fd, typename socks_processor_t::adopt_new_t() ); + (*info.p)( fd, addr ); epoll_event ev_add; ev_add.events = EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP | EPOLLET | EPOLLONESHOT; @@ -591,7 +591,7 @@ } } if ( !is_closed ) { - (*info.p)( *info.s.s, typename socks_processor_t::adopt_data_t() ); + (*info.p)( ev.data.fd, typename socks_processor_t::adopt_data_t() ); } } break; @@ -652,7 +652,7 @@ } } if ( !is_closed ) { - (*info.p)( *info.s.s, typename socks_processor_t::adopt_data_t() ); + (*info.p)( ev.data.fd, typename socks_processor_t::adopt_data_t() ); } } } else { @@ -686,13 +686,13 @@ } if ( need_delete ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; - (*info.p)( *info.s.s, typename socks_processor_t::adopt_close_t() ); + (*info.p)( ifd->first, typename socks_processor_t::adopt_close_t() ); std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; } } if ( (info.flags & fd_info::owner) != 0 && need_delete ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; - delete info.s.s; + delete info.s.s; // Ahtung! info.s.s = 0; } else { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; @@ -734,7 +734,7 @@ for ( typename fd_container_type::iterator ifd = descr.begin(); ifd != descr.end(); ) { if ( (ifd->second.flags & fd_info::owner) && (ifd->second.p == &p) ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; - p( /* *ifd->second.s.s */ /* *ifd->second.s.s.rdbuf()->fd() */, typename socks_processor_t::adopt_close_t() ); + p( ifd->first, typename socks_processor_t::adopt_close_t() ); std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; delete ifd->second.s.s; if ( epoll_ctl( efd, EPOLL_CTL_DEL, ifd->first, 0 ) < 0 ) { Modified: branches/complement-sockios/explore/include/sockios/sp.h =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.h 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sp.h 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/11 22:14:39 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:38:28 yeti> /* * Copyright (c) 2008 @@ -100,7 +100,7 @@ virtual void close(); - virtual void operator ()( int fd, const adopt_new_t& ) = 0; + virtual void operator ()( int fd, const sockaddr& ) = 0; virtual void operator ()( int fd, const adopt_close_t& ) = 0; virtual void operator ()( int fd, const adopt_data_t& ) = 0; @@ -110,10 +110,10 @@ protected: void setoptions_unsafe( sock_base2::so_t optname, bool on_off = true, int __v = 0 ); - sockstream_t* create_stream( int fd ) + sockstream_t* create_stream( int fd, const sockaddr& addr ) { sockstream_t* s = new sockstream_t(); - // s->rdbuf()->_open_sockmgr( fd, addr ); + s->rdbuf()->_open_sockmgr( fd, addr ); return s; } @@ -216,7 +216,7 @@ { if ( ploop.joinable() ) { ploop.join(); } } private: - virtual void operator ()( int fd, const typename base_t::adopt_new_t& ); + virtual void operator ()( int fd, const sockaddr& ); virtual void operator ()( int fd, const typename base_t::adopt_close_t& ); virtual void operator ()( int fd, const typename base_t::adopt_data_t& ); Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/09 21:18:52 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:37:58 yeti> /* * @@ -46,7 +46,7 @@ { /* cerr << "In destructor\n"; */ } protected: - virtual void operator ()( int, const adopt_new_t& ) + virtual void operator ()( int, const sockaddr& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } @@ -80,7 +80,7 @@ { } protected: - virtual void operator ()( int, const adopt_new_t& ) + virtual void operator ()( int, const sockaddr& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |