home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 8061 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.8 KB  |  47 lines

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