Changeset 1182:cc96a4dfb3d1 in freeDiameter
- Timestamp:
- Jun 6, 2013, 12:25:23 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameterd/main.c
r1159 r1182 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 95 /* Allow SIGINT and SIGTERM from this point to terminate the application */ 90 CHECK_POSIX( pthread_create(&signals_thr, NULL, catch_signals, NULL) ); 91 92 /* Parse the configuration file */ 93 CHECK_FCT( fd_core_parseconf(conffile) ); 94 95 /* Start the servers */ 96 CHECK_FCT( fd_core_start() ); 96 CHECK_POSIX_DO( pthread_create(&signals_thr, NULL, catch_signals, NULL), goto error ); 97 97 98 98 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); 99 99 100 100 /* Now, just wait for termination */ 101 101 CHECK_FCT( fd_core_wait_shutdown_complete() ); … … 105 105 106 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 -
libfdcore/core.c
r1167 r1182 228 228 } 229 229 230 static pthread_mutex_t core_lock = PTHREAD_MUTEX_INITIALIZER; 231 230 232 /* Parse the freeDiameter.conf configuration file, load the extensions */ 231 int fd_core_parseconf(const char * conffile)233 static int fd_core_parseconf_int(const char * conffile) 232 234 { 233 235 char * buf = NULL, *b; … … 274 276 } 275 277 278 int fd_core_parseconf(const char * conffile) 279 { 280 int ret; 281 CHECK_POSIX( pthread_mutex_lock(&core_lock) ); 282 ret = fd_core_parseconf_int(conffile); 283 CHECK_POSIX( pthread_mutex_unlock(&core_lock) ); 284 return ret; 285 } 286 287 276 288 /* For threads that would need to wait complete start of the framework (ex: in extensions) */ 277 289 int fd_core_waitstartcomplete(void) … … 283 295 284 296 /* Start the server & client threads */ 285 int fd_core_start(void)297 static int fd_core_start_int(void) 286 298 { 287 299 /* Start server threads */ … … 301 313 } 302 314 315 int fd_core_start(void) 316 { 317 int ret; 318 CHECK_POSIX( pthread_mutex_lock(&core_lock) ); 319 ret = fd_core_start_int(); 320 CHECK_POSIX( pthread_mutex_unlock(&core_lock) ); 321 return ret; 322 } 303 323 304 324 /* Initialize shutdown of the framework. This is not blocking. */ … … 308 328 309 329 if (cur_state < CORE_RUNNING) { 330 /* Calling application must make sure the initialization is not ongoing in a separate thread... */ 331 if (pthread_mutex_lock(&core_lock) != 0) { 332 /* This function must not be called asynchronously from fd_core_parseconf / fd_core_start ! Please review your main app design */ 333 ASSERT(0); 334 return EINVAL; 335 } 310 336 core_shutdown(); 311 337 core_state_set(CORE_TERM); 338 pthread_mutex_unlock(&core_lock); 312 339 } else if (cur_state == CORE_RUNNING) { 313 340 core_state_set(CORE_SHUTDOWN);
Note: See TracChangeset
for help on using the changeset viewer.