Revision 84c1291c janus.c

View differences:

janus.c
144 144
	public_ip = g_strdup(ip);
145 145
}
146 146
static volatile gint stop = 0;
147
static gint stop_signal = 0;
147 148
gint janus_is_stopping(void) {
148 149
	return g_atomic_int_get(&stop);
149 150
}
......
270 271

  
271 272
/*! \brief Signal handler (just used to intercept CTRL+C and SIGTERM) */
272 273
static void janus_handle_signal(int signum) {
274
	stop_signal = signum;
273 275
	switch(g_atomic_int_get(&stop)) {
274 276
		case 0:
275 277
			JANUS_PRINT("Stopping gateway, please wait...\n");
......
4043 4045
		} while(res == -1 && errno == EINTR);
4044 4046
	}
4045 4047

  
4048
	/* If the Event Handlers mechanism is enabled, notify handlers that Janus just started */
4049
	if(janus_events_is_enabled()) {
4050
		json_t *info = json_object();
4051
		json_object_set_new(info, "status", json_string("started"));
4052
		janus_events_notify_handlers(JANUS_EVENT_TYPE_CORE, 0, info);
4053
	}
4054

  
4046 4055
	while(!g_atomic_int_get(&stop)) {
4047 4056
		/* Loop until we have to stop */
4048 4057
		usleep(250000); /* A signal will cancel usleep() but not g_usleep() */
4049 4058
	}
4050 4059

  
4060
	/* If the Event Handlers mechanism is enabled, notify handlers that Janus is hanging up */
4061
	if(janus_events_is_enabled()) {
4062
		json_t *info = json_object();
4063
		json_object_set_new(info, "status", json_string("shutdown"));
4064
		json_object_set_new(info, "signum", json_integer(stop_signal));
4065
		janus_events_notify_handlers(JANUS_EVENT_TYPE_CORE, 0, info);
4066
	}
4067

  
4051 4068
	/* Done */
4052 4069
	JANUS_LOG(LOG_INFO, "Ending watchdog mainloop...\n");
4053 4070
	g_main_loop_quit(watchdog_loop);

Also available in: Unified diff