[sr-dev] git:master: dmq: code cleanup, remove redundant includes

Charles Chance charles.chance at sipcentric.com
Fri Sep 20 22:09:07 CEST 2013


Module: sip-router
Branch: master
Commit: dcfa15de586e28a025e34590e800571b0e3abddf
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dcfa15de586e28a025e34590e800571b0e3abddf

Author: Charles Chance <charles.chance at sipcentric.com>
Committer: Charles Chance <charles.chance at sipcentric.com>
Date:   Fri Sep 20 21:07:30 2013 +0100

dmq: code cleanup, remove redundant includes

---

 modules/dmq/bind_dmq.h  |   15 +++++++++++++++
 modules/dmq/dmq.c       |   12 +++---------
 modules/dmq/dmq.h       |   18 ------------------
 modules/dmq/dmq_funcs.c |    4 ++++
 modules/dmq/message.c   |    6 +++---
 modules/dmq/message.h   |    2 +-
 6 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/modules/dmq/bind_dmq.h b/modules/dmq/bind_dmq.h
index d0330d4..c480646 100644
--- a/modules/dmq/bind_dmq.h
+++ b/modules/dmq/bind_dmq.h
@@ -45,5 +45,20 @@ typedef int (*bind_dmq_f)(dmq_api_t* api);
 
 int bind_dmq(dmq_api_t* api);
 
+static inline int dmq_load_api(dmq_api_t* api) {
+	bind_dmq_f binddmq;
+	binddmq = (bind_dmq_f)find_export("bind_dmq", 0, 0);
+	if ( binddmq == 0) {
+		LM_ERR("cannot find bind_dmq\n");
+		return -1;
+	}
+	if (binddmq(api) < 0)
+	{
+		LM_ERR("cannot bind dmq api\n");
+		return -1;
+	}
+	return 0;
+}
+
 #endif
 
diff --git a/modules/dmq/dmq.c b/modules/dmq/dmq.c
index f4eea3a..1640a7c 100644
--- a/modules/dmq/dmq.c
+++ b/modules/dmq/dmq.c
@@ -32,27 +32,21 @@
 #include <fcntl.h>
 #include <time.h>
 
-#include "../../sr_module.h"
-#include "../../dprint.h"
-#include "../../error.h"
 #include "../../ut.h"
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../usr_avp.h"
-#include "../../modules/tm/tm_load.h"
-#include "../../parser/parse_uri.h"
-#include "../../modules/sl/sl.h"
 #include "../../pt.h"
 #include "../../lib/kmi/mi.h"
 #include "../../hashes.h"
+#include "../../mod_fix.h"
+
 #include "dmq.h"
 #include "dmq_funcs.h"
-#include "peer.h"
 #include "bind_dmq.h"
-#include "worker.h"
+#include "message.h"
 #include "notification_peer.h"
 #include "dmqnode.h"
-#include "../../mod_fix.h"
 
 static int mod_init(void);
 static int child_init(int);
diff --git a/modules/dmq/dmq.h b/modules/dmq/dmq.h
index 02c1fcc..c5dfcbf 100644
--- a/modules/dmq/dmq.h
+++ b/modules/dmq/dmq.h
@@ -32,7 +32,6 @@
 #include "../../modules/tm/tm_load.h"
 #include "../../parser/parse_uri.h"
 #include "../../modules/sl/sl.h"
-#include "bind_dmq.h"
 #include "peer.h"
 #include "worker.h"
 
@@ -57,22 +56,5 @@ extern str dmq_400_rpl;
 extern str dmq_500_rpl;
 extern str dmq_404_rpl;
 
-static inline int dmq_load_api(dmq_api_t* api) {
-	bind_dmq_f binddmq;
-	binddmq = (bind_dmq_f)find_export("bind_dmq", 0, 0);
-	if ( binddmq == 0) {
-		LM_ERR("cannot find bind_dmq\n");
-		return -1;
-	}
-	if (binddmq(api) < 0)
-	{
-		LM_ERR("cannot bind dmq api\n");
-		return -1;
-	}
-	return 0;
-}
-
-int dmq_handle_message(struct sip_msg* msg, char* str1 ,char* str2);
-
 #endif
 
diff --git a/modules/dmq/dmq_funcs.c b/modules/dmq/dmq_funcs.c
index 33c4ab1..69130cb 100644
--- a/modules/dmq/dmq_funcs.c
+++ b/modules/dmq/dmq_funcs.c
@@ -31,6 +31,10 @@
 dmq_peer_t* register_dmq_peer(dmq_peer_t* peer)
 {
 	dmq_peer_t* new_peer;
+	if (!peer_list) {
+		LM_ERR("peer list not initialized\n");
+		return NULL;
+	}
 	lock_get(&peer_list->lock);
 	if(search_peer_list(peer_list, peer)) {
 		LM_ERR("peer already exists: %.*s %.*s\n", peer->peer_id.len, peer->peer_id.s,
diff --git a/modules/dmq/message.c b/modules/dmq/message.c
index a6ce2d4..05b77f1 100644
--- a/modules/dmq/message.c
+++ b/modules/dmq/message.c
@@ -1,6 +1,3 @@
-#include "../../parser/parse_to.h"
-#include "../../parser/parse_uri.h"
-#include "../../sip_msg_clone.h"
 /*
  * $Id$
  *
@@ -27,6 +24,9 @@
  */
 
 
+#include "../../parser/parse_to.h"
+#include "../../parser/parse_uri.h"
+#include "../../sip_msg_clone.h"
 #include "../../parser/parse_content.h"
 #include "../../parser/parse_from.h"
 #include "../../ut.h"
diff --git a/modules/dmq/message.h b/modules/dmq/message.h
index 6763960..4e9dc3a 100644
--- a/modules/dmq/message.h
+++ b/modules/dmq/message.h
@@ -26,6 +26,6 @@
 #ifndef _MESSAGE_H_
 #define _MESSAGE_H_
 
-int dmq_handle_message(struct sip_msg*, char*, char*);
+int dmq_handle_message(struct sip_msg*, char* str1, char* str2);
 
 #endif




More information about the sr-dev mailing list