From patchwork Sat Jan 28 21:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3017 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp2213239dyk; Sat, 28 Jan 2023 13:59:42 -0800 (PST) X-Google-Smtp-Source: AK7set9KVZxPIg8+xnF4IqrV2Ss0hyc7UEam9xWdh7Nijkp5gOrWlO84lRPldj7C2CHgGpRb+f0m X-Received: by 2002:a05:6a20:6982:b0:bc:3e0d:7ac6 with SMTP id t2-20020a056a20698200b000bc3e0d7ac6mr7052021pzk.16.1674943182718; Sat, 28 Jan 2023 13:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674943182; cv=none; d=google.com; s=arc-20160816; b=tH+5qmFGUEcNBrr/qLpTBWT/VtfaoOx+wFrwHSFd+C5PVQG50maV9O31DnHoIyzbJs NGTs2T+HE2CjBdpBjapU556jHs5Yr+xKs3w8Z5zuXUW5z3TuuMjPbtF6StRCZ6TQmxo+ it8ji6oV9PtmXsyHd/qFXTybikKplyubLXl0k/eqK5C6CMdKfzPI4g3DwpVHhNaA/y+x Or8VvQ3CPjQ6Kqo+n/3mEtTfYqoBq2jD9yawlq98Ip3rNyRNfILAslU/dSAdUS0F9Z+n ZbnDE2ejMAkHfUKeMfWHxuKZFwfTT+PdNdoWebxRpxd6dW02Ldaq6HWBT3SjWJ+lwlY5 N6OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=geZaPq6+7AHKoBWhCEiV5Mx+X/iIS9D6Bh4pNnyQQDs=; b=f/C3PknUzivWx1BUu+dFJdfD2S2eMLnhI7PShluJA7H9ypCXCo+l7awTVIaiFtF74Z umS8at8Kb3WESJUOIUplpVo99Og3JG6TSte1EDZVa4JCtc1RxiqADqtw1YPpnRC+z8ZB 2PjeFLaamoCkSpsw1N/1P3BysBYOno+PVnxbgjVnGAyD1ipX2l6H6ltZ/WysfXW9hfgh kQqeDtj8PSLeWQaCEzZE0A9oHANQ4m3EpdvGQe4VSYvtt1kvfik+W14BjyqlqiwTqc75 YVnxSlMo9I3JR4Q1PPlx2fqPZ0UbfBgggh/0vkXLJL7lZTPTbJomAbCUoKBb6Vy6+KS4 M75g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=hHcjAYmf; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="QiAhoF/Q"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=KDPSC+B0; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id s17-20020a63af51000000b00478ae301535si8327953pgo.532.2023.01.28.13.59.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jan 2023 13:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=hHcjAYmf; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="QiAhoF/Q"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=KDPSC+B0; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pLtEE-00085v-NQ; Sat, 28 Jan 2023 21:59:17 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pLtED-00085p-OB for openvpn-devel@lists.sourceforge.net; Sat, 28 Jan 2023 21:59:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6M9WBu4zrUGWYEwGfQdrC5uWc9h2/o/MMeWe7PWj1A4=; b=hHcjAYmfePocKLa+7n882+vwtz 0Do2Job/E/kPO0wfYlw0UkM4f0pRs4Y73kjaU5C2IdPUzxRyFN2u7K1Z5773izSGywjx2BboZUyTz ixJ8aHOZAdTIOdFcyp4b1e50bksa3Cn44iBGAi77pOeCIlSCcj8GKBJDsADCvACHbkfQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=6M9WBu4zrUGWYEwGfQdrC5uWc9h2/o/MMeWe7PWj1A4=; b=Q iAhoF/Q4L58wpAazYzDJoTf0smBhy8S7Q4TjHlAyRmnkwZhNvN/l2IpcfARLrnIeS5rM2KuW32UAC vlTwtqEjAhTzBwOMBzSVbV1zErBI5TcPPc/MHZQUhNkAjWQx7q1AN3UFzMLDVToxTwkWkOGmJbbRX 6mnQi6sGsotUztlE=; Received: from mail-il1-f171.google.com ([209.85.166.171]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pLtE6-000491-Tb for openvpn-devel@lists.sourceforge.net; Sat, 28 Jan 2023 21:59:16 +0000 Received: by mail-il1-f171.google.com with SMTP id z2so3173500ilq.2 for ; Sat, 28 Jan 2023 13:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6M9WBu4zrUGWYEwGfQdrC5uWc9h2/o/MMeWe7PWj1A4=; b=KDPSC+B0x7quqeIYBrZV6AE38gpBjvCVPT/ZzwIS1/Y5f26m9L9LZDedZ/Ok76CG6y jjRZ2Q26BcsGP3lTDRgjMMcT1TG+MloaePAbB6tQGyoWdY43LWE7hiwlcV/zKG1qUgLa o/prLYgJmtzRfahc5okZH2oudYkIZIikPFrPvCBpGOeQHSm//AeKAZ4dqX+N/nNLbEvl NYMVv7U9SJMo6fzRcZr2zEycju9aWEoumTWsHVVIYr8qVdBSHq8JzCVgbPPxQNNBQk+N Ae4ssaTiyAI4SXfe02kOYVml1+1nTYTsxPmaxUozVN0azdL583gTcxm9FcrkRft2Mq/d +gBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6M9WBu4zrUGWYEwGfQdrC5uWc9h2/o/MMeWe7PWj1A4=; b=cDlDv4rfAkiL32fcEXPr1Eh0dKCHrXoVg21dQf8epnlizeBk8N2WAV3qnmegdk/UP3 rp9/CSZrU6kxD5C+qINq4DRGPLn9B6tJjzbc3CEwN5vbG97gQLKgAivyeuYQMxJMYlUy P49i39UhhDR+BvMoPKeAm+2HB9DlhBO8Y8EwGRAL6hNJxzAza8rTOUmhZfz/05/evvVx CtyaYopLQqMLmk6CYTTShi6evAFdoAurr9r2o4mDkJ+uBWBJU+Ee7zEu8G8yxZhF5R91 rxgRn3pmqaxJVPSixJdvwpFFoDqZtLQ2hjUrFbXVRt8cxVftjVo/ybkI6aqK/WdycXJo u3kg== X-Gm-Message-State: AO0yUKXgtnceRvLFsadVl7OTMNR9XkS83Tfm3Q76oMGLODy6fjQhKTQG J4HWYx6+eaIMrvFR6tuZNhplYVnw4CU= X-Received: by 2002:a05:6e02:1d05:b0:310:cc70:a152 with SMTP id i5-20020a056e021d0500b00310cc70a152mr1367652ila.2.1674943145663; Sat, 28 Jan 2023 13:59:05 -0800 (PST) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-66.dsl.bell.ca. [70.51.222.66]) by smtp.gmail.com with ESMTPSA id v20-20020a056e0213d400b00310ce3dd5b1sm1636493ilj.60.2023.01.28.13.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 13:59:05 -0800 (PST) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Sat, 28 Jan 2023 16:59:00 -0500 Message-Id: <20230128215901.2207208-1-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Selva Nair Currently we use the old signal API which follows system-V or BSD semantics depending on the platform and/or feature-set macros. Further, signal has many weaknesses which makes proper masking (deferri [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.171 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.171 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1pLtE6-000491-Tb Subject: [Openvpn-devel] [PATCH 1/2] Improve signal handling using POSIX sigaction X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1756305222442036984?= X-GMAIL-MSGID: =?utf-8?q?1756305222442036984?= From: Selva Nair Currently we use the old signal API which follows system-V or BSD semantics depending on the platform and/or feature-set macros. Further, signal has many weaknesses which makes proper masking (deferring) of signals during update not possible. Improve this: - Use sigaction to properly mask signals when modifying. Notes: Updating signal_reset() is handled in a follow up patch SIG_SOURCE_CONNECTION_FAILED is retained in a hackish way. This value has the same meaning as SIG_SOURCE_SOFT everywhere except where the signal is printed. Looks cosmetic --- could be eliminated? In pre_init_signal_catch() we ignore some unix signals, but the same signals from management are not ignored though both are treated as "HARD" signals. For example, during auth-user-pass query, "kill -SIGUSR1 " will be ignored, but "signal SIGUSR1" from management interface will cause M_FATAL and exit. This is the current behaviour, but could be improved? This patch was originally submitted as 5/5 of the signals series. Now this is 1/2 of a new series with signal_reset changes moved to 2/2 Signed-off-by: Selva Nair Acked-By: Frank Lichtenheld --- src/openvpn/errlevel.h | 1 + src/openvpn/sig.c | 264 +++++++++++++++++++++++++++++++---------- src/openvpn/socket.c | 1 - 3 files changed, 202 insertions(+), 64 deletions(-) diff --git a/src/openvpn/errlevel.h b/src/openvpn/errlevel.h index c69ea91d..dedc0790 100644 --- a/src/openvpn/errlevel.h +++ b/src/openvpn/errlevel.h @@ -115,6 +115,7 @@ #define D_CLIENT_NAT LOGLEV(6, 69, M_DEBUG) /* show client NAT debug info */ #define D_XKEY LOGLEV(6, 69, M_DEBUG) /* show xkey-provider debug info */ #define D_DCO_DEBUG LOGLEV(6, 69, M_DEBUG) /* show DCO related lowlevel debug messages */ +#define D_SIGNAL_DEBUG LOGLEV(6, 69, M_DEBUG) /* show signal related debug messages */ #define D_SHOW_KEYS LOGLEV(7, 70, M_DEBUG) /* show data channel encryption keys */ #define D_SHOW_KEY_SOURCE LOGLEV(7, 70, M_DEBUG) /* show data channel key source entropy */ diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c index 0d534601..559ca35d 100644 --- a/src/openvpn/sig.c +++ b/src/openvpn/sig.c @@ -6,6 +6,7 @@ * packet compression. * * Copyright (C) 2002-2023 OpenVPN Inc + * Copyright (C) 2016-2023 Selva Nair * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -60,6 +61,9 @@ static const struct signame signames[] = { { SIGUSR2, 1, "SIGUSR2", "sigusr2" } }; +/* mask for hard signals from management or windows */ +static unsigned long long ignored_hard_signals_mask; + int parse_signal(const char *signame) { @@ -114,24 +118,144 @@ signal_description(const int signum, const char *sigtext) } } +/** + * Block (i.e., defer) all unix signals. + * Used while directly modifying the volatile elements of + * siginfo_static. + */ +static inline void +block_async_signals(void) +{ +#ifndef _WIN32 + sigset_t all; + sigfillset(&all); /* all signals */ + sigprocmask(SIG_BLOCK, &all, NULL); +#endif +} + +/** + * Unblock all unix signals. + */ +static inline void +unblock_async_signals(void) +{ +#ifndef _WIN32 + sigset_t none; + sigemptyset(&none); + sigprocmask(SIG_SETMASK, &none, NULL); +#endif +} + +/** + * Private function for registering a signal in the specified + * signal_info struct. This could be the global siginfo_static + * or a context specific signinfo struct. + * + * A signal is allowed to override an already registered + * one only if it has a higher priority. + * Returns true if the signal is set, false otherwise. + * + * Do not call any "AS-unsafe" functions such as printf from here + * as this may be called from signal_handler(). + */ +static bool +try_throw_signal(struct signal_info *si, int signum, int source) +{ + bool ret = false; + if (signal_priority(signum) >= signal_priority(si->signal_received)) + { + si->signal_received = signum; + si->source = source; + ret = true; + } + return ret; +} + +/** + * Throw a hard signal. Called from management and when windows + * signals are received through ctrl-c, exit event etc. + */ void throw_signal(const int signum) { - if (signal_priority(signum) >= signal_priority(siginfo_static.signal_received)) + if (ignored_hard_signals_mask & (1LL << signum)) + { + msg(D_SIGNAL_DEBUG, "Signal %s is currently ignored", signal_name(signum, true)); + return; + } + block_async_signals(); + + if (!try_throw_signal(&siginfo_static, signum, SIG_SOURCE_HARD)) { - siginfo_static.signal_received = signum; - siginfo_static.source = SIG_SOURCE_HARD; + msg(D_SIGNAL_DEBUG, "Ignoring %s when %s has been received", signal_name(signum, true), + signal_name(siginfo_static.signal_received, true)); } + else + { + msg(D_SIGNAL_DEBUG, "Throw signal (hard): %s ", signal_name(signum, true)); + } + + unblock_async_signals(); } +/** + * Throw a soft global signal. Used to register internally generated signals + * due to errors that require a restart or exit, or restart requests + * received from the server. A textual description of the signal may + * be provided. + */ void throw_signal_soft(const int signum, const char *signal_text) { - if (signal_priority(signum) >= signal_priority(siginfo_static.signal_received)) + block_async_signals(); + + if (try_throw_signal(&siginfo_static, signum, SIG_SOURCE_SOFT)) { - siginfo_static.signal_received = signum; - siginfo_static.source = SIG_SOURCE_SOFT; siginfo_static.signal_text = signal_text; + msg(D_SIGNAL_DEBUG, "Throw signal (soft): %s (%s)", signal_name(signum, true), + signal_text); + } + else + { + msg(D_SIGNAL_DEBUG, "Ignoring %s when %s has been received", signal_name(signum, true), + signal_name(siginfo_static.signal_received, true)); + } + + unblock_async_signals(); +} + +/** + * Register a soft signal in the signal_info struct si respecting priority. + * si may be a pointer to the global siginfo_static or a context-specific + * signal in a multi-instance or a temporary variable. + */ +void +register_signal(struct signal_info *si, int signum, const char *signal_text) +{ + if (si == &siginfo_static) /* attempting to alter the global signal */ + { + block_async_signals(); + } + + if (try_throw_signal(si, signum, SIG_SOURCE_SOFT)) + { + si->signal_text = signal_text; + if (signal_text && strcmp(signal_text, "connection-failed") == 0) + { + si->source = SIG_SOURCE_CONNECTION_FAILED; + } + msg(D_SIGNAL_DEBUG, "register signal: %s (%s)", signal_name(signum, true), + signal_text); + } + else + { + msg(D_SIGNAL_DEBUG, "Ignoring %s when %s has been received", signal_name(signum, true), + signal_name(si->signal_received, true)); + } + + if (si == &siginfo_static) + { + unblock_async_signals(); } } @@ -239,12 +363,10 @@ signal_restart_status(const struct signal_info *si) static void signal_handler(const int signum) { - throw_signal(signum); - signal(signum, signal_handler); + try_throw_signal(&siginfo_static, signum, SIG_SOURCE_HARD); } #endif - /* set handlers for unix signals */ #define SM_UNDEF 0 @@ -256,13 +378,24 @@ void pre_init_signal_catch(void) { #ifndef _WIN32 + sigset_t block_mask; + struct sigaction sa; + CLEAR(sa); + + sigfillset(&block_mask); /* all signals */ + sa.sa_handler = signal_handler; + sa.sa_mask = block_mask; /* signals blocked inside the handler */ + sa.sa_flags = SA_RESTART; /* match with the behaviour of signal() on Linux and BSD */ + signal_mode = SM_PRE_INIT; - signal(SIGINT, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGHUP, SIG_IGN); - signal(SIGUSR1, SIG_IGN); - signal(SIGUSR2, SIG_IGN); - signal(SIGPIPE, SIG_IGN); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + sa.sa_handler = SIG_IGN; + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); + sigaction(SIGUSR2, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); #endif /* _WIN32 */ } @@ -270,14 +403,38 @@ void post_init_signal_catch(void) { #ifndef _WIN32 + sigset_t block_mask; + struct sigaction sa; + CLEAR(sa); + + sigfillset(&block_mask); /* all signals */ + sa.sa_handler = signal_handler; + sa.sa_mask = block_mask; /* signals blocked inside the handler */ + sa.sa_flags = SA_RESTART; /* match with the behaviour of signal() on Linux and BSD */ + signal_mode = SM_POST_INIT; - signal(SIGINT, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGHUP, signal_handler); - signal(SIGUSR1, signal_handler); - signal(SIGUSR2, signal_handler); - signal(SIGPIPE, SIG_IGN); -#endif + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); + sigaction(SIGUSR2, &sa, NULL); + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); +#endif /* _WIN32 */ +} + +void +halt_low_priority_signals() +{ +#ifndef _WIN32 + struct sigaction sa; + CLEAR(sa); + sa.sa_handler = SIG_IGN; + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); + sigaction(SIGUSR2, &sa, NULL); +#endif /* _WIN32 */ + ignored_hard_signals_mask = (1LL << SIGHUP) | (1LL << SIGUSR1) | (1LL << SIGUSR2); } /* called after daemonization to retain signal settings */ @@ -341,7 +498,6 @@ print_status(const struct context *c, struct status_output *so) gc_free(&gc); } - /* Small helper function to determine if we should send the exit notification * via control channel */ static inline bool @@ -371,8 +527,15 @@ process_explicit_exit_notification_init(struct context *c) event_timeout_init(&c->c2.explicit_exit_notification_interval, 1, 0); reset_coarse_timers(c); - signal_reset(c->sig); + /* Windows exit event will continue trigering SIGTERM -- halt it */ halt_non_edge_triggered_signals(); + + /* Before resetting the signal, ensure hard low priority signals + * will be ignored during the exit notification period. + */ + halt_low_priority_signals(); /* Set hard SIGUSR1/SIGHUP/SIGUSR2 to be ignored */ + signal_reset(c->sig); + c->c2.explicit_exit_notification_time_wait = now; /* Check if we are in TLS mode and should send the notification via data @@ -439,33 +602,21 @@ process_sigterm(struct context *c) } /** - * If a restart signal is received during exit-notification, reset the - * signal and return true. If its a soft restart signal from the event loop - * which implies the loop cannot continue, remap to SIGTERM to exit promptly. + * If a soft restart signal is received during exit-notification, it + * implies the event loop cannot continue: remap to SIGTERM to exit promptly. + * Hard restart signals are ignored during exit notification wait. */ -static bool -ignore_restart_signals(struct context *c) +static void +remap_restart_signals(struct context *c) { - bool ret = false; - if ( (c->sig->signal_received == SIGUSR1 || c->sig->signal_received == SIGHUP) - && event_timeout_defined(&c->c2.explicit_exit_notification_interval) ) + if ((c->sig->signal_received == SIGUSR1 || c->sig->signal_received == SIGHUP) + && event_timeout_defined(&c->c2.explicit_exit_notification_interval) + && c->sig->source != SIG_SOURCE_HARD) { - if (c->sig->source == SIG_SOURCE_HARD) - { - msg(M_INFO, "Ignoring %s received during exit notification", - signal_name(c->sig->signal_received, true)); - signal_reset(c->sig); - ret = true; - } - else - { - msg(M_INFO, "Converting soft %s received during exit notification to SIGTERM", - signal_name(c->sig->signal_received, true)); - register_signal(c->sig, SIGTERM, "exit-with-notification"); - ret = false; - } + msg(M_INFO, "Converting soft %s received during exit notification to SIGTERM", + signal_name(c->sig->signal_received, true)); + register_signal(c->sig, SIGTERM, "exit-with-notification"); } - return ret; } bool @@ -473,11 +624,9 @@ process_signal(struct context *c) { bool ret = true; - if (ignore_restart_signals(c)) - { - ret = false; - } - else if (c->sig->signal_received == SIGTERM || c->sig->signal_received == SIGINT) + remap_restart_signals(c); + + if (c->sig->signal_received == SIGTERM || c->sig->signal_received == SIGINT) { ret = process_sigterm(c); } @@ -488,14 +637,3 @@ process_signal(struct context *c) } return ret; } - -void -register_signal(struct signal_info *si, int sig, const char *text) -{ - if (signal_priority(sig) >= signal_priority(si->signal_received)) - { - si->signal_received = sig; - si->signal_text = text; - si->source = SIG_SOURCE_SOFT; - } -} diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index a883ac4a..baafe1e6 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1588,7 +1588,6 @@ socket_connect(socket_descriptor_t *sd, openvpn_close_socket(*sd); *sd = SOCKET_UNDEFINED; register_signal(sig_info, SIGUSR1, "connection-failed"); - sig_info->source = SIG_SOURCE_CONNECTION_FAILED; } else { From patchwork Sat Jan 28 21:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3016 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp2213232dyk; Sat, 28 Jan 2023 13:59:42 -0800 (PST) X-Google-Smtp-Source: AK7set/jaJtaBLFMwnWabBBE6yiWu/R8CH1d3fGwkOxBngTsVtmibw0m+tTtSG3REJNUM0/W1l3a X-Received: by 2002:a17:902:dacf:b0:196:2bf1:b68d with SMTP id q15-20020a170902dacf00b001962bf1b68dmr17170136plx.14.1674943181996; Sat, 28 Jan 2023 13:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674943181; cv=none; d=google.com; s=arc-20160816; b=Au0zpKBYWxkozkCiMmdEth+MgH9qeXgW/NE1YTDpplIKPH17BH3ZcHQ7CtEJbDc0Br +vlJJdVoFDNu8R7qur8yZGLx8QuYR7vfDunvvbAY7au1nou83dSSgfHgV0xcrXohMfyq QvJRrKKt9HsvFq82A5in/TxPIBEipfk81ZZ0sEkVMcvuwrvbsuTFRx3eV/+4sAB1Cvor v2qO/us8rzu1r4cVDm0yepRejeApNTBKwynz80Tc3B8iDrTVG3cOMC7c6I8xkh1HV0Rr QBzxBhR6QkdjsbekLO8OiUZ8Vd1xX5mYfoG6boe4MhFCZdy+TKEA5ucEbfPb/3REwFny cZ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=70yRMn+tQYA55qUi7ZaxeK2ZP4QdAF+lmdAI+Or0+28=; b=vwnXHVPOD0jspAlT6Ww7rzyV1Zj63ZnOtJWz3HA3JQHPy9Wu6sVD+0VHtF4xviatvw pwVWjZGTQhPEx/l7fShMDaRnk28oxjNNGeCi6wPTJunlb/RZGr4nYI/VPmyJhFhW8kQm OGntlYvbFsDFygp8ndYxKecwko+DY8QmZdc9EAy40a1TObbwDvOHLiPZfd3uFaQl/BcJ ZTaw6cHHaBUx6HXTMDoX1RXJrrdy9INuMdcNDx+O8bgcaZpmaATC4CH16nAx0dbNKb2I TxFIUNMtoLQWbbGX8R4rovCS2Ht6cB5XzzMFV/KNBABjcwz52gC4XrL+nybUP0upqC/f WBEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=aW6QJPny; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=CPkuKYmi; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=gn8qOI2g; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a6-20020a170902900600b00194a2577abdsi8349550plp.338.2023.01.28.13.59.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jan 2023 13:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=aW6QJPny; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=CPkuKYmi; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=gn8qOI2g; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pLtEF-00013Q-2b; Sat, 28 Jan 2023 21:59:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pLtED-00013J-Nv for openvpn-devel@lists.sourceforge.net; Sat, 28 Jan 2023 21:59:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=a5m7MHn4gOYHJPZW/borIHpue+cdAKONdXdl0kbUgg8=; b=aW6QJPnySyxLH3ihoW3JhmD5YA ctBahNeXgjQS5lSkFC6Bt+b8NQFE/AfFKl6gVBV5jjgylEas9VujSgBPiz4ljlYSLQsRytLrAgMh7 C8Y04o4M1FxxN7j0jC13my0YLLOCvwOmfqWS/dYPLi+9bnEmzHe8JPVeGHkA4lJqToPA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=a5m7MHn4gOYHJPZW/borIHpue+cdAKONdXdl0kbUgg8=; b=CPkuKYmi7q4VRmLgGCZgcp83H4 1N5nJOAu2pnBsDzba/kymMoi7JCGffsbkPrkJlGVMM2kCB3rLosXKUk5yzUdsLza9TUtyZ5FAnTkL ZocTfH6zb2yZBIkF6XIT2k/4deEtQnZ3lEBD6q3eWHESSzp7XZmLjOxuc6Rhdz60nmWI=; Received: from mail-il1-f182.google.com ([209.85.166.182]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pLtE8-000496-5n for openvpn-devel@lists.sourceforge.net; Sat, 28 Jan 2023 21:59:17 +0000 Received: by mail-il1-f182.google.com with SMTP id u8so3736468ilq.13 for ; Sat, 28 Jan 2023 13:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a5m7MHn4gOYHJPZW/borIHpue+cdAKONdXdl0kbUgg8=; b=gn8qOI2gKQIJhkP29YwJOKppVPj0NfV0EwriFsTux2JQhMWNUnk1NW9RwaHjLK04RS hwQi4v6uTLuCILFmikVILwTA0t+SrOIbfQCRpiNm+sLBNGThC3xvcYqg/qgwRk89wIjH ApUH+M3PrM9zxPC4LTjZl5HO+1NKiExeHl81Cb2xtNrUDQAJPnRLeDFjv8qUClVwcF3R mts4ofUvkqxMN+Df6T7Pt7OrhHzGpqEZ9NK0yf+Bxe+sj3YD9oPpqLZ/8ZDTQfxJb73J YzCnEy9KdypbG1fdW0g/2/fPUPgme8VIk0ietj/eC6qv0ObBePRfcwwFKAnzo1XA1ITv JC9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a5m7MHn4gOYHJPZW/borIHpue+cdAKONdXdl0kbUgg8=; b=SBzdbQcRcnX9GNSQ/HsO1nWr1951Fs3JwIv7vBezsc8oNq3gN9gVb1FEqigQEfvrQ3 +qIRACQdK6GHYmiLvRtpUslJQQzrl1hxAYq+WCNVgJZ1C6s+kt2/nNe2IL8Sc+hks3IP amFi4OA9WkKOMKh/MYU9s+Yz35BatycWnllpCsNilVkaE2g5J/xD33c1yz+K1sczksuF vpQp5e/3Xq9BjU5X6n1+S1pA5UTmAxRc/ol5PmhSUsNMIMw+XuibOlnfaHdfpFH7cpA4 AY9RYba6uVnfka6KOYolWYBqYq/ypKFEnrO2ZoWu0UiwAIU+1mckdc31yjkgwKvZ3DjD tyVw== X-Gm-Message-State: AFqh2kpSjNOlHqSPCc5wXTNHUbRF1AvQuDz6DKscPc6OrPyD7bJSQDMV V3STalEVuKba/SZTZOmbBkOc8rLj8hc= X-Received: by 2002:a92:d10:0:b0:30e:f89b:6652 with SMTP id 16-20020a920d10000000b0030ef89b6652mr6147509iln.0.1674943147103; Sat, 28 Jan 2023 13:59:07 -0800 (PST) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-66.dsl.bell.ca. [70.51.222.66]) by smtp.gmail.com with ESMTPSA id v20-20020a056e0213d400b00310ce3dd5b1sm1636493ilj.60.2023.01.28.13.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 13:59:06 -0800 (PST) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Sat, 28 Jan 2023 16:59:01 -0500 Message-Id: <20230128215901.2207208-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128215901.2207208-1-selva.nair@gmail.com> References: <20230128215901.2207208-1-selva.nair@gmail.com> MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Selva Nair - "if (sig == X) signal_reset(sig)" now becomes "signal_reset(sig, X)" so that the check and assignment can be done in one place where signals are masked. This is required to avoid change of signal st [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.182 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.182 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1pLtE8-000496-5n Subject: [Openvpn-devel] [PATCH 2/2] signal_reset(): combine check and reset operations X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1756305222355703759?= X-GMAIL-MSGID: =?utf-8?q?1756305222355703759?= From: Selva Nair - "if (sig == X) signal_reset(sig)" now becomes "signal_reset(sig, X)" so that the check and assignment can be done in one place where signals are masked. This is required to avoid change of signal state between check and reset operations. - Avoid resetting the signal except when absolutely necessary (resetting has the potential of losing signals) - In 'pre_init_signal_catch()', when certain low priority signals are set to SIG_IGN, clear any pending signals of the same type. Also, reset signal at the end of the SIGUSR1 and SIGHUP loops where their values are checked instead of later. This avoids the need for 'signal_reset()' after SIGHUP or in 'init_instance()' which could cause a signal like SIGTERM to be lost. Signed-off-by: Selva Nair Acked-by: Frank Lichtenheld --- src/openvpn/init.c | 3 --- src/openvpn/multi.c | 5 ++--- src/openvpn/openvpn.c | 5 ++--- src/openvpn/sig.c | 40 +++++++++++++++++++++++++++++++++------- src/openvpn/sig.h | 7 ++++++- src/openvpn/socket.c | 5 ++--- src/openvpn/win32.c | 2 +- 7 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index b500d354..76a7be7b 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -4299,9 +4299,6 @@ init_instance(struct context *c, const struct env_set *env, const unsigned int f do_inherit_env(c, env); } - /* signals caught here will abort */ - signal_reset(c->sig); - if (c->mode == CM_P2P) { init_management_callback_p2p(c); diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index f2559016..c52c8f14 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3868,7 +3868,7 @@ multi_push_restart_schedule_exit(struct multi_context *m, bool next_server) &m->deferred_shutdown_signal.wakeup, compute_wakeup_sigma(&m->deferred_shutdown_signal.wakeup)); - signal_reset(m->top.sig); + signal_reset(m->top.sig, 0); } /* @@ -3878,12 +3878,11 @@ multi_push_restart_schedule_exit(struct multi_context *m, bool next_server) bool multi_process_signal(struct multi_context *m) { - if (m->top.sig->signal_received == SIGUSR2) + if (signal_reset(m->top.sig, SIGUSR2) == SIGUSR2) { struct status_output *so = status_open(NULL, 0, M_INFO, NULL, 0); multi_print_status(m, so, m->status_file_version); status_close(so); - signal_reset(m->top.sig); return false; } else if (proto_is_dgram(m->top.options.ce.proto) diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index cba58276..ad0aa8a2 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -194,7 +194,6 @@ openvpn_main(int argc, char *argv[]) context_clear_all_except_first_time(&c); /* static signal info object */ - CLEAR(siginfo_static); c.sig = &siginfo_static; /* initialize garbage collector scoped to context object */ @@ -333,14 +332,14 @@ openvpn_main(int argc, char *argv[]) /* pass restart status to management subsystem */ signal_restart_status(c.sig); } - while (c.sig->signal_received == SIGUSR1); + while (signal_reset(c.sig, SIGUSR1) == SIGUSR1); env_set_destroy(c.es); uninit_options(&c.options); gc_reset(&c.gc); uninit_early(&c); } - while (c.sig->signal_received == SIGHUP); + while (signal_reset(c.sig, SIGHUP) == SIGHUP); } context_gc_free(&c); diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c index 559ca35d..4eead996 100644 --- a/src/openvpn/sig.c +++ b/src/openvpn/sig.c @@ -259,15 +259,37 @@ register_signal(struct signal_info *si, int signum, const char *signal_text) } } -void -signal_reset(struct signal_info *si) +/** + * Clear the signal if its current value equals signum. If + * signum is zero the signal is cleared independent of its current + * value. Returns the current value of the signal. + */ +int +signal_reset(struct signal_info *si, int signum) { + int sig_saved = 0; if (si) { - si->signal_received = 0; - si->signal_text = NULL; - si->source = SIG_SOURCE_SOFT; + if (si == &siginfo_static) /* attempting to alter the global signal */ + { + block_async_signals(); + } + + sig_saved = si->signal_received; + if (!signum || sig_saved == signum) + { + si->signal_received = 0; + si->signal_text = NULL; + si->source = SIG_SOURCE_SOFT; + msg(D_SIGNAL_DEBUG, "signal_reset: signal %s is cleared", signal_name(signum, true)); + } + + if (si == &siginfo_static) + { + unblock_async_signals(); + } } + return sig_saved; } void @@ -397,6 +419,10 @@ pre_init_signal_catch(void) sigaction(SIGUSR2, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); #endif /* _WIN32 */ + /* clear any pending signals of the ignored type */ + signal_reset(&siginfo_static, SIGUSR1); + signal_reset(&siginfo_static, SIGUSR2); + signal_reset(&siginfo_static, SIGHUP); } void @@ -534,7 +560,7 @@ process_explicit_exit_notification_init(struct context *c) * will be ignored during the exit notification period. */ halt_low_priority_signals(); /* Set hard SIGUSR1/SIGHUP/SIGUSR2 to be ignored */ - signal_reset(c->sig); + signal_reset(c->sig, 0); c->c2.explicit_exit_notification_time_wait = now; @@ -585,7 +611,7 @@ process_sigusr2(const struct context *c) struct status_output *so = status_open(NULL, 0, M_INFO, NULL, 0); print_status(c, so); status_close(so); - signal_reset(c->sig); + signal_reset(c->sig, SIGUSR2); } static bool diff --git a/src/openvpn/sig.h b/src/openvpn/sig.h index 4858eb93..7d76389a 100644 --- a/src/openvpn/sig.h +++ b/src/openvpn/sig.h @@ -81,7 +81,12 @@ void register_signal(struct signal_info *si, int sig, const char *text); void process_explicit_exit_notification_timer_wakeup(struct context *c); -void signal_reset(struct signal_info *si); +/** + * Clear the signal if its current value equals signum. If signum is + * zero the signal is cleared independent of its current value. + * @returns the current value of the signal. + */ +int signal_reset(struct signal_info *si, int signum); static inline void halt_non_edge_triggered_signals(void) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index baafe1e6..a2af2498 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -567,12 +567,11 @@ openvpn_getaddrinfo(unsigned int flags, if (sig_info->signal_received) /* were we interrupted by a signal? */ { /* why are we overwriting SIGUSR1 ? */ - if (sig_info->signal_received == SIGUSR1) /* ignore SIGUSR1 */ + if (signal_reset(sig_info, SIGUSR1) == SIGUSR1) /* ignore SIGUSR1 */ { msg(level, "RESOLVE: Ignored SIGUSR1 signal received during " "DNS resolution attempt"); - signal_reset(sig_info); } else { @@ -2176,7 +2175,7 @@ link_socket_init_phase2(struct context *c) if (sig_info->signal_received) { sig_save = *sig_info; - signal_reset(sig_info); + sig_save.signal_received = signal_reset(sig_info, 0); } /* initialize buffers */ diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 44176936..60e6c9fd 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -677,7 +677,7 @@ win32_signal_get(struct win32_signal *ws) } if (ret) { - throw_signal(ret); /* this will update signinfo_static.signal received */ + throw_signal(ret); /* this will update siginfo_static.signal received */ } return (siginfo_static.signal_received); }