[asterisk-commits] dlee: branch dlee/ASTERISK-22296 r397668 - in /team/dlee/ASTERISK-22296: incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 26 14:50:19 CDT 2013
Author: dlee
Date: Mon Aug 26 14:50:17 2013
New Revision: 397668
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397668
Log:
Narrow inclusion of http_websockets.h, to avoid lots of pointless optional_api thrashing
Modified:
team/dlee/ASTERISK-22296/include/asterisk/ari.h
team/dlee/ASTERISK-22296/main/optional_api.c
team/dlee/ASTERISK-22296/res/ari/ari_websockets.c
team/dlee/ASTERISK-22296/res/ari/internal.h
team/dlee/ASTERISK-22296/res/res_ari.c
team/dlee/ASTERISK-22296/res/res_ari_events.c
team/dlee/ASTERISK-22296/rest-api-templates/res_ari_resource.c.mustache
team/dlee/ASTERISK-22296/rest-api-templates/swagger_model.py
Modified: team/dlee/ASTERISK-22296/include/asterisk/ari.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/include/asterisk/ari.h?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/include/asterisk/ari.h (original)
+++ team/dlee/ASTERISK-22296/include/asterisk/ari.h Mon Aug 26 14:50:17 2013
@@ -21,7 +21,7 @@
/*! \file
*
- * \brief Stasis RESTful API hooks.
+ * \brief Asterisk RESTful API hooks.
*
* This header file is used mostly as glue code between generated declarations
* and res_ari.c.
@@ -31,7 +31,13 @@
#include "asterisk/http.h"
#include "asterisk/json.h"
-#include "asterisk/http_websocket.h"
+
+/* Forward-declare websocket structs. This avoids including http_websocket.h,
+ * which causes some optional_api monkey business to happen */
+
+struct ast_websocket_server;
+
+struct ast_websocket;
/*!
* \brief Configured encoding format for JSON output.
Modified: team/dlee/ASTERISK-22296/main/optional_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/main/optional_api.c?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/main/optional_api.c (original)
+++ team/dlee/ASTERISK-22296/main/optional_api.c Mon Aug 26 14:50:17 2013
@@ -209,8 +209,6 @@
struct optional_api *api;
- ast_verb(4, "%s: use by %s\n", symname, module);
-
api = get_api(symname);
if (!api) {
ast_log(LOG_ERROR, "%s: Allocation failed\n", symname);
@@ -254,8 +252,6 @@
struct optional_api *api;
size_t i;
- ast_verb(4, "%s: un-use by %s\n", symname, module);
-
api = get_api(symname);
if (!api) {
ast_log(LOG_ERROR, "%s: Could not find api\n", symname);
@@ -266,7 +262,7 @@
struct optional_api_user *user = api->users[i];
if (user->optional_ref == optional_ref) {
if (*user->optional_ref != user->stub) {
- ast_verb(4, "%s: Stubbing %s\n", symname,
+ ast_verb(4, "%s: stubbing for %s\n", symname,
user->module);
*user->optional_ref = user->stub;
}
Modified: team/dlee/ASTERISK-22296/res/ari/ari_websockets.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/res/ari/ari_websockets.c?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/res/ari/ari_websockets.c (original)
+++ team/dlee/ASTERISK-22296/res/ari/ari_websockets.c Mon Aug 26 14:50:17 2013
@@ -20,8 +20,9 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include "asterisk/ari.h"
#include "asterisk/astobj2.h"
-#include "asterisk/ari.h"
+#include "asterisk/http_websocket.h"
/*! \file
*
@@ -163,3 +164,15 @@
return ast_websocket_write(session->ws_session,
AST_WEBSOCKET_OPCODE_TEXT, str, strlen(str));
}
+
+void ari_handle_websocket(struct ast_websocket_server *ws_server,
+ struct ast_tcptls_session_instance *ser, const char *uri,
+ enum ast_http_method method, struct ast_variable *get_params,
+ struct ast_variable *headers)
+{
+ struct ast_http_uri fake_urih = {
+ .data = ws_server,
+ };
+ ast_websocket_uri_cb(ser, &fake_urih, uri, method, get_params,
+ headers);
+}
Modified: team/dlee/ASTERISK-22296/res/ari/internal.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/res/ari/internal.h?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/res/ari/internal.h (original)
+++ team/dlee/ASTERISK-22296/res/ari/internal.h Mon Aug 26 14:50:17 2013
@@ -25,6 +25,7 @@
* \author David M. Lee, II <dlee at digium.com>
*/
+#include "asterisk/http.h"
#include "asterisk/json.h"
#include "asterisk/stringfields.h"
@@ -140,5 +141,11 @@
/*! @} */
+struct ast_websocket_server;
+
+void ari_handle_websocket(struct ast_websocket_server *ws_server,
+ struct ast_tcptls_session_instance *ser, const char *uri,
+ enum ast_http_method method, struct ast_variable *get_params,
+ struct ast_variable *headers);
#endif /* ARI_INTERNAL_H_ */
Modified: team/dlee/ASTERISK-22296/res/res_ari.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/res/res_ari.c?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/res/res_ari.c (original)
+++ team/dlee/ASTERISK-22296/res/res_ari.c Mon Aug 26 14:50:17 2013
@@ -124,11 +124,11 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include "ari/internal.h"
+#include "asterisk/ari.h"
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
-#include "asterisk/ari.h"
-#include "ari/internal.h"
#include <string.h>
#include <sys/stat.h>
@@ -522,11 +522,8 @@
if (handler->ws_server && method == AST_HTTP_GET) {
/* WebSocket! */
- struct ast_http_uri fake_urih = {
- .data = handler->ws_server,
- };
- ast_websocket_uri_cb(ser, &fake_urih, uri, method, get_params,
- headers);
+ ari_handle_websocket(handler->ws_server, ser, uri, method,
+ get_params, headers);
/* Since the WebSocket code handles the connection, we shouldn't
* do anything else; setting no_response */
response->no_response = 1;
Modified: team/dlee/ASTERISK-22296/res/res_ari_events.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/res/res_ari_events.c?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/res/res_ari_events.c (original)
+++ team/dlee/ASTERISK-22296/res/res_ari_events.c Mon Aug 26 14:50:17 2013
@@ -48,6 +48,7 @@
#if defined(AST_DEVMODE)
#include "ari/ari_model_validators.h"
#endif
+#include "asterisk/http_websocket.h"
#define MAX_VALS 128
Modified: team/dlee/ASTERISK-22296/rest-api-templates/res_ari_resource.c.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/rest-api-templates/res_ari_resource.c.mustache?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/rest-api-templates/res_ari_resource.c.mustache (original)
+++ team/dlee/ASTERISK-22296/rest-api-templates/res_ari_resource.c.mustache Mon Aug 26 14:50:17 2013
@@ -53,6 +53,13 @@
#if defined(AST_DEVMODE)
#include "ari/ari_model_validators.h"
#endif
+{{^has_websocket}}
+{{! Only include http_websocket if necessary. Otherwise we'll do a lot of
+ * unnecessary optional_api intialization, which makes optional_api harder
+ * to debug
+ }}
+#include "asterisk/http_websocket.h"
+{{/has_websocket}}
#define MAX_VALS 128
Modified: team/dlee/ASTERISK-22296/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/rest-api-templates/swagger_model.py?view=diff&rev=397668&r1=397667&r2=397668
==============================================================================
--- team/dlee/ASTERISK-22296/rest-api-templates/swagger_model.py (original)
+++ team/dlee/ASTERISK-22296/rest-api-templates/swagger_model.py Mon Aug 26 14:50:17 2013
@@ -632,6 +632,8 @@
api_json = api_decl_json.get('apis') or []
self.apis = [
Api().load(j, processor, context) for j in api_json]
+ self.has_websocket = filter(lambda api: api.has_websocket,
+ self.apis) == []
models = api_decl_json.get('models').items() or []
self.models = [Model().load(id, json, processor, context)
for (id, json) in models]
More information about the asterisk-commits
mailing list