<p>This change fixes some threading issues with the multithreading tests in gen_tile_test:</p>

<ol>
<li>The request addition threads ended up putting duplicate render requests on the queue, causing the "number of requests queued" count verifications to fail. There were flaws in the randomization logic in <code>addition_thread()</code> that exacerbated the issue, but the biggest flaw was using randomization logic at all. Randomization does not in any way guarantee uniqueness, leading to at least occasional duplicates and therefore test failures. I removed the randomization logic, settling on a combination of thread ID and sequence counter to ensure uniqueness.</li>
<li>Access to the sequence counter used for the X coordinate of the synthesized requests was not synchronized between threads. I added a mutex to guard this access.</li>
<li>The <code>SYS_gettid</code> system call is not supported on MACH / Mac OS X, which also contributed to render request duplication on that platform. I replaced it with a call to <code>pthread_threadid_np()</code>.</li>
</ol>

<p>With these changes, I have not seen any more intermittent failures in the multithreading test cases.</p>

<hr>

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

<h4>Commit Summary</h4>
<ul>
  <li>fix threading issues in threading tests</li>
  <li>wrap up multithreading fixes to unit test</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/mod_tile/pull/129/files#diff-0">src/gen_tile_test.cpp</a>
    (51)
  </li>
</ul>

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

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/mod_tile/pull/129">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AD2-7hCDkcUoTKMst680vCevUP3Ls5XIks5qTmz_gaJpZM4JII6B">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AD2-7pl8Ap8BF_WhJHCbb33h6D4a2FIpks5qTmz_gaJpZM4JII6B.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/openstreetmap/mod_tile/pull/129"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>