asterisk/rest-api-templates
David M. Lee 9bed50db41 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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397990 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 13:40:27 +00:00
..
README.txt This patch adds a RESTful HTTP interface to Asterisk. 2013-04-22 14:58:53 +00:00
api.wiki.mustache Account for {} in Swagger notes 2013-08-29 16:21:31 +00:00
ari.make.mustache Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
ari_model_validators.c.mustache Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
ari_model_validators.h.mustache Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
ari_resource.c.mustache Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
ari_resource.h.mustache ARI - implement allowMultiple for parameters 2013-08-02 14:36:32 +00:00
asterisk_processor.py Account for {} in Swagger notes 2013-08-29 16:21:31 +00:00
do-not-edit.mustache This patch adds a RESTful HTTP interface to Asterisk. 2013-04-22 14:58:53 +00:00
make_ari_stubs.py Account for {} in Swagger notes 2013-08-29 16:21:31 +00:00
models.wiki.mustache Update events to use Swagger 1.3 subtyping, and related aftermath 2013-07-03 16:32:41 +00:00
odict.py This patch adds a RESTful HTTP interface to Asterisk. 2013-04-22 14:58:53 +00:00
param_cleanup.mustache ARI - implement allowMultiple for parameters 2013-08-02 14:36:32 +00:00
param_parsing.mustache ARI: WebSocket event cleanup 2013-08-27 19:19:36 +00:00
res_ari_resource.c.mustache optional_api: Fix linking problems between modules that export global symbols 2013-08-30 13:40:27 +00:00
rest_handler.mustache Rename everything Stasis-HTTP to ARI 2013-07-27 23:11:02 +00:00
swagger_model.py optional_api: Fix linking problems between modules that export global symbols 2013-08-30 13:40:27 +00:00
transform.py Update events to use Swagger 1.3 subtyping, and related aftermath 2013-07-03 16:32:41 +00:00

README.txt

This directory contains templates and template processing code for generating
HTTP bindings for the RESTful API's.

The RESTful API's are declared using [Swagger][swagger]. While Swagger provides
a [code generating toolkit][swagger-codegen], it requires Java to run, which
would be an unusual dependency to require for Asterisk developers.

This code generator is similar, but written in Python. Templates are processed
by using [pystache][pystache], which is a fairly simply Python implementation of
[mustache][mustache].

 [swagger]: https://github.com/wordnik/swagger-core/wiki
 [swagger-codegen]: https://github.com/wordnik/swagger-codegen
 [pystache]: https://github.com/defunkt/pystache
 [mustache]: http://mustache.github.io/