[squid-dev] ftruncate() failures on OS X (Darwin)
Markus Mayer
code at mmayer.net
Thu Jan 21 18:01:04 UTC 2016
On 21 January 2016 at 07:00, Alex Rousskov <rousskov at measurement-factory.com
> wrote:
> - Call shm_open with O_EXCL, so that it'll fail if the shm segment
> > already exists. If the call fails with EEXIST, unlink the shm segment
> > and retry. This one may not even need to be Darwin-specific. Would be
> > unnecessary on other platforms, but wouldn't really hurt.
>
> Could you please simplify your code using the following loopless sketch
> and post a tested patch as an attachment?
>
> if (!createExclusive() && errno == EEXIST) {
> unlink();
> createExclusive()
> }
> ... old error handling code here ...
> ... no need for double-truncate here ...
>
>
> where createExclusive() is a new protected method:
>
>
> bool
> Ipc::Mem::Segment::createExclusive()
> {
> theFD = shm_open(theName.termedBuf(),
> O_EXCL | O_CREAT | O_RDWR | flags,
> S_IRUSR | S_IWUSR);
> return theFD >= 0;
> }
>
Thanks for the pointers. I'll do that.
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.
Thanks,
-Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20160121/c5acf1b2/attachment.html>
More information about the squid-dev
mailing list