summaryrefslogtreecommitdiff
path: root/res/stasis
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-05-17 20:36:41 -0500
committerMatt Jordan <mjordan@digium.com>2015-05-22 11:13:34 -0500
commit9cffcca5f97d74d88e0114f588590db27aac421b (patch)
tree5f92a4f1e7c8ca2d363de0ef1611d995c160e490 /res/stasis
parentd7086a27b46a6e7965656138194af0a27e9e25d8 (diff)
res/ari: Register Stasis application on WebSocket attempt
Prior to this patch, when a WebSocket connection is made, ARI would not be informed of the connection until after the WebSocket layer had accepted the connection. This created a brief race condition where the ARI client would be notified that it was connected, a channel would be sent into the Stasis dialplan application, but ARI would not yet have registered the Stasis application presented in the HTTP request that established the WebSocket. This patch resolves this issue by doing the following: * When a WebSocket attempt is made, a callback is made into the ARI application layer, which verifies and registers the apps presented in the HTTP request. Because we do not yet have a WebSocket, we cannot have an event session for the corresponding applications. Some defensive checks were thus added to make the application objects tolerant to a NULL event session. * When a WebSocket connection is made, the registered application is updated with the newly created event session that wraps the WebSocket connection. ASTERISK-24988 #close Reported by: Joshua Colp Change-Id: Ia5dc60dc2b6bee76cd5aff0f69dd53b36e83f636
Diffstat (limited to 'res/stasis')
-rw-r--r--res/stasis/app.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/res/stasis/app.c b/res/stasis/app.c
index 5a1c5f8e2..b99e23205 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -871,8 +871,7 @@ struct stasis_app *app_create(const char *name, stasis_app_cb handler, void *dat
strncpy(app->name, name, size - sizeof(*app));
app->handler = handler;
- ao2_ref(data, +1);
- app->data = data;
+ app->data = ao2_bump(data);
ao2_ref(app, +1);
return app;
@@ -950,7 +949,7 @@ void app_update(struct stasis_app *app, stasis_app_cb handler, void *data)
{
SCOPED_AO2LOCK(lock, app);
- if (app->handler) {
+ if (app->handler && app->data) {
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
ast_verb(1, "Replacing Stasis app '%s'\n", app->name);