[Xerte-dev] Re: Lockfiles
Julian Tenney
Julian.Tenney at nottingham.ac.uk
Wed Feb 29 10:28:17 GMT 2012
Didn't we get some improvements by making some assumptions to what 'stale' means, by looking at times / dates and comparing them to now.
So if lockfile made yesterday, probably not valid;
Etc
I'm way out of my comfort zone with this stuff, but do you get a session id, can you check to see if the creating session is still active when a new session attempts to open the file?
Is there a lockfile?
Which session made it?
Is that session still alive?
-----Original Message-----
From: xerte-dev-bounces at lists.nottingham.ac.uk [mailto:xerte-dev-bounces at lists.nottingham.ac.uk] On Behalf Of Pat Lockley
Sent: 29 February 2012 09:58
To: For Xerte technical developers
Subject: [Xerte-dev] Re: Lockfiles
That's the issue. I have a lock system already, and it suffers because they become stale.
On 29 Feb 2012, at 00:53, David Goodwin <david at palepurple.co.uk> wrote:
> 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
>
>
>
>
>
>
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
_______________________________________________
Xerte-dev mailing list
Xerte-dev at lists.nottingham.ac.uk
http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
More information about the Xerte-dev
mailing list