Navigation


Changeset 1238:8f9684264fe0 in freeDiameter


Ignore:
Timestamp:
Oct 10, 2013, 11:08:46 PM (10 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Change management of the p_reqin_count counter to be updated only on routable messages. This should limit the errors in the counter value resulting from rejected or discarded link-local messages.

Location:
libfdcore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/fdcore-internal.h

    r1207 r1238  
    297297
    298298/* Peer out */
    299 int fd_out_send(struct msg ** msg, struct cnxctx * cnx, struct fd_peer * peer);
     299int fd_out_send(struct msg ** msg, struct cnxctx * cnx, struct fd_peer * peer, int update_reqin_cnt);
    300300int fd_out_start(struct fd_peer * peer);
    301301int fd_out_stop(struct fd_peer * peer);
  • libfdcore/p_ce.c

    r1230 r1238  
    635635        CHECK_FCT_DO( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, cer, MSGFL_ANSW_ERROR ), goto destroy );
    636636        CHECK_FCT_DO( fd_msg_rescode_set(*cer, error->pei_errcode, error->pei_message, error->pei_avp, 1 ), goto destroy );
    637         CHECK_FCT_DO( fd_out_send(cer, *recv_cnx, NULL), goto destroy );
     637        CHECK_FCT_DO( fd_out_send(cer, *recv_cnx, NULL, 0), goto destroy );
    638638       
    639639        if (error->pei_avp_free) {
     
    659659        /* Send CER on the new connection */
    660660        CHECK_FCT( create_CER(peer, initiator, &cer) );
    661         CHECK_FCT( fd_out_send(&cer, initiator, peer) );
     661        CHECK_FCT( fd_out_send(&cer, initiator, peer, 0) );
    662662       
    663663        /* Are we doing an election ? */
     
    714714
    715715                /* msg now contains an answer message to send back */
    716                 CHECK_FCT_DO( fd_out_send(msg, NULL, peer), /* In case of error the message has already been dumped */ );
     716                CHECK_FCT_DO( fd_out_send(msg, NULL, peer, 0), /* In case of error the message has already been dumped */ );
    717717        }
    718718       
     
    943943        }
    944944       
    945         /* Update the counter to match with the answer being sent */
    946         CHECK_POSIX( pthread_mutex_lock(&peer->p_state_mtx) );
    947         peer->p_reqin_count++;
    948         CHECK_POSIX( pthread_mutex_unlock(&peer->p_state_mtx) );
    949 
    950945        /* Reply a CEA */
    951946        CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &msg, 0 ) );
     
    956951        fd_hook_call(HOOK_PEER_CONNECT_SUCCESS, msg, peer, NULL, NULL);
    957952       
    958         CHECK_FCT( fd_out_send(&msg, peer->p_cnxctx, peer ) );
     953        CHECK_FCT( fd_out_send(&msg, peer->p_cnxctx, peer, 0 ) );
    959954       
    960955        /* Handshake if needed */
  • libfdcore/p_dp.c

    r1186 r1238  
    113113                CHECK_FCT( fd_peer_get_load_pending(&peer->p_hdr, &to_receive, &to_send) );
    114114               
    115                 if ((to_receive == 0) && (to_send == 1 /* only the DPA */)) {
     115                if ((to_receive == 0) && (to_send == 0)) {
    116116                        /* No pending exchange, move to CLOSING directly */
    117117                        CHECK_FCT( fd_psm_change_state(peer, STATE_CLOSING) );
    118118               
    119119                        /* Now send the DPA */
    120                         CHECK_FCT( fd_out_send( msg, NULL, peer) );
     120                        CHECK_FCT( fd_out_send( msg, NULL, peer, 0) );
    121121                       
    122122                        /* and move to CLOSED */
     
    132132                       
    133133                        /* Now send the DPA */
    134                         CHECK_FCT( fd_out_send( msg, NULL, peer) );
     134                        CHECK_FCT( fd_out_send( msg, NULL, peer, 0) );
    135135                }
    136136        } else {
     
    202202       
    203203        /* Now send the DPR message */
    204         CHECK_FCT_DO( fd_out_send(&msg, NULL, peer), /* ignore since we are on timeout anyway */ );
     204        CHECK_FCT_DO( fd_out_send(&msg, NULL, peer, 0), /* ignore since we are on timeout anyway */ );
    205205       
    206206        return 0;
  • libfdcore/p_dw.c

    r1186 r1238  
    8383       
    8484        /* Now send this message */
    85         CHECK_FCT( fd_out_send(&msg, NULL, peer) );
     85        CHECK_FCT( fd_out_send(&msg, NULL, peer, 0) );
    8686       
    8787        /* And mark the pending DW */
     
    106106                CHECK_FCT( fd_msg_rescode_set( *msg, "DIAMETER_SUCCESS", NULL, NULL, 0 ) );
    107107                CHECK_FCT( fd_msg_add_origin ( *msg, 1 ) );
    108                 CHECK_FCT( fd_out_send( msg, peer->p_cnxctx, peer) );
     108                CHECK_FCT( fd_out_send( msg, peer->p_cnxctx, peer, 0) );
    109109               
    110110        } else {
  • libfdcore/p_out.c

    r1207 r1238  
    160160
    161161/* Wrapper to sending a message either by out thread (peer in OPEN state) or directly; cnx or peer must be provided. Flags are valid only for direct sending, not through thread (unused) */
    162 int fd_out_send(struct msg ** msg, struct cnxctx * cnx, struct fd_peer * peer)
     162int fd_out_send(struct msg ** msg, struct cnxctx * cnx, struct fd_peer * peer, int update_reqin_cnt)
    163163{
    164164        struct msg_hdr * hdr;
     
    167167        CHECK_PARAMS( msg && *msg && (cnx || (peer && peer->p_cnxctx)));
    168168       
    169         if (peer) {
     169        if (update_reqin_cnt && peer) {
    170170                CHECK_FCT( fd_msg_hdr(*msg, &hdr) );
    171171                if (!(hdr->msg_flags & CMD_FLAG_REQUEST)) {
  • libfdcore/p_psm.c

    r1198 r1238  
    527527                        CHECK_FCT_DO( fd_msg_answ_associate( msg, req ), goto psm_end );
    528528                       
    529                 } else {
    530                         /* Mark the incoming request so that we know we have pending answers for this peer */
    531                         CHECK_POSIX_DO( pthread_mutex_lock(&peer->p_state_mtx), goto psm_end  );
    532                         peer->p_reqin_count++;
    533                         CHECK_POSIX_DO( pthread_mutex_unlock(&peer->p_state_mtx), goto psm_end  );
    534529                }
    535530               
     
    560555                                        CHECK_FCT_DO( fd_msg_source_setrr( msg, peer->p_hdr.info.pi_diamid, peer->p_hdr.info.pi_diamidlen, fd_g_config->cnf_dict ), goto psm_end);
    561556
     557                                        if ((hdr->msg_flags & CMD_FLAG_REQUEST)) {
     558                                                /* Mark the incoming request so that we know we have pending answers for this peer */
     559                                                CHECK_POSIX_DO( pthread_mutex_lock(&peer->p_state_mtx), goto psm_end  );
     560                                                peer->p_reqin_count++;
     561                                                CHECK_POSIX_DO( pthread_mutex_unlock(&peer->p_state_mtx), goto psm_end  );
     562                                        }
     563                                               
    562564                                        /* Requeue to the global incoming queue */
    563565                                        CHECK_FCT_DO(fd_fifo_post(fd_g_incoming, &msg), goto psm_end );
     
    601603                                if (msg == NULL) {
    602604                                        /* Send the error back to the peer */
    603                                         CHECK_FCT_DO( ret = fd_out_send(&error, NULL, peer),  );
     605                                        CHECK_FCT_DO( ret = fd_out_send(&error, NULL, peer, 0),  );
    604606                                        if (error) {
    605607                                                char buf[256];
     
    655657
    656658                                                /* Send the answer */
    657                                                 CHECK_FCT_DO( fd_out_send(&msg, peer->p_cnxctx, peer), break );
     659                                                CHECK_FCT_DO( fd_out_send(&msg, peer->p_cnxctx, peer, 0), break );
    658660                                        } while (0);
    659661                                } else {
  • libfdcore/p_sr.c

    r1232 r1238  
    337337        /* The list of expiring requests must be empty now */
    338338        ASSERT( FD_IS_LIST_EMPTY(&srlist->exp) );
     339        ASSERT( srlist->cnt == 0 ); /* debug the counter management if needed */
    339340       
    340341        CHECK_POSIX_DO( pthread_mutex_unlock(&srlist->mtx), /* continue anyway */ );
  • libfdcore/peers.c

    r1207 r1238  
    550550                fd_hook_call(HOOK_PEER_CONNECT_FAILED, *cer, NULL, "Received CER with invalid Origin-Host AVP", NULL);
    551551               
    552                 CHECK_FCT( fd_out_send(cer, *cnx, NULL) );
     552                CHECK_FCT( fd_out_send(cer, *cnx, NULL, 0) );
    553553                return EINVAL;
    554554        }
  • libfdcore/routing_dispatch.c

    r1230 r1238  
    415415                CHECK_FCT( fd_fifo_post(fd_g_incoming, pmsg) );
    416416        } else {
    417                 CHECK_FCT( fd_out_send(pmsg, NULL, peer) );
     417                CHECK_FCT( fd_out_send(pmsg, NULL, peer, 1) );
    418418        }
    419419       
     
    893893
    894894                /* Push the message into this peer */
    895                 CHECK_FCT( fd_out_send(&msgptr, NULL, peer) );
     895                CHECK_FCT( fd_out_send(&msgptr, NULL, peer, 1) );
    896896
    897897                /* We're done with this answer */
     
    10081008                if (fd_peer_getstate(peer) == STATE_OPEN) {
    10091009                        /* Send to this one */
    1010                         CHECK_FCT_DO( fd_out_send(&msgptr, NULL, peer), continue );
     1010                        CHECK_FCT_DO( fd_out_send(&msgptr, NULL, peer, 1), continue );
    10111011                       
    10121012                        /* If the sending was successful */
Note: See TracChangeset for help on using the changeset viewer.