From 762cbf574b66ccbe6d4931e426b6d9e95b191bd5 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 22 Aug 2011 09:27:13 -0500 Subject: dload: prevent need to copy struct in mask_signal() Since we store this directly in the download function, just rework mask_signal() to take a pointer to a location to store the original. Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 586e94f4..8387ae6f 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -220,18 +220,17 @@ static void curl_set_handle_opts(struct dload_payload *payload, } } -static struct sigaction mask_signal(int signal, void (*handler)(int)) +static void mask_signal(int signal, void (*handler)(int), + struct sigaction *origaction) { - struct sigaction newaction, origaction; + struct sigaction newaction; newaction.sa_handler = handler; sigemptyset(&newaction.sa_mask); newaction.sa_flags = 0; - sigaction(signal, NULL, &origaction); + sigaction(signal, NULL, origaction); sigaction(signal, &newaction, NULL); - - return origaction; } static void unmask_signal(int signal, struct sigaction sa) @@ -319,8 +318,8 @@ static int curl_download_internal(struct dload_payload *payload, /* ignore any SIGPIPE signals- these may occur if our FTP socket dies or * something along those lines. Store the old signal handler first. */ - orig_sig_pipe = mask_signal(SIGPIPE, SIG_IGN); - orig_sig_int = mask_signal(SIGINT, &inthandler); + mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe); + mask_signal(SIGINT, &inthandler, &orig_sig_int); /* Progress 0 - initialize */ prevprogress = 0; -- cgit v1.2.3-70-g09d2