diff options
author | Matt Johnston <matt@ucc.asn.au> | 2015-02-19 00:32:00 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2015-02-19 00:32:00 +0800 |
commit | d275e08165dda61c6ce2263cdfd8f5684d8a6b55 (patch) | |
tree | 94ae7b933f8ea0ba18edb429d7988565bdc5684f /dbutil.c | |
parent | 2213944b126c167ffaed53152b973a28c746bab7 (diff) | |
download | dropbear-d275e08165dda61c6ce2263cdfd8f5684d8a6b55.tar.gz |
In theory TFO should work. Needs platform cleanup and testing
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 46 |
1 files changed, 42 insertions, 4 deletions
@@ -1049,9 +1049,11 @@ static void connect_try_next(struct dropbear_progress_connection *c) { setnonblocking(c->sock); #if defined(__linux__) && defined(TCP_DEFER_ACCEPT) - set_piggyback_ack(sock); + //set_piggyback_ack(c->sock); #endif +#ifdef PROGRESS_CONNECT_FALLBACK +#if 0 if (connect(c->sock, r->ai_addr, r->ai_addrlen) < 0) { if (errno == EINPROGRESS) { TRACE(("Connect in progress")) @@ -1065,8 +1067,43 @@ static void connect_try_next(struct dropbear_progress_connection *c) { } break; /* Success. Treated the same as EINPROGRESS */ +#endif +#else + { + struct msghdr message = {0}; + int flags; + int res; + message.msg_name = r->ai_addr; + message.msg_namelen = r->ai_addrlen; + + if (c->writequeue) { + int iovlen; /* Linux msg_iovlen is a size_t */ + message.msg_iov = packet_queue_to_iovec(c->writequeue, &iovlen); + message.msg_iovlen = iovlen; + res = sendmsg(c->sock, &message, MSG_FASTOPEN); + if (res < 0 && errno == EOPNOTSUPP) { + TRACE(("Fastopen not supported")); + /* No kernel MSG_FASTOPEN support. Fall back below */ + c->writequeue = NULL; + } + } + + if (!c->writequeue) { + res = connect(c->sock, r->ai_addr, r->ai_addrlen); + } + if (res < 0 && errno != EINPROGRESS) { + err = errno; + close(c->sock); + c->sock = -1; + continue; + } else { + break; + } + } +#endif } + if (r) { c->res_iter = r->ai_next; } else { @@ -1130,9 +1167,6 @@ struct dropbear_progress_connection *connect_remote(const char* remotehost, cons c->res_iter = c->res; - /* Set one going */ - connect_try_next(c); - return c; } @@ -1202,3 +1236,7 @@ void handle_connect_fds(fd_set *writefd) { } TRACE(("leave handle_connect_fds - end iter")) } + +void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue) { + c->writequeue = writequeue; +} |