diff options
Diffstat (limited to 'third_party/mongoose/mongoose.c')
-rw-r--r-- | third_party/mongoose/mongoose.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/third_party/mongoose/mongoose.c b/third_party/mongoose/mongoose.c index 24874e5..26e4077 100644 --- a/third_party/mongoose/mongoose.c +++ b/third_party/mongoose/mongoose.c @@ -4486,9 +4486,13 @@ get_socket(struct mg_context *ctx, struct socket *sp) #endif if (pthread_cond_timedwait(&ctx->empty_cond, &ctx->thr_mutex, &ts) != 0) { - /* Timeout! release the mutex and return */ - (void) pthread_mutex_unlock(&ctx->thr_mutex); - return (FALSE); + // Even if the wait timed out, it is not guaranteed that the condition + // predicate is actually false. + if (ctx->sq_head == ctx->sq_tail) { + /* Timeout! release the mutex and return */ + (void) pthread_mutex_unlock(&ctx->thr_mutex); + return (FALSE); + } } } assert(ctx->sq_head > ctx->sq_tail); |