Fix: handle sys_futex() FUTEX_WAIT interrupted by signal
[urcu.git] / urcu.c
diff --git a/urcu.c b/urcu.c
index 94d1131e3dba6df7982a33def88f6ec3908c2bf2..e77306584d77f0fc012f6bfbae466452b3556b74 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -236,9 +236,22 @@ static void wait_gp(void)
 {
        /* Read reader_gp before read futex */
        smp_mb_master(RCU_MB_GROUP);
-       if (uatomic_read(&rcu_gp.futex) == -1)
-               futex_async(&rcu_gp.futex, FUTEX_WAIT, -1,
-                     NULL, NULL, 0);
+       if (uatomic_read(&rcu_gp.futex) != -1)
+               return;
+       while (futex_async(&rcu_gp.futex, FUTEX_WAIT, -1,
+                       NULL, NULL, 0)) {
+               switch (errno) {
+               case EWOULDBLOCK:
+                       /* Value already changed. */
+                       return;
+               case EINTR:
+                       /* Retry if interrupted by signal. */
+                       break;  /* Get out of switch. */
+               default:
+                       /* Unexpected error. */
+                       urcu_die(errno);
+               }
+       }
 }
 
 /*
This page took 0.022373 seconds and 4 git commands to generate.