From bed08625f0129ac2fcda3e90a778be0a78db2a3b Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 20 Sep 2022 17:11:15 +0300 Subject: [PATCH] Improve error logging. --- tdnet/td/net/SslStream.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tdnet/td/net/SslStream.cpp b/tdnet/td/net/SslStream.cpp index ca602cd7e..2888bd1f5 100644 --- a/tdnet/td/net/SslStream.cpp +++ b/tdnet/td/net/SslStream.cpp @@ -383,7 +383,13 @@ class SslStreamImpl { Result write(Slice slice) { clear_openssl_errors("Before SslFd::write"); + auto start_time = Time::now(); auto size = SSL_write(ssl_handle_.get(), slice.data(), static_cast(slice.size())); + auto elapsed_time = Time::now() - start_time; + if (elapsed_time >= 0.001) { + LOG(ERROR) << "SSL_write of size " << slice.size() << " took " << elapsed_time << " seconds and returned " << size + << ' ' << SSL_get_error(ssl_handle_.get(), size); + } if (size <= 0) { return process_ssl_error(size); } @@ -395,8 +401,9 @@ class SslStreamImpl { auto start_time = Time::now(); auto size = SSL_read(ssl_handle_.get(), slice.data(), static_cast(slice.size())); auto elapsed_time = Time::now() - start_time; - if (elapsed_time >= 0.01) { - LOG(ERROR) << "SSL_read took " << elapsed_time << " seconds and returned " << size; + if (elapsed_time >= 0.001) { + LOG(ERROR) << "SSL_read took " << elapsed_time << " seconds and returned " << size << ' ' + << SSL_get_error(ssl_handle_.get(), size); } if (size <= 0) { return process_ssl_error(size);