]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
quiche: make use of the connection timeout API properly
authorDaniel Stenberg <daniel@haxx.se>
Wed, 7 Aug 2019 10:49:27 +0000 (12:49 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 7 Aug 2019 10:51:52 +0000 (12:51 +0200)
lib/urldata.h
lib/vquic/quiche.c

index b3b1263c60f62b62f1b4d8811a3d6096ffe389e3..eabb1b5c7836565fe97b66102bb8ee099d5eee72 100644 (file)
@@ -1227,6 +1227,7 @@ typedef enum {
   EXPIRE_SPEEDCHECK,
   EXPIRE_TIMEOUT,
   EXPIRE_TOOFAST,
+  EXPIRE_QUIC,
   EXPIRE_LAST /* not an actual timer, used as a marker only */
 } expire_id;
 
index 67c2b1b423a1649b5edea45d3527dc70d3e2b3f4..c4e7b03fe3e75c3c7a3c8c8f742fd5df7836c780 100644 (file)
@@ -209,6 +209,9 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd)
   uint8_t *buf = (uint8_t *)data->state.buffer;
   size_t bufsize = data->set.buffer_size;
 
+  /* in case the timeout expired */
+  quiche_conn_on_timeout(qs->conn);
+
   do {
     recvd = recv(sockfd, buf, bufsize, 0);
     if((recvd < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
@@ -241,6 +244,7 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd)
   ssize_t sent;
   struct quicsocket *qs = &conn->quic;
   static uint8_t out[1200];
+  int64_t timeout_ns;
 
   do {
     sent = quiche_conn_send(qs->conn, out, sizeof(out));
@@ -260,6 +264,12 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd)
     }
   } while(1);
 
+  /* time until the next timeout event, as nanoseconds. */
+  timeout_ns = quiche_conn_timeout_as_nanos(qs->conn);
+  if(timeout_ns)
+    /* expire uses milliseconds */
+    Curl_expire(conn->data, (timeout_ns + 999999) / 1000000, EXPIRE_QUIC);
+
   return CURLE_OK;
 }