Mercurial > hg > freeDiameter
comparison freeDiameter/main.c @ 628:e1c6f45f5fcd
Improvements to usability, still work ongoing
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 14 Dec 2010 11:53:48 +0900 |
parents | a9a938287b49 |
children |
comparison
equal
deleted
inserted
replaced
627:330be61dbf43 | 628:e1c6f45f5fcd |
---|---|
43 /* forward declarations */ | 43 /* forward declarations */ |
44 static void fd_shutdown(int signal); | 44 static void fd_shutdown(int signal); |
45 static int main_cmdline(int argc, char *argv[]); | 45 static int main_cmdline(int argc, char *argv[]); |
46 static void main_version(void); | 46 static void main_version(void); |
47 static void main_help( void ); | 47 static void main_help( void ); |
48 static int signal_framework_ready(void); | |
48 | 49 |
49 /* The static configuration structure */ | 50 /* The static configuration structure */ |
50 static struct fd_config conf; | 51 static struct fd_config conf; |
51 struct fd_config * fd_g_config = &conf; | 52 struct fd_config * fd_g_config = &conf; |
52 | 53 |
115 /* Start the peer state machines */ | 116 /* Start the peer state machines */ |
116 CHECK_FCT( fd_psm_start() ); | 117 CHECK_FCT( fd_psm_start() ); |
117 | 118 |
118 /* Now, just wait for events */ | 119 /* Now, just wait for events */ |
119 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); | 120 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); |
121 CHECK_FCT( signal_framework_ready() ); | |
120 while (1) { | 122 while (1) { |
121 int code; size_t sz; void * data; | 123 int code; size_t sz; void * data; |
122 CHECK_FCT_DO( fd_event_get(fd_g_config->cnf_main_ev, &code, &sz, &data), break ); | 124 CHECK_FCT_DO( fd_event_get(fd_g_config->cnf_main_ev, &code, &sz, &data), break ); |
123 switch (code) { | 125 switch (code) { |
124 case FDEV_DUMP_DICT: | 126 case FDEV_DUMP_DICT: |
347 | 349 |
348 CHECK_FCT_DO( fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), exit(2) ); | 350 CHECK_FCT_DO( fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), exit(2) ); |
349 | 351 |
350 return; | 352 return; |
351 } | 353 } |
354 | |
355 | |
356 /* Signal extensions when the framework is completly initialized */ | |
357 static int is_ready = 0; | |
358 static pthread_mutex_t is_ready_mtx = PTHREAD_MUTEX_INITIALIZER; | |
359 static pthread_cond_t is_ready_cnd = PTHREAD_COND_INITIALIZER; | |
360 static int signal_framework_ready(void) | |
361 { | |
362 TRACE_ENTRY(""); | |
363 CHECK_POSIX( pthread_mutex_lock( &is_ready_mtx ) ); | |
364 is_ready = 1; | |
365 CHECK_POSIX( pthread_cond_broadcast( &is_ready_cnd ) ); | |
366 CHECK_POSIX( pthread_mutex_unlock( &is_ready_mtx ) ); | |
367 return 0; | |
368 } | |
369 int fd_wait_initialization_complete(void) | |
370 { | |
371 TRACE_ENTRY(""); | |
372 CHECK_POSIX( pthread_mutex_lock( &is_ready_mtx ) ); | |
373 pthread_cleanup_push( fd_cleanup_mutex, &is_ready_mtx ); | |
374 while (!is_ready) { | |
375 CHECK_POSIX( pthread_cond_wait( &is_ready_cnd, &is_ready_mtx ) ); | |
376 } | |
377 pthread_cleanup_pop( 0 ); | |
378 CHECK_POSIX( pthread_mutex_unlock( &is_ready_mtx ) ); | |
379 return 0; | |
380 } |