<div dir="ltr"><div>Merged in master, stable-2.6 and stable-2.5. Thanks!</div><div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 6, 2015 at 5:28 PM, Mathieu Desnoyers <span dir="ltr"><<a href="mailto:mathieu.desnoyers@efficios.com" target="_blank">mathieu.desnoyers@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">We need to handle EINTR returned by sys_futex() FUTEX_WAIT, otherwise a<br>
signal interrupting this system call could make sys_futex return too<br>
early, and therefore cause a synchronization issue.<br>
<br>
</span><span class="">Signed-off-by: Mathieu Desnoyers <<a href="mailto:mathieu.desnoyers@efficios.com">mathieu.desnoyers@efficios.com</a>><br>
---<br>
</span> src/common/futex.c | 37 ++++++++++++++++++++++++++++---------<br>
 1 file changed, 28 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/common/futex.c b/src/common/futex.c<br>
index 7f07b11..0781867 100644<br>
--- a/src/common/futex.c<br>
+++ b/src/common/futex.c<br>
@@ -55,8 +55,11 @@ void futex_wait_update(int32_t *futex, int active)<br>
 {<br>
        if (active) {<br>
                uatomic_set(futex, 1);<br>
-               futex_async(futex, FUTEX_WAKE,<br>
-                               INT_MAX, NULL, NULL, 0);<br>
+               if (futex_async(futex, FUTEX_WAKE,<br>
+                               INT_MAX, NULL, NULL, 0) < 0) {<br>
+                       PERROR("futex_async");<br>
+                       abort();<br>
+               }<br>
        } else {<br>
                uatomic_set(futex, 0);<br>
        }<br>
@@ -84,10 +87,23 @@ void futex_nto1_wait(int32_t *futex)<br>
 {<br>
        cmm_smp_mb();<br>
<br>
-       if (uatomic_read(futex) == -1) {<br>
-               futex_async(futex, FUTEX_WAIT, -1, NULL, NULL, 0);<br>
+       if (uatomic_read(futex) != -1)<br>
+               goto end;<br>
+       while (futex_async(futex, FUTEX_WAIT, -1, NULL, NULL, 0)) {<br>
<span class="">+               switch (errno) {<br>
+               case EWOULDBLOCK:<br>
+                       /* Value already changed. */<br>
</span>+                       goto end;<br>
<span class="">+               case EINTR:<br>
+                       /* Retry if interrupted by signal. */<br>
+                       break;  /* Get out of switch. */<br>
+               default:<br>
+                       /* Unexpected error. */<br>
</span>+                       PERROR("futex_async");<br>
+                       abort();<br>
+               }<br>
        }<br>
-<br>
+end:<br>
        DBG("Futex n to 1 wait done");<br>
 }<br>
<br>
@@ -97,10 +113,13 @@ void futex_nto1_wait(int32_t *futex)<br>
 LTTNG_HIDDEN<br>
 void futex_nto1_wake(int32_t *futex)<br>
 {<br>
-       if (caa_unlikely(uatomic_read(futex) == -1)) {<br>
-               uatomic_set(futex, 0);<br>
-               futex_async(futex, FUTEX_WAKE, 1, NULL, NULL, 0);<br>
+       if (caa_unlikely(uatomic_read(futex) != -1))<br>
+               goto end;<br>
+       uatomic_set(futex, 0);<br>
+       if (futex_async(futex, FUTEX_WAKE, 1, NULL, NULL, 0) < 0) {<br>
+               PERROR("futex_async");<br>
+               abort();<br>
        }<br>
-<br>
+end:<br>
        DBG("Futex n to 1 wake done");<br>
 }<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div>