From 485ec759dca009f45cd791fa0c3b102be7c44abf Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Thu, 15 Jun 2017 12:28:43 -0400
Subject: [PATCH] contrib: fix random crash due to pjproject assert

Many functions in pjproject check for calling thread
and assert if this one is not previously registered
by the application.
This is the case of pj_log and this function can be called anywhere
at anytime, as our gnutls patch uses it for logging TLS error.
Our log function in our patch has not to be done as it calls
a log register function reserved for the final application, not library.
As a result of this, our tls session code, where a thread
is not registered to pjproject, may call pj_log a causes
an application.

This patch removes the logging stuff into our gnutls pjproject patch.
If logging needed, it must be implemented by the Ring daemon code
with ad-hoc automatic thread registration.

Change-Id: If8f9d86258473ac43c0456b514cc3a078fc18fd2
---
 contrib/src/pjproject/gnutls.patch | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/contrib/src/pjproject/gnutls.patch b/contrib/src/pjproject/gnutls.patch
index 12077dc926..86ecc0c97f 100644
--- a/contrib/src/pjproject/gnutls.patch
+++ b/contrib/src/pjproject/gnutls.patch
@@ -469,7 +469,7 @@ new file mode 100644
 index 0000000..37bcaba
 --- /dev/null
 +++ b/pjlib/src/pj/ssl_sock_gtls.c
-@@ -0,0 +1,2887 @@
+@@ -0,0 +1,2877 @@
 +/* $Id$ */
 +/*
 + * Copyright (C) 2014-2016 Savoir-faire Linux. (https://www.savoirfairelinux.com)
@@ -926,13 +926,6 @@ index 0000000..37bcaba
 +}
 +
 +
-+/* GnuTLS way of reporting internal operations. */
-+static void tls_print_logs(int level, const char* msg)
-+{
-+    PJ_LOG(3, (THIS_FILE, "GnuTLS [%d]: %s", level, msg));
-+}
-+
-+
 +/* Initialize GnuTLS. */
 +static pj_status_t tls_init(void)
 +{
@@ -948,9 +941,6 @@ index 0000000..37bcaba
 +    if (ret < 0)
 +        return tls_status_from_err(NULL, ret);
 +
-+    gnutls_global_set_log_level(GNUTLS_LOG_LEVEL);
-+    gnutls_global_set_log_function(tls_print_logs);
-+
 +    /* Init available ciphers */
 +    if (!tls_available_ciphers) {
 +        unsigned int i;
-- 
GitLab