Commit 0c2ad00
pack-objects: take lock before accessing
When checking the conditional of "while (me->remaining)", we did not
hold the lock. Calling find_deltas would still be safe, since it checks
"remaining" (after taking the lock) and is able to handle all values. In
fact, this could (currently) not trigger any bug: a bug could happen if
`remaining` transitioning from zero to non-zero races with the evaluation
of the while-condition, but these are always separated by the
data_ready-mechanism.
Make sure we have the lock when we read `remaining`. This does mean we
release it just so that find_deltas can take it immediately again. We
could tweak the contract so that the lock should be taken before calling
find_deltas, but let's defer that until someone can actually show that
"unlock+lock" has a measurable negative impact.
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>remaining
1 parent 5c94c93 commit 0c2ad00
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2171 | 2171 | | |
2172 | 2172 | | |
2173 | 2173 | | |
| 2174 | + | |
2174 | 2175 | | |
| 2176 | + | |
| 2177 | + | |
2175 | 2178 | | |
2176 | 2179 | | |
2177 | 2180 | | |
| |||
2193 | 2196 | | |
2194 | 2197 | | |
2195 | 2198 | | |
| 2199 | + | |
| 2200 | + | |
2196 | 2201 | | |
| 2202 | + | |
2197 | 2203 | | |
2198 | 2204 | | |
2199 | 2205 | | |
| |||
0 commit comments