You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/06/11 13:09:00 UTC

[GitHub] [activemq-artemis-native] franz1981 commented on a change in pull request #7: ARTEMIS-2800 Fixes around Linux Kernel Bug

franz1981 commented on a change in pull request #7:
URL: https://github.com/apache/activemq-artemis-native/pull/7#discussion_r438768078



##########
File path: src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c
##########
@@ -129,9 +129,24 @@ static int user_io_getevents(io_context_t aio_ctx, unsigned int max,
                     struct io_event *events)
 {
    long i = 0;
-   unsigned head;
+   unsigned head, tail, avail;
    struct aio_ring *ring = to_aio_ring(aio_ctx);
 
+   // continue until the available values are <= max
+   do {
+       head = ring->head;
+       mem_barrier();
+       tail = ring->tail;
+
+       if (tail >= head)
+           avail = tail - head;
+       else
+           avail = ring->nr - (head - tail);
+
+       if (avail <= max)
+           break;
+    } while (1);

Review comment:
       mmmm you're right, effectively this version won't show that there is just a single writer for `head` and deserve some more comments too, my bad 
   @clebertsuconic Please bud, we can use the original version proposed by @JeffMoyer
   
   @JeffMoyer OT: do you think it would be better to replace the reaper loop using `%` with a `memcpy`? If yes I would send a different PR to address it too




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org