This is the mail archive of the cygwin-patches 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]
Other format: [Raw text]

(fixup) [PATCH] forkables: use dynloaded dll's IndexNumber as dirname


Hi Corinna,

as realized during write of tl;dr draft for the topic/forkables branch,
> 
> <damn-wrong reason="original directory may not exist any more">
>  * The temporary subdirectory name for a dynamically loaded dll is formed
>    using the original directory's NTFS-IndexNumber.
> </damn-wrong>
> https://cygwin.com/ml/cygwin-developers/2017-01/msg00000.html

here's the patch, intended as fixup for
>
> [PATCH 3/6] forkables: Create forkable hardlinks, yet unused.
> https://cygwin.com/ml/cygwin-developers/2016-12/msg00006.html

Thanks!
/haubi/
>From 66bc7176ad9a786651c306e27ce354438db5d4af Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Thu, 12 Jan 2017 10:03:52 +0100
Subject: [PATCH] forkables: use dynloaded dll's IndexNumber as dirname

---
 winsup/cygwin/forkable.cc | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc
index c92a44f..6c78d75 100644
--- a/winsup/cygwin/forkable.cc
+++ b/winsup/cygwin/forkable.cc
@@ -409,34 +409,17 @@ dll::nominate_forkable (PCWCHAR dirx_name)
   if (!*forkable_ntname)
     return; /* denominate */
 
-  if (type < DLL_LOAD)
-    wcpcpy (next, modname);
-  else
+  if (type == DLL_LOAD)
     {
-      /* Avoid lots of extra directories for loaded dll's:
-       * mangle full path into one single directory name,
-       * just keep original filename intact. The original
-       * filename is necessary to serve as linked
-       * dependencies of dynamically loaded dlls. */
-      PWCHAR lastpathsep = wcsrchr (ntname, L'\\');
-      if (!lastpathsep)
-        {
-	  forkable_ntname = NULL;
-	  return;
-	}
-      *lastpathsep = L'\0';
-      HANDLE fh = dll_list::ntopenfile (ntname, NULL, FILE_DIRECTORY_FILE);
-      *lastpathsep = L'\\';
-
-      FILE_INTERNAL_INFORMATION fii = { 0 };
-      if (fh != INVALID_HANDLE_VALUE)
-	{
-	  dll_list::read_fii (fh, &fii);
-	  NtClose (fh);
-	}
+      /* Multiple dynamically loaded dlls can have identical basenames
+       * when loaded from different directories.  But still the original
+       * basename may serve as linked dependency for another dynamically
+       * loaded dll.  So we have to create a separate directory for the
+       * dynamically loaded dll - using the dll's IndexNumber as name. */
       next += format_IndexNumber (next, -1, &fii.IndexNumber);
-      wcpcpy (next, lastpathsep);
+      next = wcpcpy (next, L"\\");
     }
+  wcpcpy (next, modname);
 }
 
 /* Create the nominated hardlink for one indivitual dll,
-- 
2.8.3


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