diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-07 14:17:42 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-05-07 16:27:49 +0200 |
commit | 14c17a2b6e0c377c16db43d0e963a31db597ece5 (patch) | |
tree | c40c748e00665f6ebf7fe7fe23bcb1ef97766b2a /lib/vquic/quiche.c | |
parent | 2a81439553286f12cd04a4bdcdf66d8e026d8201 (diff) |
ngtcp2: introduce qlog support
If the QLOGDIR environment variable is set, enable qlogging.
... and create Curl_qlogdir() in the new generic vquic/vquic.c file for
QUIC functions that are backend independent.
Closes #5353
Diffstat (limited to 'lib/vquic/quiche.c')
-rw-r--r-- | lib/vquic/quiche.c | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c index 38c0a0a3f..45c39925f 100644 --- a/lib/vquic/quiche.c +++ b/lib/vquic/quiche.c @@ -34,10 +34,7 @@ #include "multiif.h" #include "connect.h" #include "strerror.h" -#include "dynbuf.h" -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif +#include "vquic.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -204,39 +201,12 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd, /* Known to not work on Windows */ #if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD) -#ifdef O_BINARY -#define QLOGMODE O_WRONLY|O_CREAT|O_BINARY -#else -#define QLOGMODE O_WRONLY|O_CREAT -#endif { - const char *qlog_dir = getenv("QLOGDIR"); - if(qlog_dir) { - struct dynbuf fname; - unsigned int i; - Curl_dyn_init(&fname, DYN_QLOG_NAME); - result = Curl_dyn_add(&fname, qlog_dir); - if(!result) - result = Curl_dyn_add(&fname, "/"); - for(i = 0; (i < sizeof(qs->scid)) && !result; i++) { - char hex[3]; - msnprintf(hex, 3, "%02x", qs->scid[i]); - result = Curl_dyn_add(&fname, hex); - } - if(!result) - result = Curl_dyn_add(&fname, ".qlog"); - - if(!result) { - int qlogfd = open(Curl_dyn_ptr(&fname), QLOGMODE, - data->set.new_file_perms); - if(qlogfd != -1) - quiche_conn_set_qlog_fd(qs->conn, qlogfd, - "qlog title", "curl qlog"); - } - Curl_dyn_free(&fname); - if(result) - return result; - } + int qfd; + (void)Curl_qlogdir(data, qs->scid, sizeof(qs->scid), &qfd); + if(qfd != -1) + quiche_conn_set_qlog_fd(qs->conn, qfd, + "qlog title", "curl qlog"); } #endif |