A client's sleeps wait in sockpoll()

The bandwidth limiter between HTTP requests and httpsrv's delay slept
with usleep(); they are waits of sockpoll() with no fds, to be made
other than by sleeping once a client is served by an event loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-24 20:34:32 +03:00
parent df993b5304
commit bfd812f0b8
2 changed files with 4 additions and 8 deletions

View File

@ -17,6 +17,7 @@
*/ */
#include "proxy.h" #include "proxy.h"
#include <limits.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -1022,13 +1023,8 @@ static int op_data(struct httpreq *r, const unsigned char *params)
httpsrv_fill(buf, len, sent); httpsrv_fill(buf, len, sent);
if(delay > 0){ if(delay > 0) sockpoll(&r->param->srv->so, r->param->sostate, NULL, 0,
#ifdef _WIN32 (delay > INT_MAX)? INT_MAX : (int)delay);
usleep(delay);
#else
usleep(delay * 1000);
#endif
}
if(chunked){ if(chunked){
if(httpchunk(r->param, buf, len)) return 1; if(httpchunk(r->param, buf, len)) return 1;

View File

@ -1466,7 +1466,7 @@ for(;;){
if(st1 > sleeptime) sleeptime = st1; if(st1 > sleeptime) sleeptime = st1;
if(sleeptime > 0){ if(sleeptime > 0){
/* if(sleeptime > 30) sleeptime = 30; */ /* if(sleeptime > 30) sleeptime = 30; */
usleep(sleeptime * SLEEPTIME); sockpoll(&param->srv->so, param->sostate, NULL, 0, sleeptime);
} }
} }
buf[inbuf] = 0; buf[inbuf] = 0;