diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 66559199d..1d4c7fea3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,6 +1,17 @@ 2008-04-18 Corinna Vinschen - * fhandler.h (-struct wsa_event): Move to wsa_event.h. Include + 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. + +2008-04-18 Corinna Vinschen + + * fhandler.h (struct wsa_event): Move to wsa_event.h. Include wsa_event.h instead. * fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h. (wsa_events): Move from DLL shared area to cygwin_shared shared diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5d421aa17..856f68321 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -394,7 +394,13 @@ class fhandler_mailslot : public fhandler_base select_record *select_read (select_record *s); }; -#include "wsa_event.h" +struct wsa_event +{ + LONG serial_number; + long events; + int connect_errorcode; + pid_t owner; +}; class fhandler_socket: public fhandler_base { 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) diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index bb4982b6e..ea504d2e3 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -10,7 +10,6 @@ details. */ #include "tty.h" #include "security.h" -#include "wsa_event.h" #include "mtinfo.h" /* Mount table entry */ @@ -123,9 +122,9 @@ public: cygwin_version.api_minor) #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION) -#define SHARED_INFO_CB 63912 +#define SHARED_INFO_CB 31144 -#define CURR_SHARED_MAGIC 0x419c874U +#define CURR_SHARED_MAGIC 0xbc77afb0U /* NOTE: Do not make gratuitous changes to the names or organization of the below class. The layout is checksummed to determine compatibility between @@ -140,8 +139,6 @@ class shared_info unsigned heap_slop; DWORD sys_mount_table_counter; tty_list tty; - wsa_event wsa_events[NUM_SOCKS]; - LONG socket_serial_number; LONG last_used_bindresvport; mtinfo mt; diff --git a/winsup/cygwin/wsa_event.h b/winsup/cygwin/wsa_event.h deleted file mode 100644 index c5477431f..000000000 --- a/winsup/cygwin/wsa_event.h +++ /dev/null @@ -1,25 +0,0 @@ -/* wsa_event.h: type definition of a wsock event storage structure. - - Copyright 2008 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _WSA_EVENT_H_ -#define _WSA_EVENT_H_ - -/* All Cygwin processes together can share 2048 sockets. */ -#define NUM_SOCKS (32768 / sizeof (wsa_event)) - -struct wsa_event -{ - LONG serial_number; - long events; - int connect_errorcode; - pid_t owner; -}; - -#endif /* _WSA_EVENT_H_ */