fixed bug with dynamic poll stall;
This commit is contained in:
parent
d90a188e78
commit
5e1068290c
15
lib/queue.c
15
lib/queue.c
@ -261,7 +261,7 @@ static void *__poll_thread(void *poll)
|
||||
case USR_MSG:
|
||||
/* schedule new task for poll - increase or decrease */
|
||||
pthread_rwlock_rdlock(&(p->stats_lock));
|
||||
if(pth_queue_length(p->queue) > p->sleep_value) {
|
||||
if((pth_queue_length(p->queue) + 1 /* since we take a job */) >= p->sleep_value) {
|
||||
memset(&sysbuf, 0, sizeof(pth_msg_t));
|
||||
pth_queue_add(p->queue, &sysbuf, POLL_INCREASE);
|
||||
} else if((pth_queue_length(p->queue) > p->sleep_value) && (p->sleep_value > 1)) {
|
||||
@ -274,7 +274,7 @@ static void *__poll_thread(void *poll)
|
||||
break;
|
||||
case POLL_DECREASE:
|
||||
pthread_rwlock_rdlock(&(p->stats_lock));
|
||||
if(p->poll_value > 1) r = 1; /* exit now */
|
||||
if(p->poll_value > 2) r = 1; /* exit now */
|
||||
pthread_rwlock_unlock(&(p->stats_lock));
|
||||
if(r) {
|
||||
pthread_rwlock_wrlock(&(p->stats_lock));
|
||||
@ -356,6 +356,17 @@ int pth_dqtpoll_init(pth_dqtpoll_t *tpoll, int (*jobdata_callback)(void *))
|
||||
ndata->myid = 0;
|
||||
ndata->pthrd = tpoll;
|
||||
if(pthread_create(&(poll[0]), NULL, __poll_thread, ndata)) {
|
||||
__eadd:
|
||||
pthread_rwlock_destroy(&(tpoll->stats_lock));
|
||||
goto __enomem;
|
||||
}
|
||||
/* second thread initiation */
|
||||
ndata = malloc(sizeof(struct __pthrd_data));
|
||||
if(!ndata) goto __eadd;
|
||||
idx_reserve(idx, 1);
|
||||
ndata->myid = 1;
|
||||
ndata->pthrd = tpoll;
|
||||
if(pthread_create(&(poll[1]), NULL, __poll_thread, ndata)) {
|
||||
pthread_rwlock_destroy(&(tpoll->stats_lock));
|
||||
goto __enomem;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user