* fhandler.cc (fhandler_base::set_no_inheritance): Always use
SetHandleInformation. * fhandler_disk_file.cc (fhandler_disk_file::lock): Always use UnlockFileEx/LockFileEx functions. * net.cc (fdsock): Don't bother to duplicate socket for inheritance. * sysconf.cc (get_nproc_values): Take NT for granted. (get_avphys): Ditto. * syslog.cc (WIN95_EVENT_LOG_PATH): Remove define. (get_win95_event_log_path): Remove. (vsyslog): Fix formatting. Take NT for granted. * wincap.cc: Remove has_lock_file_ex, has_signal_object_and_wait, has_eventlog, has_set_handle_information, has_set_handle_information_on_console_handles and supports_smp throughout. * wincap.h: Ditto.
This commit is contained in:
@ -1281,49 +1281,38 @@ fhandler_disk_file::lock (int cmd, struct __flock64 *fl)
|
||||
|
||||
BOOL res;
|
||||
|
||||
if (wincap.has_lock_file_ex ())
|
||||
DWORD lock_flags = (cmd == F_SETLK) ? LOCKFILE_FAIL_IMMEDIATELY : 0;
|
||||
lock_flags |= (fl->l_type == F_WRLCK) ? LOCKFILE_EXCLUSIVE_LOCK : 0;
|
||||
|
||||
OVERLAPPED ov;
|
||||
|
||||
ov.Internal = 0;
|
||||
ov.InternalHigh = 0;
|
||||
ov.Offset = off_low;
|
||||
ov.OffsetHigh = off_high;
|
||||
ov.hEvent = (HANDLE) 0;
|
||||
|
||||
if (fl->l_type == F_UNLCK)
|
||||
{
|
||||
DWORD lock_flags = (cmd == F_SETLK) ? LOCKFILE_FAIL_IMMEDIATELY : 0;
|
||||
lock_flags |= (fl->l_type == F_WRLCK) ? LOCKFILE_EXCLUSIVE_LOCK : 0;
|
||||
|
||||
OVERLAPPED ov;
|
||||
|
||||
ov.Internal = 0;
|
||||
ov.InternalHigh = 0;
|
||||
ov.Offset = off_low;
|
||||
ov.OffsetHigh = off_high;
|
||||
ov.hEvent = (HANDLE) 0;
|
||||
|
||||
if (fl->l_type == F_UNLCK)
|
||||
{
|
||||
res = UnlockFileEx (get_handle (), 0, len_low, len_high, &ov);
|
||||
if (res == 0 && GetLastError () == ERROR_NOT_LOCKED)
|
||||
res = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = LockFileEx (get_handle (), lock_flags, 0,
|
||||
len_low, len_high, &ov);
|
||||
/* Deal with the fail immediately case. */
|
||||
/*
|
||||
* FIXME !! I think this is the right error to check for
|
||||
* but I must admit I haven't checked....
|
||||
*/
|
||||
if ((res == 0) && (lock_flags & LOCKFILE_FAIL_IMMEDIATELY) &&
|
||||
(GetLastError () == ERROR_LOCK_FAILED))
|
||||
{
|
||||
set_errno (EAGAIN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
res = UnlockFileEx (get_handle (), 0, len_low, len_high, &ov);
|
||||
if (res == 0 && GetLastError () == ERROR_NOT_LOCKED)
|
||||
res = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Windows 95 -- use primitive lock call */
|
||||
if (fl->l_type == F_UNLCK)
|
||||
res = UnlockFile (get_handle (), off_low, off_high, len_low, len_high);
|
||||
else
|
||||
res = LockFile (get_handle (), off_low, off_high, len_low, len_high);
|
||||
res = LockFileEx (get_handle (), lock_flags, 0,
|
||||
len_low, len_high, &ov);
|
||||
/* Deal with the fail immediately case. */
|
||||
/*
|
||||
* FIXME !! I think this is the right error to check for
|
||||
* but I must admit I haven't checked....
|
||||
*/
|
||||
if ((res == 0) && (lock_flags & LOCKFILE_FAIL_IMMEDIATELY) &&
|
||||
(GetLastError () == ERROR_LOCK_FAILED))
|
||||
{
|
||||
set_errno (EAGAIN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (res == 0)
|
||||
|
Reference in New Issue
Block a user