More accurate conditions in sockmap's main event loop

This commit is contained in:
z3APA3A 2020-10-19 13:03:55 +03:00
parent 53521393e9
commit 677ed39c8f

View File

@ -123,17 +123,17 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
if(action != PASS) RETURN(19);
while(
((!CLIENTTERM) && (inserverbuf
((!CLIENTTERM) && fromserver && (inserverbuf
#ifdef WITHSPLICE
|| inserverpipe
#endif
|| (!SERVERTERM && fromserver)))
|| (!SERVERTERM )))
||
((!SERVERTERM) && (inclientbuf
((!SERVERTERM) && fromclient && (inclientbuf
#ifdef WITHSPLICE
|| inclientpipe
#endif
|| (!CLIENTTERM && fromclient)))
|| (!CLIENTTERM )))
){
@ -316,8 +316,11 @@ log("read from client to pipe");
#ifdef WITHLOG
log("read failed");
#endif
if(res == 0 || !errno) CLIENTTERM = 1;
FROMCLIENT = TOCLIENTPIPE = 0;
if(res == 0) {
CLIENTTERM = 1;
continue;
}
}
else {
#ifdef WITHLOG
@ -340,8 +343,11 @@ log("read from server to pipe\n");
log("splice finished\n");
#endif
if(res <= 0) {
if(res == 0 || !errno) SERVERTERM = 1;
FROMSERVER = TOSERVERPIPE = 0;
if(res == 0 || !errno) {
SERVERTERM = 1;
continue;
}
}
else {
#ifdef WITHLOG
@ -375,8 +381,11 @@ log("read from client to buf");
sasize = sizeof(param->sincr);
res = so._recvfrom(param->clisock, (char *)param->clibuf + param->cliinbuf, (int)MIN((uint64_t)param->clibufsize - param->cliinbuf, fromclient-inclientbuf), 0, (struct sockaddr *)&param->sincr, &sasize);
if(res <= 0) {
if(res == 0 || !errno)CLIENTTERM = 1;
FROMCLIENT = 0;
if(res == 0){
CLIENTTERM = 1;
continue;
}
}
else {
#ifdef WITHLOG
@ -397,8 +406,11 @@ log("read from server to buf");
sasize = sizeof(param->sinsr);
res = so._recvfrom(param->remsock, (char *)param->srvbuf + param->srvinbuf, (int)MIN((uint64_t)param->srvbufsize - param->srvinbuf, fromserver-inserverbuf), 0, (struct sockaddr *)&param->sinsr, &sasize);
if(res <= 0) {
if(res == 0 || !errno) SERVERTERM = 1;
FROMSERVER = 0;
if(res == 0) {
SERVERTERM = 1;
continue;
}
}
else {
#ifdef WITHLOG