[Xerte-dev] Re: Lockfiles
David Goodwin
david at palepurple.co.uk
Wed Feb 29 00:53:51 GMT 2012
Oh, it also looks like you need to explicitly call flock($fp, LOCK_UN) afterwards.
The alternative is, I guess, having a field in the DB to store who is currently editing a file - presumably storing a session_id in a field.
The only problem with that is it would be possible on either a slow/busy/whatever webserver for two processes to think they had a "write" lock when in fact only one does, and you'd need some way of removing/detecting stale locks - so an LO isn't marked as being edited forever.
David
On 29 Feb 2012, at 00:34, David Goodwin wrote:
>
> On 28 Feb 2012, at 23:50, Pat Lockley wrote:
>
>> Stop concurrent access
>>
>
> $fp = fopen('/path/to/something.xml.lock', 'w');
> if(flock($fp, LOCK_EX, FALSE)) {
> // we have an exclusive lock on someting.xml.lock; within the scope of this webserver.
> }
> else {
> // someone else has access.
> }
>
> See also http://php.net/flock - note it's behaviour is slightly different on Windows, and it wouldn't scale past more than one web server.
>
>
> David.
>
>> On 28 Feb 2012, at 23:45, David Goodwin <david at palepurple.co.uk> wrote:
>>
>>> What do you mean by "lock an XML file down"
>>>
>>> Are you trying to stop concurrent access to it, or something else?
>>>
>>> David.
>>>
>>> On 28 Feb 2012, at 22:26, Pat Lockley wrote:
>>>
>>>> Hi all,
>>>>
>>>> Thoughts on how to lock an XML file down?
>>>>
>>>> I think it might be the session expiring, or the js might not fire properly. I am pretty sure the lockfile remove code doesn't use the session anymore.
>>>>
>>>>
>>>>
>>>
>>> Pale Purple Ltd. (Company No: 5580814)
>>> 'Business Web Application Development and Training in PHP'
>>>
>>> http://www.palepurple.co.uk
>>> Office: 0845 0046746 Mobile: 07792380669
>>>
>>> Follow us on Twitter: @PalePurpleLtd
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Xerte-dev mailing list
>>> Xerte-dev at lists.nottingham.ac.uk
>>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
>>>
>>> This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
>>>
>>> This message has been checked for viruses but the contents of an attachment
>>> may still contain software viruses which could damage your computer system:
>>> you are advised to perform your own checks. Email communications with the
>>> University of Nottingham may be monitored as permitted by UK legislation.
>>>
>>
>> _______________________________________________
>> Xerte-dev mailing list
>> Xerte-dev at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
>
> Pale Purple Ltd. (Company No: 5580814)
> 'Business Web Application Development and Training in PHP'
>
> http://www.palepurple.co.uk
> Office: 0845 0046746 Mobile: 07792380669
>
> Follow us on Twitter: @PalePurpleLtd
>
>
>
>
>
>
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
Pale Purple Ltd. (Company No: 5580814)
'Business Web Application Development and Training in PHP'
http://www.palepurple.co.uk
Office: 0845 0046746 Mobile: 07792380669
Follow us on Twitter: @PalePurpleLtd
More information about the Xerte-dev
mailing list