diff options
Diffstat (limited to 'mail/dbmail/files/patch-0014-Refactor-deprecared-functions')
-rw-r--r-- | mail/dbmail/files/patch-0014-Refactor-deprecared-functions | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/mail/dbmail/files/patch-0014-Refactor-deprecared-functions b/mail/dbmail/files/patch-0014-Refactor-deprecared-functions new file mode 100644 index 000000000000..a40f72cc87c2 --- /dev/null +++ b/mail/dbmail/files/patch-0014-Refactor-deprecared-functions @@ -0,0 +1,123 @@ +From 30e4904b6baf5c3f00d4b096f5b51cfbb69958d0 Mon Sep 17 00:00:00 2001 +From: Alan Hicks <ahicks@p-o.co.uk> +Date: Wed, 12 Oct 2016 16:56:22 +0100 +Subject: [PATCH 14/33] Refactor deprecared functions + +--- + src/modules/authldap.c | 44 ++++++++++++++++++++------------------------ + 1 file changed, 20 insertions(+), 24 deletions(-) + +diff --git src/modules/authldap.c src/modules/authldap.c +index 3f43a56..bbe553b 100644 +--- src/modules/authldap.c ++++ src/modules/authldap.c +@@ -28,7 +28,23 @@ + + extern char configFile[PATH_MAX]; + +-GStaticPrivate ldap_conn_key; ++/* ++ signal-safe releasing of thread-local ldap connection ++*/ ++static void authldap_free(gpointer data) ++{ ++ LDAP *c = (LDAP *)data; ++ struct sigaction act, oldact; ++ ++ memset(&act, 0, sizeof(act)); ++ memset(&oldact, 0, sizeof(oldact)); ++ act.sa_handler = SIG_IGN; ++ sigaction(SIGPIPE, &act, &oldact); ++ ldap_unbind(c); ++ sigaction(SIGPIPE, &oldact, 0); ++} ++ ++static GPrivate ldap_conn_key = G_PRIVATE_INIT (authldap_free); + static GOnce ldap_conn_once = G_ONCE_INIT; + static int authldap_connect(void); + +@@ -105,7 +121,6 @@ static void __auth_get_config(void) + */ + static gpointer authldap_once(gpointer UNUSED data) + { +- g_static_private_init(&ldap_conn_key); + __auth_get_config(); + return (gpointer)NULL; + } +@@ -120,7 +135,7 @@ static gpointer authldap_once(gpointer UNUSED data) + */ + static LDAP * ldap_con_get(void) + { +- LDAP * ld = (LDAP *)g_static_private_get(&ldap_conn_key); ++ LDAP * ld = (LDAP *)g_private_get(&ldap_conn_key); + if (ld) { + TRACE(TRACE_DEBUG, "connection [%p]", ld); + return ld; +@@ -136,7 +151,7 @@ static LDAP * ldap_con_get(void) + + switch (err) { + case LDAP_SUCCESS: +- ld = (LDAP *)g_static_private_get(&ldap_conn_key); ++ ld = (LDAP *)g_private_get(&ldap_conn_key); + TRACE(TRACE_DEBUG, "connection [%p]", ld); + break; + case LDAP_SERVER_DOWN: +@@ -144,7 +159,6 @@ static LDAP * ldap_con_get(void) + sleep(1); // reconnect failed. wait before trying again + break; + default: +- // Includes timeouts etc. Should probably refactor. + TRACE(TRACE_ERR, "LDAP error(%d): %s", err, ldap_err2string(err)); + sleep(1); + break; +@@ -158,22 +172,6 @@ static LDAP * ldap_con_get(void) + } + + /* +- signal-safe releasing of thread-local ldap connection +-*/ +-static void authldap_free(gpointer data) +-{ +- LDAP *c = (LDAP *)data; +- struct sigaction act, oldact; +- +- memset(&act, 0, sizeof(act)); +- memset(&oldact, 0, sizeof(oldact)); +- act.sa_handler = SIG_IGN; +- sigaction(SIGPIPE, &act, &oldact); +- ldap_unbind(c); +- sigaction(SIGPIPE, &oldact, 0); +-} +- +-/* + * auth_ldap_bind() + * + * Bind to server using config credentials +@@ -247,7 +245,7 @@ static int authldap_connect(void) + if (strncasecmp(_ldap_cfg.referrals, "no", 2) == 0) + ldap_set_option(_ldap_conn, LDAP_OPT_REFERRALS, 0); + +- g_static_private_set(&ldap_conn_key, _ldap_conn, (GDestroyNotify)authldap_free); ++ g_private_replace(&ldap_conn_key, _ldap_conn); + + return auth_ldap_bind(); + } +@@ -289,7 +287,6 @@ static LDAPMessage * authldap_search(const gchar *query) + TRACE(TRACE_WARNING, "LDAP gone away: %s. Trying again(%d/%d).", ldap_err2string(err), c, c_tries); + break; + default: +- // Includes timeouts etc. Should probably refactor. + TRACE(TRACE_ERR, "LDAP error(%d): %s. Trying again (%d/%d).", err, ldap_err2string(err), c, c_tries); + break; + } +@@ -634,7 +631,6 @@ int auth_connect(void) + } + int auth_disconnect(void) + { +- g_static_private_free(&ldap_conn_key); + return 0; + } + +-- +2.10.1 (Apple Git-78) + |