Do not terminate connection on POLLHUP if there is a data to read

This commit is contained in:
z3apa3a 2021-04-22 16:59:07 +03:00
parent cc2979ee5b
commit 6279e86086

View File

@ -469,9 +469,6 @@ log("wait writing to client");
CLIENTTERM = 1; CLIENTTERM = 1;
HASERROR |= 1; HASERROR |= 1;
} }
else if(fds[fdsc].revents & (POLLHUP)) {
CLIENTTERM = 1;
}
else { else {
if(fds[fdsc].revents & POLLIN) { if(fds[fdsc].revents & POLLIN) {
#ifdef WITHLOG #ifdef WITHLOG
@ -485,6 +482,9 @@ log("ready to write to client");
#endif #endif
TOCLIENT = 1; TOCLIENT = 1;
} }
if(fds[fdsc].revents & (POLLHUP)) {
if(!FROMCLIENT) CLIENTTERM = 1;
}
} }
} }
fdsc++; fdsc++;
@ -526,12 +526,6 @@ log("poll from server failed");
SERVERTERM = 1; SERVERTERM = 1;
HASERROR |=2; HASERROR |=2;
} }
if(fds[fdsc].revents & (POLLHUP)) {
#ifdef WITHLOG
log("server terminated connection");
#endif
SERVERTERM = 1;
}
else { else {
if(fds[fdsc].revents & POLLIN) { if(fds[fdsc].revents & POLLIN) {
#ifdef WITHLOG #ifdef WITHLOG
@ -545,6 +539,12 @@ log("ready to write to server");
#endif #endif
TOSERVER = 1; TOSERVER = 1;
} }
if(fds[fdsc].revents & (POLLHUP)) {
#ifdef WITHLOG
log("server terminated connection");
#endif
if(!FROMSERVER) SERVERTERM = 1;
}
} }
} }
fdsc++; fdsc++;
@ -581,13 +581,13 @@ log("wait reading from client pipe");
fds[fdsc].events |= (POLLIN); fds[fdsc].events |= (POLLIN);
} }
else { else {
if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){ if(fds[fdsc].revents & (POLLERR|POLLNVAL)){
RETURN(90); RETURN(90);
} }
#ifdef WITHLOG #ifdef WITHLOG
log("ready reading from client pipe"); log("ready reading from client pipe");
#endif #endif
if(fds[fdsc].revents & POLLIN) FROMCLIENTPIPE = 1; if(fds[fdsc].revents & (POLLHUP|POLLIN)) FROMCLIENTPIPE = 1;
} }
fdsc++; fdsc++;
} }
@ -619,13 +619,13 @@ log("wait reading from server pipe");
fds[fdsc].events |= (POLLIN); fds[fdsc].events |= (POLLIN);
} }
else { else {
if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){ if(fds[fdsc].revents & (POLLERR|POLLNVAL)){
RETURN(90); RETURN(90);
} }
#ifdef WITHLOG #ifdef WITHLOG
log("ready reading from server pipe"); log("ready reading from server pipe");
#endif #endif
if(fds[fdsc].revents & POLLIN) FROMSERVERPIPE = 1; if(fds[fdsc].revents & (POLLHUP|POLLIN)) FROMSERVERPIPE = 1;
} }
fdsc++; fdsc++;
} }