Navigation



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
  • extensions/test_netemul/tne_process.c

    r656 r691  
    247247       
    248248        CHECK_POSIX_DO( pthread_mutex_lock(&mtx), goto error );
     249        pthread_cleanup_push( fd_cleanup_mutex, &mtx );
    249250       
    250251        /* The loop */
    251252        while (1) {
    252253                /* First, test if we are canceled */
    253                 CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), goto error );
    254254                pthread_testcancel();
    255                 CHECK_POSIX_DO( pthread_mutex_lock(&mtx), goto error );
    256                
    257                 pthread_cleanup_push( fd_cleanup_mutex, &mtx );
    258255               
    259256                /* Send all messages that are ready (free resources before using new ones) */
    260                 CHECK_FCT_DO( send_all_ready(), goto error_ul );
     257                CHECK_FCT_DO( send_all_ready(), break );
    261258               
    262259                /* Now process the new messages in input list for duplicate filter */
    263                 CHECK_FCT_DO( do_duplicates(), goto error_ul );
     260                CHECK_FCT_DO( do_duplicates(), break );
    264261               
    265262                /* Now compute the latency for each new item */
    266                 CHECK_FCT_DO( do_latency(), goto error_ul );
     263                CHECK_FCT_DO( do_latency(), break );
    267264               
    268265                /* Now, wait then loop */
    269266                if (FD_IS_LIST_EMPTY(&waitlist)) {
    270                         CHECK_POSIX_DO( pthread_cond_wait(&cnd, &mtx), goto error_ul );
     267                        CHECK_POSIX_DO( pthread_cond_wait(&cnd, &mtx), break );
    271268                } else {
    272269                        CHECK_POSIX_DO2( pthread_cond_timedwait(&cnd, &mtx, &((struct process_item *)(waitlist.next))->ts),
    273270                                ETIMEDOUT, /* ETIMEDOUT is a normal return value, continue */,
    274                                         /* on other error, */ goto error_ul );
     271                                        /* on other error, */ break );
    275272                }
    276273               
    277                 pthread_cleanup_pop( 0 );
    278274                /* loop */
    279275        }
    280276
    281 error_ul:
     277        pthread_cleanup_pop( 0 );
    282278        CHECK_POSIX_DO( pthread_mutex_unlock(&mtx),  );
    283279error:
Note: See TracChangeset for help on using the changeset viewer.