diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-04-19 00:30:04 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-04-19 00:30:04 +0400 |
commit | 70fab4ec71b3a206b042b6c027c14ad575876b8c (patch) | |
tree | f4658b66043149f47658f67c8d68c49a8a868a87 /winsup/cygwin/fhandler_socket.cc | |
parent | db5ae61884de2a1ecf6fd05ad4e8f3d0b4f530d6 (diff) |
Revert thinko in previous patch.
* fhandler.h (struct wsa_event): Move back from wsa_event.h to here.
* fhandler_socket.cc (NUM_SOCKS): Ditto.
(wsa_events): Move back from cygwin_shared to here. Accommodate
throughout.
(socket_serial_number): Ditto.
* shared_info.h: Accommodate above changes.
* wsa_event.h: Remove.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 9f8aa2c6a..e718db097 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -403,9 +403,15 @@ fhandler_socket::af_local_set_secret (char *buf) /* Maximum number of concurrently opened sockets from all Cygwin processes per session. Note that shared sockets (through dup/fork/exec) are counted as one socket. */ +#define NUM_SOCKS (32768 / sizeof (wsa_event)) + #define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE) #define UNLOCK_EVENTS ReleaseMutex (wsock_mtx) +static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)) = { 0 }; + +static LONG socket_serial_number __attribute__((section (".cygwin_dll_common"), shared)) = 0; + static HANDLE wsa_slot_mtx; static wsa_event * @@ -430,11 +436,10 @@ search_wsa_event_slot (LONG new_serial_number) break; } unsigned int slot = new_serial_number % NUM_SOCKS; - while (cygwin_shared->wsa_events[slot].serial_number) + while (wsa_events[slot].serial_number) { HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE, - shared_name (searchname, "sock", - cygwin_shared->wsa_events[slot].serial_number)); + shared_name (searchname, "sock", wsa_events[slot].serial_number)); if (!searchmtx) break; /* Mutex still exists, attached socket is active, try next slot. */ @@ -448,10 +453,10 @@ search_wsa_event_slot (LONG new_serial_number) return NULL; } } - memset (&cygwin_shared->wsa_events[slot], 0, sizeof (wsa_event)); - cygwin_shared->wsa_events[slot].serial_number = new_serial_number; + memset (&wsa_events[slot], 0, sizeof (wsa_event)); + wsa_events[slot].serial_number = new_serial_number; ReleaseMutex (wsa_slot_mtx); - return cygwin_shared->wsa_events + slot; + return wsa_events + slot; } bool @@ -464,9 +469,9 @@ fhandler_socket::init_events () do { new_serial_number = - InterlockedIncrement (&cygwin_shared->socket_serial_number); + InterlockedIncrement (&socket_serial_number); if (!new_serial_number) /* 0 is reserved for global mutex */ - InterlockedIncrement (&cygwin_shared->socket_serial_number); + InterlockedIncrement (&socket_serial_number); wsock_mtx = CreateMutex (&sec_all, FALSE, shared_name (name, "sock", new_serial_number)); if (!wsock_mtx) |