<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10587">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: modify taskprocessor scheduling algorithm from round-robin to least-size<br><br>This patch modifies the algorithm from round-robin to least-size<br>for picking PJSIP taskprocessor from default serializer pool.<br><br>Change-Id: I7b8d8cc2c2490494f579374b6af0a4868e3a37cd<br>---<br>M res/res_pjsip.c<br>1 file changed, 11 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/10587/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index 03b86e9..58f20b8 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -2505,9 +2505,6 @@</span><br><span> /*! Number of serializers in pool if one not supplied. */</span><br><span> #define SERIALIZER_POOL_SIZE 8</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! Next serializer pool index to use. */</span><br><span style="color: hsl(0, 100%, 40%);">-static int serializer_pool_pos;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*! Pool of serializers to use if not supplied. */</span><br><span> static struct ast_taskprocessor *serializer_pool[SERIALIZER_POOL_SIZE];</span><br><span> </span><br><span>@@ -4332,22 +4329,20 @@</span><br><span> </span><br><span> static struct ast_taskprocessor *serializer_pool_pick(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_taskprocessor *serializer;</span><br><span style="color: hsl(120, 100%, 40%);">+ int idx;</span><br><span style="color: hsl(120, 100%, 40%);">+ int pos;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int pos;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!serializer_pool[0]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Pick a serializer to use from the pool.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Note: We don't care about any reentrancy behavior</span><br><span style="color: hsl(0, 100%, 40%);">- * when incrementing serializer_pool_pos. If it gets</span><br><span style="color: hsl(0, 100%, 40%);">- * incorrectly incremented it doesn't matter.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- pos = serializer_pool_pos++;</span><br><span style="color: hsl(0, 100%, 40%);">- pos %= SERIALIZER_POOL_SIZE;</span><br><span style="color: hsl(0, 100%, 40%);">- serializer = serializer_pool[pos];</span><br><span style="color: hsl(120, 100%, 40%);">+ for (pos = idx = 0; idx < SERIALIZER_POOL_SIZE; ++idx) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_taskprocessor_size(serializer_pool[idx]) < ast_taskprocessor_size(serializer_pool[pos])) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pos = idx;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- return serializer;</span><br><span style="color: hsl(120, 100%, 40%);">+ return serializer_pool[pos]; </span><br><span> }</span><br><span> </span><br><span> int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10587">change 10587</a>. To unsubscribe, or for help writing mail filters, 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/10587"/><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: I7b8d8cc2c2490494f579374b6af0a4868e3a37cd </div>
<div style="display:none"> Gerrit-Change-Number: 10587 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>