mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 02:25:40 +08:00
better error handling on splice()
This commit is contained in:
parent
1bd6eff0e6
commit
d7eb9fb82f
@ -275,7 +275,6 @@ log("done send to client from buf");
|
|||||||
log("send to server from pipe");
|
log("send to server from pipe");
|
||||||
#endif
|
#endif
|
||||||
res = splice(pipecli[0], NULL, param->remsock, NULL, MIN(MAXSPLICE, inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
res = splice(pipecli[0], NULL, param->remsock, NULL, MIN(MAXSPLICE, inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
||||||
if(res >0) {
|
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("server from pipe splice finished\n");
|
log("server from pipe splice finished\n");
|
||||||
#if WITHLOG > 1
|
#if WITHLOG > 1
|
||||||
@ -285,6 +284,7 @@ log(logbuf);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
if(res >0) {
|
||||||
param->nwrites++;
|
param->nwrites++;
|
||||||
param->statscli64 += res;
|
param->statscli64 += res;
|
||||||
inclientpipe -= res;
|
inclientpipe -= res;
|
||||||
@ -306,7 +306,6 @@ log(logbuf);
|
|||||||
log("send to client from pipe");
|
log("send to client from pipe");
|
||||||
#endif
|
#endif
|
||||||
res = splice(pipesrv[0], NULL, param->clisock, NULL, MIN(MAXSPLICE, inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
res = splice(pipesrv[0], NULL, param->clisock, NULL, MIN(MAXSPLICE, inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
||||||
if(res > 0) {
|
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("client from pipe splice finished\n");
|
log("client from pipe splice finished\n");
|
||||||
#if WITHLOG > 1
|
#if WITHLOG > 1
|
||||||
@ -316,6 +315,7 @@ log(logbuf);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
if(res > 0) {
|
||||||
inserverpipe -= res;
|
inserverpipe -= res;
|
||||||
fromserver -= res;
|
fromserver -= res;
|
||||||
if(fromserver)TOSERVERPIPE = 1;
|
if(fromserver)TOSERVERPIPE = 1;
|
||||||
@ -332,6 +332,7 @@ log(logbuf);
|
|||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("read from client to pipe");
|
log("read from client to pipe");
|
||||||
#endif
|
#endif
|
||||||
|
errno = 0;
|
||||||
res = splice(param->clisock, NULL, pipecli[1], NULL, (int)MIN((uint64_t)MAXSPLICE - inclientpipe, (uint64_t)fromclient-inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
res = splice(param->clisock, NULL, pipecli[1], NULL, (int)MIN((uint64_t)MAXSPLICE - inclientpipe, (uint64_t)fromclient-inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("client to pipe splice finished\n");
|
log("client to pipe splice finished\n");
|
||||||
@ -344,7 +345,7 @@ log(logbuf);
|
|||||||
#endif
|
#endif
|
||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMCLIENT = TOCLIENTPIPE = 0;
|
FROMCLIENT = TOCLIENTPIPE = 0;
|
||||||
if(res == 0) {
|
if(res == 0 && !errno) {
|
||||||
CLIENTTERM = 1;
|
CLIENTTERM = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -362,6 +363,7 @@ log("done read from client to pipe");
|
|||||||
if(fromserver > inserverpipe && FROMSERVER && TOSERVERPIPE){
|
if(fromserver > inserverpipe && FROMSERVER && TOSERVERPIPE){
|
||||||
int error;
|
int error;
|
||||||
socklen_t len=sizeof(error);
|
socklen_t len=sizeof(error);
|
||||||
|
errno = 0;
|
||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("read from server to pipe\n");
|
log("read from server to pipe\n");
|
||||||
#endif
|
#endif
|
||||||
@ -377,7 +379,7 @@ log(logbuf);
|
|||||||
#endif
|
#endif
|
||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
FROMSERVER = TOSERVERPIPE = 0;
|
FROMSERVER = TOSERVERPIPE = 0;
|
||||||
if(res == 0 || !errno) {
|
if(res == 0 && !errno) {
|
||||||
SERVERTERM = 1;
|
SERVERTERM = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user