diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-11-02 21:39:30 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-11-02 21:39:30 +0100 |
commit | 4c05d129e20a90a2aa25d2ad947d920f5e24a1ee (patch) | |
tree | 23c3ca544f59c96fcc303323eec3ad89d1346c7d /sys/src/9/port/qlock.c | |
parent | b2ba90e7b6b0fc0941a2061ab038917861887f2d (diff) |
eqlock: fix postnote/qunlock race
Diffstat (limited to 'sys/src/9/port/qlock.c')
-rw-r--r-- | sys/src/9/port/qlock.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/sys/src/9/port/qlock.c b/sys/src/9/port/qlock.c index d41768435..ece5488b1 100644 --- a/sys/src/9/port/qlock.c +++ b/sys/src/9/port/qlock.c @@ -42,28 +42,22 @@ eqlock(QLock *q) error(Eintr); } rwstats.qlockq++; - p = q->tail; if(p == 0) q->head = up; else p->qnext = up; q->tail = up; - + up->eql = q; up->qnext = 0; up->qpc = getcallerpc(&q); up->state = Queueing; - - lock(&up->eqlock); - up->eql = q; - unlock(&up->eqlock); - unlock(&q->use); - sched(); - if(up->notepending){ up->notepending = 0; + if(up->eql == q) + qunlock(q); error(Eintr); } } @@ -96,6 +90,7 @@ qlock(QLock *q) else p->qnext = up; q->tail = up; + up->eql = 0; up->qnext = 0; up->state = Queueing; up->qpc = getcallerpc(&q); @@ -128,12 +123,6 @@ qunlock(QLock *q) getcallerpc(&q)); p = q->head; if(p){ - if(p->eql){ - lock(&p->eqlock); - if(p->eql == q) - p->eql = 0; - unlock(&p->eqlock); - } q->head = p->qnext; if(q->head == 0) q->tail = 0; |