From bfd812f0b8c5d9691ae364ecf2aa2b09b4fc0a2a Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Sat, 24 Oct 2026 20:34:32 +0300 Subject: [PATCH] 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 --- src/httpsrv.c | 10 +++------- src/proxy.c | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/httpsrv.c b/src/httpsrv.c index 559536c..3b135ba 100644 --- a/src/httpsrv.c +++ b/src/httpsrv.c @@ -17,6 +17,7 @@ */ #include "proxy.h" +#include #include #include @@ -1022,13 +1023,8 @@ static int op_data(struct httpreq *r, const unsigned char *params) httpsrv_fill(buf, len, sent); - if(delay > 0){ -#ifdef _WIN32 - usleep(delay); -#else - usleep(delay * 1000); -#endif - } + if(delay > 0) sockpoll(&r->param->srv->so, r->param->sostate, NULL, 0, + (delay > INT_MAX)? INT_MAX : (int)delay); if(chunked){ if(httpchunk(r->param, buf, len)) return 1; diff --git a/src/proxy.c b/src/proxy.c index 8f8ef71..257485e 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1466,7 +1466,7 @@ for(;;){ if(st1 > sleeptime) sleeptime = st1; if(sleeptime > 0){ /* if(sleeptime > 30) sleeptime = 30; */ - usleep(sleeptime * SLEEPTIME); + sockpoll(¶m->srv->so, param->sostate, NULL, 0, sleeptime); } } buf[inbuf] = 0;