summaryrefslogtreecommitdiff
path: root/src/libunixonacid/unixmessage_sender_flush.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-12-31 16:27:44 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-12-31 16:27:44 +0000
commit131a18f68dc73f208bb76a944fc6d42c86cfad3b (patch)
tree3f0d007b4d2932d2131723796289a70bf630d3ff /src/libunixonacid/unixmessage_sender_flush.c
parent9d417556de94429896d5496190b15caac659597e (diff)
downloadskalibs-131a18f68dc73f208bb76a944fc6d42c86cfad3b.tar.xz
Safe wrappers around sendmsg and recvmsg in unixmessage primitives
Diffstat (limited to 'src/libunixonacid/unixmessage_sender_flush.c')
-rw-r--r--src/libunixonacid/unixmessage_sender_flush.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c
index a115c58..6a0a04b 100644
--- a/src/libunixonacid/unixmessage_sender_flush.c
+++ b/src/libunixonacid/unixmessage_sender_flush.c
@@ -9,6 +9,7 @@
#include <sys/socket.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <errno.h>
#include <skalibs/uint.h>
#include <skalibs/diuint.h>
#include <skalibs/stralloc.h>
@@ -63,8 +64,14 @@ int unixmessage_sender_flush (unixmessage_sender_t *b)
((int *)CMSG_DATA(cp))[i] = fd < 0 ? -(fd+1) : fd ;
}
}
- if (sendmsg(b->fd, &hdr, MSG_NOSIGNAL) < (int)(len + (sizeof(unsigned int) << 1)))
- return -(int)(b->head-oldhead)-1 ;
+ for (;;)
+ {
+ register int r = sendmsg(b->fd, &hdr, MSG_NOSIGNAL) ;
+ if (r == -1 && errno == EINTR) continue ;
+ if (r < (int)(len + (sizeof(unsigned int) << 1)))
+ return -(int)(b->head-oldhead)-1 ;
+ break ;
+ }
#ifndef SKALIBS_HASANCILAUTOCLOSE
if (nfds)
{