From abbde487046d0f1a775a85057d51ec4ee074e33d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 21 Apr 2008 12:46:58 +0000 Subject: * Makefile.in (DLL_OFILES): Add kernel32.o. * autoload.cc (WSACloseEvent): Remove. (WSACreateEvent): Remove. * cygheap.cc (cygheap_init): Drop initializing shared_prefix. * cygheap.h (struct init_cygheap): Drop shared_prefix and shared_prefix_buf members. * fhandler_socket.cc (sock_shared_name): New static function. (search_wsa_event_slot): Convert name buffers to WCHAR. Call NtCreateMutant/NtOpenMutant to create mutexes in session local namespace. (fhandler_socket::init_events): Ditto. Fix debug output. (fhandler_socket::release_events): Close mutexes using NtClose. (fhandler_socket::dup): Ditto. * kernel32.cc: New file, implementing Win32 calls in a Cygwin-specific way. * mmap.cc (MapView): Make static. * ntdll.h: Fix status code sorting. (STATUS_OBJECT_NAME_EXISTS): Define. (SEMAPHORE_QUERY_STATE): Define. (CYG_SHARED_DIR_ACCESS): Define. (CYG_MUTANT_ACCESS): Define. (CYG_EVENT_ACCESS): Define. (CYG_SEMAPHORE_ACCESS): Define. (enum _PROCESSINFOCLASS): Define ProcessSessionInformation. (struct _PROCESS_SESSION_INFORMATION): Define. (NtCreateSemaphore): Declare. (NtOpenSemaphore): Declare. * flock.cc: Use CYG_xxx_ACCESS access masks where appropriate. * posix_ipc.cc (ipc_mutex_init): Use native functions to create mutex. Create in cygwin-shared subdir. (ipc_cond_init): Ditto for event. (ipc_mutex_close): Use NtClose. (ipc_cond_close): Ditto. (mq_open): Drop "cyg" prefix from mqh_uname. * shared.cc (CYG_SHARED_DIR_ACCESS): Drop definition here. (_cygwin_testing): Declare extern on file level. (get_shared_parent_dir): Change name of shared directory. Add name to api_fatal output. (get_session_parent_dir): New function. (shared_name): Simplify. (shared_info::initialize): Call get_session_parent_dir. * shared_info.h (get_session_parent_dir): Declare. * smallprint.cc (__small_vswprintf): Fix bug in multibyte string conversion. * thread.cc (semaphore::semaphore): Align semaphore name to object names in posix IPC functions. * include/cygwin/version.h (CYGWIN_VERSION_SHARED_DATA): Bump. --- winsup/cygwin/posix_ipc.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'winsup/cygwin/posix_ipc.cc') diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc index f9090ae14..102691ecb 100644 --- a/winsup/cygwin/posix_ipc.cc +++ b/winsup/cygwin/posix_ipc.cc @@ -16,6 +16,7 @@ details. */ #include "dtable.h" #include "cygheap.h" #include "sigproc.h" +#include "ntdll.h" #include #include #include @@ -87,10 +88,13 @@ static int ipc_mutex_init (HANDLE *pmtx, const char *name) { char buf[MAX_PATH]; - __small_sprintf (buf, "%scyg_pmtx/%s", cygheap->shared_prefix, name); - *pmtx = CreateMutex (&sec_all, FALSE, buf); + SECURITY_ATTRIBUTES sa = sec_none; + + __small_sprintf (buf, "mqueue/mtx_%W", name); + sa.lpSecurityDescriptor = everyone_sd (CYG_MUTANT_ACCESS); + *pmtx = CreateMutex (&sa, FALSE, buf); if (!*pmtx) - debug_printf ("failed: %E\n"); + debug_printf ("CreateMutex: %E"); return *pmtx ? 0 : geterrno_from_win_error (); } @@ -129,10 +133,13 @@ static int ipc_cond_init (HANDLE *pevt, const char *name) { char buf[MAX_PATH]; - __small_sprintf (buf, "%scyg_pevt/%s", cygheap->shared_prefix, name); - *pevt = CreateEvent (&sec_all, TRUE, FALSE, buf); + SECURITY_ATTRIBUTES sa = sec_none; + + __small_sprintf (buf, "mqueue/evt_%W", name); + sa.lpSecurityDescriptor = everyone_sd (CYG_EVENT_ACCESS); + *pevt = CreateEvent (&sa, TRUE, FALSE, buf); if (!*pevt) - debug_printf ("failed: %E\n"); + debug_printf ("CreateEvent: %E"); return *pevt ? 0 : geterrno_from_win_error (); } @@ -387,7 +394,7 @@ again: __seterrno (); goto err; } - __small_sprintf (mqhdr->mqh_uname, "cyg%016X%08x%08x", + __small_sprintf (mqhdr->mqh_uname, "%016X%08x%08x", hash_path_name (0,mqname), luid.HighPart, luid.LowPart); mqhdr->mqh_head = 0; -- cgit v1.2.3