OpenVPN
|
#include "syshead.h"
#include "buffer.h"
#include "error.h"
#include "win32.h"
#include "init.h"
#include "status.h"
#include "sig.h"
#include "occ.h"
#include "manage.h"
#include "openvpn.h"
#include "memdbg.h"
Go to the source code of this file.
Data Structures | |
struct | signame |
Macros | |
#define | SM_UNDEF 0 |
#define | SM_PRE_INIT 1 |
#define | SM_POST_INIT 2 |
Functions | |
int | parse_signal (const char *signame) |
static int | signal_priority (int sig) |
const char * | signal_name (const int sig, const bool upper) |
const char * | signal_description (const int signum, const char *sigtext) |
static void | block_async_signals (void) |
Block (i.e., defer) all unix signals. More... | |
static void | unblock_async_signals (void) |
Unblock all unix signals. More... | |
static bool | try_throw_signal (struct signal_info *si, int signum, int source) |
Private function for registering a signal in the specified signal_info struct. More... | |
void | throw_signal (const int signum) |
Throw a hard signal. More... | |
void | throw_signal_soft (const int signum, const char *signal_text) |
Throw a soft global signal. More... | |
void | register_signal (struct signal_info *si, int signum, const char *signal_text) |
Register a soft signal in the signal_info struct si respecting priority. More... | |
int | signal_reset (struct signal_info *si, int signum) |
Clear the signal if its current value equals signum. More... | |
void | print_signal (const struct signal_info *si, const char *title, int msglevel) |
void | signal_restart_status (const struct signal_info *si) |
void | pre_init_signal_catch (void) |
void | post_init_signal_catch (void) |
void | halt_low_priority_signals (void) |
void | restore_signal_state (void) |
void | print_status (struct context *c, struct status_output *so) |
static void | process_explicit_exit_notification_init (struct context *c) |
void | process_explicit_exit_notification_timer_wakeup (struct context *c) |
void | remap_signal (struct context *c) |
static void | process_sigusr2 (struct context *c) |
static bool | process_sigterm (struct context *c) |
static void | remap_restart_signals (struct context *c) |
If a soft restart signal is received during exit-notification, it implies the event loop cannot continue: remap to SIGTERM to exit promptly. More... | |
bool | process_signal (struct context *c) |
Variables | |
struct signal_info | siginfo_static |
static const struct signame | signames [] |
static unsigned long long | ignored_hard_signals_mask |
static int | signal_mode |
|
inlinestatic |
Block (i.e., defer) all unix signals.
Used while directly modifying the volatile elements of siginfo_static.
Definition at line 125 of file sig.c.
Referenced by register_signal(), signal_reset(), throw_signal(), and throw_signal_soft().
void halt_low_priority_signals | ( | void | ) |
Definition at line 451 of file sig.c.
References CLEAR, and ignored_hard_signals_mask.
Referenced by process_explicit_exit_notification_init().
int parse_signal | ( | const char * | signame | ) |
Definition at line 66 of file sig.c.
References signames, SIZE, signame::upper, and signame::value.
Referenced by man_signal().
void post_init_signal_catch | ( | void | ) |
Definition at line 427 of file sig.c.
References CLEAR, signal_mode, and SM_POST_INIT.
Referenced by init_instance_handle_signals(), and restore_signal_state().
void pre_init_signal_catch | ( | void | ) |
Definition at line 398 of file sig.c.
References CLEAR, siginfo_static, signal_mode, signal_reset(), and SM_PRE_INIT.
Referenced by init_instance_handle_signals(), openvpn_main(), and restore_signal_state().
void print_signal | ( | const struct signal_info * | si, |
const char * | title, | ||
int | msglevel | ||
) |
Definition at line 294 of file sig.c.
References ASSERT, msg, SIG_SOURCE_CONNECTION_FAILED, SIG_SOURCE_HARD, SIG_SOURCE_SOFT, signal_name(), signal_info::signal_received, signal_info::signal_text, and signal_info::source.
Referenced by multi_close_instance_on_signal(), and openvpn_main().
void print_status | ( | struct context * | c, |
struct status_output * | so | ||
) |
Definition at line 484 of file sig.c.
References context::c1, context::c2, counter_format, dco_enabled(), dco_get_peer_stats(), context_2::dco_read_bytes, context_2::dco_write_bytes, gc_free(), gc_new(), context_2::link_read_bytes, context_2::link_read_bytes_auth, context_2::link_write_bytes, context::options, status_flush(), status_printf(), status_reset(), tap_win_getinfo(), time_string(), context_2::tun_read_bytes, context_2::tun_write_bytes, context_1::tuntap, and tuntap_defined().
Referenced by check_status_file(), management_callback_status_p2p(), and process_sigusr2().
|
static |
Definition at line 535 of file sig.c.
References context::c2, cc_exit_notify_enabled(), D_PUSH, event_timeout_init(), context_2::explicit_exit_notification_interval, context_2::explicit_exit_notification_time_wait, halt_low_priority_signals(), halt_non_edge_triggered_signals(), M_INFO, msg, now, reset_coarse_timers(), send_control_channel_string(), context::sig, and signal_reset().
Referenced by process_sigterm().
void process_explicit_exit_notification_timer_wakeup | ( | struct context * | c | ) |
Definition at line 564 of file sig.c.
References ASSERT, context::c2, cc_exit_notify_enabled(), options::ce, ETT_DEFAULT, event_timeout_clear(), event_timeout_trigger(), connection_entry::explicit_exit_notification, context_2::explicit_exit_notification_interval, context_2::explicit_exit_notification_time_wait, now, OCC_EXIT, context_2::occ_op, context::options, register_signal(), context::sig, and context_2::timeval.
Referenced by process_coarse_timers().
bool process_signal | ( | struct context * | c | ) |
Definition at line 637 of file sig.c.
References process_sigterm(), process_sigusr2(), remap_restart_signals(), context::sig, and signal_info::signal_received.
Referenced by process_signal_p2p().
|
static |
Definition at line 606 of file sig.c.
References context::c2, options::ce, connection_entry::explicit_exit_notification, context_2::explicit_exit_notification_time_wait, context::options, and process_explicit_exit_notification_init().
Referenced by process_signal().
|
static |
Definition at line 597 of file sig.c.
References M_INFO, print_status(), context::sig, signal_reset(), status_close(), and status_open().
Referenced by process_signal().
void register_signal | ( | struct signal_info * | si, |
int | signum, | ||
const char * | signal_text | ||
) |
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.
Definition at line 231 of file sig.c.
References block_async_signals(), D_SIGNAL_DEBUG, msg, SIG_SOURCE_CONNECTION_FAILED, SIG_SOURCE_SOFT, siginfo_static, signal_name(), signal_info::signal_received, signal_info::signal_text, signal_info::source, try_throw_signal(), and unblock_async_signals().
Referenced by check_add_routes(), check_connection_established(), check_dco_key_status(), check_inactivity_timeout(), check_scheduled_exit(), check_server_poll_timeout(), check_session_timeout(), check_tls(), check_tls_errors_co(), check_tls_errors_nco(), close_context(), dco_connect_wait(), do_init_crypto_tls_c1(), establish_http_proxy_passthru(), establish_socks_proxy_passthru(), establish_socks_proxy_udpassoc(), incoming_push_message(), link_socket_init_phase2(), multi_client_generate_tls_keys(), phase2_tcp_server(), process_explicit_exit_notification_timer_wakeup(), process_incoming_link_part1(), process_outgoing_link(), process_received_occ_msg(), read_incoming_link(), read_incoming_tun(), receive_auth_failed(), receive_exit_message(), remap_restart_signals(), remap_signal(), resolve_remote(), send_push_request(), server_pushed_signal(), socket_connect(), and trigger_ping_timeout_signal().
|
static |
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.
Definition at line 624 of file sig.c.
References context::c2, event_timeout_defined(), context_2::explicit_exit_notification_interval, M_INFO, msg, register_signal(), context::sig, SIG_SOURCE_HARD, signal_name(), signal_info::signal_received, and signal_info::source.
Referenced by process_signal().
void remap_signal | ( | struct context * | c | ) |
Definition at line 588 of file sig.c.
References context::options, register_signal(), options::remap_sigusr1, context::sig, signal_info::signal_received, and signal_info::signal_text.
Referenced by init_instance_handle_signals(), multi_close_instance_on_signal(), and process_signal_p2p().
void restore_signal_state | ( | void | ) |
Definition at line 466 of file sig.c.
References post_init_signal_catch(), pre_init_signal_catch(), signal_mode, SM_POST_INIT, and SM_PRE_INIT.
Referenced by possibly_become_daemon().
const char* signal_description | ( | const int | signum, |
const char * | sigtext | ||
) |
const char* signal_name | ( | const int | sig, |
const bool | upper | ||
) |
Definition at line 93 of file sig.c.
References signame::lower, signames, SIZE, signame::upper, and signame::value.
Referenced by man_signal(), print_signal(), register_signal(), remap_restart_signals(), signal_description(), signal_reset(), signal_restart_status(), throw_signal(), and throw_signal_soft().
|
static |
Definition at line 80 of file sig.c.
References signame::priority, signames, SIZE, and signame::value.
Referenced by try_throw_signal().
int signal_reset | ( | struct signal_info * | si, |
int | signum | ||
) |
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.
Definition at line 266 of file sig.c.
References block_async_signals(), D_SIGNAL_DEBUG, msg, SIG_SOURCE_SOFT, siginfo_static, signal_name(), signal_info::signal_received, signal_info::signal_text, signal_info::source, and unblock_async_signals().
Referenced by link_socket_init_phase2(), multi_process_signal(), multi_push_restart_schedule_exit(), openvpn_getaddrinfo(), openvpn_main(), pre_init_signal_catch(), process_explicit_exit_notification_init(), and process_sigusr2().
void signal_restart_status | ( | const struct signal_info * | si | ) |
Definition at line 348 of file sig.c.
References management_set_state(), OPENVPN_STATE_EXITING, OPENVPN_STATE_RECONNECTING, signal_name(), signal_info::signal_received, and signal_info::signal_text.
Referenced by openvpn_main().
void throw_signal | ( | const int | signum | ) |
Throw a hard signal.
Called from management and when windows signals are received through ctrl-c, exit event etc.
Definition at line 177 of file sig.c.
Referenced by link_socket_init_phase2(), man_connect(), man_signal(), multi_process_timeout(), win32_signal_get(), and win_ctrl_handler().
void throw_signal_soft | ( | const int | signum, |
const char * | signal_text | ||
) |
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.
Definition at line 206 of file sig.c.
References block_async_signals(), D_SIGNAL_DEBUG, msg, SIG_SOURCE_SOFT, siginfo_static, signal_name(), signal_info::signal_received, signal_info::signal_text, try_throw_signal(), and unblock_async_signals().
Referenced by apply_pull_filter(), do_preresolve(), man_connect(), and man_reset_client_socket().
|
static |
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().
Definition at line 160 of file sig.c.
References signal_priority(), signal_info::signal_received, and signal_info::source.
Referenced by register_signal(), throw_signal(), and throw_signal_soft().
|
inlinestatic |
Unblock all unix signals.
Definition at line 138 of file sig.c.
Referenced by register_signal(), signal_reset(), throw_signal(), and throw_signal_soft().
|
static |
Definition at line 63 of file sig.c.
Referenced by halt_low_priority_signals(), and throw_signal().
struct signal_info siginfo_static |
Definition at line 45 of file sig.c.
Referenced by link_socket_init_phase2(), openvpn_main(), pre_init_signal_catch(), register_signal(), signal_reset(), throw_signal(), throw_signal_soft(), win32_signal_get(), and win_ctrl_handler().
|
static |
Definition at line 395 of file sig.c.
Referenced by post_init_signal_catch(), pre_init_signal_catch(), and restore_signal_state().
|
static |
Definition at line 54 of file sig.c.
Referenced by parse_signal(), signal_name(), and signal_priority().