summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>2019-04-12 15:32:56 +0200
committerCorinna Vinschen <corinna@vinschen.de>2019-04-12 20:01:04 +0200
commit204efa6bbac2b355c65818100414c3ce2cda2a9e (patch)
treec5cc00fd6b2ca72f1cbbe3581b86b61eece936ce
parenta0b0a4a01820661724ee08f54fbba7a51b190c96 (diff)
downloadcygnal-204efa6bbac2b355c65818100414c3ce2cda2a9e.tar.gz
cygnal-204efa6bbac2b355c65818100414c3ce2cda2a9e.tar.bz2
cygnal-204efa6bbac2b355c65818100414c3ce2cda2a9e.zip
Cygwin: use win pid+threadid for forkables dirname
Rather than newest last write time of all dlls loaded, use the forking process' windows pid and windows thread id as directory name to create the forkable hardlinks into. While this may create hardlinks more often, it does avoid conflicts between dlls not having the newest last write time.
-rw-r--r--winsup/cygwin/forkable.cc26
1 files changed, 7 insertions, 19 deletions
diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc
index d1b0f5723..4580610b1 100644
--- a/winsup/cygwin/forkable.cc
+++ b/winsup/cygwin/forkable.cc
@@ -340,30 +340,18 @@ exename (PWCHAR buf, ssize_t bufsize)
return format_IndexNumber (buf, bufsize, &d->fii.IndexNumber);
}
-/* Into buf if not NULL, write the newest dll's LastWriteTime.
+/* Into buf if not NULL, write the current Windows Thread Identifier.
Return the number of characters (that would be) written. */
static int
-lwtimename (PWCHAR buf, ssize_t bufsize)
+winthrname (PWCHAR buf, ssize_t bufsize)
{
if (!buf)
- return sizeof (LARGE_INTEGER) * 2;
- if (bufsize >= 0 && bufsize <= (int)sizeof (LARGE_INTEGER) * 2)
+ return sizeof (DWORD) * 4;
+ if (bufsize >= 0 && bufsize <= (int)sizeof (DWORD) * 4)
return 0;
- LARGE_INTEGER newest = { 0 };
- /* Need by-handle-file-information for _all_ loaded dlls,
- as most recent ctime forms the hardlinks directory. */
- dll *d = &dlls.start;
- while ((d = d->next))
- {
- /* LastWriteTime more properly tells the last file-content modification
- time, because a newly created hardlink may have a different
- CreationTime compared to the original file. */
- if (d->fbi.LastWriteTime.QuadPart > newest.QuadPart)
- newest = d->fbi.LastWriteTime;
- }
-
- return __small_swprintf (buf, L"%016X", newest);
+ return __small_swprintf (buf, L"%08X%08X",
+ GetCurrentProcessId(), GetCurrentThreadId());
}
struct namepart {
@@ -382,7 +370,7 @@ forkable_nameparts[] = {
{ L"<sid>", sidname, true, true, },
{ L"<exe>", exename, false, false, },
{ MUTEXSEP, NULL, false, false, },
- { L"<ctime>", lwtimename, true, true, },
+ { L"<winthr>", winthrname, true, true, },
{ NULL, NULL },
};