mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Sockets read after a wait are non-blocking, and a read finding nothing waits again
A wait may end with nothing to read: a TLS record not yet whole, a connection gone before it is accepted, and, once clients share a thread, nothing more than a chance to try. Where a read or an accept() followed a wait on a blocking socket, or ended the operation when it found nothing, the socket is non-blocking and the wait is made again: the listening sockets of SOCKS BIND and of FTP passive mode, httpsrv reading what is left of a request body, and the RADIUS client, which reads with sockrecvfrom(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7718ffa9f7
commit
0d6b2950f0
4 files changed
+20
-22
No files matched your search
+7
-3
@@ -351,17 +351,21 @@ fflush(stderr);
|
||||
break;
|
||||
case 2:
|
||||
param->srv->so._listen (param->sostate, param->remsock, 1);
|
||||
nonblock(param->remsock);
|
||||
|
||||
fds[0].fd = param->remsock;
|
||||
fds[1].fd = param->clisock;
|
||||
fds[0].events = fds[1].events = POLLIN;
|
||||
res = sockpoll(¶m->srv->so, param->sostate, fds, 2, param->srv->timeouts[CONNECTION_L] * 1000);
|
||||
do {
|
||||
res = sockpoll(¶m->srv->so, param->sostate, fds, 2, param->srv->timeouts[CONNECTION_L] * 1000);
|
||||
if (res < 1 || fds[1].revents) break;
|
||||
sasize = sizeof(param->sinsr);
|
||||
s = param->srv->so._accept(param->sostate, param->remsock, (struct sockaddr *)¶m->sinsr, &sasize);
|
||||
} while (s == INVALID_SOCKET && acceptagain());
|
||||
if (res < 1 || fds[1].revents) {
|
||||
res = 460;
|
||||
break;
|
||||
}
|
||||
sasize = sizeof(param->sinsr);
|
||||
s = param->srv->so._accept(param->sostate, param->remsock, (struct sockaddr *)¶m->sinsr, &sasize);
|
||||
param->srv->so._closesocket(param->sostate, param->remsock);
|
||||
param->remsock = s;
|
||||
if(s == INVALID_SOCKET) {
|
||||
|
||||
Reference in new issue
Block a user