diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-03-05 17:59:04 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-03-05 17:59:04 +0100 |
commit | a2c02d78be1f8d53bfbfe4cb3d398858b397105c (patch) | |
tree | 4b6e85078a74b54740e43e5d031aa69228f1afae | |
parent | fe8e2c9b1f480c5b939574510b3ed10ea3c9028d (diff) | |
download | cygnal-a2c02d78be1f8d53bfbfe4cb3d398858b397105c.tar.gz cygnal-a2c02d78be1f8d53bfbfe4cb3d398858b397105c.tar.bz2 cygnal-a2c02d78be1f8d53bfbfe4cb3d398858b397105c.zip |
Cygwin: sockets: add bind state, and split out connect state to allow atomic operation
The connect state was stored in a bitfield which is not safe
to do atomic operations on.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index ec9294ab0..e9a247256 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -76,13 +76,21 @@ enum dirent_states dirent_info_mask = 0x0078 }; +enum bind_state +{ + unbound = 0, + bind_pending = 1, + bound = 2 +}; + enum conn_state { unconnected = 0, connect_pending = 1, connected = 2, listener = 3, - connect_failed = 4 + connect_failed = 4 /* FIXME: Do we really need this? It's basically + the same thing as unconnected. */ }; enum line_edit_status @@ -524,19 +532,26 @@ class fhandler_socket: public fhandler_base unsigned saw_shutdown_read : 1; /* Socket saw a SHUT_RD */ unsigned saw_shutdown_write : 1; /* Socket saw a SHUT_WR */ unsigned saw_reuseaddr : 1; /* Socket saw SO_REUSEADDR call */ - unsigned connect_state : 3; public: status_flags () : async_io (0), saw_shutdown_read (0), saw_shutdown_write (0), - saw_reuseaddr (0), connect_state (unconnected) + saw_reuseaddr (0) {} } status; + LONG _connection_state; + LONG _binding_state; public: IMPLEMENT_STATUS_FLAG (bool, async_io) IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_read) IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_write) IMPLEMENT_STATUS_FLAG (bool, saw_reuseaddr) - IMPLEMENT_STATUS_FLAG (conn_state, connect_state) + + conn_state connect_state (conn_state val) + { return (conn_state) InterlockedExchange (&_connection_state, val); } + conn_state connect_state () const { return (conn_state) _connection_state; } + bind_state binding_state (bind_state val) + { return (bind_state) InterlockedExchange (&_binding_state, val); } + bind_state binding_state () const { return (bind_state) _binding_state; } public: fhandler_socket (); |