Skip to content

Commit

Permalink
Fixed the stats for counting transaction based on the final reply code
Browse files Browse the repository at this point in the history
The fix consist of counting only ONCE each transaction (for the xxx_transaction statistics), disregarding its retransmissions, multiple 200OK replies or final code override (like 200 after a negative reply).

Closes  #1636
Many thanks to @bcnewlin for his testing and validation of the fix.

(cherry picked from commit 68bedfe)
  • Loading branch information
bogdan-iancu committed Aug 1, 2019
1 parent de942dd commit 6357a1a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
4 changes: 3 additions & 1 deletion modules/tm/t_funcs.c
Expand Up @@ -53,6 +53,7 @@
#include "t_msgbuilder.h"
#include "t_lookup.h"
#include "config.h"
#include "t_stats.h"
#include "../../context.h"


Expand Down Expand Up @@ -144,7 +145,8 @@ void put_on_wait( struct cell *Trans )
4. WAIT timer executed,
transaction deleted
*/
set_1timer( &Trans->wait_tl, WT_TIMER_LIST, 0 );
if (set_1timer( &Trans->wait_tl, WT_TIMER_LIST, 0 )==0)
stats_trans_code(Trans->uas.status);
}


Expand Down
24 changes: 20 additions & 4 deletions modules/tm/t_stats.h
Expand Up @@ -48,10 +48,12 @@ extern stat_var *tm_trans_inuse;


#ifdef STATISTICS
inline static void stats_trans_rpl( int code, int local ) {

stat_var *numerical_stat;

/* update the statistics regading the final codes of the transactions
* A single transaction will generate a single update on one of
* these statistics
*/
inline static void stats_trans_code( int code)
{
if (tm_enable_stats) {
if (code>=700) {
return;
Expand All @@ -66,6 +68,19 @@ inline static void stats_trans_rpl( int code, int local ) {
} else if (code>=200) {
update_stat( tm_trans_2xx, 1);
}
}
}

/* update the statistics regading the final replies sent to UAC side
* A single transaction may generate multiple updates on different
* statistics if (1) there is a retransmission of the final reply or
* (2) there are multiple final replies (like multi 200 OK)
*/
inline static void stats_trans_rpl( int code, int local )
{
stat_var *numerical_stat;

if (tm_enable_stats) {
if (local)
update_stat( tm_loc_rpls, 1);
else
Expand All @@ -91,6 +106,7 @@ inline static void stats_trans_new( int local ) {
}
}
#else
#define stats_trans_code( _code )
#define stats_trans_rpl( _code , _local )
#define stats_trans_new( _local )
#endif
Expand Down
15 changes: 12 additions & 3 deletions modules/tm/timer.c
Expand Up @@ -938,20 +938,26 @@ void set_timer( struct timer_link *new_tl, enum lists list_id,


/* similar to set_timer, except it allows only one-time
timer setting and all later attempts are ignored */
void set_1timer( struct timer_link *new_tl, enum lists list_id,
* timer setting and all later attempts are ignored
* Returned values:
* 0 if the linker was actually added to the list
* -1 if the linker was not added as it was already found in the list;
* do not consider this an error, but a NOP.
*/
int set_1timer( struct timer_link *new_tl, enum lists list_id,
utime_t* ext_timeout )
{
utime_t timeout;
struct timer* list;
int ret = -1;


if (list_id>=NR_OF_TIMER_LISTS) {
LM_CRIT("unknown list: %d\n", list_id);
#ifdef EXTRA_DEBUG
abort();
#endif
return;
return ret;
}

if (!ext_timeout) {
Expand All @@ -966,8 +972,11 @@ void set_1timer( struct timer_link *new_tl, enum lists list_id,
if (!new_tl->time_out) {
insert_timer_unsafe( list, new_tl, timeout +
((timer_id2type[list_id]==UTIME_TYPE)?get_uticks():get_ticks()));
ret = 0;
}
unlock(list->mutex);

return ret;
}


Expand Down
2 changes: 1 addition & 1 deletion modules/tm/timer.h
Expand Up @@ -107,7 +107,7 @@ void set_timer( struct timer_link *new_tl, enum lists list_id,

/* similar to set_timer, except it allows only one-time
timer setting and all later attempts are ignored */
void set_1timer( struct timer_link *new_tl, enum lists list_id,
int set_1timer( struct timer_link *new_tl, enum lists list_id,
utime_t* ext_timeout );

void timer_routine( unsigned int, void*);
Expand Down

0 comments on commit 6357a1a

Please sign in to comment.