Added volatile into a variable, based on advice from andyhhp from SRCF.

[22:40] <andyhhp> 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] <ff266> with respect to "static int slept", should i just put a volatile in front of it? So "volatile static int slept"?
[22:46] <ff266> I meant "static volatile int slept;"
[22:47] <andyhhp> lets say yes for the sake of argument
[22:47] <andyhhp> "its complicated"
[22:47] <andyhhp> but that will broadly do what you want
This commit is contained in:
Fufu Fang 2019-09-03 22:54:03 +01:00
parent 79004cb7ee
commit aa4aae58b2
No known key found for this signature in database
GPG Key ID: 0F6BB5EF6F8BB729
1 changed files with 1 additions and 1 deletions

View File

@ -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;