[asterisk-commits] may: branch may/ooh323_qsig r397993 - in /team/may/ooh323_qsig: ./ build_tool...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 30 09:10:53 CDT 2013
Author: may
Date: Fri Aug 30 09:10:47 2013
New Revision: 397993
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397993
Log:
Multiple revisions 397969,397978,397987-397988,397990
........
r397969 | mmichelson | 2013-08-30 04:11:22 +0400 (Fri, 30 Aug 2013) | 12 lines
Sanitize XML output for PIDF bodies.
PJSIP's PIDF API does not replace angle brackets with
their appropriate counterparts for XML. So we have to
do it ourself. In this particular case, the problem had
to do with attempting to place an unsanitized SIP URI
into an XML node. Now we don't get a 488 from recipients
of our PIDF NOTIFYs.
........
Merged revisions 397968 from http://svn.asterisk.org/svn/asterisk/branches/12
........
r397978 | rmudgett | 2013-08-30 05:20:05 +0400 (Fri, 30 Aug 2013) | 5 lines
pbx.c: Make pbx_substitute_variables_helper_full() not mask variables.
........
Merged revisions 397977 from http://svn.asterisk.org/svn/asterisk/branches/12
........
r397987 | dlee | 2013-08-30 17:27:52 +0400 (Fri, 30 Aug 2013) | 14 lines
Multiple revisions 397975-397976
........
r397975 | rmudgett | 2013-08-29 20:00:00 -0500 (Thu, 29 Aug 2013) | 1 line
pbx.c: Make ast_str_substitute_variables_full() not mask variables.
........
r397976 | rmudgett | 2013-08-29 20:00:41 -0500 (Thu, 29 Aug 2013) | 1 line
Revert last commit.
........
Merged revisions 397975-397976 from http://svn.asterisk.org/svn/asterisk/branches/12
........
r397988 | dlee | 2013-08-30 17:28:50 +0400 (Fri, 30 Aug 2013) | 28 lines
ARI: Implement /recordings/stored API's
his patch implements the ARI API's for stored recordings. While the
original task only specified deleting a recording, it was simple
enough to implement the GET for all recordings, and for an individual
recording.
The recording playback operation was modified to use the same code for
accessing the recording as the REST API, so that they will behave
consistently.
There were several problems with the api-docs that were also fixed,
bringing the ARI spec in line with the implementation. There were some
'wishful thinking' fields on the stored recording model (duration and
timestamp) that were removed, because I ended up not implementing a
metadata file to go along with the recording to store such information.
The GET /recordings/live operation was removed, since it's not really
that useful to get a list of all recordings that are currently going
on in the system. (At least, if we did that, we'd probably want to
also list all of the current playbacks. Which seems weird.)
(closes issue ASTERISK-21582)
Review: https://reviewboard.asterisk.org/r/2693/
........
Merged revisions 397985 from http://svn.asterisk.org/svn/asterisk/branches/12
........
r397990 | dlee | 2013-08-30 17:40:27 +0400 (Fri, 30 Aug 2013) | 52 lines
optional_api: Fix linking problems between modules that export global symbols
With the new work in Asterisk 12, there are some uses of the
optional_api that are prone to failure. The details are rather involved,
and captured on [the wiki][1].
This patch addresses the issue by removing almost all of the magic from
the optional API implementation. Instead of relying on weak symbol
resolution, a new optional_api.c module was added to Asterisk core.
For modules providing an optional API, the pointer to the implementation
function is registered with the core. For modules that use an optional
API, a pointer to a stub function, along with a optional_ref function
pointer are registered with the core. The optional_ref function pointers
is set to the implementation function when it's provided, or the stub
function when it's now.
Since the implementation no longer relies on magic, it is now supported
on all platforms. In the spirit of choice, an OPTIONAL_API flag was
added, so we can disable the optional_api if needed (maybe it's buggy on
some bizarre platform I haven't tested on)
The AST_OPTIONAL_API*() macros themselves remained unchanged, so
existing code could remain unchanged. But to help with debugging the
optional_api, the patch limits the #include of optional API's to just
the modules using the API. This also reduces resource waste maintaining
optional_ref pointers that aren't used.
Other changes made as a part of this patch:
* The stubs for http_websocket that wrap system calls set errno to
ENOSYS.
* res_http_websocket now properly increments module use count.
* In loader.c, the while() wrappers around dlclose() were removed. The
while(!dlclose()) is actually an anti-pattern, which can lead to
infinite loops if the module you're attempting to unload exports a
symbol that was directly linked to.
* The special handling of nonoptreq on systems without weak symbol
support was removed, since we no longer rely on weak symbols for
optional_api.
[1]: https://wiki.asterisk.org/wiki/x/wACUAQ
(closes issue ASTERISK-22296)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2797/
........
Merged revisions 397989 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 397969,397978,397987-397988,397990 from http://svn.asterisk.org/svn/asterisk/trunk
Added:
team/may/ooh323_qsig/main/optional_api.c
- copied unchanged from r397990, trunk/main/optional_api.c
team/may/ooh323_qsig/res/stasis_recording/ (props changed)
- copied from r397990, trunk/res/stasis_recording/
team/may/ooh323_qsig/tests/test_optional_api.c
- copied unchanged from r397990, trunk/tests/test_optional_api.c
Modified:
team/may/ooh323_qsig/ (props changed)
team/may/ooh323_qsig/CHANGES
team/may/ooh323_qsig/build_tools/cflags.xml
team/may/ooh323_qsig/channels/chan_sip.c
team/may/ooh323_qsig/channels/sip/include/sip.h
team/may/ooh323_qsig/configure
team/may/ooh323_qsig/configure.ac
team/may/ooh323_qsig/include/asterisk/ari.h
team/may/ooh323_qsig/include/asterisk/autoconfig.h.in
team/may/ooh323_qsig/include/asterisk/compiler.h
team/may/ooh323_qsig/include/asterisk/http_websocket.h
team/may/ooh323_qsig/include/asterisk/optional_api.h
team/may/ooh323_qsig/include/asterisk/stasis_app_recording.h
team/may/ooh323_qsig/main/asterisk.c
team/may/ooh323_qsig/main/loader.c
team/may/ooh323_qsig/main/pbx.c
team/may/ooh323_qsig/res/Makefile
team/may/ooh323_qsig/res/ari/ari_model_validators.c
team/may/ooh323_qsig/res/ari/ari_model_validators.h
team/may/ooh323_qsig/res/ari/ari_websockets.c
team/may/ooh323_qsig/res/ari/internal.h
team/may/ooh323_qsig/res/ari/resource_recordings.c
team/may/ooh323_qsig/res/ari/resource_recordings.h
team/may/ooh323_qsig/res/res_ari.c
team/may/ooh323_qsig/res/res_ari_events.c
team/may/ooh323_qsig/res/res_ari_recordings.c
team/may/ooh323_qsig/res/res_http_websocket.c
team/may/ooh323_qsig/res/res_pjsip_pidf.c
team/may/ooh323_qsig/res/res_stasis_playback.c
team/may/ooh323_qsig/res/res_stasis_recording.c
team/may/ooh323_qsig/rest-api-templates/res_ari_resource.c.mustache
team/may/ooh323_qsig/rest-api-templates/swagger_model.py
team/may/ooh323_qsig/rest-api/api-docs/recordings.json
Propchange: team/may/ooh323_qsig/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Fri Aug 30 09:10:47 2013
@@ -1,1 +1,1 @@
-/branches/12:1-397927,397938,397945-397946,397955,397958,397960
+/branches/12:1-397989
Propchange: team/may/ooh323_qsig/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug 30 09:10:47 2013
@@ -1,1 +1,1 @@
-/trunk:1-397949,397956-397962
+/trunk:1-397992
Modified: team/may/ooh323_qsig/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/CHANGES?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/CHANGES (original)
+++ team/may/ooh323_qsig/CHANGES Fri Aug 30 09:10:47 2013
@@ -63,6 +63,9 @@
Please see https://wiki.asterisk.org/wiki/x/J4GLAQ for more information on
configuring and installing PJSIP for usage with Asterisk.
+ * Optional API was re-implemented to be more portable, and no longer requires
+ weak reference support from the compiler. The build option OPTIONAL_API may
+ be disabled to disable Optional API support.
Applications
------------------
Modified: team/may/ooh323_qsig/build_tools/cflags.xml
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/build_tools/cflags.xml?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/build_tools/cflags.xml (original)
+++ team/may/ooh323_qsig/build_tools/cflags.xml Fri Aug 30 09:10:47 2013
@@ -1,4 +1,4 @@
- <category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" remove_on_change=".lastclean">
+<category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" remove_on_change=".lastclean">
<member name="DONT_OPTIMIZE" displayname="Disable Optimizations by the Compiler">
<support_level>core</support_level>
</member>
@@ -28,6 +28,13 @@
<!-- Added to work around GCC bug
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47816
-->
+ <support_level>extended</support_level>
+ </member>
+ <member name="OPTIONAL_API" displayname="Enable the optional API">
+ <!-- Added to manually disable the optional API, since
+ it's now supported on all systems.
+ -->
+ <defaultenabled>yes</defaultenabled>
<support_level>extended</support_level>
</member>
<member name="BETTER_BACKTRACES" displayname="Use libbfd (GPL) to generate better inline backtraces">
Modified: team/may/ooh323_qsig/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/channels/chan_sip.c?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/channels/chan_sip.c (original)
+++ team/may/ooh323_qsig/channels/chan_sip.c Fri Aug 30 09:10:47 2013
@@ -298,6 +298,7 @@
#include "asterisk/stasis_system.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/features_config.h"
+#include "asterisk/http_websocket.h"
/*** DOCUMENTATION
<application name="SIPDtmfMode" language="en_US">
Modified: team/may/ooh323_qsig/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/channels/sip/include/sip.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/channels/sip/include/sip.h (original)
+++ team/may/ooh323_qsig/channels/sip/include/sip.h Fri Aug 30 09:10:47 2013
@@ -35,7 +35,6 @@
#include "asterisk/indications.h"
#include "asterisk/security_events.h"
#include "asterisk/features.h"
-#include "asterisk/http_websocket.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/netsock2.h"
#include "asterisk/features_config.h"
@@ -768,6 +767,8 @@
int tcp_enabled;
int default_max_forwards; /*!< Default max forwards (SIP Anti-loop) */
};
+
+struct ast_websocket;
/*! \brief The SIP socket definition */
struct sip_socket {
Modified: team/may/ooh323_qsig/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/configure.ac?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/configure.ac (original)
+++ team/may/ooh323_qsig/configure.ac Fri Aug 30 09:10:47 2013
@@ -957,37 +957,9 @@
AST_GCC_ATTRIBUTE(deprecated)
AST_GCC_ATTRIBUTE(sentinel)
AST_GCC_ATTRIBUTE(warn_unused_result)
-
-# Support weak symbols on a platform specific basis. The Mac OS X
-# (Darwin) support must be isolated from the other platforms because
-# it has caused other platforms to fail.
-#
-case "${OSARCH}" in
- darwin*)
- # Allow weak symbol support on Darwin platforms only because there
- # is active community support for it.
- # However, Darwin seems to break weak symbols for each new version.
- #
- AST_GCC_ATTRIBUTE(weak_import, [], [], PBX_WEAKREF)
-
- # Several other platforms including Linux have GCC versions that
- # define the weak attribute. However, this attribute is only
- # setup for use in the code by Darwin.
- AST_GCC_ATTRIBUTE(weak, [], [], PBX_WEAKREF)
- ;;
- linux-gnu)
- # Primarily support weak symbols on Linux platforms.
- #
- AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF)
- ;;
- *)
- # Allow weak symbols on other platforms. However, any problems
- # with this feature on other platforms must be fixed by the
- # community.
- #
- AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF)
- ;;
-esac
+AST_GCC_ATTRIBUTE(may_alias)
+AST_GCC_ATTRIBUTE(constructor)
+AST_GCC_ATTRIBUTE(destructor)
AC_MSG_CHECKING(for -ffunction-sections support)
saved_CFLAGS="${CFLAGS}"
@@ -1180,6 +1152,8 @@
AST_C_DEFINE_CHECK([GLOB_NOMAGIC], [GLOB_NOMAGIC], [glob.h])
AST_C_DEFINE_CHECK([GLOB_BRACE], [GLOB_BRACE], [glob.h])
+
+AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
Modified: team/may/ooh323_qsig/include/asterisk/ari.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/ari.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/ari.h (original)
+++ team/may/ooh323_qsig/include/asterisk/ari.h Fri Aug 30 09:10:47 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,14 @@
#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 optional_api stuff to happen, which makes optional_api more
+ * difficult to debug. */
+
+struct ast_websocket_server;
+
+struct ast_websocket;
/*!
* \brief Configured encoding format for JSON output.
Modified: team/may/ooh323_qsig/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/autoconfig.h.in?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/autoconfig.h.in (original)
+++ team/may/ooh323_qsig/include/asterisk/autoconfig.h.in Fri Aug 30 09:10:47 2013
@@ -82,11 +82,20 @@
/* Define to 1 if your GCC C compiler supports the 'const' attribute. */
#undef HAVE_ATTRIBUTE_const
+/* Define to 1 if your GCC C compiler supports the 'constructor' attribute. */
+#undef HAVE_ATTRIBUTE_constructor
+
/* Define to 1 if your GCC C compiler supports the 'deprecated' attribute. */
#undef HAVE_ATTRIBUTE_deprecated
+/* Define to 1 if your GCC C compiler supports the 'destructor' attribute. */
+#undef HAVE_ATTRIBUTE_destructor
+
/* Define to 1 if your GCC C compiler supports the 'malloc' attribute. */
#undef HAVE_ATTRIBUTE_malloc
+
+/* Define to 1 if your GCC C compiler supports the 'may_alias' attribute. */
+#undef HAVE_ATTRIBUTE_may_alias
/* Define to 1 if your GCC C compiler supports the 'pure' attribute. */
#undef HAVE_ATTRIBUTE_pure
@@ -101,15 +110,6 @@
attribute. */
#undef HAVE_ATTRIBUTE_warn_unused_result
-/* Define to 1 if your GCC C compiler supports the 'weak' attribute. */
-#undef HAVE_ATTRIBUTE_weak
-
-/* Define to 1 if your GCC C compiler supports the 'weak_import' attribute. */
-#undef HAVE_ATTRIBUTE_weak_import
-
-/* Define to 1 if your GCC C compiler supports the 'weakref' attribute. */
-#undef HAVE_ATTRIBUTE_weakref
-
/* Define to 1 if you have the Debug symbol decoding library. */
#undef HAVE_BFD
@@ -719,6 +719,9 @@
/* Define to 1 if you have the `roundl' function. */
#undef HAVE_ROUNDL
+
+/* Define if your system has the RTLD_NOLOAD headers. */
+#undef HAVE_RTLD_NOLOAD
/* Define to 1 if your system has /sbin/launchd. */
#undef HAVE_SBIN_LAUNCHD
Modified: team/may/ooh323_qsig/include/asterisk/compiler.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/compiler.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/compiler.h (original)
+++ team/may/ooh323_qsig/include/asterisk/compiler.h Fri Aug 30 09:10:47 2013
@@ -71,6 +71,12 @@
#define attribute_warn_unused_result
#endif
+#ifdef HAVE_ATTRIBUTE_may_alias
+#define attribute_may_alias __attribute__((may_alias))
+#else
+#define attribute_may_alias
+#endif
+
/* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
#define SENTINEL ((char *)NULL)
Modified: team/may/ooh323_qsig/include/asterisk/http_websocket.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/http_websocket.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/http_websocket.h (original)
+++ team/may/ooh323_qsig/include/asterisk/http_websocket.h Fri Aug 30 09:10:47 2013
@@ -21,6 +21,8 @@
#include "asterisk/http.h"
#include "asterisk/optional_api.h"
+
+#include <errno.h>
/*!
* \file http_websocket.h
@@ -71,7 +73,7 @@
* \retval \c NULL on error
* \since 12
*/
-struct ast_websocket_server *ast_websocket_server_create(void);
+AST_OPTIONAL_API(struct ast_websocket_server *, ast_websocket_server_create, (void), { return NULL; });
/*!
* \brief Callback suitable for use with a \ref ast_http_uri.
@@ -79,7 +81,7 @@
* Set the data field of the ast_http_uri to \ref ast_websocket_server.
* \since 12
*/
-int ast_websocket_uri_cb(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers);
+AST_OPTIONAL_API(int, ast_websocket_uri_cb, (struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers), { return -1; });
/*!
* \brief Add a sub-protocol handler to the default /ws 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), { 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), { 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), { errno = ENOSYS; return -1;});
/*!
* \brief Enable multi-frame reconstruction up to a certain number of bytes
@@ -207,7 +209,7 @@
*
* \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), { errno = ENOSYS; return -1;});
/*!
* \brief Get the remote address for a WebSocket connected session.
@@ -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), { 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), { errno = ENOSYS; return -1;});
#endif
Modified: team/may/ooh323_qsig/include/asterisk/optional_api.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/optional_api.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/optional_api.h (original)
+++ team/may/ooh323_qsig/include/asterisk/optional_api.h Fri Aug 30 09:10:47 2013
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2008, Digium, Inc.
+ * Copyright (C) 2008-2013, Digium, Inc.
*
* Kevin P. Fleming <kpfleming at digium.com>
*
@@ -30,19 +30,6 @@
* have only a part of their functionality dependent on the APIs, and can
* provide the remainder even if the APIs are not available.
*
- * To accomodate this situation, the AST_OPTIONAL_API macro allows an API
- * function to be declared in a special way, if Asterisk being built on a
- * platform that supports special compiler and dynamic linker attributes.
- * If so the API function will actually be a weak symbol, which means if the
- * provider of the API is not loaded, the symbol can still be referenced (unlike a
- * strong symbol, which would cause an immediate fault if not defined when
- * referenced), but it will return NULL signifying the linker/loader was
- * not able to resolve the symbol. In addition, the macro defines a hidden
- * 'stub' version of the API call, using a provided function body, and uses
- * various methods to make the API function symbol actually resolve to
- * that hidden stub, but only when the *real* provider of the symbol has
- * not been found.
- *
* An example can be found in agi.h:
*
* \code
@@ -74,19 +61,6 @@
* apply special aliases to the function prototype; this can be done
* by defining AST_API_MODULE just before including the header file
* containing the AST_OPTIONAL_API macro calls.
- *
- * \note If the platform does not provide adequate resources,
- * then the AST_OPTIONAL_API macro will result in a non-optional function
- * definition; this means that any consumers of the API functions so
- * defined will require that the provider of the API functions be
- * loaded before they can reference the symbols.
- *
- * WARNING WARNING WARNING WARNING WARNING
- *
- * You MUST add the AST_MODFLAG_GLOBAL_SYMBOLS to the module for which you
- * are enabling optional_api functionality, or it will fail to work.
- *
- * WARNING WARNING WARNING WARNING WARNING
*/
/*!
@@ -99,122 +73,14 @@
*/
#define AST_OPTIONAL_API_UNAVAILABLE INT_MIN
-
-#if defined(HAVE_ATTRIBUTE_weak_import) || defined(HAVE_ATTRIBUTE_weak)
-
-/*
- * This is the Darwin (Mac OS/X) implementation, that only provides the 'weak'
- * or 'weak_import' compiler attribute for weak symbols. On this platform,
- *
- * - The module providing the API will only provide a '__' prefixed version
- * of the API function to other modules (this will be hidden from the other
- * modules by the macros), so any modules compiled against older versions
- * of the module that provided a non-prefixed version of the API function
- * will fail to link at runtime.
- * - In the API module itself, access to the API function without using a
- * prefixed name is provided by a static pointer variable that holds the
- * function address.
- * - 'Consumer' modules of the API will use a combination of a weak_import or
- * weak symbol, a local stub function, a pointer variable and a constructor
- * function (which initializes that pointer variable as the module is being
- * loaded) to provide safe, optional access to the API function without any
- * special code being required.
- */
-
-#if defined(HAVE_ATTRIBUTE_weak_import)
-#define __default_attribute weak_import /* pre-Lion */
-#else
-#define __default_attribute weak /* Lion-onwards */
-#endif
-
-#define AST_OPTIONAL_API_NAME(name) __##name
-
-#if defined(AST_API_MODULE)
-
-#define AST_OPTIONAL_API(result, name, proto, stub) \
- result AST_OPTIONAL_API_NAME(name) proto; \
- static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
-
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
- result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
- static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
-
-#else
-
-#define AST_OPTIONAL_API(result, name, proto, stub) \
- static result __stub__##name proto stub; \
- __attribute__((__default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
- static attribute_unused typeof(__stub__##name) * name; \
- static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
-
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
- static __attribute__((attr)) result __stub__##name proto stub; \
- __attribute__((attr, __default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
- static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
- static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
-
-#endif
-
-/* End of Darwin (Mac OS/X) implementation */
-
-#elif defined(HAVE_ATTRIBUTE_weakref)
-
-/*
- * This is the generic GCC implementation, used when the 'weakref'
- * compiler attribute is available. On these platforms:
- *
- * - The module providing the API will provide a '__' prefixed version
- * of the API function to other modules (this will be hidden from the other
- * modules by the macros), and also a non-prefixed alias so that modules
- * compiled against older versions of the module that provided a non-prefixed
- * version of the API function will continue to link properly.
- * - In the API module itself, access to the API function without using a
- * prefixed name is provided by the non-prefixed alias described above.
- * - 'Consumer' modules of the API will use a combination of a weakref
- * symbol, a local stub function, a pointer variable and a constructor function
- * (which initializes that pointer variable as the module is being loaded)
- * to provide safe, optional access to the API function without any special
- * code being required.
- */
-
-#define AST_OPTIONAL_API_NAME(name) __##name
-
-#if defined(AST_API_MODULE)
-
-#define AST_OPTIONAL_API(result, name, proto, stub) \
- result AST_OPTIONAL_API_NAME(name) proto; \
- static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
-
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
- result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
- static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
-
-#else
-
-#define AST_OPTIONAL_API(result, name, proto, stub) \
- 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; }
-
-#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; }
-
-#endif
-
-/* End of GCC implementation */
-
-#else
-
-/* This is the non-optional implementation. */
-
-#define AST_OPTIONAL_API_NAME(name) name
-
-/*!
- * \brief Define an optional API function
+/*!
+ * \def AST_OPTIONAL_API_NAME(name)
+ * \brief Expands to the name of the implementation function.
+ */
+
+/*!
+ * \def AST_OPTIONAL_API(result, name, proto, stub)
+ * \brief Declare an optional API function
*
* \param result The type of result the function returns
* \param name The name of the function
@@ -225,12 +91,12 @@
* \code
* AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd),
* { return AST_OPTIONAL_API_UNAVAILABLE; });
- * \endcode
- */
-#define AST_OPTIONAL_API(result, name, proto, stub) result AST_OPTIONAL_API_NAME(name) proto
-
-/*!
- * \brief Define an optional API function with compiler attributes
+ * \endcode
+ */
+
+/*!
+ * \def AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub)
+ * \brief Declare an optional API function with compiler attributes
*
* \param result The type of result the function returns
* \param attr Any compiler attributes to be applied to the function (without the __attribute__ wrapper)
@@ -238,12 +104,155 @@
* \param proto The prototype (arguments) of the function
* \param stub The code block that will be used by the hidden stub when needed
*/
-#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto
-
-/* End of non-optional implementation */
-
+
+#if defined(OPTIONAL_API)
+
+#if !defined(HAVE_ATTRIBUTE_constructor) || !defined(HAVE_ATTRIBUTE_constructor)
+#error OPTIONAL_API requires compiler constructor/destructor support
#endif
+/*!
+ * \internal
+ * \brief Function pointer to an optional API function.
+ *
+ * Functions that are declared as optional may have any signature they want;
+ * they are cast to this type as needed. We don't use a \c void pointer, because
+ * technically data and function pointers are incompatible.
+ *
+ * \note
+ * The may_alias attribute is to avoid type punning/strict aliasing warnings
+ * with older GCC's.
+ */
+typedef void (*ast_optional_fn)(void) attribute_may_alias;
+
+/*!
+ * \internal
+ * \brief Provide an implementation of an optional API.
+ *
+ * Any declared usages of this function are linked.
+ *
+ * \param symname Name of the provided function.
+ * \param impl Function pointer to the implementation function.
+ */
+void ast_optional_api_provide(const char *symname, ast_optional_fn impl);
+
+/*!
+ * \internal
+ * \brief Remove an implementation of an optional API.
+ *
+ * Any declared usages of this function are unlinked.
+ *
+ * \param symname Name of the provided function.
+ * \param impl Function pointer to the implementation function.
+ */
+void ast_optional_api_unprovide(const char *symname, ast_optional_fn impl);
+
+/*!
+ * \internal
+ * \brief Define a usage of an optional API.
+ *
+ * If the API has been provided, it will be linked into \a optional_ref.
+ * Otherwise, it will be linked to \a stub until an implementation is provided.
+ *
+ * \param symname Name of the function to use.
+ * \param optional_ref Pointer-to-function-pointer to link to impl/stub.
+ * \param stub Stub function to link to when impl is not available.
+ * \param module Name of the module requesting the API.
+ */
+void ast_optional_api_use(const char *symname, ast_optional_fn *optional_ref,
+ ast_optional_fn stub, const char *module);
+
+/*!
+ * \internal
+ * \brief Remove a usage of an optional API.
+ *
+ * The \a optional_ref will be linked to the \a stub provided at use time,
+ * will no longer be updated if the API is provided/removed.
+ *
+ * \param symname Name of the function to use.
+ * \param optional_ref Pointer-to-function-pointer to link to impl/stub.
+ * \param module Name of the module requesting the API.
+ */
+void ast_optional_api_unuse(const char *symname, ast_optional_fn *optional_ref,
+ const char *module);
+
+/*!
+ * \brief Call at exit to clean up optional_api internals.
+ *
+ * Since the optional_api code might run before main() starts, it can't safely
+ * register its own cleanup handlers. That has to be done within main().
+ */
+void optional_api_cleanup(void);
+
+#define AST_OPTIONAL_API_NAME(name) __##name
+
+#if defined(AST_API_MODULE)
+/* Module defining the API */
+
+#define AST_OPTIONAL_API_IMPL_INIT(name) \
+ static void __attribute__((constructor)) __init__##name##_impl(void) { \
+ ast_optional_api_provide(#name, \
+ (ast_optional_fn)AST_OPTIONAL_API_NAME(name)); \
+ } \
+ static void __attribute__((destructor)) __dtor__##name##_impl(void) { \
+ ast_optional_api_unprovide(#name, \
+ (ast_optional_fn)AST_OPTIONAL_API_NAME(name)); \
+ }
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+ result AST_OPTIONAL_API_NAME(name) proto; \
+ static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const \
+ name = AST_OPTIONAL_API_NAME(name); \
+ AST_OPTIONAL_API_IMPL_INIT(name)
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
+ result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
+ static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const \
+ name = AST_OPTIONAL_API_NAME(name); \
+ AST_OPTIONAL_API_IMPL_INIT(name)
+
+#else
+/* Module using the API */
+
+#define AST_OPTIONAL_API_INIT(name) \
+ static void __attribute__((constructor)) __init__##name(void) { \
+ ast_optional_api_use(#name, (ast_optional_fn *)&name, \
+ (ast_optional_fn)__stub__##name, \
+ AST_MODULE); \
+ } \
+ static void __attribute__((destructor)) __dtor__##name(void) { \
+ ast_optional_api_unuse(#name, (ast_optional_fn *)&name, \
+ AST_MODULE); \
+ }
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+ static result __stub__##name proto stub; \
+ static attribute_unused \
+ typeof(__stub__##name) * name; \
+ AST_OPTIONAL_API_INIT(name)
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
+ static __attribute__((attr)) result __stub__##name proto stub; \
+ static attribute_unused __attribute__((attr)) \
+ typeof(__stub__##name) * name; \
+ AST_OPTIONAL_API_INIT(name)
+
+#endif /* defined(AST_API_MODULE) */
+
+#else /* defined(OPTIONAL_API) */
+
+/* Non-optional API */
+
+#define AST_OPTIONAL_API_NAME(name) name
+
+#define AST_OPTIONAL_API(result, name, proto, stub) \
+ result AST_OPTIONAL_API_NAME(name) proto
+
+#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
+ result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto
+
+#endif /* defined(OPTIONAL_API) */
+
#undef AST_API_MODULE
#endif /* __ASTERISK_OPTIONAL_API_H */
Modified: team/may/ooh323_qsig/include/asterisk/stasis_app_recording.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/include/asterisk/stasis_app_recording.h?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/include/asterisk/stasis_app_recording.h (original)
+++ team/may/ooh323_qsig/include/asterisk/stasis_app_recording.h Fri Aug 30 09:10:47 2013
@@ -30,6 +30,68 @@
#include "asterisk/app.h"
#include "asterisk/stasis_app.h"
+
+/*! @{ */
+
+/*! \brief Structure representing a recording stored on disk */
+struct stasis_app_stored_recording;
+
+/*!
+ * \brief Returns the filename for this recording, for use with streamfile.
+ *
+ * The returned string will be valid until the \a recording object is freed.
+ *
+ * \param recording Recording to query.
+ * \return Absolute path to the recording file, without the extension.
+ * \return \c NULL on error.
+ */
+const char *stasis_app_stored_recording_get_file(
+ struct stasis_app_stored_recording *recording);
+
+/*!
+ * \brief Convert stored recording info to JSON.
+ *
+ * \param recording Recording to convert.
+ * \return JSON representation.
+ * \return \c NULL on error.
+ */
+struct ast_json *stasis_app_stored_recording_to_json(
+ struct stasis_app_stored_recording *recording);
+
+/*!
+ * \brief Find all stored recordings on disk.
+ *
+ * \return Container of \ref stasis_app_stored_recording objects.
+ * \return \c NULL on error.
+ */
+struct ao2_container *stasis_app_stored_recording_find_all(void);
+
+/*!
+ * \brief Creates a stored recording object, with the given name.
+ *
+ * \param name Name of the recording.
+ * \return New recording object.
+ * \return \c NULL if recording is not found. \c errno is set to indicate why
+ * - \c ENOMEM - out of memeory
+ * - \c EACCES - file permissions (or recording is outside the config dir)
+ * - Any of the error codes for stat(), opendir(), readdir()
+ */
+struct stasis_app_stored_recording *stasis_app_stored_recording_find_by_name(
+ const char *name);
+
+/*!
+ * \brief Delete a recording from disk.
+ *
+ * \param recording Recording to delete.
+ * \return 0 on success.
+ * \return Non-zero on error.
+ */
+int stasis_app_stored_recording_delete(
+ struct stasis_app_stored_recording *recording);
+
+/*! @} */
+
+/*! @{ */
/*! Opaque struct for handling the recording of media to a file. */
struct stasis_app_recording;
@@ -216,4 +278,6 @@
*/
struct stasis_message_type *stasis_app_recording_snapshot_type(void);
+/*! @} */
+
#endif /* _ASTERISK_STASIS_APP_RECORDING_H */
Modified: team/may/ooh323_qsig/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/main/asterisk.c?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/main/asterisk.c (original)
+++ team/may/ooh323_qsig/main/asterisk.c Fri Aug 30 09:10:47 2013
@@ -247,6 +247,7 @@
#include "asterisk/stasis_endpoints.h"
#include "asterisk/stasis_system.h"
#include "asterisk/security_events.h"
+#include "asterisk/optional_api.h"
#include "../defaults.h"
@@ -4165,6 +4166,10 @@
ast_el_read_history(filename);
}
+#if defined(OPTIONAL_API)
+ ast_register_cleanup(optional_api_cleanup);
+#endif
+
ast_json_init();
ast_ulaw_init();
ast_alaw_init();
Modified: team/may/ooh323_qsig/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/main/loader.c?view=diff&rev=397993&r1=397992&r2=397993
==============================================================================
--- team/may/ooh323_qsig/main/loader.c (original)
+++ team/may/ooh323_qsig/main/loader.c Fri Aug 30 09:10:47 2013
@@ -185,6 +185,8 @@
mod = resource_being_loaded;
}
+ ast_verb(5, "Registering module %s\n", info->name);
+
mod->info = info;
AST_LIST_HEAD_INIT(&mod->users);
@@ -230,6 +232,7 @@
AST_LIST_UNLOCK(&module_list);
if (mod) {
+ ast_verb(5, "Unregistering module %s\n", info->name);
AST_LIST_HEAD_DESTROY(&mod->users);
ast_free(mod);
}
@@ -403,16 +406,83 @@
}
[... 1102 lines stripped ...]
More information about the asterisk-commits
mailing list