Browse code

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

Marius Bucur authored on 15/04/2011 06:11:24
Showing 8 changed files
... ...
@@ -51,6 +51,7 @@
51 51
 #include "bind_dmq.h"
52 52
 #include "worker.h"
53 53
 #include "notification_peer.h"
54
+#include "dmqnode.h"
54 55
 #include "../../mod_fix.h"
55 56
 
56 57
 static int mod_init(void);
... ...
@@ -76,6 +77,8 @@ sl_api_t slb;
76 76
 /** module variables */
77 77
 dmq_worker_t* workers;
78 78
 dmq_peer_list_t* peer_list;
79
+/* the list of dmq servers */
80
+dmq_node_list_t* node_list;
79 81
 // the dmq module is a peer itself for receiving notifications regarding nodes
80 82
 dmq_peer_t dmq_notification_peer;
81 83
 
... ...
@@ -147,6 +150,9 @@ static int mod_init(void) {
147 147
 	/* load peer list - the list containing the module callbacks for dmq */
148 148
 	peer_list = init_peer_list();
149 149
 	
150
+	/* load the dmq node list - the list containing the dmq servers */
151
+	node_list = init_dmq_node_list();
152
+	
150 153
 	/* register worker processes - add one because of the ping process */
151 154
 	register_procs(num_workers);
152 155
 	
... ...
@@ -7,12 +7,15 @@
7 7
 #include "bind_dmq.h"
8 8
 #include "peer.h"
9 9
 #include "worker.h"
10
+#include "dmqnode.h"
10 11
 
11 12
 #define DEFAULT_NUM_WORKERS	2
12 13
 
13 14
 extern int num_workers;
14 15
 extern dmq_worker_t* workers;
15 16
 extern dmq_peer_t dmq_notification_peer;
17
+extern dmq_peer_list_t* peer_list;
18
+extern dmq_node_list_t* node_list;
16 19
 
17 20
 static inline int dmq_load_api(dmq_api_t* api) {
18 21
 	bind_dmq_f binddmq;
19 22
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+#include "dmqnode.h"
1
+#include "dmq.h"
2
+
3
+dmq_node_list_t* init_dmq_node_list() {
4
+	dmq_node_list_t* node_list = shm_malloc(sizeof(dmq_node_list_t));
5
+	memset(node_list, 0, sizeof(dmq_node_list_t));
6
+	lock_init(&node_list->lock);
7
+	return node_list;
8
+}
0 9
\ No newline at end of file
1 10
new file mode 100644
... ...
@@ -0,0 +1,28 @@
0
+#ifndef DMQNODE_H
1
+#define DMQNODE_H
2
+
3
+#include <string.h>
4
+#include <stdlib.h>
5
+#include "../../lock_ops.h"
6
+#include "../../str.h"
7
+#include "../../mem/mem.h"
8
+#include "../../mem/shm_mem.h"
9
+#include "../../parser/parse_uri.h"
10
+
11
+typedef struct dmq_node {
12
+	struct sip_uri* uri;
13
+	int status;
14
+	int last_notification;
15
+	struct dmqnode* next;
16
+} dmq_node_t;
17
+
18
+typedef struct dmq_node_list {
19
+	gen_lock_t lock;
20
+	struct dmq_node* nodes;
21
+	int count;
22
+} dmq_node_list_t;
23
+
24
+dmq_node_list_t* init_dmq_node_list();
25
+int update_node_list(dmq_node_list_t* remote_list);
26
+
27
+#endif
0 28
\ No newline at end of file
... ...
@@ -12,6 +12,17 @@ int add_notification_peer() {
12 12
 }
13 13
 
14 14
 int dmq_notification_callback(struct sip_msg* msg) {
15
+	/* received dmqnode list */
16
+	dmq_node_list_t* rlist;
15 17
 	LM_ERR("dmq triggered from dmq_notification_callback\n");
18
+	rlist = extract_node_list(msg);
19
+	if(!rlist) {
20
+		LM_ERR("extract_node_list failed\n");
21
+		return -1;
22
+	}
23
+	if(update_node_list(rlist) < 0) {
24
+		LM_ERR("cannot update node_list\n");
25
+		return -1;
26
+	}
16 27
 	return 0;
17 28
 }
18 29
\ No newline at end of file
... ...
@@ -1,4 +1,6 @@
1 1
 #include "dmq.h"
2
+#include "dmqnode.h"
2 3
 
3 4
 int add_notification_peer();
4
-int dmq_notification_callback(struct sip_msg* msg);
5 5
\ No newline at end of file
6
+int dmq_notification_callback(struct sip_msg* msg);
7
+dmq_node_list_t* extract_node_list(struct sip_msg* msg);
6 8
\ No newline at end of file
... ...
@@ -1,4 +1,5 @@
1 1
 #include "peer.h"
2
+#include "dmq.h"
2 3
 
3 4
 dmq_peer_list_t* init_peer_list() {
4 5
 	dmq_peer_list_t* peer_list = shm_malloc(sizeof(dmq_peer_list_t));
... ...
@@ -3,6 +3,7 @@
3 3
 
4 4
 #include <string.h>
5 5
 #include <stdlib.h>
6
+#include "../../lock_ops.h"
6 7
 #include "../../str.h"
7 8
 #include "../../mem/mem.h"
8 9
 #include "../../mem/shm_mem.h"