From 686aac46890bd4f14217924865886079955033d7 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 16 Sep 2021 02:06:41 -0400 Subject: [PATCH] [input] pthread_cond_wait when no timeout --- src/lib/in.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/in.c b/src/lib/in.c index 568013325..ebfbfde31 100644 --- a/src/lib/in.c +++ b/src/lib/in.c @@ -1818,12 +1818,16 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){ } pthread_mutex_lock(&ictx->ilock); while(!ictx->ivalid){ - if(pthread_cond_timedwait(&ictx->icond, &ictx->ilock, ts)){ - if(errno == ETIMEDOUT){ - return 0; + if(ts == NULL){ + pthread_cond_wait(&ictx->icond, &ictx->ilock); + }else{ + if(pthread_cond_timedwait(&ictx->icond, &ictx->ilock, ts)){ + if(errno == ETIMEDOUT){ + return 0; + } + inc_input_errors(ictx); + return (uint32_t)-1; } - inc_input_errors(ictx); - return (uint32_t)-1; } } memcpy(ni, &ictx->inputs[ictx->iread], sizeof(*ni)); @@ -1849,7 +1853,6 @@ uint32_t notcurses_get(notcurses* nc, const struct timespec* ts, ncinput* ni){ int notcurses_getvec(notcurses* n, const struct timespec* ts, ncinput* ni, int vcount){ for(int v = 0 ; v < vcount ; ++v){ - // FIXME need to manage ts; right now, we could delay up to ts * vcount! uint32_t u = notcurses_get(n, ts, &ni[v]); if(u == (uint32_t)-1){ if(v == 0){