home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!gatech!destroyer!cs.ubc.ca!uw-beaver!news.tek.com!psgrain!qiclab!leonard
- From: leonard@qiclab.scn.rain.com (Leonard Erickson)
- Subject: Re: File locking question
- Message-ID: <1993Jan12.063700.8784@qiclab.scn.rain.com>
- Reply-To: Leonard.Erickson@f51.n105.z1.fidonet.org
- Organization: SCN Research/Qic Laboratories of Tigard, Oregon.
- References: <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl>
- Date: Tue, 12 Jan 1993 06:37:00 GMT
- Lines: 35
-
- Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik Klompmaker) writes:
-
- >which writes the username, time and date to the log file.
- >A problem arrises when 2 people log in at the same time. Right: the log file
- >is locked by one of them and the other one gets a A-R-I error (abort,re...)
- >Is there a simple (and fast and small) method to detect if a file is locked
- >or not. (since username is a TP program it would sure be possible to do the
- >checking there (how ??) but maybe it would even be possible to do that at
- >dos/batch level.
- >Any hints ??
-
- I had to handle this too. I handled it something like this:
-
- FileMode := $12; {Deny Access to others, read/write mode}
- ctr := 0;
- repeat
- {$I-}
- append(logfile);
- {$I+}
- inc(ctr);
- until (IOResult = 0) or (ctr>limit);
- if ctr > limit then {error routine}
-
- This waits for the file to be free *or* until a retry limit is reached.
- On our heavily used LAN, it was quite possible to have unacceptable
- times to get access. Especially if some *idiot* used a file browser
- to look at the logfile! (Which did happen because it needs to be world
- writeable *and* word readable for appending to work right.)
-
-
- --
- Leonard Erickson leonard@qiclab.scn.rain.com
- CIS: [70465,203] 70465.203@compuserve.com
- FIDO: 1:105/51 Leonard.Erickson@f51.n105.z1.fidonet.org
- (The CIS & Fido addresses are preferred)
-