]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix fastopen EPIPE fallthrough to perform connect.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 1 Jun 2017 09:06:14 +0000 (09:06 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 1 Jun 2017 09:06:14 +0000 (09:06 +0000)
git-svn-id: file:///svn/unbound/trunk@4203 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/netevent.c

index 3b13a2c00a7c597ba194c5571e5b11f0b60c3d9a..c0da6bc499fea8a39f81b35cebec5418061170d4 100644 (file)
@@ -1,3 +1,6 @@
+1 June 2017: Wouter
+       - Fix fastopen EPIPE fallthrough to perform connect.
+
 31 May 2017: Ralph
        - Also use global local-zones when there is a matching view that does
          not have any local-zone specified.
index dcb9cb5adcd8d87492aec64ad192891fc81f82a5..d3955aae79973b5e7d11597416dfc55841b0b314 100644 (file)
@@ -1415,7 +1415,26 @@ comm_point_tcp_handle_write(int fd, struct comm_point* c)
                                return 0;
                        }
                        /* fallthrough to nonFASTOPEN
-                        * (MSG_FASTOPEN on Linux 3 produces EPIPE) */
+                        * (MSG_FASTOPEN on Linux 3 produces EPIPE)
+                        * we need to perform connect() */
+                       if(connect(fd, &c->repinfo.addr, c->repinfo.addrlen) == -1) {
+#ifdef EINPROGRESS
+                               if(errno == EINPROGRESS)
+                                       return 1; /* wait until connect done*/
+#endif
+#ifdef USE_WINSOCK
+                               if(WSAGetLastError() == WSAEINPROGRESS ||
+                                       WSAGetLastError() == WSAEWOULDBLOCK)
+                                       return 1; /* wait until connect done*/
+#endif
+                               if(tcp_connect_errno_needs_log(
+                                       &c->repinfo.addr, c->repinfo.addrlen)) {
+                                       log_err_addr("outgoing tcp: connect after EPIPE for fastopen",
+                                               strerror(errno), &c->repinfo.addr, c->repinfo.addrlen);
+                               }
+                               return 0;
+                       }
+
                } else {
                        c->tcp_byte_count += r;
                        if(c->tcp_byte_count < sizeof(uint16_t))