Skip to content
Snippets Groups Projects
  • Simon McVittie's avatar
    9c37f1b0
    runtime: Fix locking behaviour in variable directory · 9c37f1b0
    Simon McVittie authored
    
    We need to hold an exclusive lock while carrying out GC, because any
    number of processes could be trying to create temporary copies there
    at the same time, and if that's happening then it's unsafe for the
    GC pass to be looking at the temporary copies concurrently. Only do
    the GC pass opportunistically, if we can get an exclusive lock without
    waiting.
    
    Conversely, while we're creating the temporary copies, we continue to
    take out a non-exclusive lock; but if another process is in the middle
    of a GC pass, we want to wait for it instead of just failing.
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
    9c37f1b0
    History
    runtime: Fix locking behaviour in variable directory
    Simon McVittie authored
    
    We need to hold an exclusive lock while carrying out GC, because any
    number of processes could be trying to create temporary copies there
    at the same time, and if that's happening then it's unsafe for the
    GC pass to be looking at the temporary copies concurrently. Only do
    the GC pass opportunistically, if we can get an exclusive lock without
    waiting.
    
    Conversely, while we're creating the temporary copies, we continue to
    take out a non-exclusive lock; but if another process is in the middle
    of a GC pass, we want to wait for it instead of just failing.
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>