From 5dfdfd84761d061615addd30b4c59af5ca32e907 Mon Sep 17 00:00:00 2001 From: jaybeepee Date: Tue, 8 Mar 2016 13:09:17 +0200 Subject: [PATCH] modules/cdp: fixed typo in len check --- modules/cdp/api_process.c | 2 +- modules/cdp/peer.c | 8 -------- modules/cdp/peer.h | 9 ++++++++- modules/cdp/transaction.c | 23 +---------------------- modules/cdp/transaction.h | 30 +++++++++++++++++++++++++++--- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/modules/cdp/api_process.c b/modules/cdp/api_process.c index e53dda74304..78a0d76c73c 100644 --- a/modules/cdp/api_process.c +++ b/modules/cdp/api_process.c @@ -108,7 +108,7 @@ int api_callback(peer *p,AAAMessage *msg,void* ptr) long elapsed_usecs = (stop.tv_sec - t->started.tv_sec)*1000000 + (stop.tv_usec - t->started.tv_usec); long elapsed_msecs = elapsed_usecs/1000; if (elapsed_msecs > *latency_threshold_p) { - if (msg->sessionId && msg->sessionId->data) + if (msg->sessionId && msg->sessionId->data.len) LM_ERR("Received diameter response outside of threshold (%d) - %ld (session-id: [%.*s])\n", *latency_threshold_p, elapsed_msecs, msg->sessionId->data.len, msg->sessionId->data.s); else LM_ERR("Received diameter response outside of threshold (%d) - %ld (no session-id)\n", *latency_threshold_p, elapsed_msecs); diff --git a/modules/cdp/peer.c b/modules/cdp/peer.c index 0114f742eed..06366fbf08d 100644 --- a/modules/cdp/peer.c +++ b/modules/cdp/peer.c @@ -107,11 +107,3 @@ void free_peer(peer *x,int locked) shm_free(x); } -/** - * "Touches" the peer by updating the last activity time to the current time. - * @param p - which peer to touch - */ -inline void touch_peer(peer *p) -{ - p->activity = time(0); -} diff --git a/modules/cdp/peer.h b/modules/cdp/peer.h index db703166907..b0717235971 100644 --- a/modules/cdp/peer.h +++ b/modules/cdp/peer.h @@ -131,6 +131,13 @@ typedef struct _peer_t{ peer* new_peer(str fqdn,str realm,int port,str src_addr); void free_peer(peer *x,int locked); -inline void touch_peer(peer *p); +/** + * "Touches" the peer by updating the last activity time to the current time. + * @param p - which peer to touch + */ +inline void touch_peer(peer *p) +{ + p->activity = time(0); +} #endif diff --git a/modules/cdp/transaction.c b/modules/cdp/transaction.c index f98f6af2fd0..85456e3a2a8 100644 --- a/modules/cdp/transaction.c +++ b/modules/cdp/transaction.c @@ -50,7 +50,7 @@ #include "cdp_stats.h" extern struct cdp_counters_h cdp_cnts_h; -cdp_trans_list_t *trans_list=0; /**< list of transactions */ +//trans_list=0; /**< list of transactions */ /** * Initializes the transaction structure. @@ -153,27 +153,6 @@ inline void del_trans(AAAMessage *msg) lock_release(trans_list->lock); } -/** - * Return and remove the transaction from the transaction list. - * @param msg - the message that this transaction relates to - * @returns the cdp_trans_t* if found or NULL if not - */ -inline cdp_trans_t* cdp_take_trans(AAAMessage *msg) -{ - cdp_trans_t *x; - lock_get(trans_list->lock); - x = trans_list->head; - while(x&& x->endtoendid!=msg->endtoendId && x->hopbyhopid!=msg->hopbyhopId) x = x->next; - if (x){ - if (x->prev) x->prev->next = x->next; - else trans_list->head = x->next; - if (x->next) x->next->prev = x->prev; - else trans_list->tail = x->prev; - } - lock_release(trans_list->lock); - return x; -} - /** * Deallocate the memory taken by a transaction. * @param x - the transaction to deallocate diff --git a/modules/cdp/transaction.h b/modules/cdp/transaction.h index 5524993ca8b..2c4336a6dd7 100644 --- a/modules/cdp/transaction.h +++ b/modules/cdp/transaction.h @@ -51,6 +51,7 @@ #include "diameter.h" #include "diameter_api.h" + /** Diameter Transaction representation */ typedef struct _cdp_trans_t{ struct timeval started; /**< Time the transaction was created - used to measure response times */ @@ -74,10 +75,33 @@ typedef struct { int cdp_trans_init(); int cdp_trans_destroy(); -inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop); +cdp_trans_list_t *trans_list; /**< list of transactions */ + +extern inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop); void del_trans(AAAMessage *msg); -inline cdp_trans_t* cdp_take_trans(AAAMessage *msg); -inline void cdp_free_trans(cdp_trans_t *x); +//extern inline cdp_trans_t* cdp_take_trans(AAAMessage *msg); +/** + * Return and remove the transaction from the transaction list. + * @param msg - the message that this transaction relates to + * @returns the cdp_trans_t* if found or NULL if not + */ +inline cdp_trans_t* cdp_take_trans(AAAMessage *msg) +{ + cdp_trans_t *x; + lock_get(trans_list->lock); + x = trans_list->head; + while(x&& x->endtoendid!=msg->endtoendId && x->hopbyhopid!=msg->hopbyhopId) x = x->next; + if (x){ + if (x->prev) x->prev->next = x->next; + else trans_list->head = x->next; + if (x->next) x->next->prev = x->prev; + else trans_list->tail = x->prev; + } + lock_release(trans_list->lock); + return x; +} + +extern inline void cdp_free_trans(cdp_trans_t *x); int cdp_trans_timer(time_t now, void* ptr);