<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 21 January 2016 at 07:00, Alex Rousskov <span dir="ltr"><<a href="mailto:rousskov@measurement-factory.com" target="_blank">rousskov@measurement-factory.com</a>></span> wrote:</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> - Call shm_open with O_EXCL, so that it'll fail if the shm segment<br>
> already exists. If the call fails with EEXIST, unlink the shm segment<br>
> and retry. This one may not even need to be Darwin-specific. Would be<br>
> unnecessary on other platforms, but wouldn't really hurt.<br>
<br>
</span>Could you please simplify your code using the following loopless sketch<br>
and post a tested patch as an attachment?<br>
<br>
if (!createExclusive() && errno == EEXIST) {<br>
unlink();<br>
createExclusive()<br>
}<br>
... old error handling code here ...<br>
... no need for double-truncate here ...<br>
<br>
<br>
where createExclusive() is a new protected method:<br>
<br>
<br>
bool<br>
Ipc::Mem::Segment::createExclusive()<br>
{<br>
theFD = shm_open(theName.termedBuf(),<br>
O_EXCL | O_CREAT | O_RDWR | flags,<br>
S_IRUSR | S_IWUSR);<br>
return theFD >= 0;<br>
}<br></blockquote><div><br></div><div>Thanks for the pointers. I'll do that.</div><div><br></div><div>What's the proper way for generating a neat Bazaar patch to send to the list? I am not really familiar with it. I use GIT a lot, though.</div><div><br></div><div>Thanks,</div><div>-Markus</div><div><br></div><div><br></div><div><br></div></div></div></div>