gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnurl] 196/222: HTTP3: fix Windows build


From: gnunet
Subject: [gnurl] 196/222: HTTP3: fix Windows build
Date: Thu, 07 Nov 2019 00:11:32 +0100

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit e0ee3d9f9b6f4ad2165bfbfdef5812ca9d01d924
Author: Javier Blazquez <address@hidden>
AuthorDate: Sun Oct 27 15:48:43 2019 -0700

    HTTP3: fix Windows build
    
    The ngtcp2 QUIC backend was using the MSG_DONTWAIT flag for send/recv
    in order to perform nonblocking operations. On Windows this flag does
    not exist. Instead, the socket must be set to nonblocking mode via
    ioctlsocket.
    
    This change sets the nonblocking flag on UDP sockets used for QUIC on
    all platforms so the use of MSG_DONTWAIT is not needed.
    
    Fixes #4531
    Closes #4532
---
 lib/connect.c      |  5 +++++
 lib/vquic/ngtcp2.c | 14 +++++++-------
 lib/vquic/quiche.c |  4 ++--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/connect.c b/lib/connect.c
index 4c8c956a4..3b88a5962 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1516,6 +1516,11 @@ CURLcode Curl_socket(struct connectdata *conn,
     /* no socket, no connection */
     return CURLE_COULDNT_CONNECT;
 
+  if(conn->transport == TRNSPRT_QUIC) {
+    /* QUIC sockets need to be nonblocking */
+    (void)curlx_nonblock(*sockfd, TRUE);
+  }
+
 #if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
   if(conn->scope_id && (addr->family == AF_INET6)) {
     struct sockaddr_in6 * const sa6 = (void *)&addr->sa_addr;
diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c
index 29a84d1c3..864751101 100644
--- a/lib/vquic/ngtcp2.c
+++ b/lib/vquic/ngtcp2.c
@@ -550,7 +550,7 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
   if(!Curl_addr2string((struct sockaddr*)addr, addrlen, ipbuf, &port)) {
     char buffer[STRERROR_LEN];
     failf(data, "ssrem inet_ntop() failed with errno %d: %s",
-          errno, Curl_strerror(errno, buffer, sizeof(buffer)));
+          SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
     return CURLE_BAD_FUNCTION_ARGUMENT;
   }
 
@@ -1404,13 +1404,13 @@ static CURLcode ng_process_ingress(struct connectdata 
*conn, int sockfd,
 
   for(;;) {
     remote_addrlen = sizeof(remote_addr);
-    while((recvd = recvfrom(sockfd, buf, bufsize, MSG_DONTWAIT,
+    while((recvd = recvfrom(sockfd, buf, bufsize, 0,
                             (struct sockaddr *)&remote_addr,
                             &remote_addrlen)) == -1 &&
-          errno == EINTR)
+          SOCKERRNO == EINTR)
       ;
     if(recvd == -1) {
-      if(errno == EAGAIN || errno == EWOULDBLOCK)
+      if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK)
         break;
 
       failf(conn->data, "ngtcp2: recvfrom() unexpectedly returned %d", recvd);
@@ -1544,14 +1544,14 @@ static CURLcode ng_flush_egress(struct connectdata 
*conn, int sockfd,
     }
 
     memcpy(&remote_addr, ps.path.remote.addr, ps.path.remote.addrlen);
-    while((sent = sendto(sockfd, out, outlen, MSG_DONTWAIT,
+    while((sent = sendto(sockfd, out, outlen, 0,
                          (struct sockaddr *)&remote_addr,
                          (socklen_t)ps.path.remote.addrlen)) == -1 &&
-          errno == EINTR)
+          SOCKERRNO == EINTR)
       ;
 
     if(sent == -1) {
-      if(errno == EAGAIN || errno == EWOULDBLOCK) {
+      if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
         /* TODO Cache packet */
         break;
       }
diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c
index 28eba8bbd..0ee360d07 100644
--- a/lib/vquic/quiche.c
+++ b/lib/vquic/quiche.c
@@ -208,7 +208,7 @@ CURLcode Curl_quic_connect(struct connectdata *conn, 
curl_socket_t sockfd,
                        conn->primary_ip, &conn->primary_port)) {
     char buffer[STRERROR_LEN];
     failf(data, "ssrem inet_ntop() failed with errno %d: %s",
-          errno, Curl_strerror(errno, buffer, sizeof(buffer)));
+          SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
     return CURLE_BAD_FUNCTION_ARGUMENT;
   }
   memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
@@ -301,7 +301,7 @@ static CURLcode process_ingress(struct connectdata *conn, 
int sockfd,
 
   do {
     recvd = recv(sockfd, buf, bufsize, 0);
-    if((recvd < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
+    if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
       break;
 
     if(recvd < 0) {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]