<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/5859">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Sean Bright: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_corosync: Change thread stack size<br><br>In Corosync 2.x libraries were changed to use LibQB IPC.<br>Sadly LibQB IPC doesn't support copy-free access to received buffer, so<br>Corosync libraries were rewritten to use stack as buffer. Mostly the<br>needed stack size is quite small, but for all *_dispatch functions, 1MiB<br>is needed.<br><br>Asterisk function ast_pthread_create_background set stack size for new<br>thread to much smaller AST_BACKGROUND_STACKSIZE (~500KiB).<br><br>This results in Asterisk crash when running with Corosync 2.x.<br><br>Patch solves this issue by creating it's own version of<br>ast_pthread_create_background which sets stack size to much higher value<br>(actually it's AST_BACKGROUND_STACKSIZE + 3MiB).<br><br>Another problem may appear when "corosync show members" netconsole<br>command is executed. It is also executed in thread and also has only<br>500KiB stack size. Sadly it calls corosync_cfg_get_node_addrs which<br>again needs at least 1MiB stack.<br><br>Solution is to use HAVE_COROSYNC_CFG_STATE_TRACK as a discriminator<br>between Corosync 1.x and 2.x. If 1.x is found, nothing changes. If 2.x<br>is found, NodeID is displayed instead of IP address.<br><br>ASTERISK-25370 #close<br>Reported by: mdu113<br><br>Change-Id: Id95b0d21ab6e708e7d74ad8786c587211676fa08<br>---<br>M res/res_corosync.c<br>1 file changed, 24 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_corosync.c b/res/res_corosync.c<br>index 79cd810..0d91b18 100644<br>--- a/res/res_corosync.c<br>+++ b/res/res_corosync.c<br>@@ -77,6 +77,15 @@<br> struct ast_sockaddr addr;<br> };<br> <br>+/*! \brief Corosync ipc dispatch/request and reply size */<br>+#define COROSYNC_IPC_BUFFER_SIZE (8192 * 128)<br>+<br>+/*! \brief Version of pthread_create to ensure stack is large enough */<br>+#define corosync_pthread_create_background(a, b, c, d) \<br>+ ast_pthread_create_stack(a, b, c, d, \<br>+ (AST_BACKGROUND_STACKSIZE + (3 * COROSYNC_IPC_BUFFER_SIZE)), \<br>+ __FILE__, __FUNCTION__, __LINE__, #c)<br>+<br> static struct corosync_node *corosync_node_alloc(struct ast_event *event)<br> {<br> struct corosync_node *node;<br>@@ -808,19 +817,27 @@<br> for (i = 1, cs_err = cpg_iteration_next(cpg_iter, &cpg_desc);<br> cs_err == CS_OK;<br> cs_err = cpg_iteration_next(cpg_iter, &cpg_desc), i++) {<br>+#ifdef HAVE_COROSYNC_CFG_STATE_TRACK<br> corosync_cfg_node_address_t addrs[8];<br> int num_addrs = 0;<br> unsigned int j;<br>+#endif<br> <br>+ ast_cli(a->fd, "=== Node %u\n", i);<br>+ ast_cli(a->fd, "=== --> Group: %s\n", cpg_desc.group.value);<br>+<br>+#ifdef HAVE_COROSYNC_CFG_STATE_TRACK<br>+ /*<br>+ * Corosync 2.x cfg lib needs to allocate 1M on stack after calling<br>+ * corosync_cfg_get_node_addrs. netconsole thread has allocated only 0.5M<br>+ * resulting in crash.<br>+ */<br> cs_err = corosync_cfg_get_node_addrs(cfg_handle, cpg_desc.nodeid,<br> ARRAY_LEN(addrs), &num_addrs, addrs);<br> if (cs_err != CS_OK) {<br> ast_log(LOG_WARNING, "Failed to get node addresses\n");<br> continue;<br> }<br>-<br>- ast_cli(a->fd, "=== Node %u\n", i);<br>- ast_cli(a->fd, "=== --> Group: %s\n", cpg_desc.group.value);<br> <br> for (j = 0; j < num_addrs; j++) {<br> struct sockaddr *sa = (struct sockaddr *) addrs[j].address;<br>@@ -831,7 +848,9 @@<br> <br> ast_cli(a->fd, "=== --> Address %u: %s\n", j + 1, buf);<br> }<br>-<br>+#else<br>+ ast_cli(a->fd, "=== --> Nodeid: %"PRIu32"\n", cpg_desc.nodeid);<br>+#endif<br> }<br> <br> ast_cli(a->fd, "===\n"<br>@@ -1157,7 +1176,7 @@<br> goto failed;<br> }<br> <br>- if (ast_pthread_create_background(&dispatch_thread.id, NULL,<br>+ if (corosync_pthread_create_background(&dispatch_thread.id, NULL,<br> dispatch_thread_handler, NULL)) {<br> ast_log(LOG_ERROR, "Error starting CPG dispatch thread.\n");<br> goto failed;<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5859">change 5859</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/5859"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id95b0d21ab6e708e7d74ad8786c587211676fa08 </div>
<div style="display:none"> Gerrit-Change-Number: 5859 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jan Friesse <jfriesse@redhat.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jan Friesse <jfriesse@redhat.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>