summaryrefslogtreecommitdiff
path: root/lib/sendf.c
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2016-04-03 13:08:28 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-04-18 23:21:50 +0200
commit03de4e4b2192bec7de94d2d5abd2a25f86c17ac3 (patch)
tree689fd77d0022d451ed0d1a5947519ac493cedc49 /lib/sendf.c
parentd49087f6bc95d159eeb1172173fc1e95411041fa (diff)
downloadcurl-03de4e4b2192bec7de94d2d5abd2a25f86c17ac3.tar.gz
connect: implement TCP Fast Open for Linux
Closes #660
Diffstat (limited to 'lib/sendf.c')
-rw-r--r--lib/sendf.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index ea04ae83e..a75c5c743 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -254,7 +254,17 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
const void *mem, size_t len, CURLcode *code)
{
curl_socket_t sockfd = conn->sock[num];
- ssize_t bytes_written = swrite(sockfd, mem, len);
+ ssize_t bytes_written;
+
+#ifdef MSG_FASTOPEN /* Linux */
+ if(conn->bits.tcp_fastopen) {
+ bytes_written = sendto(sockfd, mem, len, MSG_FASTOPEN,
+ conn->ip_addr->ai_addr, conn->ip_addr->ai_addrlen);
+ conn->bits.tcp_fastopen = FALSE;
+ }
+ else
+#endif
+ bytes_written = swrite(sockfd, mem, len);
*code = CURLE_OK;
if(-1 == bytes_written) {
@@ -268,7 +278,8 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
/* errno may be EWOULDBLOCK or on some systems EAGAIN when it returned
due to its inability to send off data without blocking. We therefor
treat both error codes the same here */
- (EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err)
+ (EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err) ||
+ (EINPROGRESS == err)
#endif
) {
/* this is just a case of EWOULDBLOCK */