network.cc: Properly close old fd on Socket assignment operator

Fix thanks to Igor Bukanov. Closes #470.
This commit is contained in:
Keith Winstein
2014-01-04 02:50:13 -05:00
parent 492cfa3449
commit 27678941d4
+1 -3
View File
@@ -640,9 +640,7 @@ Connection::Socket::Socket( const Socket & other )
Connection::Socket & Connection::Socket::operator=( const Socket & other ) Connection::Socket & Connection::Socket::operator=( const Socket & other )
{ {
_fd = dup( other._fd ); if ( dup2( other._fd, _fd ) < 0 ) {
if ( _fd < 0 ) {
throw NetworkException( "socket", errno ); throw NetworkException( "socket", errno );
} }