mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Event loop: what is due called when waiting fails; units on Windows
looponce() called nothing due when waiting for the sockets failed, returning at once: a caller waiting for a timer turned forever. What is due is called all the same, and on Windows WSAEINTR is no failure, not errno. looptest reports any failure to wait with its error; fibertest starts Winsock, its loop could not be made without, and recurses into half of a fiber's stack rather than most of it, which Windows takes more of. The units case shows what a test which never finished wrote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e1455b419
commit
30f6043160
4 files changed
+54
-17
No files matched your search
+11
-3
@@ -234,7 +234,7 @@ static unsigned deepresult;
|
||||
|
||||
static void deeper(void *arg){
|
||||
fiberyield();
|
||||
deepresult = deep(150);
|
||||
deepresult = deep(100);
|
||||
}
|
||||
|
||||
static void depth(void){
|
||||
@@ -243,7 +243,7 @@ static void depth(void){
|
||||
if(fiberinit(&f, STACK)) return;
|
||||
fiberstart(&f, deeper, NULL);
|
||||
while(fiberresume(&f));
|
||||
check(deepresult == deep(150), "a fiber uses most of its stack", "wrong result");
|
||||
check(deepresult == deep(100), "a fiber uses half of its stack", "wrong result");
|
||||
fiberfree(&f);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,10 @@ static void onloop(void){
|
||||
int i, left, early = 0;
|
||||
char what[64];
|
||||
|
||||
if(loopinit(&l)) return;
|
||||
if(loopinit(&l)){
|
||||
check(0, "fibers sleep on the loop's timers", "loopinit() failed");
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < NWAIT; i++){
|
||||
memset(w + i, 0, sizeof(w[i]));
|
||||
if(fiberinit(&w[i].f, STACK)) return;
|
||||
@@ -306,6 +309,11 @@ static void onloop(void){
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
#ifdef _WIN32
|
||||
WSADATA wd;
|
||||
|
||||
WSAStartup(MAKEWORD(2, 2), &wd);
|
||||
#endif
|
||||
if(!fiberusable()){
|
||||
printf("ok fibers cannot be used here (a shadow stack): each client has a thread\n");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user