mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-14 18:52:01 +00:00
mwindow: free unused windows if we fail to mmap
The first time may be due to memory fragmentation or just bad luck on a 32-bit system. When we hit the mmap error for the first time, free up the unused windows and try again.
This commit is contained in:
parent
9ee498e800
commit
4ebf745f06
@ -295,10 +295,20 @@ static git_mwindow *new_window(
|
|||||||
* window.
|
* window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) {
|
||||||
|
/*
|
||||||
|
* The first error might be down to memory fragmentation even if
|
||||||
|
* we're below our soft limits, so free up what we can and try again.
|
||||||
|
*/
|
||||||
|
|
||||||
|
while (git_mwindow_close_lru(mwf) == 0)
|
||||||
|
/* nop */;
|
||||||
|
|
||||||
if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) {
|
if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) {
|
||||||
git__free(w);
|
git__free(w);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctl->mmap_calls++;
|
ctl->mmap_calls++;
|
||||||
ctl->open_windows++;
|
ctl->open_windows++;
|
||||||
|
Loading…
Reference in New Issue
Block a user