mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Socket functions: _poll becomes _prepoll, which never waits
A layer over the sockets, TLS or a plugin's, no longer waits itself. Its _prepoll only tells what it knows without asking the system: the fds it knows to be ready, data TLS has already decrypted, or, returning 0, that the sockets have to be polled, for events it may rewrite: a TLS read waiting for its socket to be writable. The wait is sockpoll()'s, which calls _prepoll first and then polls, so that a wait can be made other than with poll() in one place: a client of an event loop is to wait in the loop. Whatever a rewritten wait gets is given to the caller as what it asked for, its chance to try again, and the events it asked for are given back. With no fds sockpoll() sleeps, which WSAPoll() would refuse. TLS remembers what a read or a write it could not do waits for. A read needing to write, or a write to read, was an error which ended the connection, as when TLS 1.3 answers a key update while the socket cannot take more; it now waits for what TLS needs, as one needing what it was asked for always did. Incompatible for plugins, which have to be built again with the same version of 3proxy, the structures they share not kept compatible: - struct sockfuncs has _prepoll(state, fds, nfds) in place of _poll(state, fds, nfds, timeout). A plugin replacing _poll replaces _prepoll: it must not wait, returns the number of fds it set revents of (events then left as they are), 0 for the fds to be polled (with events as it leaves them, revents left to the poll) or -1, and calls the _prepoll it replaced when it has nothing to say itself. - Waiting for sockets is sockpoll(sf, state, fds, nfds, timeout), not so._poll() of the socket functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
718798c7fc
commit
b4bbcb9e9a
16 files changed
+109
-53
No files matched your search
+1
-1
@@ -355,7 +355,7 @@ fflush(stderr);
|
||||
fds[0].fd = param->remsock;
|
||||
fds[1].fd = param->clisock;
|
||||
fds[0].events = fds[1].events = POLLIN;
|
||||
res = param->srv->so._poll(param->sostate, fds, 2, param->srv->timeouts[CONNECTION_L] * 1000);
|
||||
res = sockpoll(¶m->srv->so, param->sostate, fds, 2, param->srv->timeouts[CONNECTION_L] * 1000);
|
||||
if (res < 1 || fds[1].revents) {
|
||||
res = 460;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user