summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2019-08-17 15:04:33 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-08-17 17:00:49 +0200
commite54affa82cba9d1a2113c3867f4b8d7855df9200 (patch)
tree138ad3347d2748f91de2f30ee3e1fa44f6a30acf /lib
parentea28a6cb2f168ce0b4e01c0f05e3675687dbd497 (diff)
downloadcurl-e54affa82cba9d1a2113c3867f4b8d7855df9200.tar.gz
quiche: register debug callback once and earlier
The quiche debug callback is global and can only be initialized once, so make sure we don't do it multiple times (e.g. if multiple requests are executed). In addition this initializes the callback before the connection is created, so we get logs for the handshake as well. Closes #4236
Diffstat (limited to 'lib')
-rw-r--r--lib/vquic/quiche.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c
index 0ac848134..b84cc4779 100644
--- a/lib/vquic/quiche.c
+++ b/lib/vquic/quiche.c
@@ -137,6 +137,14 @@ static const struct Curl_handler Curl_handler_h3_quiche = {
PROTOPT_SSL | PROTOPT_STREAM /* flags */
};
+#ifdef DEBUG_QUICHE
+static void quiche_debug_log(const char *line, void *argp)
+{
+ (void)argp;
+ fprintf(stderr, "%s\n", line);
+}
+#endif
+
CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
int sockindex,
const struct sockaddr *addr, socklen_t addrlen)
@@ -144,6 +152,16 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
CURLcode result;
struct quicsocket *qs = &conn->hequic[sockindex];
struct Curl_easy *data = conn->data;
+
+#ifdef DEBUG_QUICHE
+ /* initialize debug log callback only once */
+ static int debug_log_init = 0;
+ if(!debug_log_init) {
+ quiche_enable_debug_logging(quiche_debug_log, NULL);
+ debug_log_init = 1;
+ }
+#endif
+
(void)addr;
(void)addrlen;
@@ -505,14 +523,6 @@ int Curl_quic_ver(char *p, size_t len)
return msnprintf(p, len, " quiche/%s", quiche_version());
}
-#ifdef DEBUG_QUICHE
-static void debug_log(const char *line, void *argp)
-{
- (void)argp;
- fprintf(stderr, "%s\n", line);
-}
-#endif
-
/* Index where :authority header field will appear in request header
field list. */
#define AUTHORITY_DST_IDX 3
@@ -534,10 +544,6 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
-#ifdef DEBUG_QUICHE
- quiche_enable_debug_logging(debug_log, NULL);
-#endif
-
stream->h3req = TRUE; /* senf off! */
/* Calculate number of headers contained in [mem, mem + len). Assumes a