From 229095cb7e4044e9e4fcd49caa298f93a7f842c6 Mon Sep 17 00:00:00 2001 From: darkeye Date: Sat, 20 Jul 2002 16:37:06 +0000 Subject: [PATCH] added fault tolerance in case a server connection is dropped --- darkice/trunk/ChangeLog | 2 ++ darkice/trunk/src/Connector.cpp | 33 ++++++++++++++++---------- darkice/trunk/src/TcpSocket.cpp | 5 +++- darkice/trunk/src/VorbisLibEncoder.cpp | 5 +++- darkice/trunk/src/VorbisLibEncoder.h | 5 +++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index ca4e0a9..898a63a 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -4,6 +4,8 @@ DarkIce 0.10 encoding modes with specifying encoding quality as well. thanks to Nicu Pavel o added support for Ogg Vorbis 1.0 final, removed support for rc2 + o added fault tolerance: if one of several server connection drops, + DarkIce carries on with the rest of the servers still connected 09-04-2002: DarkIce 0.9.1 released diff --git a/darkice/trunk/src/Connector.cpp b/darkice/trunk/src/Connector.cpp index a04ea27..5ad455e 100644 --- a/darkice/trunk/src/Connector.cpp +++ b/darkice/trunk/src/Connector.cpp @@ -281,22 +281,26 @@ Connector :: transfer ( unsigned long bytes, } for ( u = 0; u < numSinks; ++u ) { - + if ( sinks[u]->canWrite( sec, usec) ) { - e = sinks[u]->write( buf, d); - } else { - sinks[u]->close(); - detach( sinks[u].get() ); - /* with the call to detach, numSinks gets 1 lower, - * and the next sink comes to sinks[u] */ - --u; + try { + e = sinks[u]->write( buf, d); + } catch ( Exception & e ) { + sinks[u]->close(); + detach( sinks[u].get() ); + /* with the call to detach, numSinks gets 1 lower, + * and the next sink comes to sinks[u] */ + --u; - reportEvent( 5, - "Connector :: transfer, sink removed, remaining", u); + reportEvent( 4, + "Connector :: transfer, sink removed, remaining", + numSinks); - if ( numSinks == 0 ) { - reportEvent( 4, "Connector :: transfer, no more sinks"); - break; + if ( numSinks == 0 ) { + reportEvent( 4, + "Connector :: transfer, no more sinks"); + break; + } } } } @@ -334,6 +338,9 @@ Connector :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.8 2002/07/20 16:37:06 darkeye + added fault tolerance in case a server connection is dropped + Revision 1.7 2002/05/28 12:35:41 darkeye code cleanup: compiles under gcc-c++ 3.1, using -pedantic option diff --git a/darkice/trunk/src/TcpSocket.cpp b/darkice/trunk/src/TcpSocket.cpp index dcd4039..619e93e 100644 --- a/darkice/trunk/src/TcpSocket.cpp +++ b/darkice/trunk/src/TcpSocket.cpp @@ -313,7 +313,7 @@ TcpSocket :: write ( const void * buf, } // ret = send( sockfd, buf, len, MSG_DONTWAIT); - ret = send( sockfd, buf, len, 0); + ret = send( sockfd, buf, len, MSG_NOSIGNAL); if ( ret == -1 ) { if ( errno == EAGAIN ) { @@ -349,6 +349,9 @@ TcpSocket :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.7 2002/07/20 16:37:06 darkeye + added fault tolerance in case a server connection is dropped + Revision 1.6 2001/09/18 16:44:10 darkeye TcpSocket did not report closed state when could not connect() diff --git a/darkice/trunk/src/VorbisLibEncoder.cpp b/darkice/trunk/src/VorbisLibEncoder.cpp index 8a27f16..c6fd28a 100644 --- a/darkice/trunk/src/VorbisLibEncoder.cpp +++ b/darkice/trunk/src/VorbisLibEncoder.cpp @@ -257,7 +257,7 @@ VorbisLibEncoder :: flush ( void ) * Send pending Vorbis blocks to the underlying stream *----------------------------------------------------------------------------*/ void -VorbisLibEncoder :: vorbisBlocksOut ( void ) throw () +VorbisLibEncoder :: vorbisBlocksOut ( void ) throw ( Exception ) { while ( 1 == vorbis_analysis_blockout( &vorbisDspState, &vorbisBlock) ) { ogg_packet oggPacket; @@ -316,6 +316,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.11 2002/07/20 16:37:06 darkeye + added fault tolerance in case a server connection is dropped + Revision 1.10 2002/07/20 10:59:00 darkeye added support for Ogg Vorbis 1.0, removed support for rc2 diff --git a/darkice/trunk/src/VorbisLibEncoder.h b/darkice/trunk/src/VorbisLibEncoder.h index 5f2b3b2..94395dd 100644 --- a/darkice/trunk/src/VorbisLibEncoder.h +++ b/darkice/trunk/src/VorbisLibEncoder.h @@ -171,7 +171,7 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter * Send pending Vorbis blocks to the underlying stream */ void - vorbisBlocksOut( void ) throw (); + vorbisBlocksOut( void ) throw ( Exception ); protected: @@ -445,6 +445,9 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter $Source$ $Log$ + Revision 1.6 2002/07/20 16:37:06 darkeye + added fault tolerance in case a server connection is dropped + Revision 1.5 2002/04/13 11:26:00 darkeye added cbr, abr and vbr setting feature with encoding quality