From aa4aae58b201f91a39f979845374f4f8262dca81 Mon Sep 17 00:00:00 2001 From: Fufu Fang Date: Tue, 3 Sep 2019 22:54:03 +0100 Subject: [PATCH] Added volatile into a variable, based on advice from andyhhp from SRCF. [22:40] curl_process_msgs()'s use of "static int slept" is dangerous and racy. an optimising compiler can and probably will do bad things [22:45] with respect to "static int slept", should i just put a volatile in front of it? So "volatile static int slept"? [22:46] I meant "static volatile int slept;" [22:47] lets say yes for the sake of argument [22:47] "its complicated" [22:47] but that will broadly do what you want --- src/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.c b/src/network.c index 3656a3e..1e98295 100644 --- a/src/network.c +++ b/src/network.c @@ -107,7 +107,7 @@ static void curl_process_msgs(CURLMsg *curl_msg, int n_running_curl, { (void) n_running_curl; (void) n_mesgs; - static int slept = 0; + static volatile int slept = 0; if (curl_msg->msg == CURLMSG_DONE) { TransferStruct *transfer; CURL *curl = curl_msg->easy_handle;