- Catch up to falloc() changes.

- PHOLD() before using a task structure on the stack.
 - Fix a LOR between the sleepq lock and thread lock in _intr_drain().
This commit is contained in:
Jeff Roberson 2011-04-26 07:30:52 +00:00
parent 37508ef3eb
commit 5bd186a65a
3 changed files with 14 additions and 5 deletions

View File

@ -746,7 +746,6 @@ intr_handler_source(void *cookie)
void
_intr_drain(int irq)
{
struct mtx *mtx;
struct intr_event *ie;
struct intr_thread *ithd;
struct thread *td;
@ -758,13 +757,21 @@ _intr_drain(int irq)
return;
ithd = ie->ie_thread;
td = ithd->it_thread;
/*
* We set the flag and wait for it to be cleared to avoid
* long delays with potentially busy interrupt handlers
* were we to only sample TD_AWAITING_INTR() every tick.
*/
thread_lock(td);
mtx = td->td_lock;
if (!TD_AWAITING_INTR(td)) {
ithd->it_flags |= IT_WAIT;
msleep_spin(ithd, mtx, "isync", 0);
while (ithd->it_flags & IT_WAIT) {
thread_unlock(td);
pause("idrain", 1);
thread_lock(td);
}
}
mtx_unlock_spin(mtx);
thread_unlock(td);
return;
}

View File

@ -92,7 +92,7 @@ get_unused_fd(void)
int error;
int fd;
error = falloc(curthread, &file, &fd);
error = falloc(curthread, &file, &fd, 0);
if (error)
return -error;
return fd;

View File

@ -160,9 +160,11 @@ flush_taskqueue(struct taskqueue *tq)
{
struct task flushtask;
PHOLD(curproc);
TASK_INIT(&flushtask, 0, _flush_fn, NULL);
taskqueue_enqueue(tq, &flushtask);
taskqueue_drain(tq, &flushtask);
PRELE(curproc);
}
static inline int