<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9034">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">channel.c: Fix off nominal channel allocation failure path.<br><br>__ast_channel_alloc_ap() had a failure exit path that hadn't setup the fd<br>descriptors to -1 yet. The destructor would then attempt to close these<br>fd's that had never been opened.<br><br>Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3<br>---<br>M main/channel.c<br>1 file changed, 14 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/9034/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/channel.c b/main/channel.c<br>index cbcf134..8de7ad2 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -818,7 +818,20 @@<br> <br> ast_channel_stage_snapshot(tmp);<br> <br>- if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {<br>+ /*<br>+ * Init file descriptors to unopened state so<br>+ * the destructor can know not to close them.<br>+ */<br>+ ast_channel_timingfd_set(tmp, -1);<br>+ ast_channel_internal_alertpipe_clear(tmp);<br>+ ast_channel_internal_fd_clear_all(tmp);<br>+<br>+#ifdef HAVE_EPOLL<br>+ ast_channel_epfd_set(tmp, epoll_create(25));<br>+#endif<br>+<br>+ nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);<br>+ if (!nativeformats) {<br> /*<br> * Aborting the channel creation. We do not need to complete staging<br> * the channel snapshot because the channel has not been finalized or<br>@@ -835,18 +848,6 @@<br> ast_channel_set_rawreadformat(tmp, ast_format_none);<br> ast_channel_set_writeformat(tmp, ast_format_none);<br> ast_channel_set_readformat(tmp, ast_format_none);<br>-<br>- /*<br>- * Init file descriptors to unopened state so<br>- * the destructor can know not to close them.<br>- */<br>- ast_channel_timingfd_set(tmp, -1);<br>- ast_channel_internal_alertpipe_clear(tmp);<br>- ast_channel_internal_fd_clear_all(tmp);<br>-<br>-#ifdef HAVE_EPOLL<br>- ast_channel_epfd_set(tmp, epoll_create(25));<br>-#endif<br> <br> if (!(schedctx = ast_sched_context_create())) {<br> ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9034">change 9034</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9034"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Icf21093f36c60781e8cf6ee9d586536302af33e3 </div>
<div style="display:none"> Gerrit-Change-Number: 9034 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>