public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: sockets: add bind state, and split out connect state to allow atomic operation
@ 2018-03-05 17:01 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2018-03-05 17:01 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a2c02d78be1f8d53bfbfe4cb3d398858b397105c
commit a2c02d78be1f8d53bfbfe4cb3d398858b397105c
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Mon Mar 5 17:59:04 2018 +0100
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>
Diff:
---
winsup/cygwin/fhandler.h | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index ec9294a..e9a2472 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 ();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-05 17:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 17:01 [newlib-cygwin] Cygwin: sockets: add bind state, and split out connect state to allow atomic operation Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).