<p>Under high load, the value returned by <code>shm_available()</code> can be total garbage, because it is not multiprocess safe. In the tls module, it makes the tests against the <code>low_mem_thresholdX</code> limits randomly return false positives, with errors such as:</p>

<pre><code>ERROR: tls [tls_server.c:273]: tls_fix_connection(): tls: ssl bug #1491 workaround: not enough memory for safe operation: 88
</code></pre>

<p>although there is plenty of free shm memory.</p>

<p>This patch solves the issue by adding a safe version of the function.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/kamailio/kamailio/pull/126'>https://github.com/kamailio/kamailio/pull/126</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>mem: add a multiprocess-safe shm_available()</li>
  <li>tls: use multiprocess-safe shm_available()</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/kamailio/kamailio/pull/126/files#diff-0">mem/shm_mem.c</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/kamailio/kamailio/pull/126/files#diff-1">mem/shm_mem.h</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/kamailio/kamailio/pull/126/files#diff-2">modules/tls/tls_server.c</a>
    (4)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/kamailio/kamailio/pull/126.patch'>https://github.com/kamailio/kamailio/pull/126.patch</a></li>
  <li><a href='https://github.com/kamailio/kamailio/pull/126.diff'>https://github.com/kamailio/kamailio/pull/126.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/pull/126">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZYYcJgbsSv2NUILfQFONCz04i7IDks5n_U2pgaJpZM4EAcUC.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/kamailio/kamailio/pull/126"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>