[Xerte-dev] Re: Lockfiles

Ron Mitchell ronm at mitchellmedia.co.uk
Wed Feb 29 11:17:41 GMT 2012


also if the solution requires a change to the database will need some kind
of easy to run update script. There are lots of installations out there
which pre-date the current version of the database.

-----Original Message-----
From: xerte-dev-bounces at lists.nottingham.ac.uk
[mailto:xerte-dev-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
Sent: 29 February 2012 10:56
To: For Xerte technical developers
Subject: [Xerte-dev] Re: Lockfiles

> This will only fall down if there are multiple people using the same 
> login within Xerte

Been here before:

Me to systemsy people: you're sure that user names are unique?
Systemsy people: Yep. Bet your house on it.
Me. Cool.

...much time and development passes...

Me: We seem to be getting duplicate user names logging in, you said they
were unique...
Systemsy people: ah, er, yes, well, we meant unique for each part of the
network
Me: so they're not unique then?
Systemsy people: On different parts of the network they're unique.

-----Original Message-----
From: xerte-dev-bounces at lists.nottingham.ac.uk
[mailto:xerte-dev-bounces at lists.nottingham.ac.uk] On Behalf Of David Goodwin
Sent: 29 February 2012 10:47
To: For Xerte technical developers
Subject: [Xerte-dev] Re: Lockfiles


Yes - the flock thing should work fine (at least it has for me in the past)
- but the lock is only held for the duration of the process - which wouldn't
necessarily be sufficient for you - as a http request wouldn't persist while
someone was editing the stuff. I think I didn't quite understand what you
were trying to achieve.



Perhaps something like the following would work for Xerte: ?

1 On going to edit a LO, you could use the flock stuff to ensure you (the
user) are the only ones to have gained an EDIT status on an LO. Once you get
EDIT status, you mark it as being edited within the db (e.g.
learning_object.edited_by = 'dg', learning_object.edited_time = '2011-02-29
10:00').


2. Your edit page has a background AJAXy HTTP request which fires every 30
seconds to update learning_object.edited_time 

3. If someone else goes to edit the LO, if there is a
learning_object.edited_time within 45 (?) seconds of now then you don't
allow them to edit it - and say it's "in use by dg"


This will only fall down if there are multiple people using the same login
within Xerte; so perhaps you'd need to make it slightly more distinct - e.g.
using the user's login and a uniqid() token - which would be stored in their
$_SESSION? Or use their IP address?

David.


On 29 Feb 2012, at 09:58, Pat Lockley wrote:

> 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

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