mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-27 16:24:07 +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_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);
|
||||
|
||||
worker_handle_request(worker, &req);
|
||||
continue;
|
||||
}
|
||||
|
||||
Client req;
|
||||
request_queue_pop(&ctx->req_queue, &req);
|
||||
pthread_mutex_unlock(&ctx->mutex);
|
||||
pthread_cond_wait(&ctx->cond, &ctx->mutex);
|
||||
|
||||
worker_handle_request(worker, &req);
|
||||
pthread_mutex_unlock(&ctx->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user