* fhandler_socket.cc: Create shared objects session local throughout.

* shared.cc (shared_name): Add argument to allow opening session
	local shared memory.
	* shared_info.h (shared_name): Change declaration accordingly.
This commit is contained in:
Corinna Vinschen 2008-03-27 10:43:14 +00:00
parent 4af0c5e8f3
commit e21ac1ebdb
4 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2008-03-27 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc: Create shared objects session local throughout.
* shared.cc (shared_name): Add argument to allow opening session
local shared memory.
* shared_info.h (shared_name): Change declaration accordingly.
2008-03-26 Christopher Faylor <me+cygwin@cgf.cx> 2008-03-26 Christopher Faylor <me+cygwin@cgf.cx>
* hookapi.cc (find_first_notloaded_dll): New function. * hookapi.cc (find_first_notloaded_dll): New function.

View File

@ -405,7 +405,7 @@ fhandler_socket::af_local_set_secret (char *buf)
} }
/* Maximum number of concurrently opened sockets from all Cygwin processes /* Maximum number of concurrently opened sockets from all Cygwin processes
on a machine. Note that shared sockets (through dup/fork/exec) are per session. Note that shared sockets (through dup/fork/exec) are
counted as one socket. */ counted as one socket. */
#define NUM_SOCKS (65536 / sizeof (wsa_event)) #define NUM_SOCKS (65536 / sizeof (wsa_event))
@ -426,7 +426,7 @@ search_wsa_event_slot (LONG new_serial_number)
if (!wsa_slot_mtx) if (!wsa_slot_mtx)
{ {
wsa_slot_mtx = CreateMutex (&sec_all, FALSE, wsa_slot_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", 0)); shared_name (name, "sock", 0, true));
if (!wsa_slot_mtx) if (!wsa_slot_mtx)
api_fatal ("Couldn't create/open shared socket mutex, %E"); api_fatal ("Couldn't create/open shared socket mutex, %E");
} }
@ -443,7 +443,8 @@ search_wsa_event_slot (LONG new_serial_number)
while (wsa_events[slot].serial_number) while (wsa_events[slot].serial_number)
{ {
HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE, HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE,
shared_name (searchname, "sock", wsa_events[slot].serial_number)); shared_name (searchname, "sock", wsa_events[slot].serial_number,
true));
if (!searchmtx) if (!searchmtx)
break; break;
/* Mutex still exists, attached socket is active, try next slot. */ /* Mutex still exists, attached socket is active, try next slot. */
@ -476,7 +477,8 @@ fhandler_socket::init_events ()
if (!new_serial_number) /* 0 is reserved for global mutex */ if (!new_serial_number) /* 0 is reserved for global mutex */
InterlockedIncrement (&socket_serial_number); InterlockedIncrement (&socket_serial_number);
wsock_mtx = CreateMutex (&sec_all, FALSE, wsock_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", new_serial_number)); shared_name (name, "sock", new_serial_number,
true));
if (!wsock_mtx) if (!wsock_mtx)
{ {
debug_printf ("CreateMutex, %E"); debug_printf ("CreateMutex, %E");

View File

@ -35,11 +35,12 @@ user_info NO_COPY *user_shared;
HANDLE NO_COPY cygwin_user_h; HANDLE NO_COPY cygwin_user_h;
char * __stdcall char * __stdcall
shared_name (char *ret_buf, const char *str, int num) shared_name (char *ret_buf, const char *str, int num, bool session_local)
{ {
extern bool _cygwin_testing; extern bool _cygwin_testing;
__small_sprintf (ret_buf, "%s%s.%s.%d", cygheap->shared_prefix, __small_sprintf (ret_buf, "%s%s.%s.%d",
session_local ? "" : cygheap->shared_prefix,
cygwin_version.shared_id, str, num); cygwin_version.shared_id, str, num);
if (_cygwin_testing) if (_cygwin_testing)
strcat (ret_buf, cygwin_version.dll_build_date); strcat (ret_buf, cygwin_version.dll_build_date);

View File

@ -176,7 +176,7 @@ struct console_state
}; };
#endif #endif
char *__stdcall shared_name (char *, const char *, int); char *__stdcall shared_name (char *, const char *, int, bool = false);
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size,
shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all, shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all,
DWORD access = FILE_MAP_READ | FILE_MAP_WRITE); DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);