Jelajahi Sumber

modules/cdp: fixed typo in len check

jaybeepee 9 tahun lalu
induk
melakukan
5dfdfd8476
5 mengubah file dengan 37 tambahan dan 35 penghapusan
  1. 1 1
      modules/cdp/api_process.c
  2. 0 8
      modules/cdp/peer.c
  3. 8 1
      modules/cdp/peer.h
  4. 1 22
      modules/cdp/transaction.c
  5. 27 3
      modules/cdp/transaction.h

+ 1 - 1
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_usecs =  (stop.tv_sec - t->started.tv_sec)*1000000 + (stop.tv_usec - t->started.tv_usec);
             long elapsed_msecs = elapsed_usecs/1000;
             long elapsed_msecs = elapsed_usecs/1000;
             if (elapsed_msecs > *latency_threshold_p) {
             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);
                     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 
                 else 
                     LM_ERR("Received diameter response outside of threshold (%d) - %ld (no session-id)\n", *latency_threshold_p, elapsed_msecs);
                     LM_ERR("Received diameter response outside of threshold (%d) - %ld (no session-id)\n", *latency_threshold_p, elapsed_msecs);

+ 0 - 8
modules/cdp/peer.c

@@ -107,11 +107,3 @@ void free_peer(peer *x,int locked)
 	shm_free(x);
 	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);
-}

+ 8 - 1
modules/cdp/peer.h

@@ -131,6 +131,13 @@ typedef struct _peer_t{
 peer* new_peer(str fqdn,str realm,int port,str src_addr);
 peer* new_peer(str fqdn,str realm,int port,str src_addr);
 void free_peer(peer *x,int locked);
 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
 #endif

+ 1 - 22
modules/cdp/transaction.c

@@ -50,7 +50,7 @@
 #include "cdp_stats.h"
 #include "cdp_stats.h"
 
 
 extern struct cdp_counters_h cdp_cnts_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.
  * Initializes the transaction structure.
@@ -153,27 +153,6 @@ inline void del_trans(AAAMessage *msg)
 	lock_release(trans_list->lock);
 	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.
  * Deallocate the memory taken by a transaction.
  * @param x - the transaction to deallocate
  * @param x - the transaction to deallocate

+ 27 - 3
modules/cdp/transaction.h

@@ -51,6 +51,7 @@
 #include "diameter.h"
 #include "diameter.h"
 #include "diameter_api.h"
 #include "diameter_api.h"
 
 
+
 /** Diameter Transaction representation */
 /** Diameter Transaction representation */
 typedef struct _cdp_trans_t{
 typedef struct _cdp_trans_t{
 	struct timeval started;			/**< Time the transaction was created - used to measure response times */
 	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_init();
 int cdp_trans_destroy();
 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);
 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);
 int cdp_trans_timer(time_t now, void* ptr);