Navigation


Changeset 691:78b665400097 in freeDiameter for libfdcore/p_expiry.c


Ignore:
Timestamp:
Jan 20, 2011, 7:44:27 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cleanup all pthread_cleanup_push / pop pairs so that pop is always called after push, or ASSERT(0) is some grave errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/p_expiry.c

    r686 r691  
    9898        TRACE_ENTRY( "%p", arg );
    9999       
    100         CHECK_POSIX_DO( pthread_mutex_lock(&exp_mtx),  goto error );
     100        CHECK_POSIX_DO( pthread_mutex_lock(&exp_mtx), { ASSERT(0); } );
    101101        pthread_cleanup_push( fd_cleanup_mutex, &exp_mtx );
    102102       
     
    108108                if (FD_IS_LIST_EMPTY(&exp_list)) {
    109109                        /* Just wait for a change or cancelation */
    110                         CHECK_POSIX_DO( pthread_cond_wait( &exp_cnd, &exp_mtx ), goto error );
     110                        CHECK_POSIX_DO( pthread_cond_wait( &exp_cnd, &exp_mtx ), { ASSERT(0); } );
    111111                        /* Restart the loop on wakeup */
    112112                        continue;
     
    118118               
    119119                /* Get the current time */
    120                 CHECK_SYS_DO(  clock_gettime(CLOCK_REALTIME, &now),  goto error  );
     120                CHECK_SYS_DO(  clock_gettime(CLOCK_REALTIME, &now),  { ASSERT(0); }  );
    121121
    122122                /* If first peer is not expired, we just wait until it happens */
     
    125125                        CHECK_POSIX_DO2(  pthread_cond_timedwait( &exp_cnd, &exp_mtx, &first->p_exp_timer ), 
    126126                                        ETIMEDOUT, /* ETIMEDOUT is a normal return value, continue */,
    127                                         /* on other error, */ goto error );
     127                                        /* on other error, */ { ASSERT(0); } );
    128128       
    129129                        /* on wakeup, loop */
     
    133133                /* Now, the first peer in the list is expired; signal it */
    134134                fd_list_unlink( &first->p_expiry );
    135                 CHECK_FCT_DO( fd_event_send(first->p_events, FDEVP_TERMINATE, 0, "DO_NOT_WANT_TO_TALK_TO_YOU"), goto error );
     135                CHECK_FCT_DO( fd_event_send(first->p_events, FDEVP_TERMINATE, 0, "DO_NOT_WANT_TO_TALK_TO_YOU"), break );
    136136               
    137137        } while (1);
    138138       
    139139        pthread_cleanup_pop( 1 );
    140 error:
     140
    141141        TRACE_DEBUG(INFO, "An error occurred in peers module! Expiry thread is terminating...");
    142         ASSERT(0);
    143142        CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
    144143        return NULL;
Note: See TracChangeset for help on using the changeset viewer.