fscache: load directories only once
commit1a62aa8a5ca89bb9c6399c3191b8cffc0a65d269
authorKarsten Blees <blees@dcon.de>
Tue, 24 Jun 2014 11:22:35 +0000 (24 13:22 +0200)
committerKarsten Blees <blees@dcon.de>
Sat, 16 Aug 2014 01:03:17 +0000 (16 03:03 +0200)
treefd857a410adb5f20ee8c6c7a99fd1fb23ba9f0a5
parent2e646a9330ad9babf9351bdab8f82edf901bc65b
fscache: load directories only once

If multiple threads access a directory that is not yet in the cache, the
directory will be loaded by each thread. Only one of the results is added
to the cache, all others are leaked. This wastes performance and memory.

On cache miss, add a future object to the cache to indicate that the
directory is currently being loaded. Subsequent threads register themselves
with the future object and wait. When the first thread has loaded the
directory, it replaces the future object with the result and notifies
waiting threads.

Signed-off-by: Karsten Blees <blees@dcon.de>
compat/win32/fscache.c