<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2797/">https://reviewboard.asterisk.org/r/2797/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By David Lee.</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-22296">ASTERISK-22296</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">New optional_api tests pass.
The config below consistently fails when attempting to connect to the
ARI WebSocket without this patch; consistently passes with this patch.
modules.conf:
[modules]
load => res_stasis.so
load => res_ari.so
load => res_ari_model.so
load => res_ari_events.so
load => res_http_websocket.so
http.conf:
[general]
enabled=yes
bindaddr=127.0.0.1
ari.conf:
[general]
enabled = yes
[ari]
type = user
password = ari
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/12/tests/test_optional_api.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/branches/12/rest-api-templates/swagger_model.py <span style="color: grey">(397673)</span></li>
<li>/branches/12/rest-api-templates/res_ari_resource.c.mustache <span style="color: grey">(397673)</span></li>
<li>/branches/12/res/res_http_websocket.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/res/res_ari_events.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/res/res_ari.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/res/ari/internal.h <span style="color: grey">(397673)</span></li>
<li>/branches/12/res/ari/ari_websockets.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/main/optional_api.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/branches/12/main/loader.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/main/asterisk.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/include/asterisk/optional_api.h <span style="color: grey">(397673)</span></li>
<li>/branches/12/include/asterisk/http_websocket.h <span style="color: grey">(397673)</span></li>
<li>/branches/12/include/asterisk/ari.h <span style="color: grey">(397673)</span></li>
<li>/branches/12/channels/sip/include/sip.h <span style="color: grey">(397673)</span></li>
<li>/branches/12/channels/chan_sip.c <span style="color: grey">(397673)</span></li>
<li>/branches/12/build_tools/cflags.xml <span style="color: grey">(397673)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2797/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>