Only wake up the logwatcher if it is running

This fixes a use-after-destroy of the logwather condition variable
reported in #19
parent 154fe30b
......@@ -5142,7 +5142,8 @@ fellow_logs_rewrite(struct fellow_fd *ffd,
AZ(pthread_mutex_lock(&ffd->logmtx));
ffd->rewriting = 0;
AZ(pthread_cond_broadcast(&ffd->watcher_cond));
if (ffd->watcher_running)
AZ(pthread_cond_broadcast(&ffd->watcher_cond));
AZ(pthread_mutex_unlock(&ffd->logmtx));
ffd->diag("... done: %fs\n", VTIM_mono() - t0);
}
......@@ -5521,7 +5522,7 @@ fellow_logwatcher_check(struct fellow_fd *ffd)
DBG("need %s", flw_need_s[need]);
AZ(pthread_mutex_lock(&ffd->logmtx));
if (ffd->phase == FP_OPEN)
if (ffd->phase == FP_OPEN && ffd->watcher_running)
AZ(pthread_cond_broadcast(&ffd->watcher_cond));
AZ(pthread_mutex_unlock(&ffd->logmtx));
}
......@@ -5554,8 +5555,8 @@ fellow_logwatcher_fini(struct fellow_fd *ffd)
{
CHECK_OBJ_NOTNULL(ffd, FELLOW_FD_MAGIC);
ffd->watcher_running = 0;
AZ(pthread_mutex_lock(&ffd->logmtx));
ffd->watcher_running = 0;
AZ(pthread_cond_broadcast(&ffd->watcher_cond));
AZ(pthread_mutex_unlock(&ffd->logmtx));
AZ(pthread_join(ffd->watcher_thread, NULL));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment