Fix: handle sys_futex() FUTEX_WAIT interrupted by signal
[userspace-rcu.git] / urcu-qsbr.c
index 1a94efa61a47fc48e12f9fc671b7c147d29382b4..52cb04aee9ff1b1b5a7b2caef45d6d5b5317ba77 100644 (file)
@@ -125,9 +125,22 @@ static void wait_gp(void)
 {
        /* Read reader_gp before read futex */
        cmm_smp_rmb();
-       if (uatomic_read(&gp_futex) == -1)
-               futex_noasync(&gp_futex, FUTEX_WAIT, -1,
-                     NULL, NULL, 0);
+       if (uatomic_read(&gp_futex) != -1)
+               return;
+       while (futex_noasync(&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.023174 seconds and 4 git commands to generate.