diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-04-06 14:47:20 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-07 07:05:21 +0200 |
commit | 3e20706643c7709483fcd7d436e89090171fcc0f (patch) | |
tree | 7c2f90cf93d08be8d2ab0c35e72a7971cc97dd91 | |
parent | 5fe5588351801dadb0c71584ca2c390f4ae2c57a (diff) |
Fix error handling in TCP and IPC connecters
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r-- | src/ipc_connecter.cpp | 7 | ||||
-rw-r--r-- | src/tcp_connecter.cpp | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp index 4ed7b2f..ab2d872 100644 --- a/src/ipc_connecter.cpp +++ b/src/ipc_connecter.cpp @@ -66,8 +66,7 @@ xs::ipc_connecter_t::~ipc_connecter_t () handle = NULL; } - if (s != retired_fd) - close (); + close (); } void xs::ipc_connecter_t::process_plug () @@ -209,7 +208,9 @@ int xs::ipc_connecter_t::open () int xs::ipc_connecter_t::close () { - xs_assert (s != retired_fd); + if (s == retired_fd) + return 0; + int rc = ::close (s); if (rc != 0) return -1; diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index c819f86..8072209 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -74,8 +74,7 @@ xs::tcp_connecter_t::~tcp_connecter_t () if (handle) rm_fd (handle); - if (s != retired_fd) - close (); + close (); } void xs::tcp_connecter_t::process_plug () @@ -301,7 +300,9 @@ xs::fd_t xs::tcp_connecter_t::connect () void xs::tcp_connecter_t::close () { - xs_assert (s != retired_fd); + if (s == retired_fd) + return; + #ifdef XS_HAVE_WINDOWS int rc = closesocket (s); wsa_assert (rc != SOCKET_ERROR); |