[Xerte-dev] Re: Lockfiles

Pat Lockley patrick.lockley at googlemail.com
Wed Feb 29 15:45:03 GMT 2012


once we've got an almost release candidate I will see if i've time

On Wed, Feb 29, 2012 at 2:37 PM, Julian Tenney
<Julian.Tenney at nottingham.ac.uk> wrote:
> You want to get this in for the next build?
>
> -----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 11:47
> To: For Xerte technical developers
> Subject: [Xerte-dev] Re: Lockfiles
>
> It uses the timestamp already (I think).
>
> So edit.php just needs a set interval call adding and some ajax writing.
>
> On Wed, Feb 29, 2012 at 11:45 AM, David Goodwin <david at palepurple.co.uk> wrote:
>> I think you'd want a small amount of grace in there - e.g. if you do an update every N seconds, then check if the last update was within N + 15 seconds or something before ignoring the lock file - incase someone's browser is having a bad day / web server is busy or whatever.
>>
>> I suspect you could just go on the timestamp of a file - so perhaps you could avoid making any changes to the database?
>>
>> thanks,
>>
>> David.
>>
>>
>> On 29 Feb 2012, at 11:35, Pat Lockley wrote:
>>
>>> We have the lock file in the template folder already - so we could set
>>> up setinterval to update the lockfile every 30 seconds or so, and if
>>> the last update isn't within 30 seconds, ignore the lockfile?
>>>
>>> On Wed, Feb 29, 2012 at 11:20 AM, David Goodwin <david at palepurple.co.uk> wrote:
>>>> That's already dealt with - I've already added an 'upgrade.php' script somewhere..
>>>>
>>>> You'd just need to ask people to point their web browser at it. or have some sort of detection code which causes the upgrade to run if the code thinks the database isn't up to date.
>>>>
>>>> thanks
>>>> David.
>>>>
>>>>
>>>> On 29 Feb 2012, at 11:17, Ron Mitchell wrote:
>>>>
>>>>> 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
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>> 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.
>>
>> 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
>
> _______________________________________________
> 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.



More information about the Xerte-dev mailing list