Flush splice pipe on socket close

This commit is contained in:
z3APA3A 2018-05-12 01:19:11 +03:00
parent 68fed46ea0
commit 3d9ac1e1fb

View File

@ -103,7 +103,7 @@ int splicemap(struct clientparam * param, int timeo){
fds[0].fd = param->clisock; fds[0].fd = param->clisock;
fds[1].fd = param->remsock; fds[1].fd = param->remsock;
while(!stop && !conf.timetoexit){ while((!stop || (inclipipe && param->remsock != INVALID_SOCKET) || (insrvpipe && param->clisock != INVALID_SOCKET)) && !conf.timetoexit){
#ifdef NOIPV6 #ifdef NOIPV6
sasize = sizeof(struct sockaddr_in); sasize = sizeof(struct sockaddr_in);
@ -112,7 +112,7 @@ int splicemap(struct clientparam * param, int timeo){
#endif #endif
fds[0].events = fds[1].events = 0; fds[0].events = fds[1].events = 0;
if(srvstate && !param->waitclient64){ if(srvstate && !param->waitclient64 && param->clisock != INVALID_SOCKET){
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "splice: will send to client"); (*param->srv->logfunc)(param, "splice: will send to client");
#endif #endif
@ -120,13 +120,13 @@ int splicemap(struct clientparam * param, int timeo){
} }
rfromserver = MAXSPLICE; rfromserver = MAXSPLICE;
if(param->waitserver64) rfromserver = MIN(MAXSPLICE, param->waitserver64 - (received + insrvpipe)); if(param->waitserver64) rfromserver = MIN(MAXSPLICE, param->waitserver64 - (received + insrvpipe));
if(srvstate < 2 && rfromserver > 0) { if(srvstate < 2 && rfromserver > 0 && param->remsock != INVALID_SOCKET) {
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "splice: will recv from server"); (*param->srv->logfunc)(param, "splice: will recv from server");
#endif #endif
fds[1].events |= POLLIN; fds[1].events |= POLLIN;
} }
if(clistate && !param->waitserver64){ if(clistate && !param->waitserver64 && param->remsock != INVALID_SOCKET){
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "splice: will send to server"); (*param->srv->logfunc)(param, "splice: will send to server");
#endif #endif
@ -134,7 +134,7 @@ int splicemap(struct clientparam * param, int timeo){
} }
rfromclient = MAXSPLICE; rfromclient = MAXSPLICE;
if(param->waitclient64) rfromclient = MIN(MAXSPLICE, param->waitclient64 - (sent + inclipipe)); if(param->waitclient64) rfromclient = MIN(MAXSPLICE, param->waitclient64 - (sent + inclipipe));
if(clistate < 2 && rfromclient > 0) { if(clistate < 2 && rfromclient > 0 && param->clisock != INVALID_SOCKET) {
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "splice :will recv from client"); (*param->srv->logfunc)(param, "splice :will recv from client");
#endif #endif