Cygwin: FIFO: fix and simplify listen_client_thread
Remove fifo_client_handler::connect and move its code into listen_client_thread. That way we can check the return status when a client handler's connect_evt is signaled. Previously we incorrectly assumed there was a successful connection. Also simplify listen_client_thread in the following ways: - Replace fhandler_fifo::disconnect_and_reconnect by a new delete_client_handler method. Now we just delete invalid client handlers rather than trying to re-use them. - Try to maintain a client handler list that consists of connected client handlers and exactly one that is listening for a connection. This allows us to call WaitForMultipleObjects with only two wait objects. - Remove 'dummy_evt' from the fifo_client_handler struct; it is no longer needed. - On exit from listen_client_thread, delete the "extra" (listening) client handler. Otherwise there could be a connection that doesn't get recorded in the client handler list. This could happen when a file descriptor is being duplicated.
This commit is contained in:
committed by
Corinna Vinschen
parent
bb46627871
commit
2b4cf7622e
@ -1250,13 +1250,10 @@ struct fifo_client_handler
|
||||
fhandler_base *fh;
|
||||
fifo_client_connect_state state;
|
||||
HANDLE connect_evt;
|
||||
HANDLE dummy_evt; /* Never signaled. */
|
||||
fifo_client_handler () : fh (NULL), state (fc_unknown), connect_evt (NULL),
|
||||
dummy_evt (NULL) {}
|
||||
fifo_client_handler () : fh (NULL), state (fc_unknown), connect_evt (NULL) {}
|
||||
fifo_client_handler (fhandler_base *_fh, fifo_client_connect_state _state,
|
||||
HANDLE _connect_evt, HANDLE _dummy_evt)
|
||||
: fh (_fh), state (_state), connect_evt (_connect_evt),
|
||||
dummy_evt (_dummy_evt) {}
|
||||
HANDLE _connect_evt)
|
||||
: fh (_fh), state (_state), connect_evt (_connect_evt) {}
|
||||
int connect ();
|
||||
int close ();
|
||||
};
|
||||
@ -1278,8 +1275,8 @@ class fhandler_fifo: public fhandler_base
|
||||
NTSTATUS npfs_handle (HANDLE &);
|
||||
HANDLE create_pipe_instance (bool);
|
||||
NTSTATUS open_pipe ();
|
||||
int disconnect_and_reconnect (int);
|
||||
int add_client_handler ();
|
||||
void delete_client_handler (int);
|
||||
bool listen_client ();
|
||||
int stop_listen_client ();
|
||||
public:
|
||||
|
Reference in New Issue
Block a user