Subject: Re: [PATCH 2/2] lock_packed_refs(): allow retries when acquiring the packed-refs lock

From: Michael Haggerty <[email-masked]>
Date: Mon, 11 May 2015 11:31:00 +0200

On 05/02/2015 11:43 PM, Johannes Sixt wrote:
> Am 02.05.2015 um 05:47 schrieb Michael Haggerty:
>> On 05/01/2015 06:13 PM, Johannes Sixt wrote:
>>> How about this:
>>>
>>>      test_when_finished "wait; rm -f $LOCK" &&
>>>      { sleep 1 & } &&
>>>      ...
>>
>> Thanks for pointing out this problem. Your suggestion seems good. I
>> assume that you didn't intend to omit the "rm -f $LOCK" from the
>> subprocess, because the whole point is for that to happen while "git
>> pack-refs" is running.
> 
> I see. So, if git pack-refs works correctly, it waits for the
> sub-process, and the 'wait' in test_when_finished does not buy a lot. If
> there is breakage, the trash directory is not attempted to be removed,
> and it does not matter that a process potentially occupies it. I think
> your version is good then.

Well, even if my version is working correctly, there is still a gap
between when the subprocess removes the lockfile and when the subprocess
ends, during which the outer process could theoretically finish and try
to delete the test directory. It may not cause problems in practice, but
let's add the wait anyway to make everything kosher.

Michael

-- 
Michael Haggerty
[email-masked]