summaryrefslogtreecommitdiff
path: root/src/ipc_connecter.cpp
diff options
context:
space:
mode:
authorMartin Lucina <martin@lucina.net>2012-05-04 14:34:18 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-05-04 14:34:18 +0200
commit5bba016135cdc13e0f5b537807c516d5f1089d1b (patch)
treea93947a67f7bf5708e531953fbd68c9340a217bc /src/ipc_connecter.cpp
parent357a20ef6feae94c033eed392b025e57fe8eaa81 (diff)
Correct handling of connect() errors in tcp, ipc_connecter_t
EAGAIN was being used as a translation value for EINPROGRESS, thus shadowing a real EAGAIN return value from the OS. This caused later assertions of "Invalid argument" in stream_engine.cpp when it attempted to use a socket which was not connected. I also add EINTR to mean EINPROGRESS, as per the POSIX and FreeBSD documentation which specifies that a connect() call interrupted due to a signal will complete asynchronously. Signed-off-by: Martin Lucina <martin@lucina.net>
Diffstat (limited to 'src/ipc_connecter.cpp')
-rw-r--r--src/ipc_connecter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp
index af3665c..0722532 100644
--- a/src/ipc_connecter.cpp
+++ b/src/ipc_connecter.cpp
@@ -133,7 +133,7 @@ void xs::ipc_connecter_t::start_connecting ()
}
// Connection establishment may be delayed. Poll for its completion.
- else if (rc == -1 && errno == EAGAIN) {
+ else if (rc == -1 && errno == EINPROGRESS) {
xs_assert (!handle);
handle = add_fd (s);
set_pollout (handle);
@@ -196,9 +196,10 @@ int xs::ipc_connecter_t::open ()
if (rc == 0)
return 0;
- // Asynchronous connect was launched.
- if (rc == -1 && errno == EINPROGRESS) {
- errno = EAGAIN;
+ // Translate other error codes indicating asynchronous connect has been
+ // launched to a uniform EINPROGRESS.
+ if (rc == -1 && errno == EINTR) {
+ errno = EINPROGRESS;
return -1;
}