Skip to content

Commit

Permalink
modules/cdp: fixed typo in len check
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeepee committed Mar 8, 2016
1 parent e5b4cfd commit 5dfdfd8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion modules/cdp/api_process.c
Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions modules/cdp/peer.c
Expand Up @@ -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);
}
9 changes: 8 additions & 1 deletion modules/cdp/peer.h
Expand Up @@ -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
23 changes: 1 addition & 22 deletions modules/cdp/transaction.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
30 changes: 27 additions & 3 deletions modules/cdp/transaction.h
Expand Up @@ -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 */
Expand All @@ -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);

Expand Down

0 comments on commit 5dfdfd8

Please sign in to comment.