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 bc90308328
Closes #11045
This commit is contained in:
parent
a9b7f72bc9
commit
da9d9c3d1c
21
lib/multi.c
21
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user