+26 Aug 2013: Wouter
+ - More fixes for bug#519: for the threaded case test if the bg
+ thread has been killed, on ub_ctx_delete, to avoid hangs.
+
22 Aug 2013: Wouter
- more fixes that I overlooked.
- review fixes from Willem.
#include "services/localzone.h"
#include "services/cache/infra.h"
#include "services/cache/rrset.h"
+#ifdef HAVE_PTHREAD
+#include <signal.h>
+#endif
#if defined(UB_ON_WINDOWS) && defined (HAVE_WINDOWS_H)
#include <windows.h>
context_query_delete(q);
}
-void
-ub_ctx_delete(struct ub_ctx* ctx)
+/** stop the bg thread */
+static void ub_stop_bg(struct ub_ctx* ctx)
{
- struct alloc_cache* a, *na;
- if(!ctx) return;
/* stop the bg thread */
lock_basic_lock(&ctx->cfglock);
if(ctx->created_bg) {
else {
lock_basic_unlock(&ctx->cfglock);
}
+}
+
+void
+ub_ctx_delete(struct ub_ctx* ctx)
+{
+ struct alloc_cache* a, *na;
+ int do_stop = 1;
+ if(!ctx) return;
+ /* see if bg thread is created and if threads have been killed */
+ /* no locks, because those may be held by terminated threads */
+ /* for processes the read pipe is closed and we see that on read */
+#ifdef HAVE_PTHREAD
+ if(ctx->created_bg && ctx->dothread) {
+ if(pthread_kill(ctx->bg_tid, 0) == ESRCH) {
+ /* thread has been killed */
+ do_stop = 0;
+ }
+ }
+#endif /* HAVE_PTHREAD */
+ if(do_stop)
+ ub_stop_bg(ctx);
modstack_desetup(&ctx->mods, ctx->env);
a = ctx->alloc_list;