diff options
author | Matt Jordan <mjordan@digium.com> | 2015-05-17 20:36:41 -0500 |
---|---|---|
committer | Matt Jordan <mjordan@digium.com> | 2015-05-22 11:12:03 -0500 |
commit | 5ac65ddfb46f715490b4eccbef57dc6f424e9bc2 (patch) | |
tree | 986bf038659867abd94189051637ddb5f180dcff /res/stasis | |
parent | 9d8a462356a938eea82e8424242d89a682495b57 (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.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/res/stasis/app.c b/res/stasis/app.c index 330e711e6..caa27abfc 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); |