From 129d080a8ac461a1a0e859f861d92f4e7ac0231b Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 14 Nov 2018 20:04:14 +0800 Subject: [PATCH] service: if we got POLLIN service it before checking timeout --- lib/core/service.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/core/service.c b/lib/core/service.c index be8b4fab4..00258fa21 100644 --- a/lib/core/service.c +++ b/lib/core/service.c @@ -936,9 +936,11 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, if (!context || context->being_destroyed1) return -1; - /* the socket we came to service timed out, nothing to do */ - if (lws_service_periodic_checks(context, pollfd, tsi) || !pollfd) + /* the case there's no pollfd to service, we just want to do periodic */ + if (!pollfd) { + lws_service_periodic_checks(context, pollfd, tsi); return -2; + } /* no, here to service a socket descriptor */ wsi = wsi_from_fd(context, pollfd->fd); @@ -1034,6 +1036,9 @@ handled: #endif pollfd->revents = 0; + /* check the timeout situation if we didn't in the last second */ + lws_service_periodic_checks(context, pollfd, tsi); + lws_pt_lock(pt, __func__); __lws_hrtimer_service(pt); lws_pt_unlock(pt);