From: Daniel Stenberg Date: Thu, 27 Apr 2023 14:27:55 +0000 (+0200) Subject: multi: add multi-ignore logic to multi_socket_action X-Git-Tag: curl-8_1_0~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da9d9c3d1ccaa4522882c4fc81e5375770c09637;p=thirdparty%2Fcurl.git multi: add multi-ignore logic to multi_socket_action The multi-ignore logic that was previously applied to curl_multi_perform() (#10750) is here applied to the loop within curl_multi_socket_action() to make it use the same optimization: most handles have the same signal-ignore option state so this drastically reduces the number of ignore/unignore calls per libcurl function invoke. Follow-up to bc90308328afb8 Closes #11045 --- diff --git a/lib/multi.c b/lib/multi.c index 4414356288..5fcb20fa61 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -3180,6 +3180,9 @@ static CURLMcode multi_socket(struct Curl_multi *multi, struct Curl_easy *data = NULL; struct Curl_tree *t; struct curltime now = Curl_now(); + bool first = FALSE; + bool nosig = FALSE; + SIGPIPE_VARIABLE(pipe_st); if(checkall) { /* *perform() deals with running_handles on its own */ @@ -3254,18 +3257,24 @@ static CURLMcode multi_socket(struct Curl_multi *multi, do { /* the first loop lap 'data' can be NULL */ if(data) { - SIGPIPE_VARIABLE(pipe_st); - - sigpipe_ignore(data, &pipe_st); + if(!first) { + first = TRUE; + nosig = data->set.no_signal; /* initial state */ + sigpipe_ignore(data, &pipe_st); + } + else if(data->set.no_signal != nosig) { + sigpipe_restore(&pipe_st); + sigpipe_ignore(data, &pipe_st); + nosig = data->set.no_signal; /* remember new state */ + } result = multi_runsingle(multi, &now, data); - sigpipe_restore(&pipe_st); if(CURLM_OK >= result) { /* get the socket(s) and check if the state has been changed since last */ result = singlesocket(multi, data); if(result) - return result; + break; } } @@ -3279,6 +3288,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi, } } while(t); + if(first) + sigpipe_restore(&pipe_st); *running_handles = multi->num_alive; return result;