diff options
author | Brad G <43330364+bakedpotat0@users.noreply.github.com> | 2018-11-29 12:17:21 -0600 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-12-16 18:46:01 +0100 |
commit | 306a47cea67f29a1c7a19a42de85e66acb03f1d7 (patch) | |
tree | 61ffad27ec4f7a2d4e155a64d2fa3ad37b9725b7 /lib/sendf.c | |
parent | 9e6518481cd4e2603b4f9e04d6cfd1a214a72726 (diff) | |
download | curl-TFO-windows.tar.gz |
connect: Add TCP Fast Open support for WindowsTFO-windows
This is the former PR #3327, saved by Johannes Schindelin, rebased, squashed
and pushed again.
Requires Windows 10 ver 1607 or newer
Diffstat (limited to 'lib/sendf.c')
-rw-r--r-- | lib/sendf.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index e8598e617..2a4db3971 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -387,6 +387,37 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num, conn->bits.tcp_fastopen = FALSE; } else +#elif defined(HAVE_CONNECTEX) + if(conn->bits.tcp_fastopen && !conn->fastopen_connected) { + conn->fastopen_connected = TRUE; + bytes_written = 0; + + if(!Curl_ConnectEx(sockfd, + conn->ip_addr->ai_addr, conn->ip_addr->ai_addrlen, + (void *)mem, (DWORD)len, + (LPDWORD)&bytes_written, + &conn->fastopen_state)) { + if(SOCKERRNO != WSA_IO_PENDING) + bytes_written = -1; + else + if(!GetOverlappedResult((HANDLE)sockfd, &conn->fastopen_state, + (LPDWORD)&bytes_written, TRUE)) { + int err = GetLastError(); + failf(conn->data, "Send failure: %s", + Curl_strerror(conn, err)); + conn->data->state.os_errno = err; + *code = CURLE_SEND_ERROR; + return 0; + } + } + + /* socket in default state; enable previously-set socket params */ + if(setsockopt(sockfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0)) + infof(conn->data, + "setsockopt() failed after TCP Fast Open for fd %d, errno: %d", + sockfd, SOCKERRNO); + } + else #endif bytes_written = swrite(sockfd, mem, len); |