summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-02-21 00:43:32 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-02-21 00:43:32 +0800
commita2d8cf3df607ede1cfb30dbefdc4fc9d1c6d4bf5 (patch)
tree08f76a4cdc64d02d3c21f8892ede19a21d52c788
parent2ec56766b8d145ba6d772404da16c73d3e9ba53a (diff)
downloaddropbear-a2d8cf3df607ede1cfb30dbefdc4fc9d1c6d4bf5.tar.gz
get rid of some unnecessary code
-rw-r--r--netio.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/netio.c b/netio.c
index 43f69d1..5b97e4d 100644
--- a/netio.c
+++ b/netio.c
@@ -71,13 +71,9 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
int res = 0;
int fastopen = 0;
#ifdef DROPBEAR_TCP_FAST_OPEN
- struct msghdr message;
+ struct msghdr message;
#endif
- if (!c->res_iter) {
- return;
- }
-
for (r = c->res_iter; r; r = r->ai_next)
{
assert(c->sock == -1);
@@ -88,6 +84,7 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
}
ses.maxfd = MAX(ses.maxfd, c->sock);
+ set_sock_nodelay(c->sock);
setnonblocking(c->sock);
#if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
@@ -114,9 +111,7 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
c->writequeue = NULL;
}
m_free(message.msg_iov);
- if (res > 0) {
- packet_queue_consume(c->writequeue, res);
- }
+ packet_queue_consume(c->writequeue, res);
}
#endif
@@ -126,10 +121,12 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
}
if (res < 0 && errno != EINPROGRESS) {
+ /* failure */
close(c->sock);
c->sock = -1;
continue;
} else {
+ /* new connection was successful, wait for it to complete */
break;
}
}
@@ -139,28 +136,6 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
} else {
c->res_iter = NULL;
}
-
- if (c->sock >= 0 || (errno == EINPROGRESS)) {
- /* Success */
- set_sock_nodelay(c->sock);
- return;
- } else {
- if (!c->res_iter)
- {
-
- }
- /* XXX - returning error message through */
-#if 0
- /* Failed */
- if (errstring != NULL && *errstring == NULL) {
- int len;
- len = 20 + strlen(strerror(err));
- *errstring = (char*)m_malloc(len);
- snprintf(*errstring, len, "Error connecting: %s", strerror(err));
- }
- TRACE(("Error connecting: %s", strerror(err)))
-#endif
- }
}
/* Connect via TCP to a host. */