* fhandler.h (struct wsa_event): Define here.

(class fhandler_socket): Make wsock_evt private again.
	(fhandler_socket::wsock_event): New read accessor for wsock_evt.
	(fhandler_socket::serial_number): New read accessor to get the
	socket's serial number.
	(fhandler_socket::ready_for_read): Just return true.
	* fhandler_socket.cc (struct wsa_event): Move definition to fhandler.h.
	* select.cc (struct socketinf): Add serial number vector.
	(start_thread_socket): Identify duplicate sockets by their serial
	number, not (wrongly) by their wsock_evt.
This commit is contained in:
Corinna Vinschen 2006-07-28 08:50:46 +00:00
parent bc31293a0d
commit 8f713b6b08
4 changed files with 35 additions and 15 deletions

View File

@ -1,3 +1,16 @@
2006-07-28 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (struct wsa_event): Define here.
(class fhandler_socket): Make wsock_evt private again.
(fhandler_socket::wsock_event): New read accessor for wsock_evt.
(fhandler_socket::serial_number): New read accessor to get the
socket's serial number.
(fhandler_socket::ready_for_read): Just return true.
* fhandler_socket.cc (struct wsa_event): Move definition to fhandler.h.
* select.cc (struct socketinf): Add serial number vector.
(start_thread_socket): Identify duplicate sockets by their serial
number, not (wrongly) by their wsock_evt.
2006-07-27 Corinna Vinschen <corinna@vinschen.de> 2006-07-27 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc: Revert misguided attempt to handle FD_CLOSE error * fhandler_socket.cc: Revert misguided attempt to handle FD_CLOSE error

View File

@ -378,7 +378,13 @@ class fhandler_mailslot : public fhandler_base
select_record *select_read (select_record *s); select_record *select_read (select_record *s);
}; };
struct wsa_event; 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
{ {
@ -389,10 +395,12 @@ class fhandler_socket: public fhandler_base
wsa_event *wsock_events; wsa_event *wsock_events;
HANDLE wsock_mtx; HANDLE wsock_mtx;
public:
HANDLE wsock_evt; HANDLE wsock_evt;
public:
bool init_events (); bool init_events ();
int evaluate_events (const long event_mask, long &events, bool erase); int evaluate_events (const long event_mask, long &events, const bool erase);
const HANDLE wsock_event () const { return wsock_evt; }
const LONG serial_number () const { return wsock_events->serial_number; }
private: private:
int wait_for_events (const long event_mask); int wait_for_events (const long event_mask);
void release_events (); void release_events ();
@ -486,6 +494,7 @@ class fhandler_socket: public fhandler_base
select_record *select_read (select_record *s); select_record *select_read (select_record *s);
select_record *select_write (select_record *s); select_record *select_write (select_record *s);
select_record *select_except (select_record *s); select_record *select_except (select_record *s);
int ready_for_read (int, DWORD) { return true; }
void set_addr_family (int af) {addr_family = af;} void set_addr_family (int af) {addr_family = af;}
int get_addr_family () {return addr_family;} int get_addr_family () {return addr_family;}
void set_socket_type (int st) { type = st;} void set_socket_type (int st) { type = st;}

View File

@ -382,14 +382,6 @@ fhandler_socket::af_local_set_secret (char *buf)
connect_secret [2], connect_secret [3]); connect_secret [2], connect_secret [3]);
} }
struct wsa_event
{
LONG serial_number;
long events;
int connect_errorcode;
pid_t owner;
};
/* 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 on a machine. Note that shared sockets (through dup/fork/exec) are
counted as one socket. */ counted as one socket. */

View File

@ -1286,6 +1286,7 @@ struct socketinf
{ {
cygthread *thread; cygthread *thread;
int num_w4; int num_w4;
LONG ser_num[MAXIMUM_WAIT_OBJECTS];
HANDLE w4[MAXIMUM_WAIT_OBJECTS]; HANDLE w4[MAXIMUM_WAIT_OBJECTS];
select_record *start; select_record *start;
}; };
@ -1344,13 +1345,18 @@ start_thread_socket (select_record *me, select_stuff *stuff)
while ((s = s->next)) while ((s = s->next))
if (s->startup == start_thread_socket) if (s->startup == start_thread_socket)
{ {
HANDLE evt = ((fhandler_socket *) me->fh)->wsock_evt; /* No event/socket should show up multiple times. Every socket
/* No event/socket should show up multiple times. */ is uniquely identified by its serial number in the global
wsock_events record. */
const LONG ser_num = ((fhandler_socket *) me->fh)->serial_number ();
for (int i = 1; i < si->num_w4; ++i) for (int i = 1; i < si->num_w4; ++i)
if (si->w4[i] == evt) if (si->ser_num[i] == ser_num)
goto continue_outer_loop; goto continue_outer_loop;
if (si->num_w4 < MAXIMUM_WAIT_OBJECTS) if (si->num_w4 < MAXIMUM_WAIT_OBJECTS)
si->w4[si->num_w4++] = evt; {
si->ser_num[si->num_w4] = ser_num;
si->w4[si->num_w4++] = ((fhandler_socket *) me->fh)->wsock_event ();
}
else /* for now */ else /* for now */
goto err; goto err;
continue_outer_loop: continue_outer_loop: