Navigation


Changeset 1216:581bbd48524a in freeDiameter


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

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_rt/dbg_rt.c

    r1127 r1216  
    5959
    6060/* Path selection debug callback */
    61 static int dbgrt_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)
     61static int dbgrt_out_cb(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
    6262{
    6363        struct fd_list * li;
     64        struct msg * msg = *pmsg;
    6465        char * buf = NULL; size_t buflen;
    6566       
  • extensions/rt_default/rt_default.c

    r741 r1216  
    4141
    4242/* The callback called on new messages */
    43 static int rtd_out(void * cbdata, struct msg * msg, struct fd_list * candidates)
     43static int rtd_out(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
    4444{
     45        struct msg * msg = *pmsg;
    4546        TRACE_ENTRY("%p %p %p", cbdata, msg, candidates);
    4647       
  • extensions/rt_ereg/rtereg.c

    r1127 r1216  
    126126
    127127/* The callback called on new messages */
    128 static int rtereg_out(void * cbdata, struct msg * msg, struct fd_list * candidates)
    129 {
     128static int rtereg_out(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
     129{
     130        struct msg * msg = *pmsg;
    130131        struct avp * avp = NULL;
    131132       
  • extensions/rt_load_balance/rt_load_balance.c

    r1043 r1216  
    3737
    3838/* The callback for load balancing the requests across the peers */
    39 static int rt_load_balancing(void * cbdata, struct msg * msg, struct fd_list * candidates)
     39static int rt_load_balancing(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
    4040{
    4141        struct fd_list *lic;
     42        struct msg * msg = *pmsg;
    4243       
    4344        TRACE_ENTRY("%p %p %p", cbdata, msg, candidates);
  • extensions/rt_redirect/redir_out.c

    r1127 r1216  
    3838
    3939/* Find the data pertinent to a type in the input data */
    40 static int get_data_to_match(enum redir_h_u type, struct msg * msg, union matchdata * data, int * nodata)
     40static int get_data_to_match(enum redir_h_u type, struct msg *msg, union matchdata * data, int * nodata)
    4141{
    4242        TRACE_ENTRY("%d %p %p %p", type, msg, data, nodata);
     
    220220
    221221/* OUT callback */
    222 int redir_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)
     222int redir_out_cb(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
    223223{
    224224        int i, ret = 0;
     225        struct msg * msg = *pmsg;
    225226       
    226227        TRACE_ENTRY("%p %p %p", cbdata, msg, candidates);
  • extensions/rt_redirect/rt_redir.h

    r740 r1216  
    171171
    172172/* Out callback */
    173 int redir_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates);
     173int redir_out_cb(void * cbdata, struct msg ** pmsg, struct fd_list * candidates);
  • extensions/test_rt_any/test_rt_any.c

    r741 r1216  
    4141
    4242/* The callback */
    43 static int tra_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)
     43static int tra_out_cb(void * cbdata, struct msg ** pmsg, struct fd_list * candidates)
    4444{
     45        struct msg * msg = *pmsg;
    4546        struct fd_list * li;
    4647       
  • include/freeDiameter/libfdcore.h

    r1194 r1216  
    763763 *  ENOMEM      : Not enough memory to complete the operation
    764764 */
    765 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 );
     765int 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 );
    766766/*
    767767 * CALLBACK:    rt_out_cb
     
    769769 * PARAMETERS:
    770770 *  cbdata      : pointer to some data that was registered with the callback.
    771  *  msg         : The message that must be sent.
     771 *  pmsg        : pointer to the message that must be sent. upon return if *msg is NULL, the processing stops and the message is not sent.
    772772 *  list        : The list of peers to which the message may be sent to, as returned by fd_rtd_candidate_extract
    773773 *
  • 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.