Doug's fixes
This commit is contained in:
16
network.c
16
network.c
@ -326,7 +326,7 @@ int NETConnectFinished(mkChannel * self)
|
||||
return -1;
|
||||
}
|
||||
oldopts = fcntl(self->sockid, F_GETFL, 0);
|
||||
if (!(oldopts | O_NONBLOCK)) {
|
||||
if (!(oldopts & O_NONBLOCK)) { /* DCL was | */
|
||||
/* assume success when in blocking mode */
|
||||
return 1;
|
||||
}
|
||||
@ -359,7 +359,7 @@ int NETConnectFinished(mkChannel * self)
|
||||
}
|
||||
/* reset to blocking mode */
|
||||
olderrno = errno;
|
||||
fcntl(self->sockid, F_SETFL, oldopts | ~O_NONBLOCK);
|
||||
fcntl(self->sockid, F_SETFL, oldopts & ~O_NONBLOCK); /* DCL was | */
|
||||
errno = olderrno;
|
||||
return iret;
|
||||
}
|
||||
@ -752,14 +752,20 @@ int NETReconnectWithFlags(mkChannel * self, int flags)
|
||||
if (self->sockid != 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