Changeset 691:78b665400097 in freeDiameter for libfdproto/sessions.c
- Timestamp:
- Jan 20, 2011, 7:44:27 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/sessions.c
r686 r691 176 176 if (FD_IS_LIST_EMPTY(&exp_sentinel)) { 177 177 /* Just wait for a change or cancelation */ 178 CHECK_POSIX_DO( pthread_cond_wait( &exp_cond, &exp_lock ), break );178 CHECK_POSIX_DO( pthread_cond_wait( &exp_cond, &exp_lock ), break /* this might not pop the cleanup handler, but since we ASSERT(0), it is not the big issue... */ ); 179 179 /* Restart the loop on wakeup */ 180 180 goto again; … … 207 207 } while (1); 208 208 209 TRACE_DEBUG(INFO, "A nerror occurred in session module! Expiry thread is terminating...");209 TRACE_DEBUG(INFO, "A system error occurred in session module! Expiry thread is terminating..."); 210 210 ASSERT(0); 211 211 return NULL; … … 442 442 /* We added a new expiring element, we must signal */ 443 443 if (li == &exp_sentinel) { 444 CHECK_POSIX ( pthread_cond_signal(&exp_cond) );444 CHECK_POSIX_DO( pthread_cond_signal(&exp_cond), { ASSERT(0); } ); /* if it fails, we might not pop the cleanup handlers, but this should not happen -- and we'd have a serious problem otherwise */ 445 445 } 446 446 … … 458 458 /* We're done */ 459 459 pthread_cleanup_pop(0); 460 CHECK_POSIX ( pthread_mutex_unlock( &exp_lock ) );460 CHECK_POSIX_DO( pthread_mutex_unlock( &exp_lock ), { ASSERT(0); } ); /* if it fails, we might not pop the cleanup handler, but this should not happen -- and we'd have a serious problem otherwise */ 461 461 } 462 462 … … 540 540 /* We added a new expiring element, we must signal if it was in first position */ 541 541 if (session->expire.prev == &exp_sentinel) { 542 CHECK_POSIX ( pthread_cond_signal(&exp_cond));542 CHECK_POSIX_DO( pthread_cond_signal(&exp_cond), { ASSERT(0); /* so that we don't have a pending cancellation handler */ } ); 543 543 } 544 544 … … 573 573 574 574 /* Unlink and invalidate */ 575 CHECK_ FCT( pthread_mutex_lock( H_LOCK(sess->hash) ) );575 CHECK_POSIX( pthread_mutex_lock( H_LOCK(sess->hash) ) ); 576 576 pthread_cleanup_push( fd_cleanup_mutex, H_LOCK(sess->hash) ); 577 CHECK_ FCT( pthread_mutex_lock( &exp_lock ));577 CHECK_POSIX_DO( pthread_mutex_lock( &exp_lock ), { ASSERT(0); /* otherwise cleanup handler is not pop'd */ } ); 578 578 fd_list_unlink( &sess->chain_h ); 579 579 fd_list_unlink( &sess->expire ); /* no need to signal the condition here */ 580 580 sess->eyec = 0xdead; 581 CHECK_ FCT( pthread_mutex_unlock( &exp_lock ));581 CHECK_POSIX_DO( pthread_mutex_unlock( &exp_lock ), { ASSERT(0); /* otherwise cleanup handler is not pop'd */ } ); 582 582 pthread_cleanup_pop(0); 583 CHECK_ FCT( pthread_mutex_unlock( H_LOCK(sess->hash) ) );583 CHECK_POSIX( pthread_mutex_unlock( H_LOCK(sess->hash) ) ); 584 584 585 585 /* Now destroy all states associated -- we don't take the lock since nobody can access this session anymore (in theory) */ … … 614 614 CHECK_POSIX( pthread_mutex_lock( H_LOCK(sess->hash) ) ); 615 615 pthread_cleanup_push( fd_cleanup_mutex, H_LOCK(sess->hash) ); 616 CHECK_POSIX ( pthread_mutex_lock( &exp_lock ));616 CHECK_POSIX_DO( pthread_mutex_lock( &exp_lock ), { ASSERT(0); /* otherwise, cleanup not poped on FreeBSD */ } ); 617 617 if (FD_IS_LIST_EMPTY(&sess->states)) { 618 618 fd_list_unlink( &sess->chain_h ); … … 622 622 free(sess); 623 623 } 624 CHECK_POSIX ( pthread_mutex_unlock( &exp_lock ));624 CHECK_POSIX_DO( pthread_mutex_unlock( &exp_lock ), { ASSERT(0); /* otherwise, cleanup not poped on FreeBSD */ } ); 625 625 pthread_cleanup_pop(0); 626 626 CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) ); … … 635 635 struct fd_list * li; 636 636 int already = 0; 637 int ret = 0; 637 638 638 639 TRACE_ENTRY("%p %p %p", handler, session, state); … … 644 645 645 646 /* Create the new state object */ 646 CHECK_MALLOC (new = malloc(sizeof(struct state)));647 CHECK_MALLOC_DO(new = malloc(sizeof(struct state)), { ret = ENOMEM; goto out; } ); 647 648 memset(new, 0, sizeof(struct state)); 648 649 … … 661 662 if (st->hdl->id == handler->id) { 662 663 TRACE_DEBUG(INFO, "A state was already stored for session '%s' and handler '%p', at location %p", session->sid, st->hdl, st->state); 663 already = 1;664 already = EALREADY; 664 665 } 665 666 … … 673 674 free(new); 674 675 } 675 676 out: 677 ; 676 678 pthread_cleanup_pop(0); 677 679 CHECK_POSIX( pthread_mutex_unlock(&session->stlock) ); 678 680 679 return already ? EALREADY : 0;681 return ret ?: already; 680 682 } 681 683
Note: See TracChangeset
for help on using the changeset viewer.