[sr-dev] git:mariusbucur/dmq: added support for maintaining the dmq serverlist, and updating in accordingly.

Marius Ovidiu Bucur marius at marius-bucur.ro
Fri Apr 15 08:13:50 CEST 2011


Module: sip-router
Branch: mariusbucur/dmq
Commit: 8620313f057e7e9b7744c356e954daaf213d12b2
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8620313f057e7e9b7744c356e954daaf213d12b2

Author: Marius Bucur <marius at marius-bucur.ro>
Committer: Marius Bucur <marius at marius-bucur.ro>
Date:   Fri Apr 15 09:11:24 2011 +0300

added support for maintaining the dmq serverlist, and updating in accordingly.
currently, some of the functions are stubs

---

 modules_k/dmq/dmq.c               |    6 ++++++
 modules_k/dmq/dmq.h               |    3 +++
 modules_k/dmq/dmqnode.c           |    9 +++++++++
 modules_k/dmq/dmqnode.h           |   28 ++++++++++++++++++++++++++++
 modules_k/dmq/notification_peer.c |   11 +++++++++++
 modules_k/dmq/notification_peer.h |    4 +++-
 modules_k/dmq/peer.c              |    1 +
 modules_k/dmq/peer.h              |    1 +
 8 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/modules_k/dmq/dmq.c b/modules_k/dmq/dmq.c
index 7920361..b07d176 100644
--- a/modules_k/dmq/dmq.c
+++ b/modules_k/dmq/dmq.c
@@ -51,6 +51,7 @@
 #include "bind_dmq.h"
 #include "worker.h"
 #include "notification_peer.h"
+#include "dmqnode.h"
 #include "../../mod_fix.h"
 
 static int mod_init(void);
@@ -76,6 +77,8 @@ sl_api_t slb;
 /** module variables */
 dmq_worker_t* workers;
 dmq_peer_list_t* peer_list;
+/* the list of dmq servers */
+dmq_node_list_t* node_list;
 // the dmq module is a peer itself for receiving notifications regarding nodes
 dmq_peer_t dmq_notification_peer;
 
@@ -147,6 +150,9 @@ static int mod_init(void) {
 	/* load peer list - the list containing the module callbacks for dmq */
 	peer_list = init_peer_list();
 	
+	/* load the dmq node list - the list containing the dmq servers */
+	node_list = init_dmq_node_list();
+	
 	/* register worker processes - add one because of the ping process */
 	register_procs(num_workers);
 	
diff --git a/modules_k/dmq/dmq.h b/modules_k/dmq/dmq.h
index 6d0aac9..800ecbd 100644
--- a/modules_k/dmq/dmq.h
+++ b/modules_k/dmq/dmq.h
@@ -7,12 +7,15 @@
 #include "bind_dmq.h"
 #include "peer.h"
 #include "worker.h"
+#include "dmqnode.h"
 
 #define DEFAULT_NUM_WORKERS	2
 
 extern int num_workers;
 extern dmq_worker_t* workers;
 extern dmq_peer_t dmq_notification_peer;
+extern dmq_peer_list_t* peer_list;
+extern dmq_node_list_t* node_list;
 
 static inline int dmq_load_api(dmq_api_t* api) {
 	bind_dmq_f binddmq;
diff --git a/modules_k/dmq/dmqnode.c b/modules_k/dmq/dmqnode.c
new file mode 100644
index 0000000..4d57fe0
--- /dev/null
+++ b/modules_k/dmq/dmqnode.c
@@ -0,0 +1,9 @@
+#include "dmqnode.h"
+#include "dmq.h"
+
+dmq_node_list_t* init_dmq_node_list() {
+	dmq_node_list_t* node_list = shm_malloc(sizeof(dmq_node_list_t));
+	memset(node_list, 0, sizeof(dmq_node_list_t));
+	lock_init(&node_list->lock);
+	return node_list;
+}
\ No newline at end of file
diff --git a/modules_k/dmq/dmqnode.h b/modules_k/dmq/dmqnode.h
new file mode 100644
index 0000000..d62395b
--- /dev/null
+++ b/modules_k/dmq/dmqnode.h
@@ -0,0 +1,28 @@
+#ifndef DMQNODE_H
+#define DMQNODE_H
+
+#include <string.h>
+#include <stdlib.h>
+#include "../../lock_ops.h"
+#include "../../str.h"
+#include "../../mem/mem.h"
+#include "../../mem/shm_mem.h"
+#include "../../parser/parse_uri.h"
+
+typedef struct dmq_node {
+	struct sip_uri* uri;
+	int status;
+	int last_notification;
+	struct dmqnode* next;
+} dmq_node_t;
+
+typedef struct dmq_node_list {
+	gen_lock_t lock;
+	struct dmq_node* nodes;
+	int count;
+} dmq_node_list_t;
+
+dmq_node_list_t* init_dmq_node_list();
+int update_node_list(dmq_node_list_t* remote_list);
+
+#endif
\ No newline at end of file
diff --git a/modules_k/dmq/notification_peer.c b/modules_k/dmq/notification_peer.c
index 28fba07..8256142 100644
--- a/modules_k/dmq/notification_peer.c
+++ b/modules_k/dmq/notification_peer.c
@@ -12,6 +12,17 @@ int add_notification_peer() {
 }
 
 int dmq_notification_callback(struct sip_msg* msg) {
+	/* received dmqnode list */
+	dmq_node_list_t* rlist;
 	LM_ERR("dmq triggered from dmq_notification_callback\n");
+	rlist = extract_node_list(msg);
+	if(!rlist) {
+		LM_ERR("extract_node_list failed\n");
+		return -1;
+	}
+	if(update_node_list(rlist) < 0) {
+		LM_ERR("cannot update node_list\n");
+		return -1;
+	}
 	return 0;
 }
\ No newline at end of file
diff --git a/modules_k/dmq/notification_peer.h b/modules_k/dmq/notification_peer.h
index 0e6121a..e1e7963 100644
--- a/modules_k/dmq/notification_peer.h
+++ b/modules_k/dmq/notification_peer.h
@@ -1,4 +1,6 @@
 #include "dmq.h"
+#include "dmqnode.h"
 
 int add_notification_peer();
-int dmq_notification_callback(struct sip_msg* msg);
\ No newline at end of file
+int dmq_notification_callback(struct sip_msg* msg);
+dmq_node_list_t* extract_node_list(struct sip_msg* msg);
\ No newline at end of file
diff --git a/modules_k/dmq/peer.c b/modules_k/dmq/peer.c
index 4215289..85e5c70 100644
--- a/modules_k/dmq/peer.c
+++ b/modules_k/dmq/peer.c
@@ -1,4 +1,5 @@
 #include "peer.h"
+#include "dmq.h"
 
 dmq_peer_list_t* init_peer_list() {
 	dmq_peer_list_t* peer_list = shm_malloc(sizeof(dmq_peer_list_t));
diff --git a/modules_k/dmq/peer.h b/modules_k/dmq/peer.h
index b9a09ee..702ae34 100644
--- a/modules_k/dmq/peer.h
+++ b/modules_k/dmq/peer.h
@@ -3,6 +3,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include "../../lock_ops.h"
 #include "../../str.h"
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"




More information about the sr-dev mailing list