[asterisk-commits] dlee: branch dlee/ASTERISK-22296 r397569 - in /team/dlee/ASTERISK-22296: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 23 13:04:38 CDT 2013


Author: dlee
Date: Fri Aug 23 13:04:36 2013
New Revision: 397569

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397569
Log:
MOAR DEBUG

Modified:
    team/dlee/ASTERISK-22296/include/asterisk/http_websocket.h
    team/dlee/ASTERISK-22296/include/asterisk/optional_api.h
    team/dlee/ASTERISK-22296/main/loader.c

Modified: team/dlee/ASTERISK-22296/include/asterisk/http_websocket.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/include/asterisk/http_websocket.h?view=diff&rev=397569&r1=397568&r2=397569
==============================================================================
--- team/dlee/ASTERISK-22296/include/asterisk/http_websocket.h (original)
+++ team/dlee/ASTERISK-22296/include/asterisk/http_websocket.h Fri Aug 23 13:04:36 2013
@@ -21,6 +21,8 @@
 
 #include "asterisk/http.h"
 #include "asterisk/optional_api.h"
+
+#include <errno.h>
 
 /*!
  * \file http_websocket.h
@@ -90,7 +92,7 @@
  * \retval 0 success
  * \retval -1 if sub-protocol handler could not be registered
  */
-AST_OPTIONAL_API(int, ast_websocket_add_protocol, (const char *name, ast_websocket_callback callback), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_add_protocol, (const char *name, ast_websocket_callback callback), {ast_log(LOG_ERROR, "Stubbed!\n"); return -1;});
 
 /*!
  * \brief Remove a sub-protocol handler from the default /ws server.
@@ -101,7 +103,7 @@
  * \retval 0 success
  * \retval -1 if sub-protocol was not found or if callback did not match
  */
-AST_OPTIONAL_API(int, ast_websocket_remove_protocol, (const char *name, ast_websocket_callback callback), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_remove_protocol, (const char *name, ast_websocket_callback callback), {ast_log(LOG_ERROR, "Stubbed!\n"); return -1;});
 
 /*!
  * \brief Add a sub-protocol handler to the given server.
@@ -141,7 +143,7 @@
  *
  * \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed
  */
-AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 /*!
  * \brief Construct and transmit a WebSocket frame
@@ -154,7 +156,7 @@
  * \retval 0 if successfully written
  * \retval -1 if error occurred
  */
-AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 /*!
  * \brief Close a WebSocket session by sending a message with the CLOSE opcode and an optional code
@@ -165,7 +167,7 @@
  * \retval 0 if successfully written
  * \retval -1 if error occurred
  */
