Better handle socket closing

This commit is contained in:
z3APA3A 2020-10-15 16:25:37 +03:00
parent 22555b58ec
commit aeb0f4caa5

View File

@ -314,6 +314,7 @@ log("read from client to pipe");
#ifdef WITHLOG
log("read failed");
#endif
if(res == 0 || !errno) CLIENTTERM = 1;
FROMCLIENT = TOCLIENTPIPE = 0;
}
else {
@ -337,6 +338,7 @@ log("read from server to pipe\n");
log("splice finished\n");
#endif
if(res <= 0) {
if(res == 0 || !errno) SERVERTERM = 1;
FROMSERVER = TOSERVERPIPE = 0;
}
else {
@ -371,7 +373,7 @@ 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(!errno)CLIENTTERM = 1;
if(res == 0 || !errno)CLIENTTERM = 1;
FROMCLIENT = 0;
}
else {
@ -393,7 +395,7 @@ 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(!errno) SERVERTERM = 1;
if(res == 0 || !errno) SERVERTERM = 1;
FROMSERVER = 0;
}
else {