|
@@ -29,6 +29,9 @@
|
|
str notification_content_type = str_init("text/plain");
|
|
str notification_content_type = str_init("text/plain");
|
|
dmq_resp_cback_t notification_callback = {¬ification_resp_callback_f, 0};
|
|
dmq_resp_cback_t notification_callback = {¬ification_resp_callback_f, 0};
|
|
|
|
|
|
|
|
+int *dmq_init_callback_done;
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @brief add notification peer
|
|
* @brief add notification peer
|
|
*/
|
|
*/
|
|
@@ -36,6 +39,7 @@ int add_notification_peer()
|
|
{
|
|
{
|
|
dmq_peer_t not_peer;
|
|
dmq_peer_t not_peer;
|
|
not_peer.callback = dmq_notification_callback;
|
|
not_peer.callback = dmq_notification_callback;
|
|
|
|
+ not_peer.init_callback = NULL;
|
|
not_peer.description.s = "notification_peer";
|
|
not_peer.description.s = "notification_peer";
|
|
not_peer.description.len = 17;
|
|
not_peer.description.len = 17;
|
|
not_peer.peer_id.s = "notification_peer";
|
|
not_peer.peer_id.s = "notification_peer";
|
|
@@ -165,6 +169,21 @@ error:
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+int run_init_callbacks() {
|
|
|
|
+ dmq_peer_t* crt;
|
|
|
|
+
|
|
|
|
+ crt = peer_list->peers;
|
|
|
|
+ while(crt) {
|
|
|
|
+ if (crt->init_callback) {
|
|
|
|
+ crt->init_callback();
|
|
|
|
+ }
|
|
|
|
+ crt = crt->next;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @brief dmq notification callback
|
|
* @brief dmq notification callback
|
|
*/
|
|
*/
|
|
@@ -206,6 +225,10 @@ int dmq_notification_callback(struct sip_msg* msg, peer_reponse_t* resp)
|
|
¬ification_callback, maxforwards, ¬ification_content_type);
|
|
¬ification_callback, maxforwards, ¬ification_content_type);
|
|
}
|
|
}
|
|
pkg_free(response_body);
|
|
pkg_free(response_body);
|
|
|
|
+ if (!*dmq_init_callback_done) {
|
|
|
|
+ *dmq_init_callback_done = 1;
|
|
|
|
+ run_init_callbacks();
|
|
|
|
+ }
|
|
return 0;
|
|
return 0;
|
|
error:
|
|
error:
|
|
return -1;
|
|
return -1;
|
|
@@ -292,8 +315,17 @@ int notification_resp_callback_f(struct sip_msg* msg, int code,
|
|
dmq_node_t* node, void* param)
|
|
dmq_node_t* node, void* param)
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
|
|
+ int nodes_recv;
|
|
|
|
+
|
|
LM_DBG("notification_callback_f triggered [%p %d %p]\n", msg, code, param);
|
|
LM_DBG("notification_callback_f triggered [%p %d %p]\n", msg, code, param);
|
|
- if(code == 408) {
|
|
|
|
|
|
+ if(code == 200) {
|
|
|
|
+ nodes_recv = extract_node_list(node_list, msg);
|
|
|
|
+ LM_DBG("received %d new or changed nodes\n", nodes_recv);
|
|
|
|
+ if (!*dmq_init_callback_done) {
|
|
|
|
+ *dmq_init_callback_done = 1;
|
|
|
|
+ run_init_callbacks();
|
|
|
|
+ }
|
|
|
|
+ } else if(code == 408) {
|
|
/* deleting node - the server did not respond */
|
|
/* deleting node - the server did not respond */
|
|
LM_ERR("deleting server %.*s because of failed request\n", STR_FMT(&node->orig_uri));
|
|
LM_ERR("deleting server %.*s because of failed request\n", STR_FMT(&node->orig_uri));
|
|
if (STR_EQ(node->orig_uri, dmq_notification_address)) {
|
|
if (STR_EQ(node->orig_uri, dmq_notification_address)) {
|