-AST_OPTIONAL_API(int, ast_websocket_close, (struct ast_websocket *session, uint16_t reason), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_close, (struct ast_websocket *session, uint16_t reason), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 /*!
  * \brief Enable multi-frame reconstruction up to a certain number of bytes
@@ -174,7 +176,7 @@
  * \param bytes If a reconstructed payload exceeds the specified number of bytes the payload will be returned
  *              and upon reception of the next multi-frame a new reconstructed payload will begin.
  */
-AST_OPTIONAL_API(void, ast_websocket_reconstruct_enable, (struct ast_websocket *session, size_t bytes), {return;});
+AST_OPTIONAL_API(void, ast_websocket_reconstruct_enable, (struct ast_websocket *session, size_t bytes), {ast_log(LOG_ERROR, "Stubbed!\n"); return;});
 
 /*!
  * \brief Disable multi-frame reconstruction
@@ -184,14 +186,14 @@
  * \note If reconstruction is disabled each message that is part of a multi-frame message will be sent up to
  *       the user when ast_websocket_read is called.
  */
-AST_OPTIONAL_API(void, ast_websocket_reconstruct_disable, (struct ast_websocket *session), {return;});
+AST_OPTIONAL_API(void, ast_websocket_reconstruct_disable, (struct ast_websocket *session), {ast_log(LOG_ERROR, "Stubbed!\n"); return;});
 
 /*!
  * \brief Increase the reference count for a WebSocket session
  *
  * \param session Pointer to the WebSocket session
  */
-AST_OPTIONAL_API(void, ast_websocket_ref, (struct ast_websocket *session), {return;});
+AST_OPTIONAL_API(void, ast_websocket_ref, (struct ast_websocket *session), {ast_log(LOG_ERROR, "Stubbed!\n"); return;});
 
 /*!
  * \brief Decrease the reference count for a WebSocket session
@@ -207,14 +209,14 @@
  *
  * \note You must *not* directly read from or write to this file descriptor. It should only be used for polling.
  */
-AST_OPTIONAL_API(int, ast_websocket_fd, (struct ast_websocket *session), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_fd, (struct ast_websocket *session), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 /*!
  * \brief Get the remote address for a WebSocket connected session.
  *
  * \retval ast_sockaddr Remote address
  */
-AST_OPTIONAL_API(struct ast_sockaddr *, ast_websocket_remote_address, (struct ast_websocket *session), {return NULL;});
+AST_OPTIONAL_API(struct ast_sockaddr *, ast_websocket_remote_address, (struct ast_websocket *session), {ast_log(LOG_ERROR, "Stubbed!\n"); return NULL;});
 
 /*!
  * \brief Get whether the WebSocket session is using a secure transport or not.
@@ -222,7 +224,7 @@
  * \retval 0 if unsecure
  * \retval 1 if secure
  */
-AST_OPTIONAL_API(int, ast_websocket_is_secure, (struct ast_websocket *session), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_is_secure, (struct ast_websocket *session), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 /*!
  * \brief Set the socket of a WebSocket session to be non-blocking.
@@ -230,6 +232,6 @@
  * \retval 0 on success
  * \retval -1 on failure
  */
-AST_OPTIONAL_API(int, ast_websocket_set_nonblock, (struct ast_websocket *session), {return -1;});
+AST_OPTIONAL_API(int, ast_websocket_set_nonblock, (struct ast_websocket *session), { ast_log(LOG_ERROR, "Stubbed!\n"); errno = ENOSYS; return -1;});
 
 #endif

Modified: team/dlee/ASTERISK-22296/include/asterisk/optional_api.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/include/asterisk/optional_api.h?view=diff&rev=397569&r1=397568&r2=397569
==============================================================================
--- team/dlee/ASTERISK-22296/include/asterisk/optional_api.h (original)
+++ team/dlee/ASTERISK-22296/include/asterisk/optional_api.h Fri Aug 23 13:04:36 2013
@@ -195,13 +195,29 @@
 	static result __stub__##name proto stub; \
 	static __attribute__((weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
 	static attribute_unused typeof(__stub__##name) * name; \
-	static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
+	static void __attribute__((constructor)) __init__##name(void) {	\
+		if (__ref__##name) {					\
+			ast_verb(3, "Binding " #name "\n");		\
+			name = __ref__##name;				\
+		} else {						\
+			ast_verb(3, "Stubbing " #name "\n" );		\
+			name = __stub__##name;				\
+		}							\
+	}
 
 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
 	static __attribute__((attr)) result __stub__##name proto stub; \
 	static __attribute__((attr, weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
 	static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
-	static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
+	static void __attribute__((constructor)) __init__##name(void) { \
+		if (__ref__##name) {					\
+			ast_verb(3, "Binding " #name "\n");		\
+			name = __ref__##name;				\
+		} else {						\
+			ast_verb(3, "Stubbing " #name "\n");		\
+			name = __stub__##name;				\
+		}							\
+	}
 
 #endif
 

Modified: team/dlee/ASTERISK-22296/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/main/loader.c?view=diff&rev=397569&r1=397568&r2=397569
==============================================================================
--- team/dlee/ASTERISK-22296/main/loader.c (original)
+++ team/dlee/ASTERISK-22296/main/loader.c Fri Aug 23 13:04:36 2013
@@ -445,6 +445,7 @@
 	if (missing_so)
 		strcat(resource_being_loaded->resource, ".so");
 
+	ast_verb(3, "Inspecting %s\n", fn);
 	if (!(lib = dlopen(fn, RTLD_LAZY | RTLD_LOCAL))) {
 		ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
 		ast_free(resource_being_loaded);
@@ -472,6 +473,7 @@
 	/* if we are being asked only to load modules that provide global symbols,
 	   and this one does not, then close it and return */
 	if (global_symbols_only && !wants_global) {
+		ast_verb(3, "  Unloading %s\n", fn);
 		while (!dlclose(lib));
 		return NULL;
 	}
@@ -497,6 +499,7 @@
 	}
 #endif
 
+	ast_verb(3, "  Unloading %s\n", fn);
 	while (!dlclose(lib));
 	resource_being_loaded = NULL;
 
@@ -508,6 +511,7 @@
 	if (missing_so)
 		strcat(resource_being_loaded->resource, ".so");
 
+	ast_verb(3, "Opening %s\n", fn);
 	if (!(lib = dlopen(fn, wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) {
 		ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
 		ast_free(resource_being_loaded);




More information about the asterisk-commits mailing list