From ea4f56a537321c0f8352a7e97d62763564d78478 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 16 Apr 2012 21:57:27 +0200 Subject: Make sure we don't get interupted by signals when we can't handle them properly --- src/fastd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 #include #include +#include #include #include #include @@ -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); -- cgit v1.2.3