pmc: avoid potential race on shutdown

Clear shutdown flag first, conservatively allow 5ms for all hardclock consumers to
see flag before drainining
This commit is contained in:
Matt Macy 2018-05-20 19:35:24 +00:00
parent 6cff19a3be
commit f2daab2c8f

View file

@ -872,18 +872,20 @@ pmclog_close(struct pmc_owner *po)
pmclog_process_closelog(po);
mtx_lock(&pmc_kthread_mtx);
/*
* Initiate shutdown: no new data queued,
* thread will close file on last block.
*/
po->po_flags |= PMC_PO_SHUTDOWN;
/* give time for all to see */
DELAY(50);
/*
* Schedule the current buffer.
*/
pmclog_schedule_all(po);
wakeup_one(po);
/*
* Initiate shutdown: no new data queued,
* thread will close file on last block.
*/
po->po_flags |= PMC_PO_SHUTDOWN;
mtx_unlock(&pmc_kthread_mtx);
return (0);