Mercurial > hg > freeDiameter
comparison freeDiameterd/main.c @ 1182:cc96a4dfb3d1
Early shutdown situation: detect the race condition and delay the shutdown in freeDiameterd. Alternative would be to initialize in a separate thread that we can cancel before calling shutdown.
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Thu, 06 Jun 2013 11:25:23 +0800 |
parents | 05f74dc19c49 |
children | d8c998e7c535 |
comparison
equal
deleted
inserted
replaced
1181:22de21feec64 | 1182:cc96a4dfb3d1 |
---|---|
84 gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); | 84 gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); |
85 gnutls_global_set_log_level (gnutls_debug); | 85 gnutls_global_set_log_level (gnutls_debug); |
86 TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", gnutls_debug); | 86 TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", gnutls_debug); |
87 } | 87 } |
88 | 88 |
89 /* Parse the configuration file */ | |
90 CHECK_FCT_DO( fd_core_parseconf(conffile), goto error ); | |
91 | |
92 /* Start the servers */ | |
93 CHECK_FCT_DO( fd_core_start(), goto error ); | |
94 | |
89 /* Allow SIGINT and SIGTERM from this point to terminate the application */ | 95 /* Allow SIGINT and SIGTERM from this point to terminate the application */ |
90 CHECK_POSIX( pthread_create(&signals_thr, NULL, catch_signals, NULL) ); | 96 CHECK_POSIX_DO( pthread_create(&signals_thr, NULL, catch_signals, NULL), goto error ); |
91 | |
92 /* Parse the configuration file */ | |
93 CHECK_FCT( fd_core_parseconf(conffile) ); | |
94 | |
95 /* Start the servers */ | |
96 CHECK_FCT( fd_core_start() ); | |
97 | 97 |
98 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); | 98 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); |
99 | 99 |
100 /* Now, just wait for termination */ | 100 /* Now, just wait for termination */ |
101 CHECK_FCT( fd_core_wait_shutdown_complete() ); | 101 CHECK_FCT( fd_core_wait_shutdown_complete() ); |
102 | 102 |
103 /* Just in case it was not the result of a signal, we cancel signals_thr */ | 103 /* Just in case it was not the result of a signal, we cancel signals_thr */ |
104 fd_thr_term(&signals_thr); | 104 fd_thr_term(&signals_thr); |
105 | 105 |
106 return 0; | 106 return 0; |
107 error: | |
108 CHECK_FCT_DO( fd_core_shutdown(), ); | |
109 CHECK_FCT( fd_core_wait_shutdown_complete() ); | |
110 fd_thr_term(&signals_thr); | |
111 return -1; | |
107 } | 112 } |
108 | 113 |
109 | 114 |
110 /* Display package version */ | 115 /* Display package version */ |
111 static void main_version_core(void) | 116 static void main_version_core(void) |