Hi Thierry,

could you please take a look at this bind-dyndb-ldap patch? I was trying
to fix https://fedorahosted.org/bind-dyndb-ldap/ticket/149

I wasn't able to reproduce the issue, but I think the problem is fixed
now. Petr Spacek was helping me with this, but I think it would be good
if you could take a look as well.

We were able to identify two causes: a) isc_thread_create fails and
ldap_inst->watcher is undefined (fixed by setting it to 0) and b) the
thread terminates for some reason (i.e. some checks fail) and then a
signal can't be sent to it. This was addressed by removing the REQUIRE
and logging an error instead.


Tomas Krizek

From b801fb06a77f2ec8867884bc769d5bb1db0e1c2e Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tkri...@redhat.com>
Date: Mon, 19 Dec 2016 12:39:07 +0100
Subject: [PATCH] handle termination of syncrepl watcher thread

In some cases, the thread could have been already terminated and
sending a signal to the thread using pthread_kill() would result in an
error. Now if the thread has already been terminated for some reason,
only an error message is logged.

 src/ldap_helper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index ad6e417..f4c1811 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -643,6 +643,7 @@ new_ldap_instance(isc_mem_t *mctx, const char *db_name,
 	result = isc_thread_create(ldap_syncrepl_watcher, ldap_inst,
 	if (result != ISC_R_SUCCESS) {
+		ldap_inst->watcher = 0;
 		log_error("Failed to create syncrepl watcher thread");
 		goto cleanup;
@@ -683,7 +684,10 @@ destroy_ldap_instance(ldap_instance_t **ldap_instp)
 		 * We use SIGUSR1 to not to interfere with any signal
 		 * used by BIND itself.
-		REQUIRE(pthread_kill(ldap_inst->watcher, SIGUSR1) == 0);
+		if (pthread_kill(ldap_inst->watcher, SIGUSR1) != 0) {
+			log_error("unable to send signal to syncrepl watcher thread "
+					  "(already terminated?)");
+		}
 		RUNTIME_CHECK(isc_thread_join(ldap_inst->watcher, NULL)
 			      == ISC_R_SUCCESS);
 		ldap_inst->watcher = 0;

Manage your subscription for the Freeipa-devel mailing list:
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to