From 69adc524a60c2628571ff9a1a520b49e5c7dbfa1 Mon Sep 17 00:00:00 2001 From: Bob Henz Date: Tue, 3 Sep 2024 15:24:13 -0400 Subject: [PATCH] Handle "connection refused" when sending a uevent This error was already being handled on the `connect` call right above these changes, but was being handled on the call to `sendmsg`. Depending on the timing it was possible for the `connect` call to succeed while the `sendmsg` call failed with an ECONNREFUSED error leading to the test crashing from the abort call. --- src/uevent_sender.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/uevent_sender.c b/src/uevent_sender.c index a9e3b5b..e9b2888 100644 --- a/src/uevent_sender.c +++ b/src/uevent_sender.c @@ -100,8 +100,14 @@ sendmsg_one(struct iovec *iov, size_t iov_len, const char *path) const struct msghdr msg = { .msg_name = &event_addr, .msg_iov = iov, .msg_iovlen = iov_len }; ssize_t count = sendmsg(fd, &msg, 0); if (count < 0) { - perror("uevent_sender sendmsg_one: sendmsg failed"); - abort(); + if (errno == ECONNREFUSED) { + /* client side closed its monitor underneath us, so clean up and ignore */ + unlink(event_addr.sun_path); + close(fd); + return; + } + perror("uevent_sender sendmsg_one: sendmsg failed"); + abort(); } /* printf("passed %zi bytes to event socket %s\n", count, path); */ close(fd);