From f8a178fe9a21116320c7d30b5a9ced01c29ac3d3 Mon Sep 17 00:00:00 2001 From: jaybeepee Date: Wed, 9 Mar 2016 07:58:41 +0200 Subject: [PATCH] Revert "modules/cdp: fixed typo in len check" This reverts commit 5dfdfd84761d061615addd30b4c59af5ca32e907. --- 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, 35 insertions(+), 37 deletions(-) diff --git a/modules/cdp/api_process.c b/modules/cdp/api_process.c index 78a0d76c73c..e53dda74304 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.len) + if (msg->sessionId && msg->sessionId->data) 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 06366fbf08d..0114f742eed 100644 --- a/modules/cdp/peer.c +++ b/modules/cdp/peer.c @@ -107,3 +107,11 @@ 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 b0717235971..db703166907 100644 --- a/modules/cdp/peer.h +++ b/modules/cdp/peer.h @@ -131,13 +131,6 @@ typedef struct _peer_t{ peer* new_peer(str fqdn,str realm,int port,str src_addr); void free_peer(peer *x,int locked); -/** - * "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); -} +inline void touch_peer(peer *p); #endif diff --git a/modules/cdp/transaction.c b/modules/cdp/transaction.c index 85456e3a2a8..f98f6af2fd0 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; -//trans_list=0; /**< list of transactions */ +cdp_trans_list_t *trans_list=0; /**< list of transactions */ /** * Initializes the transaction structure. @@ -153,6 +153,27 @@ 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 2c4336a6dd7..5524993ca8b 100644 --- a/modules/cdp/transaction.h +++ b/modules/cdp/transaction.h @@ -51,7 +51,6 @@ #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 */ @@ -75,33 +74,10 @@ typedef struct { int cdp_trans_init(); int cdp_trans_destroy(); -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); +inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop); void del_trans(AAAMessage *msg); -//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); +inline cdp_trans_t* cdp_take_trans(AAAMessage *msg); +inline void cdp_free_trans(cdp_trans_t *x); int cdp_trans_timer(time_t now, void* ptr);