Mercurial > hg > freeDiameter
comparison libfdcore/p_psm.c @ 1238:8f9684264fe0
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.
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Thu, 10 Oct 2013 16:08:46 +0200 |
parents | 8c4dd4b693c6 |
children | 949973661b25 |
comparison
equal
deleted
inserted
replaced
1236:a0d9fb49694e | 1238:8f9684264fe0 |
---|---|
524 } | 524 } |
525 | 525 |
526 /* Associate */ | 526 /* Associate */ |
527 CHECK_FCT_DO( fd_msg_answ_associate( msg, req ), goto psm_end ); | 527 CHECK_FCT_DO( fd_msg_answ_associate( msg, req ), goto psm_end ); |
528 | 528 |
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 ); | |
534 } | 529 } |
535 | 530 |
536 /* Log incoming message */ | 531 /* Log incoming message */ |
537 fd_hook_call(HOOK_MESSAGE_RECEIVED, msg, peer, NULL, fd_msg_pmdl_get(msg)); | 532 fd_hook_call(HOOK_MESSAGE_RECEIVED, msg, peer, NULL, fd_msg_pmdl_get(msg)); |
538 | 533 |
557 CHECK_FCT_DO( fd_p_expi_update(peer), goto psm_end ); | 552 CHECK_FCT_DO( fd_p_expi_update(peer), goto psm_end ); |
558 | 553 |
559 /* Set the message source and add the Route-Record */ | 554 /* Set the message source and add the Route-Record */ |
560 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); | 555 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); |
561 | 556 |
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 | |
562 /* Requeue to the global incoming queue */ | 564 /* Requeue to the global incoming queue */ |
563 CHECK_FCT_DO(fd_fifo_post(fd_g_incoming, &msg), goto psm_end ); | 565 CHECK_FCT_DO(fd_fifo_post(fd_g_incoming, &msg), goto psm_end ); |
564 | 566 |
565 /* Update the peer timer (only in OPEN state) */ | 567 /* Update the peer timer (only in OPEN state) */ |
566 if ((cur_state == STATE_OPEN) && (!peer->p_flags.pf_dw_pending)) { | 568 if ((cur_state == STATE_OPEN) && (!peer->p_flags.pf_dw_pending)) { |
598 goto psm_end; | 600 goto psm_end; |
599 } ); | 601 } ); |
600 } else { | 602 } else { |
601 if (msg == NULL) { | 603 if (msg == NULL) { |
602 /* Send the error back to the peer */ | 604 /* 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), ); |
604 if (error) { | 606 if (error) { |
605 char buf[256]; | 607 char buf[256]; |
606 /* Only if an error occurred & the message was not saved / dumped */ | 608 /* Only if an error occurred & the message was not saved / dumped */ |
607 snprintf(buf, sizeof(buf), "%s: error sending a message", peer->p_hdr.info.pi_diamid); | 609 snprintf(buf, sizeof(buf), "%s: error sending a message", peer->p_hdr.info.pi_diamid); |
608 fd_hook_call(HOOK_MESSAGE_DROPPED, error, peer, buf, fd_msg_pmdl_get(error)); | 610 fd_hook_call(HOOK_MESSAGE_DROPPED, error, peer, buf, fd_msg_pmdl_get(error)); |
652 | 654 |
653 /* Set the error code */ | 655 /* Set the error code */ |
654 CHECK_FCT_DO( fd_msg_rescode_set(msg, "DIAMETER_COMMAND_UNSUPPORTED", "Or maybe the P-bit or application Id are erroneous.", NULL, 1 ), break ); | 656 CHECK_FCT_DO( fd_msg_rescode_set(msg, "DIAMETER_COMMAND_UNSUPPORTED", "Or maybe the P-bit or application Id are erroneous.", NULL, 1 ), break ); |
655 | 657 |
656 /* Send the answer */ | 658 /* 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 ); |
658 } while (0); | 660 } while (0); |
659 } else { | 661 } else { |
660 /* We did ASK for it ??? */ | 662 /* We did ASK for it ??? */ |
661 TRACE_DEBUG(INFO, "Received answer with erroneous 'is_routable' result..."); | 663 TRACE_DEBUG(INFO, "Received answer with erroneous 'is_routable' result..."); |
662 } | 664 } |