[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 82/208: http2: handle PING frames
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 82/208: http2: handle PING frames |
Date: |
Wed, 09 Aug 2017 17:34:39 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.55.0
in repository gnurl.
commit c98e97e9c32b7c55d9002860655bdd7fb5eefd66
Author: Max Dymond <address@hidden>
AuthorDate: Wed May 31 14:00:45 2017 +0100
http2: handle PING frames
Add a connection check function to HTTP2 based off RTSP. This causes
PINGs to be handled the next time the connection is reused.
Closes #1521
---
lib/http2.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/lib/http2.c b/lib/http2.c
index a93348641..0e5580133 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -28,6 +28,7 @@
#include "http2.h"
#include "http.h"
#include "sendf.h"
+#include "select.h"
#include "curl_base64.h"
#include "strcase.h"
#include "multiif.h"
@@ -151,6 +152,49 @@ static CURLcode http2_disconnect(struct connectdata *conn,
return CURLE_OK;
}
+/*
+ * The server may send us data at any point (e.g. PING frames). Therefore,
+ * we cannot assume that an HTTP/2 socket is dead just because it is readable.
+ *
+ * Instead, if it is readable, run Curl_connalive() to peek at the socket
+ * and distinguish between closed and data.
+ */
+static bool http2_connisdead(struct connectdata *check)
+{
+ int sval;
+ bool ret_val = TRUE;
+
+ sval = SOCKET_READABLE(check->sock[FIRSTSOCKET], 0);
+ if(sval == 0) {
+ /* timeout */
+ ret_val = FALSE;
+ }
+ else if(sval & CURL_CSELECT_ERR) {
+ /* socket is in an error state */
+ ret_val = TRUE;
+ }
+ else if(sval & CURL_CSELECT_IN) {
+ /* readable with no error. could still be closed */
+ ret_val = !Curl_connalive(check);
+ }
+
+ return ret_val;
+}
+
+
+static unsigned int http2_conncheck(struct connectdata *check,
+ unsigned int checks_to_perform)
+{
+ unsigned int ret_val = CONNRESULT_NONE;
+
+ if(checks_to_perform & CONNCHECK_ISDEAD) {
+ if(http2_connisdead(check))
+ ret_val |= CONNRESULT_DEAD;
+ }
+
+ return ret_val;
+}
+
/* called from Curl_http_setup_conn */
void Curl_http2_setup_req(struct Curl_easy *data)
{
@@ -196,7 +240,7 @@ static const struct Curl_handler Curl_handler_http2 = {
http2_perform_getsock, /* perform_getsock */
http2_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
- ZERO_NULL, /* connection_check */
+ http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_STREAM /* flags */
@@ -217,7 +261,7 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
http2_perform_getsock, /* perform_getsock */
http2_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
- ZERO_NULL, /* connection_check */
+ http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 106/208: TODO: 1.10 auto-detect proxy, (continued)
- [GNUnet-SVN] [gnurl] 106/208: TODO: 1.10 auto-detect proxy, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 117/208: memdebug: don't setbuf() if the file open failed, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 81/208: handler: refactor connection checking, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 130/208: tool_getparam: fix potentially uninitialized err, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 78/208: curl_strequal.3: fix typo in SYNOPSIS, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 89/208: unit1399: fix integer overflow, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 77/208: RELEASE-NOTES: synced with ce2c3ebda, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 80/208: openssl: improve fallback seed of PRNG with a time based hash, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 52/208: if2ip: fix compiler warning in ISO C90 mode, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 76/208: curl --socks5-{basic, gssapi}: control socks5 auth, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 82/208: http2: handle PING frames,
gnunet <=
- [GNUnet-SVN] [gnurl] 57/208: lib1521: fix missing-variable-declarations clang warnings, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 88/208: cmake: Added compatibility options for older Windows versions, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 100/208: smb: fix build for djgpp/MSDOS, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 105/208: TODO: HTTP proxy CONNECT is non-blocking now, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 91/208: url: make the original string get used on subsequent transfers, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 119/208: travis: do more tests in the coverage run, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 122/208: cmake: offer CMAKE_DEBUG_POSTFIX when building with MSVC, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 108/208: select.h: avoid macro redefinition harder, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 128/208: tool_cb_wrt: fix variable shadowing warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 127/208: RELEASE-NOTES: synced with be2c999b8, gnunet, 2017/08/09