mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-28 08:44:06 +02:00
handle all enqueued before waiting
This commit is contained in:
parent
e5bad9cf74
commit
1ebc52560d
@ -241,18 +241,19 @@ static inline void worker_listen(Worker* worker)
|
|||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
|
|
||||||
pthread_mutex_lock(&ctx->mutex);
|
pthread_mutex_lock(&ctx->mutex);
|
||||||
pthread_cond_wait(&ctx->cond, &ctx->mutex);
|
|
||||||
|
|
||||||
if (request_queue_size(&ctx->req_queue) == 0) {
|
if (request_queue_size(&ctx->req_queue) > 0) {
|
||||||
|
Client req;
|
||||||
|
request_queue_pop(&ctx->req_queue, &req);
|
||||||
pthread_mutex_unlock(&ctx->mutex);
|
pthread_mutex_unlock(&ctx->mutex);
|
||||||
|
|
||||||
|
worker_handle_request(worker, &req);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Client req;
|
pthread_cond_wait(&ctx->cond, &ctx->mutex);
|
||||||
request_queue_pop(&ctx->req_queue, &req);
|
|
||||||
pthread_mutex_unlock(&ctx->mutex);
|
|
||||||
|
|
||||||
worker_handle_request(worker, &req);
|
pthread_mutex_unlock(&ctx->mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user