libsystemd: ignore both EINTR and EAGAIN

This commit is contained in:
Yu Watanabe
2021-11-30 03:33:55 +09:00
parent 8add30a03c
commit b3d06b9226
3 changed files with 14 additions and 12 deletions

View File

@@ -149,7 +149,7 @@ static int bus_socket_write_auth(sd_bus *b) {
}
if (k < 0)
return errno == EAGAIN ? 0 : -errno;
return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
iovec_advance(b->auth_iovec, &b->auth_index, (size_t) k);
return 1;
@@ -301,7 +301,7 @@ static int verify_external_token(sd_bus *b, const char *p, size_t l) {
uid_t u;
int r;
/* We don't do any real authentication here. Instead, if
/* We don't do any real authentication here. Instead, if
* the owner of this bus wanted authentication they should have
* checked SO_PEERCRED before even creating the bus object. */
@@ -565,10 +565,11 @@ static int bus_socket_read_auth(sd_bus *b) {
} else
handle_cmsg = true;
}
if (k == -EAGAIN)
return 0;
if (k < 0)
if (k < 0) {
if (ERRNO_IS_TRANSIENT(k))
return 0;
return (int) k;
}
if (k == 0) {
if (handle_cmsg)
cmsg_close_all(&mh); /* paranoia, we shouldn't have gotten any fds on EOF */
@@ -1073,7 +1074,7 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) {
}
if (k < 0)
return errno == EAGAIN ? 0 : -errno;
return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
*idx += (size_t) k;
return 1;
@@ -1230,10 +1231,11 @@ int bus_socket_read_message(sd_bus *bus) {
} else
handle_cmsg = true;
}
if (k == -EAGAIN)
return 0;
if (k < 0)
if (k < 0) {
if (ERRNO_IS_TRANSIENT(k))
return 0;
return (int) k;
}
if (k == 0) {
if (handle_cmsg)
cmsg_close_all(&mh); /* On EOF we shouldn't have gotten an fd, but let's make sure */

View File

@@ -445,7 +445,7 @@ int device_monitor_receive_device(sd_device_monitor *m, sd_device **ret) {
buflen = recvmsg(m->sock, &smsg, 0);
if (buflen < 0) {
if (errno != EINTR)
if (ERRNO_IS_TRANSIENT(errno))
log_debug_errno(errno, "sd-device-monitor: Failed to receive message: %m");
return -errno;
}

View File

@@ -418,7 +418,7 @@ static void* thread_worker(void *p) {
length = recv(resolve->fds[REQUEST_RECV_FD], &buf, sizeof buf, 0);
if (length < 0) {
if (errno == EINTR)
if (ERRNO_IS_TRANSIENT(errno))
continue;
break;
@@ -847,7 +847,7 @@ _public_ int sd_resolve_process(sd_resolve *resolve) {
l = recv(resolve->fds[RESPONSE_RECV_FD], &buf, sizeof buf, 0);
if (l < 0) {
if (errno == EAGAIN)
if (ERRNO_IS_TRANSIENT(errno))
return 0;
return -errno;