// Since tests run in the same process, we need to duplicate all file
// descriptors so that both page maps can close them.
Since tests run in the same process, we need to duplicate all file
descriptors so that both page maps can close them.
Since tests run in the same process we need to duplicate all file descriptors so that both page maps can close them .
fn duplicate_file_descriptors(
    mut serialized_page_map: PageMapSerialization,
) -> PageMapSerialization {
    serialized_page_map.checkpoint.mapping =
        serialized_page_map
            .checkpoint
            .mapping
            .map(|mapping| MappingSerialization {
                file_descriptor: FileDescriptor {
                    fd: dup(mapping.file_descriptor.fd).unwrap(),
                },
                ..mapping
            });
    serialized_page_map.page_allocator = match serialized_page_map.page_allocator {
        PageAllocatorSerialization::Mmap(file_descriptor) => {
            PageAllocatorSerialization::Mmap(FileDescriptor {
                fd: dup(file_descriptor.fd).unwrap(),
            })
        }
        _ => serialized_page_map.page_allocator,
    };
    serialized_page_map
}
fn duplicate_file_descriptors ( mut serialized_page_map : PageMapSerialization , ) -> PageMapSerialization { serialized_page_map . checkpoint . mapping = serialized_page_map . checkpoint . mapping . map ( | mapping | MappingSerialization { file_descriptor : FileDescriptor { fd : dup ( mapping . file_descriptor . fd ) . unwrap ( ) , } , .. mapping } ) ; serialized_page_map . page_allocator = match serialized_page_map . page_allocator { PageAllocatorSerialization :: Mmap ( file_descriptor ) => { PageAllocatorSerialization :: Mmap ( FileDescriptor { fd : dup ( file_descriptor . fd ) . unwrap ( ) , } ) } _ => serialized_page_map . page_allocator , } ; serialized_page_map }
Since tests run in the same process, we need to duplicate all file
descriptors so that both page maps can close them.
Since tests run in the same process we need to duplicate all file descriptors so that both page maps can close them .
serialized_page_map
PageMapSerialization