Close server-related file descriptors before executing child process
Closes #170 github issue.
This commit is contained in:
+5
-18
@@ -427,22 +427,9 @@ uint64_t Connection::timeout( void ) const
|
||||
return RTO;
|
||||
}
|
||||
|
||||
class Socket {
|
||||
public:
|
||||
int fd;
|
||||
|
||||
Socket( int domain, int type, int protocol )
|
||||
: fd( socket( domain, type, protocol ) )
|
||||
{
|
||||
if ( fd < 0 ) {
|
||||
throw NetworkException( "socket", errno );
|
||||
}
|
||||
Connection::~Connection()
|
||||
{
|
||||
if ( close( sock ) < 0 ) {
|
||||
throw NetworkException( "close", errno );
|
||||
}
|
||||
|
||||
~Socket()
|
||||
{
|
||||
if ( close( fd ) < 0 ) {
|
||||
throw NetworkException( "close", errno );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ namespace Network {
|
||||
public:
|
||||
Connection( const char *desired_ip, const char *desired_port ); /* server */
|
||||
Connection( const char *key_str, const char *ip, int port ); /* client */
|
||||
|
||||
~Connection();
|
||||
|
||||
void send( string s );
|
||||
string recv( void );
|
||||
int fd( void ) const { return sock; }
|
||||
|
||||
Reference in New Issue
Block a user