This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Help on posix file lock semantics


Hi folks.

Have written a device driver for NT/W2K/XP which enumerates file locks per file.
This may make it possible to implement posix like file locks in cygwin:-)
But posix locks are complicated, so any feedback on issues below are appreciated.
I actually don't have linux to test it out myself (shoot me).

Gunnar André Dalsnes

Issue 1:
Affects: Uniprocess, CloseHandle (file)

Both win32 and posix discharges locks made by process when ends.

Win32 associate locks with handles. 
If one of many handles for a file close, only locks made by that handle is discharged.

Posix associate lock with files.
If one of many handles for a file close, all locks for file is discharged.

Fix:
Before every CloseHandle call (file), call driver->UNLOCKALL.
Driver unlock all locks our process holds on that file.


Issue 2:
Affects: Uniprocess, fcntl->F_SETLK->F_RDLCK/F_WRLCK/F_UNLCK

Both win32 and posix allow only one type of lock per byte of a file.

Win32 fails if any region overlap.

Posix upgrades a lock if a region overlap.
HELP! A lock can upgrade multiple overlapped regions of any type?
HELP! An unlock can unlock multiple overlapped regions of any type?

Fix:
Before every fcntl->F_SETLK->F_RDLCK/F_WRLCK call, call driver->UNLOCKOVL.
Driver unlocks conflicting overlapped regions for our process

Redirect every fcntl->F_SETLK->F_UNLCK call to driver->UNLOCKOVL. 
Driver unlocks affected overlapped regions for our process.


Issue 3:
Affects: Multiprocess, fcntl->F_GETLK

Win32 has no way of obtaining blocking locks.

Posix can obtaing blocking read locks or both.
HELP! How can readlocks be blocking if locks are upgradeable (uniprocess)?
There is no such thing as blocking read locks among multiple processes eighter!
All i can think of is blocking write locks among multiple processes.

Fix:
Redirect every fcntl->F_SETLK->F_GETLK call to driver->GETLOCK. 
Driver enumerates locks and returns first blocking lock.


Issue 4:
Affects: Multiprocess, fcntl->F_SETLKW

Win32 wait infinite on blocking locks.

HELP! Posix wait on blocking locks, but may be interupted by primitive signals?

Fix:
Clueless



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]