Skip to content

Commit

Permalink
service: if we got POLLIN service it before checking timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Nov 14, 2018
1 parent 0647806 commit 129d080
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/core/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1034,6 +1036,9 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
#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);
Expand Down

0 comments on commit 129d080

Please sign in to comment.