[klibc] [klibc:master] ipconfig: Handle error events from poll
klibc-bot for Ben Hutchings
ben at decadent.org.uk
Sun Jun 4 16:48:09 PDT 2023
Commit-ID: 4ae6735c9f899815325a100a4019a7b385662bb4
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=4ae6735c9f899815325a100a4019a7b385662bb4
Author: Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Mon, 5 Jun 2023 00:16:26 +0200
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Mon, 5 Jun 2023 01:27:41 +0200
[klibc] ipconfig: Handle error events from poll
When poll returns events for a socket other than POLLRDNORM, such as
POLLERR, we do not read from the socket but keep polling on it. This
results in busy-polling while the error state persists.
In case some other event is returned, put the device into DEVST_ERROR
state for 1 second.
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/kinit/ipconfig/main.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index 32e3dd1f..d45be354 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -404,6 +404,12 @@ static void process_timeout_event(struct state *s, time_t now)
}
}
+static void process_error_event(struct state *s, time_t now)
+{
+ s->state = DEVST_ERROR;
+ s->expire = now + 1;
+}
+
static struct state *slist;
struct netdev *ifaces;
@@ -420,8 +426,11 @@ static int do_pkt_recv(int nr, struct pollfd *fds, time_t now)
for (i = 0, s = slist; s && nr; s = s->next) {
if (s->dev->pkt_fd != fds[i].fd)
continue;
- if (fds[i].revents & POLLRDNORM) {
- ret |= process_receive_event(s, now);
+ if (fds[i].revents) {
+ if (fds[i].revents & POLLRDNORM)
+ ret |= process_receive_event(s, now);
+ else
+ process_error_event(s, now);
nr--;
}
i++;
More information about the klibc
mailing list