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
This commit is contained in:
Jan Alexander Steffens (heftig) 2018-11-06 16:50:29 +01:00 committed by Sebastian Dröge
parent 51f0307900
commit b1509b1047

View file

@ -42,7 +42,12 @@
#include <openssl/err.h>
#include <openssl/ssl.h>
#ifdef G_OS_WIN32
#include <winsock2.h>
#else
#include <string.h>
#include <errno.h>
#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] = "<unknown>";
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: