From e4fa5074cac04f7ba5f8e86b4ce371a3af6a0961 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Wed, 4 Jan 2023 12:05:16 -0500
Subject: [PATCH] manager: call gnutls_global_init/deinit on Windows

We use the ShiftMediaProject repo for gnutls and it seems the
initialization is still required on Windows. This commit prevents
the client from having to do it.

Change-Id: Id358a61fe6d0f2809d840a18978567dc309963d8
---
 src/manager.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/manager.cpp b/src/manager.cpp
index 3edfbf3d55..e66f7cf986 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -758,6 +758,10 @@ Manager::init(const std::string& config_file)
         JAMI_ERR("Unable to initialize git transport %s", error ? error->message : "(unknown)");
     }
 
+#if defined _MSC_VER
+    gnutls_global_init();
+#endif
+
 #ifndef WIN32
     // Set the max number of open files.
     struct rlimit nofiles;
@@ -918,6 +922,10 @@ Manager::finish() noexcept
         if (pimpl_->ioContextRunner_.joinable())
             pimpl_->ioContextRunner_.join();
 
+#if defined _MSC_VER
+        gnutls_global_deinit();
+#endif
+
     } catch (const VoipLinkException& err) {
         JAMI_ERR("%s", err.what());
     }
@@ -2703,8 +2711,8 @@ Manager::addAccount(const std::map<std::string, std::string>& details, const std
     auto newAccount = accountFactory.createAccount(accountType, newAccountID);
     if (!newAccount) {
         JAMI_ERROR("Unknown {:s} param when calling addAccount(): {:s}",
-                 Conf::CONFIG_ACCOUNT_TYPE,
-                 accountType);
+                   Conf::CONFIG_ACCOUNT_TYPE,
+                   accountType);
         return "";
     }
 
-- 
GitLab