Re: Re: skinning a cat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2008-09-01 at 14:51 +0200, Per Jessen wrote:
> Jochem Maas wrote:
> 
> > Per Jessen schreef:
> >> Jochem Maas wrote:
> >> 
> >>>> lockfile=/var/lock/<xxxx>/file
> >>>> # clear out a lock older than 60mins
> >>>> find $lockfile -cmin +60 | xargs rm
> >>>> test ! -f $lockfile && (
> >>>> touch $lockfile
> >>>> <run some php>
> >>>> rm -f $lockfile
> >>>> )
> >>> wouldn't creating a dir be better here? (with regard to atomicity)
> >>>
> >> 
> >> I haven't thought it through, but I don't think it would change
> >> anything.
> > 
> > directory creation is garanteed to be atomic, even across NFS, or
> > so Rob said. 
> 
> Maybe so, but to avoid a race-condition, you need the test+touch
> sequence to be atomic.

The return value of creating the directory is either true for it having
been made or false for it having not been made. Therein lies the
atomicity. The OS will not return success if it was not made and will
not return failure if it was made.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux