• Nils Goroll's avatar
    Workaround for Varnish-Cache VC#4013: Wrong trim use, inefficient copy · 8409356f
    Nils Goroll authored
    https://github.com/varnishcache/varnish-cache/pull/4013 fixes two
    issues in Varnish-Cache, which are relevant for SLASH/fellow and of
    which the first is the root cause of #33.
    
    This commit works around these issues until the fix gets merged:
    
    Because of the wrong use of the .objtrimstore API function by
    varnish-cache, we remove it from our obj_methods and exploit the fact
    that varnish-cache always sets the OA_LEN attribute when the object is
    complete: We move the trimstore function there, effectively calling it
    at the right time only.
    
    The inefficient memory allocation fixed in the second commit of
    VC#4013 is particularly relevant for fellow, because it causes the
    allocation code to assume that the object might grow up to the maximum
    possible size, which causes a substantial over-allocation. We work
    around this issue for the case that a 304 copy is made from fellow to
    fellow by using private thread-local storage to emulate basically the
    same function as the #4013 fix.
    
    Closes #33
    Ref https://github.com/varnishcache/varnish-cache/pull/4013
    8409356f
fellow_cache_storage.h 1.97 KB