@@ -514,22 +514,23 @@
}
/*
- * Schedule a signal n_seconds from now.
+ * Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds from now.
*/
-void
-schedule_exit(struct context *c, const int n_seconds, const int signal)
+bool
+schedule_exit(struct context *c)
{
- /* don't reschedule if already scheduled; we drop the new signal, but it
- * only ever seems to be SIGTERM anyway. */
+ const int n_seconds = c->options.scheduled_exit_interval;
+ /* don't reschedule if already scheduled. */
if (event_timeout_defined(&c->c2.scheduled_exit)) {
- return;
+ return false;
}
tls_set_single_session(c->c2.tls_multi);
update_time();
reset_coarse_timers(c);
event_timeout_init(&c->c2.scheduled_exit, n_seconds, now);
- c->c2.scheduled_exit_signal = signal;
+ c->c2.scheduled_exit_signal = SIGTERM;
msg(D_SCHED_EXIT, "Delayed exit in %d seconds", n_seconds);
+ return true;
}
/*
@@ -303,7 +303,7 @@
void process_ip_header(struct context *c, unsigned int flags, struct buffer *buf);
-void schedule_exit(struct context *c, const int n_seconds, const int signal);
+bool schedule_exit(struct context *c);
static inline struct link_socket_info *
get_link_socket_info(struct context *c)
@@ -191,6 +191,7 @@
receive_exit_message(struct context *c)
{
dmsg(D_STREAM_ERRORS, "CC-EEN exit message received by peer");
+ bool notify_management = true;
/* With control channel exit notification, we want to give the session
* enough time to handle retransmits and acknowledgment, so that eventual
* retries from the client to resend the exit or ACKs will not trigger
@@ -204,14 +205,14 @@
* */
if (c->options.mode == MODE_SERVER)
{
- schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM);
+ notify_management = schedule_exit(c);
}
else
{
register_signal(c->sig, SIGUSR1, "remote-exit");
}
#ifdef ENABLE_MANAGEMENT
- if (management)
+ if (management && notify_management)
{
management_notify(management, "info", "remote-exit", "EXIT");
}
@@ -391,7 +392,7 @@
void
send_auth_failed(struct context *c, const char *client_reason)
{
- if (event_timeout_defined(&c->c2.scheduled_exit))
+ if (!schedule_exit(c))
{
msg(D_TLS_DEBUG, "exit already scheduled for context");
return;
@@ -401,8 +402,6 @@
static const char auth_failed[] = "AUTH_FAILED";
size_t len;
- schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM);
-
len = (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_failed);
if (len > PUSH_BUNDLE_SIZE)
{
@@ -492,7 +491,7 @@
void
send_restart(struct context *c, const char *kill_msg)
{
- schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM);
+ schedule_exit(c);
send_control_channel_string(c, kill_msg ? kill_msg : "RESTART", D_PUSH);
}