From 1137831dddd637cc743e6114506a425d438066b4 Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 9 Jul 2018 21:01:37 +0000 Subject: [PATCH] make fastopen fall back to connect if len==0 --- io.h | 2 +- socket/socket_fastopen_connect4.c | 6 +++++- socket/socket_fastopen_connect6.c | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/io.h b/io.h index 5284245..14b96f4 100644 --- a/io.h +++ b/io.h @@ -177,7 +177,7 @@ enum { IOM_WRITE=2, IOM_ERROR=4 }; -/* return -1 if error, or | of IOM_READ, IOM_WRITE or IOM_ERROR */ +/* return -1 if error, events can be IOM_READ or IOM_WRITE */ int iom_add(iomux_t* c,int64 s,unsigned int events); /* Blocking wait for single event, timeout in milliseconds */ diff --git a/socket/socket_fastopen_connect4.c b/socket/socket_fastopen_connect4.c index 188c0b3..8893743 100644 --- a/socket/socket_fastopen_connect4.c +++ b/socket/socket_fastopen_connect4.c @@ -13,7 +13,11 @@ ssize_t socket_fastopen_connect4(int s,const char* ip,uint16 port,const char* bu int r; { #else - int r=socket_send4_flag(s,buf,len,ip,port,MSG_FASTOPEN); + int r; + if (len) + r=socket_send4_flag(s,buf,len,ip,port,MSG_FASTOPEN); + else + r=socket_connect4(s,ip,port); if (r==-1 && errno==ENOTCONN) { #endif /* apparently the kernel does not support TCP fast open */ diff --git a/socket/socket_fastopen_connect6.c b/socket/socket_fastopen_connect6.c index 33ae21f..5b52af9 100644 --- a/socket/socket_fastopen_connect6.c +++ b/socket/socket_fastopen_connect6.c @@ -13,7 +13,11 @@ ssize_t socket_fastopen_connect6(int s,const char* ip,uint16 port,uint32_t scope int r; { #else - int r=socket_send6_flag(s,buf,len,ip,port,scope_id,MSG_FASTOPEN); + int r; + if (len) + r=socket_send6_flag(s,buf,len,ip,port,scope_id,MSG_FASTOPEN); + else + r=socket_connect6(s,ip,port,scope_id); if (r==-1 && errno==ENOTCONN) { #endif /* apparently the kernel does not support TCP fast open */