Navigation


Changeset 628:e1c6f45f5fcd in freeDiameter


Ignore:
Timestamp:
Dec 14, 2010, 11:53:48 AM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Improvements to usability, still work ongoing

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/main.c

    r502 r628  
    4646static void main_version(void);
    4747static void main_help( void );
     48static int signal_framework_ready(void);
    4849
    4950/* The static configuration structure */
     
    118119        /* Now, just wait for events */
    119120        TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized.");
     121        CHECK_FCT( signal_framework_ready() );
    120122        while (1) {
    121123                int code; size_t sz; void * data;
     
    350352        return;
    351353}
     354
     355
     356/* Signal extensions when the framework is completly initialized */
     357static int             is_ready = 0;
     358static pthread_mutex_t is_ready_mtx = PTHREAD_MUTEX_INITIALIZER;
     359static pthread_cond_t  is_ready_cnd = PTHREAD_COND_INITIALIZER;
     360static 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}
     369int 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}
  • include/freeDiameter/freeDiameter.h

    r621 r628  
    676676
    677677
     678/* The following function does not really use events, but it may be used
     679by extensions that need to start an action when the framework is fully initialized.
     680This function will block until all initializations are performed in the daemon.
     681It is meant to be used as follow by extensions:
     682 - in initialization callback, create a new thread.
     683 - this new thread calls this function.
     684 - when the function returns, the thread can start working and using all framework features.
     685*/
     686int fd_wait_initialization_complete(void);
     687
     688
    678689/***************************************/
    679690/*   Endpoints lists helpers           */
Note: See TracChangeset for help on using the changeset viewer.