summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-16 13:48:40 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-16 13:48:40 +0100
commitf5015f4c933706f34dbe3cb78e7db29e2ab7f870 (patch)
treee314c67ede3fe74fa4eda25dff2b7f7c59fc0b8b /src
parent32ded2b457b2102dba4c15e00363f031d212b1c4 (diff)
Incorrect errno reported from tcp_listener_t::set_address
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/tcp_listener.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tcp_listener.cpp b/src/tcp_listener.cpp
index c3dc0b6..205ddc1 100644
--- a/src/tcp_listener.cpp
+++ b/src/tcp_listener.cpp
@@ -201,14 +201,20 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Bind the socket to the network interface and port.
rc = bind (s, (struct sockaddr*) &addr, addr_len);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
// Listen for incomming connections.
rc = listen (s, backlog_);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
@@ -241,7 +247,10 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Bind the socket to the file path.
rc = bind (s, (struct sockaddr*) &addr, addr_len);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}
has_file = true;
@@ -249,7 +258,10 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_,
// Listen for incomming connections.
rc = listen (s, backlog_);
if (rc != 0) {
- close ();
+ int err = errno;
+ if (close () != 0)
+ return -1;
+ errno = err;
return -1;
}