Navigation


Changeset 1216:581bbd48524a in freeDiameter for libfdcore


Ignore:
Timestamp:
Jun 19, 2013, 11:03:24 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Children:
1217:3f7c74ef3787, 1218:152466ff49f8
Phase:
public
Message:

Change prototype of rt_out callbacks to allow disposal of messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/routing_dispatch.c

    r1212 r1216  
    5858        union {
    5959                int (*rt_fwd_cb)(void * cbdata, struct msg ** msg);
    60                 int (*rt_out_cb)(void * cbdata, struct msg * msg, struct fd_list * candidates);
     60                int (*rt_out_cb)(void * cbdata, struct msg ** msg, struct fd_list * candidates);
    6161        };
    6262};     
     
    135135
    136136/* Register a new OUT callback */
    137 int fd_rt_out_register ( int (*rt_out_cb)(void * cbdata, struct msg * msg, struct fd_list * candidates), void * cbdata, int priority, struct fd_rt_out_hdl ** handler )
     137int fd_rt_out_register ( int (*rt_out_cb)(void * cbdata, struct msg ** pmsg, struct fd_list * candidates), void * cbdata, int priority, struct fd_rt_out_hdl ** handler )
    138138{
    139139        struct rt_hdl * new;
     
    189189
    190190/* Prevent sending to peers that do not support the message application */
    191 static int dont_send_if_no_common_app(void * cbdata, struct msg * msg, struct fd_list * candidates)
    192 {
     191static int dont_send_if_no_common_app(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
     192{
     193        struct msg * msg = *pmsg;
    193194        struct fd_list * li;
    194195        struct msg_hdr * hdr;
     
    221222
    222223/* Detect if the Destination-Host and Destination-Realm match the peer */
    223 static int score_destination_avp(void * cbdata, struct msg * msg, struct fd_list * candidates)
    224 {
     224static int score_destination_avp(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
     225{
     226        struct msg * msg = *pmsg;
    225227        struct fd_list * li;
    226228        struct avp * avp;
     
    959961
    960962                /* We call the cb by reverse priority order */
    961                 for (   li = rt_out_list.prev ; li != &rt_out_list ; li = li->prev ) {
     963                for (   li = rt_out_list.prev ; (msgptr != NULL) && (li != &rt_out_list) ; li = li->prev ) {
    962964                        struct rt_hdl * rh = (struct rt_hdl *)li;
    963965
    964966                        TRACE_DEBUG(ANNOYING, "Calling next OUT callback on %p : %p (prio %d)", msgptr, rh->rt_out_cb, rh->prio);
    965                         CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, msgptr, candidates),
     967                        CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, &msgptr, candidates),
    966968                                {
    967969                                        char buf[256];
     
    971973                                        fd_msg_free(msgptr);
    972974                                        msgptr = NULL;
    973                                         break;
    974975                                } );
    975976                }
     
    978979                CHECK_FCT( pthread_rwlock_unlock( &rt_out_lock ) );
    979980
    980                 /* If an error occurred, skip to the next message */
     981                /* If an error occurred or the callback disposed of the message, go to next message */
    981982                if (! msgptr) {
    982                         if (rtd)
    983                                 fd_rtd_free(&rtd);
    984983                        return 0;
    985984                }
Note: See TracChangeset for help on using the changeset viewer.