Socket::operator = https://github.com/keithw/mosh/blob/master/src/network/network.cc#L592 does not close the current socket before dupping another one.
I suppose the bug is inconsequential as the usage of Socket never triggers calls to the assignment operator, but this is fragile.
issue #470 - close old socket before its is overwritten before assign…
The patch also changes socket copy constructor and assignment of Socket to simply clear the _fd field in the copy source to avoid the need for calling dup - move semantic fot _fd is sufficient.
network.cc: Properly close old fd on Socket assignment operator
Fix thanks to Igor Bukanov. Closes #470.
Nice catch, thank you.