diff options
author | srinivas%netscape.com <devnull@localhost> | 2000-02-12 23:00:03 +0000 |
---|---|---|
committer | srinivas%netscape.com <devnull@localhost> | 2000-02-12 23:00:03 +0000 |
commit | 17cfe4f816c118bc587b23003ab303a58c169f89 (patch) | |
tree | 669337feee210a43b8593f5ce2173cb0be1a1760 | |
parent | fcc1170547d8944ebc3278bf01429738a2720040 (diff) | |
download | nspr-hg-17cfe4f816c118bc587b23003ab303a58c169f89.tar.gz |
The job lock should be held when updating status field. The PR_POLL_ERR
error, from PR_Poll, should be handled.
-rw-r--r-- | pr/src/misc/prtpool.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pr/src/misc/prtpool.c b/pr/src/misc/prtpool.c index eb5908f0..7d3b196b 100644 --- a/pr/src/misc/prtpool.c +++ b/pr/src/misc/prtpool.c @@ -138,6 +138,18 @@ static void notify_ioq(PRThreadPool *tp); static void notify_timerq(PRThreadPool *tp); /* + * locks are acquired in the following order + * + * tp->ioq.lock,tp->timerq.lock + * | + * V + * tp->jobq->lock + * | + * V + * jobp->jlock + */ + +/* * worker thread function */ static void wstart(void *arg) @@ -233,7 +245,9 @@ add_to_jobq(PRThreadPool *tp, PRJob *jobp) #else PR_Lock(tp->jobq.lock); PR_APPEND_LINK(&jobp->links,&tp->jobq.list); + PR_Lock(jobp->jlock); jobp->status = JOB_QUEUED; + PR_Unlock(jobp->jlock); tp->jobq.cnt++; if ((tp->idle_threads < tp->jobq.cnt) && (tp->current_threads < tp->max_threads)) { @@ -391,6 +405,7 @@ PRIntervalTime now; jobp = polljobs[index]; if ((revents & PR_POLL_NVAL) || /* busted in all cases */ + (revents & PR_POLL_ERR) || ((events & PR_POLL_WRITE) && (revents & PR_POLL_HUP))) { /* write op & hup */ PR_Lock(tp->ioq.lock); @@ -403,6 +418,8 @@ PRIntervalTime now; jobp->iod->error = PR_BAD_DESCRIPTOR_ERROR; else if (PR_POLL_HUP & revents) jobp->iod->error = PR_CONNECT_RESET_ERROR; + else + jobp->iod->error = PR_IO_ERROR; /* * add to jobq |