commit cd717c2d04eee6fc86c5efc8b3012854a1d66902
parent ec2ce4546d68710112f5ebdf61c868163b9bea8e
Author: Erik Agsjö <erik.agsjo@gmail.com>
Date: Sun, 17 Sep 2023 22:07:28 +0200
Improved linux scheduling
Diffstat:
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/naett.c b/naett.c
@@ -836,10 +836,21 @@ static void* curlWorker(void* data) {
panic("CURL processing failure");
}
+ struct CURLMsg* message = curl_multi_info_read(mc, &messagesLeft);
+ if (message && message->msg == CURLMSG_DONE) {
+ CURL* handle = message->easy_handle;
+ InternalResponse* res = NULL;
+ curl_easy_getinfo(handle, CURLINFO_PRIVATE, (char**)&res);
+ curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &res->code);
+ res->complete = 1;
+ curl_easy_cleanup(handle);
+ }
+
+
int readyFDs = 0;
- curl_multi_wait(mc, &readFd, 1, 1000, &readyFDs);
+ curl_multi_wait(mc, &readFd, 1, 1, &readyFDs);
- if (readyFDs == 0) {
+ if (readyFDs == 0 && activeHandles == 0 && messagesLeft == 0) {
usleep(100 * 1000);
}
@@ -851,16 +862,6 @@ static void* curlWorker(void* data) {
curl_multi_add_handle(mc, newHandle.handle);
newHandlePos = 0;
}
-
- struct CURLMsg* message = curl_multi_info_read(mc, &messagesLeft);
- if (message && message->msg == CURLMSG_DONE) {
- CURL* handle = message->easy_handle;
- InternalResponse* res = NULL;
- curl_easy_getinfo(handle, CURLINFO_PRIVATE, (char**)&res);
- curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &res->code);
- res->complete = 1;
- curl_easy_cleanup(handle);
- }
}
return NULL;
diff --git a/src/naett_linux.c b/src/naett_linux.c
@@ -38,10 +38,21 @@ static void* curlWorker(void* data) {
panic("CURL processing failure");
}
+ struct CURLMsg* message = curl_multi_info_read(mc, &messagesLeft);
+ if (message && message->msg == CURLMSG_DONE) {
+ CURL* handle = message->easy_handle;
+ InternalResponse* res = NULL;
+ curl_easy_getinfo(handle, CURLINFO_PRIVATE, (char**)&res);
+ curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &res->code);
+ res->complete = 1;
+ curl_easy_cleanup(handle);
+ }
+
+
int readyFDs = 0;
- curl_multi_wait(mc, &readFd, 1, 1000, &readyFDs);
+ curl_multi_wait(mc, &readFd, 1, 1, &readyFDs);
- if (readyFDs == 0) {
+ if (readyFDs == 0 && activeHandles == 0 && messagesLeft == 0) {
usleep(100 * 1000);
}
@@ -53,16 +64,6 @@ static void* curlWorker(void* data) {
curl_multi_add_handle(mc, newHandle.handle);
newHandlePos = 0;
}
-
- struct CURLMsg* message = curl_multi_info_read(mc, &messagesLeft);
- if (message && message->msg == CURLMSG_DONE) {
- CURL* handle = message->easy_handle;
- InternalResponse* res = NULL;
- curl_easy_getinfo(handle, CURLINFO_PRIVATE, (char**)&res);
- curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &res->code);
- res->complete = 1;
- curl_easy_cleanup(handle);
- }
}
return NULL;