mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-45621: Small changes to mmap (GH-29247)
* Small tidy-ups / comments * Use randomized names when testing tagged mmaps to avoid any risk of parallel tests treading on each others' toes
This commit is contained in:
parent
074fa57506
commit
7bddd96982
2 changed files with 21 additions and 24 deletions
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <winternl.h>
|
||||
static int
|
||||
my_getpagesize(void)
|
||||
{
|
||||
|
|
@ -505,21 +504,6 @@ mmap_resize_method(mmap_object *self,
|
|||
}
|
||||
|
||||
{
|
||||
/*
|
||||
To resize an mmap on Windows:
|
||||
|
||||
- Close the existing mapping
|
||||
- If the mapping is backed to a named file:
|
||||
unmap the view, clear the data, and resize the file
|
||||
If the file can't be resized (eg because it has other mapped references
|
||||
to it) then let the mapping be recreated at the original size and set
|
||||
an error code so an exception will be raised.
|
||||
- Create a new mapping of the relevant size to the same file
|
||||
- Map a new view of the resized file
|
||||
- If the mapping is backed by the pagefile:
|
||||
copy any previous data into the new mapped area
|
||||
unmap the original view which will release the memory
|
||||
*/
|
||||
#ifdef MS_WINDOWS
|
||||
DWORD error = 0, file_resize_error = 0;
|
||||
char* old_data = self->data;
|
||||
|
|
@ -567,6 +551,11 @@ mmap_resize_method(mmap_object *self,
|
|||
self->tagname);
|
||||
|
||||
error = GetLastError();
|
||||
/* ERROR_ALREADY_EXISTS implies that between our closing the handle above and
|
||||
calling CreateFileMapping here, someone's created a different mapping with
|
||||
the same name. There's nothing we can usefully do so we invalidate our
|
||||
mapping and error out.
|
||||
*/
|
||||
if (error == ERROR_ALREADY_EXISTS) {
|
||||
CloseHandle(self->map_handle);
|
||||
self->map_handle = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue