Skip to content

Commit

Permalink
Handle "connection refused" when sending a uevent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bobhenz-jabil committed Sep 4, 2024
1 parent 659df15 commit 69adc52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/uevent_sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 69adc52

Please sign in to comment.