aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-07-29 19:01:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-07-29 19:01:02 +0000
commitc2292209eb4ece185f555a5c7823726794fe34cc (patch)
tree3bad472400717626400238c24057caacb325aac1
parentff5688b09c21242c2a0bee70cdfd1ea50b06f4f0 (diff)
downloadlibbu++-c2292209eb4ece185f555a5c7823726794fe34cc.tar.gz
libbu++-c2292209eb4ece185f555a5c7823726794fe34cc.tar.bz2
libbu++-c2292209eb4ece185f555a5c7823726794fe34cc.tar.xz
libbu++-c2292209eb4ece185f555a5c7823726794fe34cc.zip
Wow, socket, as it turned out, was not able to close after the remote end
disconnected. It now automatically closes down the local end when the remote end dies.
Diffstat (limited to '')
-rw-r--r--src/server.cpp1
-rw-r--r--src/socket.cpp4
2 files changed, 3 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp
index b7dec41..bfa7880 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -92,6 +92,7 @@ void Bu::Server::scan()
92 if( !pClient->isOpen() ) 92 if( !pClient->isOpen() )
93 { 93 {
94 onClosedConnection( pClient ); 94 onClosedConnection( pClient );
95 pClient->close();
95 hClients.erase( j ); 96 hClients.erase( j );
96 FD_CLR( j, &fdActive ); 97 FD_CLR( j, &fdActive );
97 } 98 }
diff --git a/src/socket.cpp b/src/socket.cpp
index 46e6cd7..3ddc492 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -159,7 +159,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes )
159 bu_recv( nSocket, (char *) pBuf, nBytes, 0 ) ); 159 bu_recv( nSocket, (char *) pBuf, nBytes, 0 ) );
160 if( nRead == 0 ) 160 if( nRead == 0 )
161 { 161 {
162 bActive = false; 162 close();
163 throw SocketException( SocketException::cClosed, "Socket closed."); 163 throw SocketException( SocketException::cClosed, "Socket closed.");
164 } 164 }
165 if( nRead < 0 ) 165 if( nRead < 0 )
@@ -171,7 +171,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes )
171#else 171#else
172 if( errno == ENETRESET || errno == ECONNRESET ) 172 if( errno == ENETRESET || errno == ECONNRESET )
173 { 173 {
174 bActive = false; 174 close();
175 throw SocketException( SocketException::cClosed, 175 throw SocketException( SocketException::cClosed,
176 strerror(errno) ); 176 strerror(errno) );
177 } 177 }