[asterisk-commits] kharwell: branch kharwell/pimp_sip_state r388473 - in /team/kharwell/pimp_sip...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 10 18:03:34 CDT 2013
Author: kharwell
Date: Fri May 10 18:03:33 2013
New Revision: 388473
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388473
Log:
addressed a few more review issues
Modified:
team/kharwell/pimp_sip_state/res/res_sip_exten_state.c
team/kharwell/pimp_sip_state/res/res_sip_providers/res_sip_pidf.c
Modified: team/kharwell/pimp_sip_state/res/res_sip_exten_state.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_state/res/res_sip_exten_state.c?view=diff&rev=388473&r1=388472&r2=388473
==============================================================================
--- team/kharwell/pimp_sip_state/res/res_sip_exten_state.c (original)
+++ team/kharwell/pimp_sip_state/res/res_sip_exten_state.c Fri May 10 18:03:33 2013
@@ -175,8 +175,6 @@
char context[AST_MAX_CONTEXT];
/*! Extension within the context to receive updates from */
char exten[AST_MAX_EXTENSION];
- /*! pjsip state for NOTIFY request */
- pjsip_evsub_state evsub_state;
};
static void exten_state_subscription_destructor(void *obj)
@@ -252,7 +250,7 @@
* \brief Create and send a NOTIFY request to the subscriber.
*/
static void create_send_notify(struct exten_state_subscription *exten_state_sub, const char *reason,
- struct ast_sip_exten_state_data *exten_state_data)
+ pjsip_evsub_state evsub_state, struct ast_sip_exten_state_data *exten_state_data)
{
RAII_VAR(struct ast_str *, body_text, ast_str_create(BODY_SIZE), ast_free_ptr);
pj_str_t reason_str;
@@ -281,7 +279,7 @@
}
if (pjsip_evsub_notify(ast_sip_subscription_get_evsub(exten_state_sub->sip_sub),
- exten_state_sub->evsub_state, NULL, reason_str_ptr, &tdata) != PJ_SUCCESS) {
+ evsub_state, NULL, reason_str_ptr, &tdata) != PJ_SUCCESS) {
ast_log(LOG_WARNING, "Unable to create NOTIFY request\n");
return;
}
@@ -302,7 +300,8 @@
* \internal
* \brief Get device state information and send notification to the subscriber.
*/
-static void send_notify(struct exten_state_subscription *exten_state_sub, const char *reason)
+static void send_notify(struct exten_state_subscription *exten_state_sub, const char *reason,
+ pjsip_evsub_state evsub_state)
{
RAII_VAR(struct ao2_container*, info, NULL, ao2_cleanup);
char *subtype = NULL, *message = NULL;
@@ -322,12 +321,13 @@
}
exten_state_data.device_state_info = info;
- create_send_notify(exten_state_sub, reason, &exten_state_data);
+ create_send_notify(exten_state_sub, reason, evsub_state, &exten_state_data);
}
struct notify_task_data {
struct ast_sip_exten_state_data exten_state_data;
struct exten_state_subscription *exten_state_sub;
+ pjsip_evsub_state evsub_state;
};
static void notify_task_data_destructor(void *obj)
@@ -335,9 +335,7 @@
struct notify_task_data *task_data = obj;
ao2_ref(task_data->exten_state_sub, -1);
- if (task_data->exten_state_data.device_state_info) {
- ao2_ref(task_data->exten_state_data.device_state_info, -1);
- }
+ ao2_cleanup(task_data->exten_state_data.device_state_info);
}
static struct notify_task_data *alloc_notify_task_data(struct exten_state_subscription *exten_state_sub)
@@ -350,8 +348,9 @@
return NULL;
}
+ task_data->evsub_state = PJSIP_EVSUB_STATE_ACTIVE;
task_data->exten_state_sub = exten_state_sub;
- task_data->exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_ACTIVE;
+ ao2_ref(task_data->exten_state_sub, +1);
task_data->exten_state_data.exten = exten_state_sub->exten;
return task_data;
@@ -361,8 +360,9 @@
{
RAII_VAR(struct notify_task_data *, task_data, obj, ao2_cleanup);
- create_send_notify(task_data->exten_state_sub, task_data->exten_state_sub->evsub_state ==
- PJSIP_EVSUB_STATE_TERMINATED ? "noresource" : NULL, &task_data->exten_state_data);
+ create_send_notify(task_data->exten_state_sub, task_data->evsub_state ==
+ PJSIP_EVSUB_STATE_TERMINATED ? "noresource" : NULL,
+ task_data->evsub_state, &task_data->exten_state_data);
return 0;
}
@@ -391,13 +391,18 @@
if ((info->exten_state == AST_EXTENSION_DEACTIVATED) ||
(info->exten_state == AST_EXTENSION_REMOVED)) {
- task_data->exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_TERMINATED;
+ task_data->evsub_state = PJSIP_EVSUB_STATE_TERMINATED;
ast_log(LOG_WARNING, "Watcher for hint %s %s\n", exten, info->exten_state
== AST_EXTENSION_REMOVED ? "removed" : "deactivated");
}
- ast_sip_push_task(ast_sip_subscription_get_serializer(task_data->exten_state_sub->sip_sub),
- notify_task, task_data);
+ /* safe to push this async since we copy the data from info and
+ add a ref for the device state info */
+ if (ast_sip_push_task(ast_sip_subscription_get_serializer(task_data->exten_state_sub->sip_sub),
+ notify_task, task_data)) {
+ ao2_cleanup(task_data);
+ return -1;
+ }
return 0;
}
@@ -489,8 +494,7 @@
return NULL;
}
- exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_ACTIVE;
- send_notify(exten_state_sub, NULL);
+ send_notify(exten_state_sub, NULL, PJSIP_EVSUB_STATE_ACTIVE);
return exten_state_sub->sip_sub;
}
@@ -500,8 +504,7 @@
struct exten_state_subscription *exten_state_sub = get_exten_state_sub(sub);
if (exten_state_sub) {
- exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_ACTIVE;
- send_notify(exten_state_sub, NULL);
+ send_notify(exten_state_sub, NULL, PJSIP_EVSUB_STATE_ACTIVE);
}
}
@@ -514,8 +517,7 @@
}
ast_verbose(VERBOSE_PREFIX_3 "Subscription for has timed out.\n");
- exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_TERMINATED;
- send_notify(exten_state_sub, "timeout");
+ send_notify(exten_state_sub, "timeout", PJSIP_EVSUB_STATE_TERMINATED);
}
static void subscription_terminated(struct ast_sip_subscription *sub,
@@ -528,8 +530,7 @@
}
ast_verbose(VERBOSE_PREFIX_3 "Subscription has been terminated.\n");
- exten_state_sub->evsub_state = PJSIP_EVSUB_STATE_TERMINATED;
- send_notify(exten_state_sub, NULL);
+ send_notify(exten_state_sub, NULL, PJSIP_EVSUB_STATE_TERMINATED);
}
/*!
Modified: team/kharwell/pimp_sip_state/res/res_sip_providers/res_sip_pidf.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_state/res/res_sip_providers/res_sip_pidf.c?view=diff&rev=388473&r1=388472&r2=388473
==============================================================================
--- team/kharwell/pimp_sip_state/res/res_sip_providers/res_sip_pidf.c (original)
+++ team/kharwell/pimp_sip_state/res/res_sip_providers/res_sip_pidf.c Fri May 10 18:03:33 2013
@@ -23,6 +23,8 @@
<depend>res_sip_exten_state</depend>
<support_level>core</support_level>
***/
+
+
#include "asterisk.h"
#include "asterisk/res_sip_exten_state.h"
@@ -79,6 +81,22 @@
break;
}
}
+
+/* static int pool_initialized = 0; */
+/* static pj_caching_pool caching_pool; */
+
+/* static pj_pool_t *create_pj_pool(void) */
+/* { */
+/* if (!pool_initialized) { */
+/* pj_caching_pool_init(&cachingpool, &pj_pool_factory_default_policy, 0); */
+/* } */
+
+/* pj_pool_t *pool = pj_pool_create(&caching_pool.factory, "SIP", 1024, 1024, NULL); */
+/* if (!memory_pool) { */
+/* ast_log(LOG_ERROR, "Failed to create memory pool for SIP. Aborting load\n"); */
+/* goto error; */
+/* } */
+/* } */
static int pidf_xml_create_body(struct ast_sip_exten_state_data *data, const char *local,
const char *remote, struct ast_str **body_text)
More information about the asterisk-commits
mailing list