Subject: Bug report: flock
From: [email-masked] (Pasqualino Assini)

22 Feb 1997 17:06:50 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (WinNT; I)
Original-To: [email-masked]
Original-Sender: [email-masked]

It appears that there is some problem with flock in beta 17.1 under
Windows 3.51 and Windows 95

I use flock to get an exclusive lock by using the routine listed at the
end of the message.
While it seems to work perfectly under my WinNT 4.0 workstation a client
told me that the lock is not granted under WinNT 3.51 server and Win95.

It also doesn't work on any platform with beta 16.1 (but that's quite
normal as I think that flock support wasn't there at the time!)

Did anyone else experiment with flock support ?

int lock_open(const char* filename
             ,int timeout 
             ,int flags   
             )
{
  int fid;

  TRACE2("Trying to get lock on file %s",filename);  
  fid=open(filename, flags, S_IREAD|S_IWRITE);
  if (fid == -1) return(-1);

  struct flock cntrl;
  cntrl.l_type=F_WRLCK; // exclusive lock
  int error;
  int elapsed=0;
  while ( (error=fcntl(fid,F_SETLK,&cntrl)) && (elapsed<timeout) )
	 { 
	   sleep(1);
	   ++elapsed;
	 }

  if (error) return -1;
  return fid;
}

-- 
Pasqualino Assini        --- Kamus Internet Consulting
Via Nazioni Unite,47     --- 50126 Firenze Italy
Tel/Fax: +39 55 68.58.07 --- Tel/Fax: +39 55 48.29.29
Tel: +39 584 79.11.31    --- 
Email: [email-masked]   --- Web: http://www.kamus.it/

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".