• Sergey Vojtovich's avatar
    Fixup: reshuffle code to avoid going negative · 370474b6
    Sergey Vojtovich authored
    In reply to:
    Note that as the above is uint, it can never be < 0, so it's easier to just test == 0
    /* Wait for preceding concurrent writes completion */
         while ((uint64_t) my_atomic_load64_explicit((int64*) &cache->cached_eof,
                                                     MY_MEMORY_ORDER_RELAXED) <
                start)
           LF_BACKOFF();
    Why wait. Can't we start writing to the beginning of the cache buffer up to the last flushed byte?
    Isn't the cache a round-buffer?  From the code it looks like we write to the end always, then flush and then start from the beginning.
    hm.. It's probably right that we test for <= 0 above, but we need to cast the full expression to int or just make avail an int64_t
    370474b6
append_cache.c 16.5 KB