mirror of
				https://github.com/isar/libmdbx.git
				synced 2025-10-31 15:38:57 +08:00 
			
		
		
		
	mdbx: windows - fix truncation race while unmap.
Change-Id: I93983d100c78aa3e57c5a7ebd9d5bf2a96081ed7
This commit is contained in:
		| @@ -2041,6 +2041,11 @@ static int mdbx_mapresize(MDBX_env *env, const pgno_t size_pgno, | ||||
|  | ||||
| bailout: | ||||
|   if (rc == MDBX_SUCCESS) { | ||||
| #if defined(_WIN32) || defined(_WIN64) | ||||
|     assert(size_bytes == env->me_dxb_mmap.current); | ||||
|     assert(size_bytes <= env->me_dxb_mmap.filesize); | ||||
|     assert(limit_bytes == env->me_dxb_mmap.length); | ||||
| #endif | ||||
|     env->me_dbgeo.now = size_bytes; | ||||
|     env->me_dbgeo.upper = limit_bytes; | ||||
|     if (env->me_txn) { | ||||
|   | ||||
							
								
								
									
										12
									
								
								src/osal.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/osal.c
									
									
									
									
									
								
							| @@ -892,11 +892,6 @@ int mdbx_munmap(mdbx_mmap_t *map) { | ||||
|   if (!NT_SUCCESS(rc)) | ||||
|     ntstatus2errcode(rc); | ||||
|  | ||||
|   if (map->filesize != map->current && | ||||
|       mdbx_filesize(map->fd, &map->filesize) == MDBX_SUCCESS && | ||||
|       map->filesize != map->current) | ||||
|     (void)mdbx_ftruncate(map->fd, map->current); | ||||
|  | ||||
|   map->length = 0; | ||||
|   map->current = 0; | ||||
|   map->address = nullptr; | ||||
| @@ -922,8 +917,11 @@ int mdbx_mresize(int flags, mdbx_mmap_t *map, size_t size, size_t limit) { | ||||
|     /* growth rw-section */ | ||||
|     SectionSize.QuadPart = size; | ||||
|     status = NtExtendSection(map->section, &SectionSize); | ||||
|     if (NT_SUCCESS(status)) | ||||
|       map->filesize = map->current = size; | ||||
|     if (NT_SUCCESS(status)) { | ||||
|       map->current = size; | ||||
|       if (map->filesize < size) | ||||
|         map->filesize = size; | ||||
|     } | ||||
|     return ntstatus2errcode(status); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user