Mercurial > dropbear
diff dbutil.c @ 1027:daf21fd50abf fastopen
In theory TFO should work. Needs platform cleanup and testing
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 19 Feb 2015 00:32:00 +0800 |
parents | 02baa0b334e8 |
children | 5ad81aa19c2d ea4676b840ef |
line wrap: on
line diff
--- a/dbutil.c Wed Feb 18 23:02:49 2015 +0800 +++ b/dbutil.c Thu Feb 19 00:32:00 2015 +0800 @@ -1049,9 +1049,11 @@ 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 @@ } 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 @@ c->res_iter = c->res; - /* Set one going */ - connect_try_next(c); - return c; } @@ -1202,3 +1236,7 @@ } TRACE(("leave handle_connect_fds - end iter")) } + +void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue) { + c->writequeue = writequeue; +}