Navigation


Changeset 291:2d3a799ad29c in freeDiameter


Ignore:
Timestamp:
May 10, 2010, 2:10:51 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cache the session pointer in answers when it was present in queries

Location:
libfreeDiameter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libfreeDiameter/libfD.h

    r258 r291  
    6262/* Messages / sessions API */
    6363int fd_sess_fromsid_msg ( unsigned char * sid, size_t len, struct session ** session, int * new);
     64int fd_sess_ref_msg ( struct session * session );
    6465int fd_sess_reclaim_msg ( struct session ** session );
    6566
  • libfreeDiameter/messages.c

    r280 r291  
    336336                CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
    337337                CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ) );
     338                ans->msg_sess = sess;
     339                CHECK_FCT( fd_sess_ref_msg(sess) );
    338340        }
    339341       
     
    22082210        CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto error );
    22092211        while (avp != NULL) {
    2210                 /* Sanity */
    2211                 ASSERT( avp->avp_public.avp_value );
    2212                
    22132212                /* For unknown AVP, we don't have a callback registered, so just skip */
    22142213                if (avp->avp_model) {
    22152214                        struct dict_object * type, * enumval;
    22162215                       
     2216                        /* Sanity */
     2217                        ASSERT( avp->avp_public.avp_value );
     2218
    22172219                        /* Get the list of callback for this AVP */
    22182220                        CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_AVP, avp->avp_model, &cb_list), goto error );
  • libfreeDiameter/sessions.c

    r258 r291  
    712712        CHECK_FCT( fd_sess_fromsid ( (char *) sid, len, session, new) );
    713713       
     714        /* Increase count */
     715        CHECK_FCT( fd_sess_ref_msg ( *session ) );
     716       
     717        /* Done */
     718        return 0;
     719}
     720
     721int fd_sess_ref_msg ( struct session * session )
     722{
     723        TRACE_ENTRY("%p", session);
     724        CHECK_PARAMS( VALIDATE_SI(session) );
     725
    714726        /* Update the msg refcount */
    715         CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );
    716         (*session)->msg_cnt++;
    717         CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );
    718        
    719         /* Done */
     727        CHECK_POSIX( pthread_mutex_lock(&session->stlock) );
     728        session->msg_cnt++;
     729        CHECK_POSIX( pthread_mutex_unlock(&session->stlock) );
     730       
    720731        return 0;
    721732}
Note: See TracChangeset for help on using the changeset viewer.