summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-22 09:27:13 -0500
committerDan McGee <dan@archlinux.org>2011-08-22 09:27:13 -0500
commit762cbf574b66ccbe6d4931e426b6d9e95b191bd5 (patch)
tree6472226cd663f7db8b554a0181fdbbec861f21f7
parentf3e285862143c09bc846fd62992cddd24aefd37e (diff)
downloadpacman-762cbf574b66ccbe6d4931e426b6d9e95b191bd5.tar.xz
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 <dan@archlinux.org>
-rw-r--r--lib/libalpm/dload.c13
1 files 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;