From 3fc95726c4065a4b38d3fffa570f94db07faba91 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 24 Sep 2004 20:28:00 +0000 Subject: [PATCH] Protect fdc->flags within the worker thread, too. Use kthread_exit() instead of falling through the end of the worker thread's main function. Since kthread_exit() wakeup(9)s everyone sleeping on the thread handle, drop the superfluous wakeup() call. --- sys/dev/fdc/fdc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index e44f03019d8..6b179da1723 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -1140,8 +1140,10 @@ fdc_thread(void *arg) fdc = arg; int i; + mtx_lock(&fdc->fdc_mtx); fdc->flags |= FDC_KTHREAD_ALIVE; while ((fdc->flags & FDC_KTHREAD_EXIT) == 0) { + mtx_unlock(&fdc->fdc_mtx); i = fdc_worker(fdc); if (i && debugflags & 0x20) { if (fdc->bp != NULL) { @@ -1151,9 +1153,12 @@ fdc_thread(void *arg) printf("Retry line %d\n", retry_line); } fdc->retry += i; + mtx_lock(&fdc->fdc_mtx); } fdc->flags &= ~(FDC_KTHREAD_EXIT | FDC_KTHREAD_ALIVE); - wakeup(&fdc->fdc_thread); + mtx_unlock(&fdc->fdc_mtx); + + kthread_exit(0); } /*