Module: sip-router
Branch: mariusbucur/dmq
Commit: e7811507b27c38e34b8c05d989fcadbd55ac0fec
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e781150…
Author: Marius Bucur <marius(a)marius-bucur.ro>
Committer: Marius Bucur <marius(a)marius-bucur.ro>
Date: Fri May 27 09:50:42 2011 +0300
fixed a bug in dmq_register_peer
---
modules_k/dmq/dmq.h | 4 +---
modules_k/dmq/dmq_funcs.c | 1 +
modules_k/dmq/dmq_funcs.h | 1 +
modules_k/dmq/dmqnode.h | 1 +
modules_k/presence/presence.c | 16 +++++++++++++---
5 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/modules_k/dmq/dmq.h b/modules_k/dmq/dmq.h
index f43b53d..e4c639c 100644
--- a/modules_k/dmq/dmq.h
+++ b/modules_k/dmq/dmq.h
@@ -10,17 +10,15 @@
#include "bind_dmq.h"
#include "peer.h"
#include "worker.h"
-#include "dmqnode.h"
#define DEFAULT_NUM_WORKERS 2
-#define MIN_PING_INTERVAL 4
+#define MIN_PING_INTERVAL 60
extern int num_workers;
extern dmq_worker_t* workers;
extern dmq_peer_t* dmq_notification_peer;
extern str dmq_server_address;
extern dmq_peer_list_t* peer_list;
-extern dmq_node_list_t* node_list;
extern str dmq_request_method;
extern struct sip_uri dmq_server_uri;
extern str dmq_notification_address;
diff --git a/modules_k/dmq/dmq_funcs.c b/modules_k/dmq/dmq_funcs.c
index 8a97c99..3f15bee 100644
--- a/modules_k/dmq/dmq_funcs.c
+++ b/modules_k/dmq/dmq_funcs.c
@@ -7,6 +7,7 @@ dmq_peer_t* register_dmq_peer(dmq_peer_t* peer) {
if(search_peer_list(peer_list, peer)) {
LM_ERR("peer already exists: %.*s %.*s\n", peer->peer_id.len,
peer->peer_id.s,
peer->description.len, peer->description.s);
+ lock_release(&peer_list->lock);
return NULL;
}
new_peer = add_peer(peer_list, peer);
diff --git a/modules_k/dmq/dmq_funcs.h b/modules_k/dmq/dmq_funcs.h
index d2aab2e..7c5ecf8 100644
--- a/modules_k/dmq/dmq_funcs.h
+++ b/modules_k/dmq/dmq_funcs.h
@@ -8,6 +8,7 @@
#include "dmq.h"
#include "peer.h"
#include "worker.h"
+#include "dmqnode.h"
void ping_servers(unsigned int ticks,void *param);
diff --git a/modules_k/dmq/dmqnode.h b/modules_k/dmq/dmqnode.h
index 3bd69b0..e2c2437 100644
--- a/modules_k/dmq/dmqnode.h
+++ b/modules_k/dmq/dmqnode.h
@@ -32,6 +32,7 @@ typedef struct dmq_node_list {
} dmq_node_list_t;
extern str dmq_node_status_str;
+extern dmq_node_list_t* node_list;
dmq_node_list_t* init_dmq_node_list();
dmq_node_t* build_dmq_node(str* uri, int shm);
diff --git a/modules_k/presence/presence.c b/modules_k/presence/presence.c
index e32e527..43216f5 100644
--- a/modules_k/presence/presence.c
+++ b/modules_k/presence/presence.c
@@ -210,9 +210,19 @@ struct module_exports exports= {
child_init /* per-child init function */
};
-int dmq_callback(struct sip_msg* msg) {
+int dmq_presence_callback(struct sip_msg* msg, peer_reponse_t* resp) {
LM_ERR("it worked - dmq module triggered the presence callback [%ld %d]\n",
time(0), my_pid());
- sleep(4);
+ if(update_presentity(msg, 0, (str*)msg->body, 0, 0, 0) <0)
+ {
+ LM_ERR("when updating presentity\n");
+ return -1;
+ }
+ str ct = str_init("text/xml");
+ str reason = str_init("200 OK");
+ resp->content_type = ct;
+ resp->reason = reason;
+ resp->body.s = 0;
+ resp->resp_code = 200;
return 0;
}
@@ -222,7 +232,7 @@ static void add_dmq_peer() {
presence_peer.peer_id.len = 8;
presence_peer.description.s = "presence";
presence_peer.description.len = 8;
- presence_peer.callback = dmq_callback;
+ presence_peer.callback = dmq_presence_callback;
register_dmq(&presence_peer);
}