summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-05-31 06:10:25 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-05-31 06:11:31 +0200
commit6ed0948d5df69ff81404a702cfbebe3217fa2f90 (patch)
tree6ddaf5523639c2f6f81f479b12745a2f9926a52e /src
parent73f7d5048c0e2ad4817ad208de02adee73938ed0 (diff)
downloadfastd-6ed0948d5df69ff81404a702cfbebe3217fa2f90.tar
fastd-6ed0948d5df69ff81404a702cfbebe3217fa2f90.zip
Remove EINTR handling where signals are blocked anyways
Diffstat (limited to 'src')
-rw-r--r--src/async.c12
-rw-r--r--src/fastd.c5
-rw-r--r--src/random.c6
-rw-r--r--src/receive.c2
-rw-r--r--src/send.c10
-rw-r--r--src/tuntap.c8
6 files changed, 9 insertions, 34 deletions
diff --git a/src/async.c b/src/async.c
index a443cfe..c1c4802 100644
--- a/src/async.c
+++ b/src/async.c
@@ -102,20 +102,16 @@ void fastd_async_handle(void) {
.msg_iovlen = 1,
};
- while (recvmsg(ctx.async_rfd, &msg, MSG_PEEK) < 0) {
- if (errno != EINTR)
- exit_errno("fastd_async_handle: recvmsg");
- }
+ if (recvmsg(ctx.async_rfd, &msg, MSG_PEEK) < 0)
+ exit_errno("fastd_async_handle: recvmsg");
uint8_t buf[header.len] __attribute__((aligned(8)));
vec[1].iov_base = buf;
vec[1].iov_len = sizeof(buf);
msg.msg_iovlen = 2;
- while (recvmsg(ctx.async_rfd, &msg, 0) < 0) {
- if (errno != EINTR)
- exit_errno("fastd_async_handle: recvmsg");
- }
+ if (recvmsg(ctx.async_rfd, &msg, 0) < 0)
+ exit_errno("fastd_async_handle: recvmsg");
switch (header.type) {
case ASYNC_TYPE_RESOLVE_RETURN:
diff --git a/src/fastd.c b/src/fastd.c
index c129a3c..c7a5f1e 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -294,11 +294,6 @@ void fastd_close_all_fds(void) {
for (fd = 3; fd < maxfd; fd++) {
if (close(fd) < 0) {
- if (errno == EINTR) {
- fd--;
- continue;
- }
-
if (errno != EBADF)
pr_error_errno("close");
}
diff --git a/src/random.c b/src/random.c
index 72a238b..72e6c6a 100644
--- a/src/random.c
+++ b/src/random.c
@@ -53,12 +53,8 @@ void fastd_random_bytes(void *buffer, size_t len, bool secure) {
while (read_bytes < len) {
ssize_t ret = read(fd, ((char*)buffer)+read_bytes, len-read_bytes);
- if (ret < 0) {
- if (errno == EINTR)
- continue;
-
+ if (ret < 0)
exit_errno("unable to read from random device");
- }
read_bytes += ret;
}
diff --git a/src/receive.c b/src/receive.c
index a232eae..d954102 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -219,7 +219,7 @@ void fastd_receive(fastd_socket_t *sock) {
ssize_t len = recvmsg(sock->fd, &message, 0);
if (len <= 0) {
- if (len < 0 && errno != EINTR)
+ if (len < 0)
pr_warn_errno("recvmsg");
fastd_buffer_free(buffer);
diff --git a/src/send.c b/src/send.c
index c613fc6..9de0b3b 100644
--- a/src/send.c
+++ b/src/send.c
@@ -128,10 +128,7 @@ static void send_type(const fastd_socket_t *sock, const fastd_peer_address_t *lo
if (!msg.msg_controllen)
msg.msg_control = NULL;
- int ret;
- do {
- ret = sendmsg(sock->fd, &msg, 0);
- } while (ret < 0 && errno == EINTR);
+ int ret = sendmsg(sock->fd, &msg, 0);
if (ret < 0 && errno == EINVAL && msg.msg_controllen) {
pr_debug2("sendmsg failed, trying again without pktinfo");
@@ -142,10 +139,7 @@ static void send_type(const fastd_socket_t *sock, const fastd_peer_address_t *lo
msg.msg_control = NULL;
msg.msg_controllen = 0;
- do {
- ret = sendmsg(sock->fd, &msg, 0);
- } while (ret < 0 && errno == EINTR);
-
+ ret = sendmsg(sock->fd, &msg, 0);
}
if (ret < 0) {
diff --git a/src/tuntap.c b/src/tuntap.c
index b5a5df9..7f60caf 100644
--- a/src/tuntap.c
+++ b/src/tuntap.c
@@ -312,14 +312,8 @@ void fastd_tuntap_handle(void) {
buffer = fastd_buffer_alloc(max_len, conf.min_encrypt_head_space, conf.min_encrypt_tail_space);
ssize_t len = read(ctx.tunfd, buffer.data, max_len);
- if (len < 0) {
- if (errno == EINTR) {
- fastd_buffer_free(buffer);
- return;
- }
-
+ if (len < 0)
exit_errno("read");
- }
buffer.len = len;