diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-16 21:57:27 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-16 21:57:27 +0200 |
commit | ea4f56a537321c0f8352a7e97d62763564d78478 (patch) | |
tree | c8214c2a849eed552ed3f40e3357ff3a34da6ae1 | |
parent | 73710b6b23ac9a4a58f5a4c3b78be87c1bd22124 (diff) | |
download | fastd-ea4f56a537321c0f8352a7e97d62763564d78478.tar fastd-ea4f56a537321c0f8352a7e97d62763564d78478.zip |
Make sure we don't get interupted by signals when we can't handle them properly
-rw-r--r-- | src/fastd.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/fastd.c b/src/fastd.c index c4a9162..89b764d 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -35,6 +35,7 @@ #include <linux/if_tun.h> #include <net/if.h> #include <poll.h> +#include <pthread.h> #include <signal.h> #include <string.h> #include <sys/ioctl.h> @@ -231,7 +232,13 @@ static void fastd_send_type(fastd_context *ctx, fastd_peer *peer, uint8_t packet msg.msg_iov = iov; msg.msg_iovlen = buffer.len ? 2 : 1; - sendmsg(sockfd, &msg, 0); + int ret; + do { + ret = sendmsg(sockfd, &msg, 0); + } while (ret < 0 && errno == EINTR); + + if (ret < 0) + pr_warn_errno(ctx, "sendmsg"); fastd_buffer_free(buffer); } @@ -668,12 +675,18 @@ int main(int argc, char *argv[]) { maintenance(&ctx); + sigset_t set, oldset; + sigemptyset(&set); + pthread_sigmask(SIG_SETMASK, &set, &oldset); + if (sighup) { sighup = false; fastd_reconfigure(&ctx, &conf); } handle_resolv_returns(&ctx); + + pthread_sigmask(SIG_SETMASK, &oldset, NULL); } on_down(&ctx); |