Преглед на файлове

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

Marius Bucur преди 14 години
родител
ревизия
8620313f05
променени са 8 файла, в които са добавени 62 реда и са изтрити 1 реда
  1. 6 0
      modules_k/dmq/dmq.c
  2. 3 0
      modules_k/dmq/dmq.h
  3. 9 0
      modules_k/dmq/dmqnode.c
  4. 28 0
      modules_k/dmq/dmqnode.h
  5. 11 0
      modules_k/dmq/notification_peer.c
  6. 3 1
      modules_k/dmq/notification_peer.h
  7. 1 0
      modules_k/dmq/peer.c
  8. 1 0
      modules_k/dmq/peer.h

+ 6 - 0
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);
 	

+ 3 - 0
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;

+ 9 - 0
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;
+}

+ 28 - 0
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

+ 11 - 0
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;
 }

+ 3 - 1
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);
+int dmq_notification_callback(struct sip_msg* msg);
+dmq_node_list_t* extract_node_list(struct sip_msg* msg);

+ 1 - 0
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));

+ 1 - 0
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"