mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Fixed FD leak on accept-timeout with retry
This commit is contained in:
parent
67027cee59
commit
486bb2c65c
2 changed files with 8 additions and 0 deletions
3
CHANGES
3
CHANGES
|
@ -13,6 +13,9 @@ Corrections:
|
||||||
SOCKET-LISTEN:1:1:'"/tmp/sock"'
|
SOCKET-LISTEN:1:1:'"/tmp/sock"'
|
||||||
Test: DALAN_NO_SIGSEGV
|
Test: DALAN_NO_SIGSEGV
|
||||||
|
|
||||||
|
The retry option with some address types (TCP) did not close() the
|
||||||
|
sockets after failed attempts, resulting in an FD leak.
|
||||||
|
|
||||||
Coding:
|
Coding:
|
||||||
New Environment variable SOCAT_TRANSFER_WAIT that Socat sleep before
|
New Environment variable SOCAT_TRANSFER_WAIT that Socat sleep before
|
||||||
starting the data transfer loop. Useful, e.g., to accumulate multiple
|
starting the data transfer loop. Useful, e.g., to accumulate multiple
|
||||||
|
|
|
@ -826,12 +826,14 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
Msg4(level, "xiopoll({%d,POLLOUT|POLLERR},,{"F_tv_sec"."F_tv_usec"): %s",
|
Msg4(level, "xiopoll({%d,POLLOUT|POLLERR},,{"F_tv_sec"."F_tv_usec"): %s",
|
||||||
xfd->fd, timeout.tv_sec, timeout.tv_usec, strerror(errno));
|
xfd->fd, timeout.tv_sec, timeout.tv_usec, strerror(errno));
|
||||||
|
Close(xfd->fd);
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
Msg2(level, "connecting to %s: %s",
|
Msg2(level, "connecting to %s: %s",
|
||||||
sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
||||||
strerror(ETIMEDOUT));
|
strerror(ETIMEDOUT));
|
||||||
|
Close(xfd->fd);
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
if (writefd.revents & POLLERR) {
|
if (writefd.revents & POLLERR) {
|
||||||
|
@ -847,6 +849,7 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
|
||||||
xfd->fd, sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
xfd->fd, sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
||||||
themlen, strerror(errno));
|
themlen, strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
|
Close(xfd->fd);
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
/* otherwise OK or network error */
|
/* otherwise OK or network error */
|
||||||
|
@ -854,6 +857,7 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Msg2(level, "getsockopt(%d, SOL_SOCKET, SO_ERROR, ...): %s",
|
Msg2(level, "getsockopt(%d, SOL_SOCKET, SO_ERROR, ...): %s",
|
||||||
xfd->fd, strerror(err));
|
xfd->fd, strerror(err));
|
||||||
|
Close(xfd->fd);
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
Debug2("getsockopt(%d, SOL_SOCKET, SO_ERROR, { %d }) -> 0",
|
Debug2("getsockopt(%d, SOL_SOCKET, SO_ERROR, { %d }) -> 0",
|
||||||
|
@ -862,6 +866,7 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
|
||||||
Msg4(level, "connect(%d, %s, "F_Zd"): %s",
|
Msg4(level, "connect(%d, %s, "F_Zd"): %s",
|
||||||
xfd->fd, sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
xfd->fd, sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
|
||||||
themlen, strerror(err));
|
themlen, strerror(err));
|
||||||
|
Close(xfd->fd);
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
Fcntl_l(xfd->fd, F_SETFL, fcntl_flags);
|
Fcntl_l(xfd->fd, F_SETFL, fcntl_flags);
|
||||||
|
|
Loading…
Reference in a new issue