fix win shutdown in both places
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15169 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
16ec5bad39
commit
ffba393bc2
|
@ -1528,6 +1528,28 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
|
||||||
return switch_micro_time_now() - runtime.initiated;
|
return switch_micro_time_now() - runtime.initiated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
static void win_shutdown(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
HANDLE shutdown_event;
|
||||||
|
char path[512];
|
||||||
|
/* for windows we need the event to signal for shutting down a background FreeSWITCH */
|
||||||
|
snprintf(path, sizeof(path), "Global\\Freeswitch.%d", getpid());
|
||||||
|
|
||||||
|
/* open the event so we can signal it */
|
||||||
|
shutdown_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, path);
|
||||||
|
|
||||||
|
if (shutdown_event) {
|
||||||
|
/* signal the event to shutdown */
|
||||||
|
SetEvent(shutdown_event);
|
||||||
|
/* cleanup */
|
||||||
|
CloseHandle(shutdown_event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)
|
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)
|
||||||
{
|
{
|
||||||
if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
|
if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
|
||||||
|
@ -1579,11 +1601,18 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_
|
||||||
|
|
||||||
if (switch_test_flag((&runtime), SCF_SHUTDOWN_REQUESTED)) {
|
if (switch_test_flag((&runtime), SCF_SHUTDOWN_REQUESTED)) {
|
||||||
switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
|
switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
win_shutdown();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (*val) {
|
if (*val) {
|
||||||
switch_set_flag((&runtime), SCF_RESTART);
|
switch_set_flag((&runtime), SCF_RESTART);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Shutting down\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Shutting down\n");
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
fclose(stdin);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
runtime.running = 0;
|
runtime.running = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1595,26 +1624,9 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_
|
||||||
case SCSC_SHUTDOWN:
|
case SCSC_SHUTDOWN:
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
{
|
win_shutdown();
|
||||||
HANDLE shutdown_event;
|
|
||||||
char path[512];
|
|
||||||
/* for windows we need the event to signal for shutting down a background FreeSWITCH */
|
|
||||||
snprintf(path, sizeof(path), "Global\\Freeswitch.%d", getpid());
|
|
||||||
|
|
||||||
/* open the event so we can signal it */
|
|
||||||
shutdown_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, path);
|
|
||||||
|
|
||||||
|
|
||||||
if (shutdown_event) {
|
|
||||||
/* signal the event to shutdown */
|
|
||||||
SetEvent(shutdown_event);
|
|
||||||
/* cleanup */
|
|
||||||
CloseHandle(shutdown_event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (*val) {
|
if (*val) {
|
||||||
switch_set_flag((&runtime), SCF_RESTART);
|
switch_set_flag((&runtime), SCF_RESTART);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
|
||||||
|
|
Loading…
Reference in New Issue