]> git.proxmox.com Git - pve-cluster.git/commitdiff
correctly handle EAGAIN
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 6 Dec 2012 07:28:53 +0000 (08:28 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 6 Dec 2012 07:28:53 +0000 (08:28 +0100)
We simply sleep 1ms and repeat sendmsg (not perfect, but good enough).

data/PVE/IPCC.xs

index 6c27ad5b8b8c0705ba26f731ee6575a77d697ce3..9d2c6d95547cbe0e532819bacb16537324e616ff 100644 (file)
@@ -20,6 +20,7 @@
 #error "SCM_RIGHTS undefined"
 #endif 
 
+/* interface to pmxcfs (libqb) */
 #include <sys/syslog.h>
 #include <qb/qbdefs.h>
 #include <qb/qbutil.h>
@@ -158,10 +159,20 @@ CODE:
        h->cmsg_type = SCM_RIGHTS;
        *((int*)CMSG_DATA(h)) = send_me_fd;
 
+       int repeat;
        do {
+               repeat = 0;
                ret = sendmsg(sock_fd, &msg, 0);
-       } while (ret < 0 && errno == EINTR);
-
+               if (ret < 0) {
+                       if (errno == EINTR) {
+                               repeat = 1;
+                       } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
+                               repeat = 1;
+                               usleep(1000);
+                       }
+               }
+       } while (repeat);
+       
        RETVAL = ret;
 }
 OUTPUT: RETVAL