• Nils Goroll's avatar
    Fix races for streaming busy objects · a1dbf0fe
    Nils Goroll authored
    For streaming busy objects, we basically rely on the varnish-cache
    ObjExtend() / ObjWaitExtend() API to never read past the object: In
    fellow_stream_f(), we always wait for more data (or the end of the
    object) before returning, such that fellow_cache_obj_iter(), which
    iterates over segments, should never touch a segment past the final
    FCS_BUSY segment.
    
    Yet - it did, by means of the read-ahead and the peek-ahead to determine
    whether or not OBJ_ITER_END should be signaled.
    
    We fix this issue by reading/peeking ahead only for segments with a
    state beyond FCS_BUSY.
    
    There is now also extensive test infrastructure to specifically test
    concurrent access ti busy objects. To keep layers separate,
    fellow_cache_test uses a lightweight signal/wait implementation
    analogous to the ObjExtend() / ObjWaitExtend() Varnish-Cache
    interface.
    
    An earlier version of t_busyobj() had run on my dev laptop for 3.5
    hours without crashing, while without the fixes it had run into
    assertion failures within seconds.
    
    Fixes #35 and #36 (I hope)
    a1dbf0fe
fellow_cache.c 146 KB