Add linger timeout

This commit is contained in:
Vladimir Dubrovin 2026-08-08 19:13:02 +03:00
parent eceb5a22df
commit a986ed7a07
4 changed files with 15 additions and 7 deletions

View File

@ -427,9 +427,9 @@ can use %A as produced archive name and %F as filename.
.br .br
.BR timeouts .BR timeouts
\fI<BYTE_SHORT>\fR \fI<BYTE_LONG>\fR \fI<STRING_SHORT>\fR \fI<STRING_LONG>\fR \fI<CONNECTION_SHORT>\fR \fI<CONNECTION_LONG>\fR \fI<DNS>\fR \fI<CHAIN>\fR \fI<CONNECT>\fR \fI<CONNECTBACK>\fR \fI<BYTE_SHORT>\fR \fI<BYTE_LONG>\fR \fI<STRING_SHORT>\fR \fI<STRING_LONG>\fR \fI<CONNECTION_SHORT>\fR \fI<CONNECTION_LONG>\fR \fI<DNS>\fR \fI<CHAIN>\fR \fI<CONNECT>\fR \fI<CONNECTBACK>\fR \fI<LINGER>\fR
.br .br
Sets timeout values, defaults 1, 5, 30, 60, 180, 1800, 15, 60, 15, 5. Sets timeout values, defaults 1, 5, 30, 60, 180, 1800, 15, 60, 15, 5, 5.
.br .br
\fBBYTE_SHORT\fR short timeout for single byte, is usually used for receiving single byte from stream. \fBBYTE_SHORT\fR short timeout for single byte, is usually used for receiving single byte from stream.
.br .br
@ -447,7 +447,12 @@ can use %A as produced archive name and %F as filename.
.br .br
\fBCHAIN\fR timeout for reading data from chained connection \fBCHAIN\fR timeout for reading data from chained connection
.br .br
default timeouts 1 5 30 60 180 1800 15 60 15 5 \fBLINGER\fR timeout to deliver buffered data after one of the sides has closed
its sending side, also used as SO_LINGER value on outgoing connections. Too small
value may cause the tail of the data to be lost on slow connections, too large one
delays release of the sockets.
.br
default timeouts 1 5 30 60 180 1800 15 60 15 5 5
.br .br
.BR maxseg .BR maxseg

View File

@ -130,7 +130,7 @@ int timeouts[12] = {
60, /* CHAIN_TO */ 60, /* CHAIN_TO */
15, /* CONNECT_TO */ 15, /* CONNECT_TO */
5, /* CONNBACK_TO */ 5, /* CONNBACK_TO */
0, 5, /* LINGER_TO */
0 0
}; };
@ -650,7 +650,7 @@ int doconnect(struct clientparam * param){
if(param->srv->so._getpeername(param->sostate, param->remsock, (struct sockaddr *)&param->sinsr, &size)==-1) {return (14);} if(param->srv->so._getpeername(param->sostate, param->remsock, (struct sockaddr *)&param->sinsr, &size)==-1) {return (14);}
} }
else { else {
struct linger lg = {1,conf.timeouts[SINGLEBYTE_S]}; struct linger lg = {1,conf.timeouts[LINGER_TO]};
if(SAISNULL(&param->sinsr)){ if(SAISNULL(&param->sinsr)){
if(SAISNULL(&param->req)) { if(SAISNULL(&param->req)) {

View File

@ -780,7 +780,9 @@ log("ready reading from server pipe");
#ifdef WITHLOG #ifdef WITHLOG
log("entering poll"); log("entering poll");
#endif #endif
res = param->srv->so._poll(param->sostate, fds, fdsc, timeo*1000); res = param->srv->so._poll(param->sostate, fds, fdsc,
((CLIENTTERMREAD || SERVERTERMREAD)?
MIN(timeo, conf.timeouts[LINGER_TO]) : timeo) * 1000);
#ifdef WITHLOG #ifdef WITHLOG
log("leaving poll"); log("leaving poll");
#endif #endif

View File

@ -882,7 +882,8 @@ typedef enum {
DNS_TO, DNS_TO,
CHAIN_TO, CHAIN_TO,
CONNECT_TO, CONNECT_TO,
CONNBACK_TO CONNBACK_TO,
LINGER_TO
}TIMEOUT; }TIMEOUT;
typedef enum { typedef enum {