Reconnect was bleeding socket handles on a path
r3549 | dcl | 2012-05-18 16:25:52 +1000 (Fri, 18 May 2012) | 1 line
This commit is contained in:
13
network.c
13
network.c
@@ -729,14 +729,21 @@ int NETReconnectWithFlags(mkChannel* self, int flags)
|
||||
*/
|
||||
oldopts = fcntl(self->sockid, F_GETFL, 0);
|
||||
close(self->sockid);
|
||||
/* Reopen and try to get it on the olf fd */
|
||||
/* Reopen and try to get it on the old fd */
|
||||
sock = socket(AF_INET,SOCK_STREAM,0);
|
||||
/* If this isn't the same fd, try to move it over */
|
||||
if (self->sockid != sock) {
|
||||
/* Duplicate the new socket with the old fd if we can */
|
||||
iRet = fcntl(sock, F_DUPFD, self->sockid);
|
||||
if (iRet != sock)
|
||||
if (iRet != self->sockid) {
|
||||
/* If we didn't get the one we want, use original and close new */
|
||||
self->sockid = sock;
|
||||
else
|
||||
close(iRet);
|
||||
}
|
||||
else {
|
||||
/* If we did get the one we want, close original and use old */
|
||||
close(sock);
|
||||
}
|
||||
sock = self->sockid;
|
||||
}
|
||||
/* restore the old flags */
|
||||
|
||||
Reference in New Issue
Block a user