diff options
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); |