* fhandler.cc (lock): use signed math to allow checking ranges
properly.
This commit is contained in:
parent
31ca470d43
commit
c469b6a2b0
|
@ -1,3 +1,8 @@
|
||||||
|
2000-05-08 DJ Delorie <dj@cygnus.com>
|
||||||
|
|
||||||
|
* fhandler.cc (lock): use signed math to allow checking ranges
|
||||||
|
properly.
|
||||||
|
|
||||||
Sat May 6 23:22:25 2000 Christopher Faylor <cgf@cygnus.com>
|
Sat May 6 23:22:25 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* dcrt0.cc (insert_file): Eliminate unused parameter.
|
* dcrt0.cc (insert_file): Eliminate unused parameter.
|
||||||
|
|
|
@ -1243,8 +1243,8 @@ fhandler_disk_file::close ()
|
||||||
int
|
int
|
||||||
fhandler_disk_file::lock (int cmd, struct flock *fl)
|
fhandler_disk_file::lock (int cmd, struct flock *fl)
|
||||||
{
|
{
|
||||||
DWORD win32_start;
|
int win32_start;
|
||||||
DWORD win32_len;
|
int win32_len;
|
||||||
DWORD win32_upper;
|
DWORD win32_upper;
|
||||||
DWORD startpos;
|
DWORD startpos;
|
||||||
|
|
||||||
|
@ -1304,7 +1304,8 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
|
||||||
|
|
||||||
if (win32_start < 0)
|
if (win32_start < 0)
|
||||||
{
|
{
|
||||||
win32_len -= win32_start;
|
/* watch the signs! */
|
||||||
|
win32_len -= -win32_start;
|
||||||
if (win32_len <= 0)
|
if (win32_len <= 0)
|
||||||
{
|
{
|
||||||
/* Failure ! */
|
/* Failure ! */
|
||||||
|
@ -1337,17 +1338,17 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
|
||||||
|
|
||||||
ov.Internal = 0;
|
ov.Internal = 0;
|
||||||
ov.InternalHigh = 0;
|
ov.InternalHigh = 0;
|
||||||
ov.Offset = win32_start;
|
ov.Offset = (DWORD)win32_start;
|
||||||
ov.OffsetHigh = 0;
|
ov.OffsetHigh = 0;
|
||||||
ov.hEvent = (HANDLE) 0;
|
ov.hEvent = (HANDLE) 0;
|
||||||
|
|
||||||
if (fl->l_type == F_UNLCK)
|
if (fl->l_type == F_UNLCK)
|
||||||
{
|
{
|
||||||
res = UnlockFileEx (get_handle (), 0, win32_len, win32_upper, &ov);
|
res = UnlockFileEx (get_handle (), 0, (DWORD)win32_len, win32_upper, &ov);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = LockFileEx (get_handle (), lock_flags, 0, win32_len,
|
res = LockFileEx (get_handle (), lock_flags, 0, (DWORD)win32_len,
|
||||||
win32_upper, &ov);
|
win32_upper, &ov);
|
||||||
/* Deal with the fail immediately case. */
|
/* Deal with the fail immediately case. */
|
||||||
/*
|
/*
|
||||||
|
@ -1366,10 +1367,10 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
|
||||||
{
|
{
|
||||||
/* Windows 95 -- use primitive lock call */
|
/* Windows 95 -- use primitive lock call */
|
||||||
if (fl->l_type == F_UNLCK)
|
if (fl->l_type == F_UNLCK)
|
||||||
res = UnlockFile (get_handle (), win32_start, 0, win32_len,
|
res = UnlockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len,
|
||||||
win32_upper);
|
win32_upper);
|
||||||
else
|
else
|
||||||
res = LockFile (get_handle (), win32_start, 0, win32_len, win32_upper);
|
res = LockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
|
|
Loading…
Reference in New Issue