ngtcp2: remove fprintf() calls

- convert some of them to H3BUF() calls to infof()
- remove some of them completely
- made DEBUG_HTTP3 defined only if CURLDEBUG is set for now

Closes #4421
This commit is contained in:
Daniel Stenberg 2019-09-25 12:27:26 +02:00
Родитель af3ced3b9c
Коммит 217812fa9e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5CC908FDB71E12C2
1 изменённых файлов: 17 добавлений и 23 удалений

Просмотреть файл

@ -43,7 +43,9 @@
#include "memdebug.h" #include "memdebug.h"
/* #define DEBUG_NGTCP2 */ /* #define DEBUG_NGTCP2 */
#ifdef CURLDEBUG
#define DEBUG_HTTP3 #define DEBUG_HTTP3
#endif
#ifdef DEBUG_HTTP3 #ifdef DEBUG_HTTP3
#define H3BUGF(x) x #define H3BUGF(x) x
#else #else
@ -204,7 +206,7 @@ static int quic_add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level,
qs->qconn, level, (uint8_t *)(&crypto_data->buf[crypto_data->len] - len), qs->qconn, level, (uint8_t *)(&crypto_data->buf[crypto_data->len] - len),
len); len);
if(rv) { if(rv) {
fprintf(stderr, "write_client_handshake failed\n"); H3BUGF(fprintf(stderr, "write_client_handshake failed\n"));
} }
assert(0 == rv); assert(0 == rv);
@ -597,12 +599,11 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
ngtcp2_conn_get_local_transport_params(qs->qconn, &params); ngtcp2_conn_get_local_transport_params(qs->qconn, &params);
nwrite = ngtcp2_encode_transport_params( nwrite = ngtcp2_encode_transport_params(
paramsbuf, sizeof(paramsbuf), NGTCP2_TRANSPORT_PARAMS_TYPE_CLIENT_HELLO, paramsbuf, sizeof(paramsbuf), NGTCP2_TRANSPORT_PARAMS_TYPE_CLIENT_HELLO,
&params); &params);
if(nwrite < 0) { if(nwrite < 0) {
fprintf(stderr, "ngtcp2_encode_transport_params: %s\n", failf(data, "ngtcp2_encode_transport_params: %s\n",
ngtcp2_strerror((int)nwrite)); ngtcp2_strerror((int)nwrite));
return CURLE_FAILED_INIT; return CURLE_FAILED_INIT;
} }
@ -699,7 +700,7 @@ static int cb_h3_stream_close(nghttp3_conn *conn, int64_t stream_id,
(void)stream_id; (void)stream_id;
(void)app_error_code; (void)app_error_code;
(void)user_data; (void)user_data;
fprintf(stderr, "cb_h3_stream_close CALLED\n"); H3BUGF(infof(data, "cb_h3_stream_close CALLED\n"));
stream->closed = TRUE; stream->closed = TRUE;
Curl_expire(data, 0, EXPIRE_QUIC); Curl_expire(data, 0, EXPIRE_QUIC);
@ -715,7 +716,7 @@ static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream_id,
struct Curl_easy *data = stream_user_data; struct Curl_easy *data = stream_user_data;
struct HTTP *stream = data->req.protop; struct HTTP *stream = data->req.protop;
(void)conn; (void)conn;
fprintf(stderr, "cb_h3_recv_data CALLED with %d bytes\n", buflen); H3BUGF(infof(data, "cb_h3_recv_data CALLED with %d bytes\n", buflen));
/* TODO: this needs to be handled properly */ /* TODO: this needs to be handled properly */
DEBUGASSERT(buflen <= stream->len); DEBUGASSERT(buflen <= stream->len);
@ -749,7 +750,6 @@ static int cb_h3_deferred_consume(nghttp3_conn *conn, int64_t stream_id,
struct quicsocket *qs = user_data; struct quicsocket *qs = user_data;
(void)conn; (void)conn;
(void)stream_user_data; (void)stream_user_data;
fprintf(stderr, "cb_h3_deferred_consume CALLED\n");
ngtcp2_conn_extend_max_stream_offset(qs->qconn, stream_id, consumed); ngtcp2_conn_extend_max_stream_offset(qs->qconn, stream_id, consumed);
ngtcp2_conn_extend_max_offset(qs->qconn, consumed); ngtcp2_conn_extend_max_offset(qs->qconn, consumed);
@ -818,8 +818,6 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id,
(void)flags; (void)flags;
(void)user_data; (void)user_data;
fprintf(stderr, "cb_h3_recv_header called!\n");
if(h3name.len == sizeof(":status") - 1 && if(h3name.len == sizeof(":status") - 1 &&
!memcmp(":status", h3name.base, h3name.len)) { !memcmp(":status", h3name.base, h3name.len)) {
int status = decode_status_code(h3val.base, h3val.len); int status = decode_status_code(h3val.base, h3val.len);
@ -849,7 +847,6 @@ static int cb_h3_send_stop_sending(nghttp3_conn *conn, int64_t stream_id,
(void)app_error_code; (void)app_error_code;
(void)user_data; (void)user_data;
(void)stream_user_data; (void)stream_user_data;
fprintf(stderr, "cb_h3_send_stop_sending CALLED\n");
return 0; return 0;
} }
@ -947,9 +944,6 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn,
struct HTTP *stream = conn->data->req.protop; struct HTTP *stream = conn->data->req.protop;
struct quicsocket *qs = conn->quic; struct quicsocket *qs = conn->quic;
fprintf(stderr, "ngh3_stream_recv CALLED (easy %p, socket %d)\n",
conn->data, sockfd);
if(!stream->memlen) { if(!stream->memlen) {
/* remember where to store incoming data for this stream and how big the /* remember where to store incoming data for this stream and how big the
buffer is */ buffer is */
@ -1003,8 +997,9 @@ static int cb_h3_acked_stream_data(nghttp3_conn *conn, int64_t stream_id,
if(!data->set.postfields) { if(!data->set.postfields) {
stream->h3out->used -= datalen; stream->h3out->used -= datalen;
fprintf(stderr, "cb_h3_acked_stream_data, %zd bytes, %zd left unacked\n", H3BUGF(infof(data,
datalen, stream->h3out->used); "cb_h3_acked_stream_data, %zd bytes, %zd left unacked\n",
datalen, stream->h3out->used));
DEBUGASSERT(stream->h3out->used < H3_SEND_SIZE); DEBUGASSERT(stream->h3out->used < H3_SEND_SIZE);
} }
return 0; return 0;
@ -1057,9 +1052,9 @@ static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
if(!stream->upload_left) if(!stream->upload_left)
*pflags = NGHTTP3_DATA_FLAG_EOF; *pflags = NGHTTP3_DATA_FLAG_EOF;
} }
fprintf(stderr, "cb_h3_readfunction %zd bytes%s (at %zd unacked)\n", H3BUGF(infof(data, "cb_h3_readfunction %zd bytes%s (at %zd unacked)\n",
nread, *pflags == NGHTTP3_DATA_FLAG_EOF?" EOF":"", nread, *pflags == NGHTTP3_DATA_FLAG_EOF?" EOF":"",
out->used); out->used));
} }
if(stream->upload_done && !stream->upload_len && if(stream->upload_done && !stream->upload_len &&
(stream->upload_left <= 0)) { (stream->upload_left <= 0)) {
@ -1333,7 +1328,8 @@ static ssize_t ngh3_stream_send(struct connectdata *conn,
sent = len; sent = len;
} }
else { else {
fprintf(stderr, "ngh3_stream_send() wants to send %zd bytes\n", len); H3BUGF(infof(conn->data, "ngh3_stream_send() wants to send %zd bytes\n",
len));
if(!stream->upload_len) { if(!stream->upload_len) {
stream->upload_mem = mem; stream->upload_mem = mem;
stream->upload_len = len; stream->upload_len = len;
@ -1590,8 +1586,6 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
/* only for HTTP/3 transfers */ /* only for HTTP/3 transfers */
struct HTTP *stream = conn->data->req.protop; struct HTTP *stream = conn->data->req.protop;
struct quicsocket *qs = conn->quic; struct quicsocket *qs = conn->quic;
fprintf(stderr, "!!! Curl_quic_done_sending stream %zu\n",
stream->stream3_id);
stream->upload_done = TRUE; stream->upload_done = TRUE;
(void)nghttp3_conn_resume_stream(qs->h3conn, stream->stream3_id); (void)nghttp3_conn_resume_stream(qs->h3conn, stream->stream3_id);
} }