Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-03-24 17:48:58 +0300
committerCorinna Vinschen <corinna@vinschen.de>2008-03-24 17:48:58 +0300
commita998dd705576606f85e3598e5a38ea8d3805f798 (patch)
tree4c93e5acf920571b791af3f4ac4d5cf5829e6e1a /winsup/cygwin/fhandler.cc
parent88f0dc31d111c9f0ff4a888777a7f8afdc7bf295 (diff)
* fhandler.cc (fhandler_base::dup): Drop setting flags in the parent.
Implement advisory file locking. * cygheap.h (struct init_cygheap): Add inode_list member. * cygwin.din (lockf): Export. * dcrt0.cc (child_info_spawn::handle_spawn): Call fixup_lockf_after_exec. * dtable.h (class dtable): Add fhandler_disk_file as friend class. * fhandler.cc (fhandler_base::close): Call del_my_locks if node is set. (fhandler_base::fhandler_base): Initialize node to NULL. (fhandler_base::fixup_after_fork): Ditto. * fhandler.h (class fhandler_base): Add member node. * fhandler_disk_file.cc (fhandler_disk_file::lock): Delete. * flock.cc: Implement all advisory file locking here. (fhandler_disk_file::lock): Implement here. (flock): Call fcntl with F_FLOCK bit set. Remove test main function. (lockf): New function. * fork.cc (frok::child): Call fixup_lockf_after_fork. * ntdll.h (DIRECTORY_ALL_ACCESS): Define. (struct _OBJECT_BASIC_INFORMATION): Define. (enum _EVENT_TYPE): Define. (NtCreateDirectoryObject): Declare. (NtCreateEvent): Declare. (NtCreateMutant): Declare. (NtOpenEvent): Declare. (NtOpenMutant): Declare. * include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index c283b3e3c..22afb63ac 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1004,9 +1004,13 @@ fhandler_base::pwrite (void *, size_t, _off64_t)
int
fhandler_base::close ()
{
+ extern void del_my_locks (inode_t *);
int res = -1;
syscall_printf ("closing '%s' handle %p", get_name (), get_handle ());
+ /* Delete all POSIX locks on the file. */
+ if (node)
+ del_my_locks (node);
if (nohandle () || CloseHandle (get_handle ()))
res = 0;
else
@@ -1135,7 +1139,6 @@ fhandler_base::dup (fhandler_base *child)
}
if (get_overlapped ())
child->setup_overlapped ();
- set_flags (child->get_flags ());
return 0;
}
@@ -1265,6 +1268,7 @@ fhandler_base::fhandler_base () :
raixget (0),
raixput (0),
rabuflen (0),
+ node (NULL),
fs_flags (0),
archetype (NULL),
usecount (0)
@@ -1336,6 +1340,10 @@ fhandler_base::fixup_after_fork (HANDLE parent)
fork_fixup (parent, io_handle, "io_handle");
if (get_overlapped ())
setup_overlapped ();
+ /* POSIX locks are not inherited across fork. The lock structures
+ are deleted globally in fixup_lockf_after_fork. Here we just
+ have to reset the pointer. */
+ node = NULL;
}
void