From b1509b1047bb76c9b2d8b14e9cecd0da72fd8e65 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 6 Nov 2018 16:50:29 +0100 Subject: [PATCH] dtlsconnection: Print out errno info for syscall errors As suggested in [the SSL_get_error manpage][1]. Upgrade the message to a warning if the errno isn't 0 (success). The latter apparently means the transport encountered an EOF (shutdown) without the shut down handshake on the (D)TLS level. This happens quite often for otherwise normal DTLS connections. [1]: https://www.openssl.org/docs/man1.1.1/man3/SSL_get_error.html --- ext/dtls/gstdtlsconnection.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ext/dtls/gstdtlsconnection.c b/ext/dtls/gstdtlsconnection.c index 7e48ddd645..6b6e90c538 100644 --- a/ext/dtls/gstdtlsconnection.c +++ b/ext/dtls/gstdtlsconnection.c @@ -42,7 +42,12 @@ #include #include +#ifdef G_OS_WIN32 +#include +#else #include +#include +#endif GST_DEBUG_CATEGORY_STATIC (gst_dtls_connection_debug); #define GST_CAT_DEFAULT gst_dtls_connection_debug @@ -773,7 +778,19 @@ openssl_poll (GstDtlsConnection * self) GST_LOG_OBJECT (self, "SSL wants write"); break; case SSL_ERROR_SYSCALL:{ - GST_LOG_OBJECT (self, "SSL syscall error"); + gchar message[1024] = ""; + gint syserror; +#ifdef G_OS_WIN32 + syserror = WSAGetLastError (); + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, syserror, 0, message, + sizeof message, NULL); +#else + syserror = errno; + strerror_r (syserror, message, sizeof message); +#endif + GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, + syserror != 0 ? GST_LEVEL_WARNING : GST_LEVEL_LOG, + self, "SSL syscall error: errno %d: %s", syserror, message); break; } default: