public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] forkables: Keep hardlinks disabled via shared mem.
@ 2019-02-08 11:37 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-02-08 11:37 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5a41aa6f4d5eb12a1fc2ef084d98f63d65f5fcc3

commit 5a41aa6f4d5eb12a1fc2ef084d98f63d65f5fcc3
Author: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date:   Wed Dec 7 11:58:29 2016 +0100

    forkables: Keep hardlinks disabled via shared mem.
    
    To avoid the need for each process to check the filesystem to detect
    that hardlink creation is impossible or disabled, cache this fact in
    shared memory.  Removing cygfork directory while in use does disable
    hardlinks creation.  To (re-)enable hardlinks creation, the cygfork
    directory has to exist before the first cygwin process does fork.
    
    	* forkable.cc (dll_list::forkable_ntnamesize): Short cut
    	forkables needs to impossible when disabled via shared memory.
    	(dll_list::update_forkables_needs): When detecting hardlink
    	creation as impossible (not on NTFS) while still (we are the
    	first one checking) enabled via shared memory, disable the
    	shared memory value.
    	(dll_list::request_forkables): Disable the shared memory value
    	when hardlinks creation became disabled, that is when the
    	cygfork directory was removed.
    	* include/cygwin/version.h: Bump CYGWIN_VERSION_SHARED_DATA 6.
    	* shared_info.h (struct shared_info): Add member
    	prefer_forkable_hardlinks.  Update CURR_SHARED_MAGIC.
    	* shared.cc (shared_info::initialize): Initialize
    	prefer_forkable_hardlinks to 1 (Yes).

Diff:
---
 winsup/cygwin/forkable.cc              | 13 +++++++++++++
 winsup/cygwin/include/cygwin/version.h |  2 +-
 winsup/cygwin/shared_info.h            |  3 ++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc
index cc28f9f..da45643 100644
--- a/winsup/cygwin/forkable.cc
+++ b/winsup/cygwin/forkable.cc
@@ -522,6 +522,11 @@ dll::create_forkable ()
 size_t
 dll_list::forkable_ntnamesize (dll_type type, PCWCHAR fullntname, PCWCHAR modname)
 {
+  /* per process, this is the first forkables-method ever called */
+  if (forkables_needs == forkables_unknown &&
+      !cygwin_shared->prefer_forkable_hardlinks)
+      forkables_needs = forkables_impossible; /* short cut */
+
   if (forkables_needs == forkables_impossible)
     return 0;
 
@@ -667,6 +672,7 @@ dll_list::update_forkables_needs ()
 	{
 	  debug_printf ("impossible, not on NTFS %W", fn.Buffer);
 	  forkables_needs = forkables_impossible;
+	  cygwin_shared->prefer_forkable_hardlinks = 0;
 	}
     }
 
@@ -1056,6 +1062,13 @@ dll_list::request_forkables ()
 
   set_forkables_inheritance (true);
 
+  if (forkables_needs == forkables_disabled)
+    {
+      /* we do not support (re-)enabling on the fly */
+      forkables_needs = forkables_impossible;
+      cygwin_shared->prefer_forkable_hardlinks = 0;
+    }
+
   if (forkables_needs <= forkables_needless)
     return;
 
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 8926d49..f7ed351 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -518,7 +518,7 @@ details. */
    regions.  It is incremented when incompatible changes are made to the shared
    memory region *or* to any named shared mutexes, semaphores, etc. */
 
-#define CYGWIN_VERSION_SHARED_DATA 5
+#define CYGWIN_VERSION_SHARED_DATA 6
 
 /* An identifier used in the names used to create shared objects.  The full
    names include the CYGWIN_VERSION_SHARED_DATA version as well as this
diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h
index 1a5648b..8f0954f 100644
--- a/winsup/cygwin/shared_info.h
+++ b/winsup/cygwin/shared_info.h
@@ -33,7 +33,7 @@ public:
 /* Data accessible to all tasks */
 
 
-#define CURR_SHARED_MAGIC 0x6758de88U
+#define CURR_SHARED_MAGIC 0x3a6025edU
 
 #define USER_VERSION   1
 
@@ -51,6 +51,7 @@ class shared_info
   mtinfo mt;
   loadavginfo loadavg;
   LONG pid_src;
+  char prefer_forkable_hardlinks; /* single byte access always is atomic */
 
   void initialize ();
   void init_obcaseinsensitive ();


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-08 11:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 11:37 [newlib-cygwin] forkables: Keep hardlinks disabled via shared mem Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).