From 3ca8625129813c3ee8c8c42d6af06a03e89f234d Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 14 Mar 2021 13:53:48 +0000 Subject: [PATCH] adopt: rejection should not loop with listen adoption --- lib/plat/unix/unix-service.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/plat/unix/unix-service.c b/lib/plat/unix/unix-service.c index 49d06920b..d5288de18 100644 --- a/lib/plat/unix/unix-service.c +++ b/lib/plat/unix/unix-service.c @@ -43,6 +43,8 @@ _lws_plat_service_forced_tsi(struct lws_context *context, int tsi) /* any socket with events to service? */ for (n = 0; n < (int)pt->fds_count; n++) { + lws_sockfd_type fd = pt->fds[n].fd; + if (!pt->fds[n].revents) continue; @@ -52,8 +54,9 @@ _lws_plat_service_forced_tsi(struct lws_context *context, int tsi) __func__, m); return -1; } - /* if something closed, retry this slot */ - if (m) + /* if something closed, retry this slot since may have been + * swapped with end fd */ + if (m && pt->fds[n].fd != fd) n--; }