Fix: handle sys_futex() FUTEX_WAIT interrupted by signal
[userspace-rcu.git] / urcu.c
diff --git a/urcu.c b/urcu.c
index 1d4bf7afb04030155f7cb88d4dcb2cf8e2518a66..c5abeafa06d3bd796a2148a1effdf90c2c959dd1 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -224,9 +224,22 @@ static void wait_gp(void)
 {
        /* Read reader_gp before read futex */
        smp_mb_master(RCU_MB_GROUP);
-       if (uatomic_read(&gp_futex) == -1)
-               futex_async(&gp_futex, FUTEX_WAIT, -1,
-                     NULL, NULL, 0);
+       if (uatomic_read(&gp_futex) != -1)
+               return;
+       while (futex_async(&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.023504 seconds and 4 git commands to generate.