X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcache.C;h=80bf347b677a49d9aee95d011514719aa814f799;hp=3a0d118e0397f01a28b227d6d2796c186df6e97b;hb=f5725c7e12def18fec49a295dad688652edaa4b3;hpb=c387b8938dc838e5b92d1cd735975d0928ecf61a diff --git a/cinelerra-5.1/cinelerra/cache.C b/cinelerra-5.1/cinelerra/cache.C index 3a0d118e..80bf347b 100644 --- a/cinelerra-5.1/cinelerra/cache.C +++ b/cinelerra-5.1/cinelerra/cache.C @@ -37,7 +37,7 @@ // edl came from a command which won't exist anymore CICache::CICache(Preferences *preferences) - : List() + : Garbage("CICache"), List() { this->preferences = preferences; edl = 0; @@ -69,11 +69,11 @@ File* CICache::check_out(Asset *asset, EDL *edl, int block) CICacheItem *current = 0; long tid = (long)Thread::get_self(); if( !tid ) tid = 1; + total_lock->lock("CICache::check_out"); + add_user(); - while(1) - { + while( users > 1 ) { File *file = 0; - total_lock->lock("CICache::check_out"); // Scan directory for item current = first; while(current && strcmp(current->asset->path, asset->path) != 0) @@ -108,12 +108,21 @@ File* CICache::check_out(Asset *asset, EDL *edl, int block) else current = 0; } - total_lock->unlock(); if( current || !file || !block ) break; // Try again after blocking + total_lock->unlock(); check_out_lock->lock("CICache::check_out"); + total_lock->lock("CICache::check_out"); + } + +// cache deleted during checkout, destroy this + if( users == 1 ) { + remove_user(); + return 0; } + remove_user(); + total_lock->unlock(); //printf("check out %p %lx %s\n", current, tid, asset->path); return current ? current->file : 0; }