diff options
author | Christopher Faylor <me@cgf.cx> | 2008-07-27 18:52:46 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2008-07-27 18:52:46 +0400 |
commit | 904413e731347d5fd0e8356c3f79744eb3d977a4 (patch) | |
tree | dfda56c0bf0bfe3d28273c1de3c3b006e04e6cfb /winsup/cygwin | |
parent | bfd2b1c9307ebe2cf8611b447cafa2809c9ac8dd (diff) |
* shared_info.h (shared_destroy): Declare.
* shared.cc (shared_destroy): Define new function to destroy shared memory
regions.
* init.cc (dll_entry): Call shared_destroy when dll detaches from the process.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/init.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/shared.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 3 |
4 files changed, 22 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 08013867f..125e5a4ea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2008-07-27 Christopher Faylor <me+cygwin@cgf.cx> + + * shared_info.h (shared_destroy): Declare. + * shared.cc (shared_destroy): Define new function to destroy shared + memory regions. + * init.cc (dll_entry): Call shared_destroy when dll detaches from the + process. + 2008-07-27 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::send_internal): Send never more diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index b05427592..1e633f432 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -12,6 +12,7 @@ details. */ #include "winsup.h" #include "cygtls.h" #include "ntdll.h" +#include "shared_info.h" static DWORD _my_oldfunc; @@ -142,6 +143,8 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) _my_oldfunc = TlsAlloc (); break; case DLL_PROCESS_DETACH: + if (dynamically_loaded) + shared_destroy (); break; case DLL_THREAD_ATTACH: if (hwait_sig) diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index db24e71f1..23a8d992d 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -254,6 +254,15 @@ user_shared_initialize (bool reinit) } } +void __stdcall +shared_destroy () +{ + ForceCloseHandle (cygwin_shared_h); + UnmapViewOfFile (cygwin_shared); + ForceCloseHandle (cygwin_user_h); + UnmapViewOfFile (user_shared); +} + /* Use absolute path of cygwin1.dll to derive the Win32 dir which is our installation root. Note that we can't handle Cygwin installation root dirs of more than 4K path length. I assume that's ok... */ diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index d0ef600f9..45b347014 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -120,7 +120,7 @@ public: #define SHARED_INFO_CB 39328 -#define CURR_SHARED_MAGIC 0x22f9ff0bU +#define CURR_SHARED_MAGIC 0x398d8baU /* NOTE: Do not make gratuitous changes to the names or organization of the below class. The layout is checksummed to determine compatibility between @@ -164,6 +164,7 @@ enum shared_locations }; void __stdcall memory_init (); +void __stdcall shared_destroy (); #define shared_align_past(p) \ ((char *) (system_info.dwAllocationGranularity * \ |