From 8c7d541011a01dbb5ecaf26a63ea16ba6c15fced Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 21 Sep 2021 05:42:55 +0100 Subject: [PATCH] threadpool: SYNC timeout on netbsdBE NetBSD Big-Endian on an RPi 3 + uSD is very slow, increase the threadpool SYNC timeout a bit and normalize the task stop flow if it is exceeded. --- lib/misc/threadpool/threadpool.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/misc/threadpool/threadpool.c b/lib/misc/threadpool/threadpool.c index 27dae3058..40df5ba40 100644 --- a/lib/misc/threadpool/threadpool.c +++ b/lib/misc/threadpool/threadpool.c @@ -426,13 +426,13 @@ lws_threadpool_worker_sync(struct lws_pool *pool, } /* - * So tries times this is the maximum time between SYNC asking + * So "tries" times this is the maximum time between SYNC asking * for a callback on writable and actually getting it we are * willing to sit still for. * * If it is exceeded, we will stop the task. */ - abstime.tv_sec = time(NULL) + 2; + abstime.tv_sec = time(NULL) + 3; abstime.tv_nsec = 0; task->wanted_writeable_cb = 1; @@ -462,8 +462,9 @@ lws_threadpool_worker_sync(struct lws_pool *pool, __func__, pool->tp->name, task, task->name, lws_wsi_tag(task_to_wsi(task))); - state_transition(task, LWS_TP_STATUS_STOPPING); - goto done; + pthread_mutex_unlock(&pool->lock); /* ----------------- - pool unlock */ + lws_threadpool_dequeue_task(task); + return 1; /* destroyed task */ } continue; @@ -605,7 +606,10 @@ lws_threadpool_worker(void *d) } /* block until writable acknowledges */ then = lws_now_usecs(); - lws_threadpool_worker_sync(pool, task); + if (lws_threadpool_worker_sync(pool, task)) { + lwsl_notice("%s: Sync failed\n", __func__); + goto doneski; + } us_accrue(&task->acc_syncing, then); break; case LWS_TP_RETURN_FINISHED: