Changeset 5:c2d2729e3603 in freeDiameter for libfreeDiameter/sessions.c
- Timestamp:
- Sep 3, 2009, 2:33:45 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfreeDiameter/sessions.c
r4 r5 296 296 if (st->hdl->id < del->id) 297 297 continue; 298 if (st->hdl->id > del->id) 299 break; 300 /* This state belongs to the handler we are deleting, move the item to the deleted_states list */ 301 fd_list_unlink(&st->chain); 302 CHECK_MALLOC( st->sid = strdup(sess->sid) ); 303 fd_list_insert_before(&deleted_states, &st->chain); 298 if (st->hdl->id == del->id) { 299 /* This state belongs to the handler we are deleting, move the item to the deleted_states list */ 300 fd_list_unlink(&st->chain); 301 CHECK_MALLOC( st->sid = strdup(sess->sid) ); 302 fd_list_insert_before(&deleted_states, &st->chain); 303 } 304 break; 304 305 } 305 306 CHECK_POSIX( pthread_mutex_unlock(&sess->stlock) ); … … 400 401 } 401 402 402 /* If the session did not exist, we can add it into the hash table*/403 /* If the session did not exist, we can link it in global tables */ 403 404 if (!found) { 404 fd_list_insert_before(li, &sess->chain_h); 405 fd_list_insert_before(li, &sess->chain_h); /* hash table */ 405 406 406 407 /* We must also insert in the expiry list */ … … 410 411 for (li = exp_sentinel.prev; li != &exp_sentinel; li = li->prev) { 411 412 struct session * s = (struct session *)(li->o); 412 413 413 if (TS_IS_INFERIOR( &s->timeout, &sess->timeout ) ) 414 414 break; 415 416 continue;417 415 } 418 416 fd_list_insert_after( li, &sess->expire ); 417 418 #if 0 419 if (TRACE_BOOL(ANNOYING)) { 420 TRACE_DEBUG(FULL, "-- Updated session expiry list --"); 421 for (li = exp_sentinel.next; li != &exp_sentinel; li = li->next) { 422 struct session * s = (struct session *)(li->o); 423 fd_sess_dump(FULL, s); 424 } 425 TRACE_DEBUG(FULL, "-- end of expiry list --"); 426 } 427 #endif 419 428 420 429 /* We added a new expiring element, we must signal */ … … 502 511 /* We added a new expiring element, we must signal */ 503 512 CHECK_POSIX( pthread_cond_signal(&exp_cond) ); 513 514 #if 0 515 if (TRACE_BOOL(ANNOYING)) { 516 TRACE_DEBUG(FULL, "-- Updated session expiry list --"); 517 for (li = exp_sentinel.next; li != &exp_sentinel; li = li->next) { 518 struct session * s = (struct session *)(li->o); 519 fd_sess_dump(FULL, s); 520 } 521 TRACE_DEBUG(FULL, "-- end of expiry list --"); 522 } 523 #endif 504 524 505 525 /* We're done */ … … 548 568 549 569 /* Save a state information with a session */ 550 int fd_sess_state_store ( struct session_handler * handler, struct session * session, session_state ** state )570 int fd_sess_state_store_int ( struct session_handler * handler, struct session * session, session_state ** state ) 551 571 { 552 572 struct state *new; … … 597 617 598 618 /* Get the data back */ 599 int fd_sess_state_retrieve ( struct session_handler * handler, struct session * session, session_state ** state )619 int fd_sess_state_retrieve_int ( struct session_handler * handler, struct session * session, session_state ** state ) 600 620 { 601 621 struct fd_list * li; … … 632 652 633 653 634 635 654 /* Dump functions */ 636 655 void fd_sess_dump(int level, struct session * session) 637 656 { 638 657 struct fd_list * li; 658 char buf[30]; 659 struct tm tm; 660 639 661 if (!TRACE_BOOL(level)) 640 662 return; 641 663 642 fd_log_debug(" Session @%p:\n", session);664 fd_log_debug("\t %*s -- Session @%p --\n", level, "", session); 643 665 if (!VALIDATE_SI(session)) { 644 fd_log_debug(" Invalid session object\n"); 645 return; 646 } 647 648 fd_log_debug(" sid '%s', hash %x\n", session->sid, session->hash); 649 fd_log_debug(" timeout %d.%09d\n", session->timeout.tv_sec, session->timeout.tv_nsec); 650 651 CHECK_POSIX_DO( pthread_mutex_lock(&session->stlock), /* ignore */ ); 652 for (li = session->states.next; li != &session->states; li = li->next) { 653 struct state * st = (struct state *)(li->o); 654 fd_log_debug(" handler %d registered data %p\n", st->hdl->id, st->state); 655 } 656 CHECK_POSIX_DO( pthread_mutex_unlock(&session->stlock), /* ignore */ ); 666 fd_log_debug("\t %*s Invalid session object\n", level, ""); 667 } else { 668 669 fd_log_debug("\t %*s sid '%s', hash %x\n", level, "", session->sid, session->hash); 670 671 strftime(buf, sizeof(buf), "%D,%T", localtime_r( &session->timeout.tv_sec , &tm )); 672 fd_log_debug("\t %*s timeout %s.%09ld\n", level, "", buf, session->timeout.tv_nsec); 673 674 CHECK_POSIX_DO( pthread_mutex_lock(&session->stlock), /* ignore */ ); 675 for (li = session->states.next; li != &session->states; li = li->next) { 676 struct state * st = (struct state *)(li->o); 677 fd_log_debug("\t %*s handler %d registered data %p\n", level, "", st->hdl->id, st->state); 678 } 679 CHECK_POSIX_DO( pthread_mutex_unlock(&session->stlock), /* ignore */ ); 680 } 681 fd_log_debug("\t %*s -- end of session @%p --\n", level, "", session); 657 682 } 658 683 … … 662 687 return; 663 688 664 fd_log_debug(" Handler @%p:\n", handler);689 fd_log_debug("\t %*s -- Handler @%p --\n", level, "", handler); 665 690 if (!VALIDATE_SH(handler)) { 666 fd_log_debug(" Invalid session handler object\n");667 return;668 }669 670 fd_log_debug(" id %d, cleanup %p\n", handler->id, handler->cleanup);691 fd_log_debug("\t %*s Invalid session handler object\n", level, ""); 692 } else { 693 fd_log_debug("\t %*s id %d, cleanup %p\n", level, "", handler->id, handler->cleanup); 694 } 695 fd_log_debug("\t %*s -- end of handler @%p --\n", level, "", handler); 671 696 }
Note: See TracChangeset
for help on using the changeset viewer.