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);