comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Suggestions on the use of lockfiles?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Suggestions on the use of lockfiles? [message #33923] Sat, 08 February 2003 22:48
Jonathan Greenberg is currently offline  Jonathan Greenberg
Messages: 91
Registered: November 2002
Member
I am having some troubles using lockfiles to do simple database read/writes
without getting a database corruption (I'm trying to hack my way around
buying Dataminer):

I have two or more computers running this code:

dblockname is the name of the lockfile for the database

***

while [program is still running] do begin
; Waits for the lockfile to not exist
while (file_test(dblockname) eq 1) do begin
wait,1
endwhile
; Creates a lockfile
openw,dblocklun,dblockname,/GET_LUN
printf,dblocklun,''
free_lun,dblocklun

[gets the database, reads and writes to it]
; Deletes the lockfile, and returns to the top of the loop
file_delete,dblockname

endwhile

***

The problem I'm having is that from time to time (depending on the speed of
the database I/O), I'm getting errors where, and this is a guess, one
computer manages to check for a nonexistant lockfile at the same time as
another, and so both computers break out of the loop at the same time and
start fooling around with the database at the same time. At the end,
whichever computer deletes the lockfile first can reenter the loop, but the
2nd computer gets an error since the file was already deleted (and the
database is likely to be corrupted at this point).

Ideas? The astronomy lockfile procedures appear to be unix only, and I'm
trying to design this for any platform (Windows, Mac, UNIX). Apparently I
can openw the same file from two computers without error (I wish that I
could override this fact). Help!

--j

--
Jonathan Greenberg
Graduate Group in Ecology, U.C. Davis
http://www.cstars.ucdavis.edu/~jongreen
http://www.cstars.ucdavis.edu
AIM: jgrn307 or jgrn3007
MSN: jgrn307@msn.com or jgrn3007@msn.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Strange floating-point precision behavior
Next Topic: display window disabling problems in batch mode idl

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 21:50:09 PDT 2025

Total time taken to generate the page: 0.55858 seconds