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.
This commit is contained in:
Corinna Vinschen 2008-04-18 20:30:04 +00:00
parent db5ae61884
commit 70fab4ec71
5 changed files with 34 additions and 40 deletions

View File

@ -1,6 +1,17 @@
2008-04-18 Corinna Vinschen <corinna@vinschen.de> 2008-04-18 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de>
* fhandler.h (struct wsa_event): Move to wsa_event.h. Include
wsa_event.h instead. wsa_event.h instead.
* fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h. * fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h.
(wsa_events): Move from DLL shared area to cygwin_shared shared (wsa_events): Move from DLL shared area to cygwin_shared shared

View File

@ -394,7 +394,13 @@ class fhandler_mailslot : public fhandler_base
select_record *select_read (select_record *s); 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 class fhandler_socket: public fhandler_base
{ {

View File

@ -403,9 +403,15 @@ 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
per session. 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 (32768 / sizeof (wsa_event))
#define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE) #define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE)
#define UNLOCK_EVENTS ReleaseMutex (wsock_mtx) #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 HANDLE wsa_slot_mtx;
static wsa_event * static wsa_event *
@ -430,11 +436,10 @@ search_wsa_event_slot (LONG new_serial_number)
break; break;
} }
unsigned int slot = new_serial_number % NUM_SOCKS; 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, HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE,
shared_name (searchname, "sock", shared_name (searchname, "sock", wsa_events[slot].serial_number));
cygwin_shared->wsa_events[slot].serial_number));
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. */
@ -448,10 +453,10 @@ search_wsa_event_slot (LONG new_serial_number)
return NULL; return NULL;
} }
} }
memset (&cygwin_shared->wsa_events[slot], 0, sizeof (wsa_event)); memset (&wsa_events[slot], 0, sizeof (wsa_event));
cygwin_shared->wsa_events[slot].serial_number = new_serial_number; wsa_events[slot].serial_number = new_serial_number;
ReleaseMutex (wsa_slot_mtx); ReleaseMutex (wsa_slot_mtx);
return cygwin_shared->wsa_events + slot; return wsa_events + slot;
} }
bool bool
@ -464,9 +469,9 @@ fhandler_socket::init_events ()
do do
{ {
new_serial_number = new_serial_number =
InterlockedIncrement (&cygwin_shared->socket_serial_number); InterlockedIncrement (&socket_serial_number);
if (!new_serial_number) /* 0 is reserved for global mutex */ 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, wsock_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", new_serial_number)); shared_name (name, "sock", new_serial_number));
if (!wsock_mtx) if (!wsock_mtx)

View File

@ -10,7 +10,6 @@ details. */
#include "tty.h" #include "tty.h"
#include "security.h" #include "security.h"
#include "wsa_event.h"
#include "mtinfo.h" #include "mtinfo.h"
/* Mount table entry */ /* Mount table entry */
@ -123,9 +122,9 @@ public:
cygwin_version.api_minor) cygwin_version.api_minor)
#define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION) #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 /* NOTE: Do not make gratuitous changes to the names or organization of the
below class. The layout is checksummed to determine compatibility between below class. The layout is checksummed to determine compatibility between
@ -140,8 +139,6 @@ class shared_info
unsigned heap_slop; unsigned heap_slop;
DWORD sys_mount_table_counter; DWORD sys_mount_table_counter;
tty_list tty; tty_list tty;
wsa_event wsa_events[NUM_SOCKS];
LONG socket_serial_number;
LONG last_used_bindresvport; LONG last_used_bindresvport;
mtinfo mt; mtinfo mt;

View File

@ -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_ */