www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/04/18/19:57:41

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Date: Tue, 18 Apr 2000 20:57:37 -0400
Message-Id: <200004190057.UAA07671@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: cygwin-developers AT sourceware DOT cygnus DOT com
Subject: fhandler_disk_file::lock fix?

I've had this patch floating around in my sources for a while.  Anyone
want to comment on it?

Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/ChangeLog,v
retrieving revision 1.55
diff -p -3 -r1.55 ChangeLog
*** ChangeLog	2000/04/18 23:16:56	1.55
--- ChangeLog	2000/04/19 00:57:08
***************
*** 1,3 ****
--- 1,7 ----
+ 2000-04-18  DJ Delorie  <dj AT cygnus DOT com>
+ 
+ 	* fhandler.cc (lock): use signed math.  Fix math bug.
+ 
  Tue Apr 18 19:15:29 2000  Christopher Faylor <cgf AT cygnus DOT com>
  
  	* dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS
Index: fhandler.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v
retrieving revision 1.12
diff -p -3 -r1.12 fhandler.cc
*** fhandler.cc	2000/04/08 04:47:15	1.12
--- fhandler.cc	2000/04/19 00:57:08
*************** fhandler_disk_file::close ()
*** 1242,1249 ****
  int
  fhandler_disk_file::lock (int cmd, struct flock *fl)
  {
!   DWORD win32_start;
!   DWORD win32_len;
    DWORD win32_upper;
    DWORD startpos;
  
--- 1242,1249 ----
  int
  fhandler_disk_file::lock (int cmd, struct flock *fl)
  {
!   int win32_start;
!   int win32_len;
    DWORD win32_upper;
    DWORD startpos;
  
*************** fhandler_disk_file::lock (int cmd, struc
*** 1303,1309 ****
  
    if (win32_start < 0)
      {
!       win32_len -= win32_start;
        if (win32_len <= 0)
  	{
  	  /* Failure ! */
--- 1303,1310 ----
  
    if (win32_start < 0)
      {
!       /* watch the signs! */
!       win32_len -= -win32_start;
        if (win32_len <= 0)
  	{
  	  /* Failure ! */
*************** fhandler_disk_file::lock (int cmd, struc
*** 1336,1352 ****
  
        ov.Internal = 0;
        ov.InternalHigh = 0;
!       ov.Offset = win32_start;
        ov.OffsetHigh = 0;
        ov.hEvent = (HANDLE) 0;
  
        if (fl->l_type == F_UNLCK)
  	{
! 	  res = UnlockFileEx (get_handle (), 0, win32_len, win32_upper, &ov);
  	}
        else
  	{
! 	  res = LockFileEx (get_handle (), lock_flags, 0, win32_len,
  							win32_upper, &ov);
  	  /* Deal with the fail immediately case. */
  	  /*
--- 1337,1353 ----
  
        ov.Internal = 0;
        ov.InternalHigh = 0;
!       ov.Offset = (DWORD)win32_start;
        ov.OffsetHigh = 0;
        ov.hEvent = (HANDLE) 0;
  
        if (fl->l_type == F_UNLCK)
  	{
! 	  res = UnlockFileEx (get_handle (), 0, (DWORD)win32_len, win32_upper, &ov);
  	}
        else
  	{
! 	  res = LockFileEx (get_handle (), lock_flags, 0, (DWORD)win32_len,
  							win32_upper, &ov);
  	  /* Deal with the fail immediately case. */
  	  /*
*************** fhandler_disk_file::lock (int cmd, struc
*** 1365,1374 ****
      {
        /* Windows 95 -- use primitive lock call */
        if (fl->l_type == F_UNLCK)
! 	res = UnlockFile (get_handle (), win32_start, 0, win32_len,
  							win32_upper);
        else
! 	res = LockFile (get_handle (), win32_start, 0, win32_len, win32_upper);
      }
  
    if (res == 0)
--- 1366,1375 ----
      {
        /* Windows 95 -- use primitive lock call */
        if (fl->l_type == F_UNLCK)
! 	res = UnlockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len,
  							win32_upper);
        else
! 	res = LockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper);
      }
  
    if (res == 0)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019