From 4cba1a737d9865be8602dc49fdc663a2d86e8268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 11 May 2015 18:52:25 +0200 Subject: [PATCH] Avoid debug flooding with non-blocking reads --- library/debug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/debug.c b/library/debug.c index 3164ad76b..940a2d28d 100644 --- a/library/debug.c +++ b/library/debug.c @@ -108,6 +108,14 @@ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, if( ssl->conf->f_dbg == NULL || level > debug_threshold ) return; + /* + * With non-blocking I/O and examples that just retry immediately, + * the logs would be quickly flooded with WANT_READ, so ignore that. + * Don't ignore WANT_WRITE however, since is is usually rare. + */ + if( ret == MBEDTLS_ERR_SSL_WANT_READ ) + return; + if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL ) idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );