File opened by mmap is not closed causes removing file failure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Dulwich |
Fix Released
|
Medium
|
Unassigned |
Bug Description
This is like an issue for Windows because from my personal experience, file deletion on Linux won't be affected by opened file lock. But on Windows opened files cannot be deleted.
Related id: 557585, 565448.
I've downloaded Dulwich 0.6.0 and try out with the hg-git extension.
Combing Python debug mode with Anatoly Techtonik's "monkeypatching" code and file handle dumper, here is the result:
Output of printOpenFiles():
### 3 OPEN FILES: [R:\hg\
Partial output of handle -p hg.exe:
dc: File R:\hg\inspection
1e0: File R:\hg\inspectio
1e8: File R:\hg\inspectio
1ec: File R:\hg\inspectio
1f0: File R:\hg\inspectio
384: File R:\hg\inspectio
It shows that the files ending in .idx are so special that doesn't appear in the Python opened file list.
By debugging deep, it is found that the use of mmap.mmap(...) in pack.py(
Changed in dulwich: | |
status: | New → Triaged |
importance: | Undecided → Medium |
milestone: | none → 0.7.0 |
Changed in dulwich: | |
status: | Fix Committed → Fix Released |
It is inspected that the dulwich/pack.py file have two path way, one uses mmap and another not.
By disabling the use of mmap() has resolved the problem since mmap() opens the file and dulwich has no where to close it.
A quick look to the code shows that it's rather quite complicated to determine a proper point for closing the file opened by mmap. Therefore, a temporary resolution of disabling mmap maybe satisfactory when the running platform is Windows.