Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

send switch disconnect message at sigterm/sigint

  • Loading branch information...
commit 8ed8578203633181f284a8bfc7b2129367329911 1 parent 57202d6
@sugyo sugyo authored
Showing with 23 additions and 2 deletions.
  1. +23 −2 src/switch_manager/switch.c
View
25 src/switch_manager/switch.c
@@ -486,8 +486,7 @@ switch_event_disconnected( struct switch_info *sw_info ) {
}
flush_messenger();
- stop_event_handler();
- stop_messenger();
+ stop_trema();
return 0;
}
@@ -565,6 +564,22 @@ management_recv( uint16_t tag, void *data, size_t data_len ) {
}
+static void
+stop_switch_daemon( void ) {
+ switch_event_disconnected( &switch_info );
+}
+
+
+static void
+handle_sigterm( int signum ) {
+ UNUSED( signum );
+
+ if ( !set_external_callback( stop_switch_daemon ) ) {
+ stop_trema();
+ }
+}
+
+
int
main( int argc, char *argv[] ) {
int ret;
@@ -604,6 +619,12 @@ main( int argc, char *argv[] ) {
}
}
+ struct sigaction signal_exit;
+ memset( &signal_exit, 0, sizeof( struct sigaction ) );
+ signal_exit.sa_handler = handle_sigterm;
+ sigaction( SIGINT, &signal_exit, NULL );
+ sigaction( SIGTERM, &signal_exit, NULL );
+
fcntl( switch_info.secure_channel_fd, F_SETFL, O_NONBLOCK );
set_fd_handler( switch_info.secure_channel_fd, secure_channel_read, NULL, secure_channel_write, NULL );
Please sign in to comment.
Something went wrong with that request. Please try again.