summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2023-04-27 16:27:55 +0200
committerDaniel Stenberg <daniel@haxx.se>2023-04-28 16:27:45 +0200
commitda9d9c3d1ccaa4522882c4fc81e5375770c09637 (patch)
tree5c296032e0660ed935e4fd71e508b28d75eacfc5
parenta9b7f72bc999f2e3c40607edd6974fd240966a08 (diff)
downloadcurl-da9d9c3d1ccaa4522882c4fc81e5375770c09637.tar.gz
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
-rw-r--r--lib/multi.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/multi.c b/lib/multi.c
index 441435628..5fcb20fa6 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;