Changeset 924:877592751fee in freeDiameter for libfdproto/sessions.c
- Timestamp:
- Feb 15, 2013, 1:52:57 AM (11 years ago)
- Branch:
- default
- Children:
- 925:e5a09fab5ef3, 950:51c15f98a965
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/sessions.c
r788 r924 360 360 361 361 362 /* Create a new session object with the default timeout value, and link it */362 /* Create a new session object with the default timeout value, and link it. The refcount is increased by 1, whether the session existed or not */ 363 363 int fd_sess_new ( struct session ** session, DiamId_t diamid, size_t diamidlen, uint8_t * opt, size_t optlen ) 364 364 { … … 461 461 462 462 fd_list_insert_before(li, &sess->chain_h); /* hash table */ 463 sess->msg_cnt++; 463 464 } else { 464 465 free(sid); 466 467 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) ); 468 (*session)->msg_cnt++; 469 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) ); 470 465 471 /* it was found: was it previously destroyed? */ 466 472 if ((*session)->is_destroyed == 0) { … … 469 475 } else { 470 476 /* the session was marked destroyed, let's re-activate it. */ 471 TODO("Re-creating a deleted session. Should investigate if this can lead to an issue... (need more feedback)");472 477 sess = *session; 478 sess->is_destroyed = 0; 473 479 474 480 /* update the expiry time */ … … 501 507 502 508 out: 503 ; 509 ; 504 510 pthread_cleanup_pop(0); 505 511 CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) ); … … 512 518 } 513 519 514 /* Find or create a session */515 int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new)520 /* Find or create a session -- the msg refcount is increased */ 521 int fd_sess_fromsid_msg ( uint8_t * sid, size_t len, struct session ** session, int * new) 516 522 { 517 523 int ret; … … 802 808 803 809 /* For the messages module */ 804 int fd_sess_fromsid _msg( uint8_t * sid, size_t len, struct session ** session, int * new)810 int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new) 805 811 { 806 812 TRACE_ENTRY("%p %zd %p %p", sid, len, session, new); … … 808 814 809 815 /* Get the session object */ 810 CHECK_FCT( fd_sess_fromsid ( sid, len, session, new) ); 811 812 /* Increase count */ 813 CHECK_FCT( fd_sess_ref_msg ( *session ) ); 814 816 CHECK_FCT( fd_sess_fromsid_msg ( sid, len, session, new) ); 817 818 /* Decrease the refcount */ 819 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) ); 820 (*session)->msg_cnt--; /* was increased in fd_sess_new */ 821 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) ); 822 815 823 /* Done */ 816 824 return 0; … … 833 841 { 834 842 int reclaim; 843 uint32_t hash; 835 844 836 845 TRACE_ENTRY("%p", session); 837 846 CHECK_PARAMS( session && VALIDATE_SI(*session) ); 838 847 848 /* Lock the hash line to avoid possibility that session is freed while we are reclaiming */ 849 hash = (*session)->hash; 850 CHECK_POSIX( pthread_mutex_lock( H_LOCK(hash)) ); 851 pthread_cleanup_push( fd_cleanup_mutex, H_LOCK(hash) ); 852 839 853 /* Update the msg refcount */ 840 854 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) ); … … 843 857 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) ); 844 858 859 /* Ok, now unlock the hash line */ 860 pthread_cleanup_pop( 0 ); 861 CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) ); 862 863 /* and reclaim if no message references the session anymore */ 845 864 if (reclaim == 1) { 846 865 CHECK_FCT(fd_sess_reclaim ( session ));
Note: See TracChangeset
for help on using the changeset viewer.