OpenVPN
|
Go to the source code of this file.
Data Structures | |
struct | signal_info |
Macros | |
#define | SIG_SOURCE_SOFT 0 |
#define | SIG_SOURCE_HARD 1 |
#define | SIG_SOURCE_CONNECTION_FAILED 2 |
#define | IS_SIG(c) ((c)->sig->signal_received) |
Functions | |
int | parse_signal (const char *signame) |
const char * | signal_name (const int sig, const bool upper) |
const char * | signal_description (const int signum, const char *sigtext) |
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 | pre_init_signal_catch (void) |
void | post_init_signal_catch (void) |
void | restore_signal_state (void) |
void | print_signal (const struct signal_info *si, const char *title, int msglevel) |
void | print_status (struct context *c, struct status_output *so) |
void | remap_signal (struct context *c) |
void | signal_restart_status (const struct signal_info *si) |
bool | process_signal (struct context *c) |
void | register_signal (struct signal_info *si, int sig, const char *text) |
Register a soft signal in the signal_info struct si respecting priority. More... | |
void | process_explicit_exit_notification_timer_wakeup (struct context *c) |
int | signal_reset (struct signal_info *si, int signum) |
Clear the signal if its current value equals signum. More... | |
static void | halt_non_edge_triggered_signals (void) |
static void | get_signal (volatile int *sig) |
Copy the global signal_received (if non-zero) to the passed-in argument sig. More... | |
Variables | |
struct signal_info | siginfo_static |
|
inlinestatic |
Copy the global signal_received (if non-zero) to the passed-in argument sig.
As the former is volatile, do not assign if sig and &signal_received are the same. Even on windows signal_received is really volatile as it can change if a ctrl-C or ctrl-break is delivered. So use the same logic as above.
Also, on windows always call win32_signal_get to pickup any signals simulated by key-board short cuts or the exit event.
Definition at line 110 of file sig.h.
References siginfo_static, signal_info::signal_received, and win32_signal_get().
Referenced by dco_connect_wait(), io_wait_dowork(), man_check_for_signals(), multi_tcp_process_io(), openvpn_connect(), openvpn_getaddrinfo(), recv_line(), recv_socks_reply(), socket_connect(), socket_listen_accept(), socks_handshake(), and socks_username_password_auth().
|
inlinestatic |
Definition at line 92 of file sig.h.
References win32_signal_close().
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().
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().
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().
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().
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.
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.
References ASSERT, block_async_signals(), D_SIGNAL_DEBUG, ignored_hard_signals_mask, msg, SIG_SOURCE_HARD, siginfo_static, signal_name(), signal_info::signal_received, try_throw_signal(), and unblock_async_signals().
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().
struct signal_info siginfo_static |
Definition at line 45 of file sig.c.
Referenced by get_signal(), 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().