Skip to content

Commit

Permalink
tm: support to add text in Reason header for local generated CANCEL
Browse files Browse the repository at this point in the history
(cherry picked from commit 743fee5)
  • Loading branch information
miconda committed Nov 4, 2015
1 parent c5a53e0 commit 6d3db65
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/tm/t_cancel.c
Expand Up @@ -37,6 +37,36 @@
#include "t_hooks.h"


typedef struct cancel_reason_map {
int code;
str text;
} cancel_reason_map_t;

static cancel_reason_map_t _cancel_reason_map[] = {
200, str_init("Answered elsewhere"),
0, {0, 0}
};

/**
*
*/
void cancel_reason_text(struct cancel_info* cancel_data)
{
int i;

if(cancel_data->reason.cause<=0
|| cancel_data->reason.u.text.s!=NULL) return;

for(i=0; _cancel_reason_map[i].text.s!=0; i++) {
if(_cancel_reason_map[i].code==cancel_data->reason.cause) {
cancel_data->reason.u.text = _cancel_reason_map[i].text;
return;
}
}

return;
}

/** Prepare to cancel a transaction.
* Determine which branches should be canceled and prepare them (internally
* mark them as "cancel in progress", see prepare_cancel_branch()).
Expand Down Expand Up @@ -87,6 +117,9 @@ int cancel_uacs( struct cell *t, struct cancel_info* cancel_data, int flags)
int r;

ret=0;

cancel_reason_text(cancel_data);

/* cancel pending client transactions, if any */
for( i=0 ; i<t->nr_of_outgoings ; i++ )
if (cancel_data->cancel_bitmap & (1<<i)){
Expand Down

0 comments on commit 6d3db65

Please sign in to comment.