# HG changeset patch # User Paul Boddie # Date 1666299991 -7200 # Node ID 7d8fc09a1edd2b057f6e94baf788ed14b724db59 # Parent 0946dd297b3b36d3e346ddb6d6076b2846d7b04b Detach dataspaces from the region mapper before attaching new ones, hopefully avoiding problems with regions going missing. diff -r 0946dd297b3b -r 7d8fc09a1edd libfsclient/lib/src/file.cc --- a/libfsclient/lib/src/file.cc Thu Oct 20 23:04:46 2022 +0200 +++ b/libfsclient/lib/src/file.cc Thu Oct 20 23:06:31 2022 +0200 @@ -356,12 +356,16 @@ offset_t start_visible, offset_t end_visible, l4re_rm_flags_t region_flags) { - char *memory = file->memory; long err = file_mmap_only(file, position, length, start_visible, end_visible); if (err) return err; + if (file->memory != NULL) + ipc_detach_dataspace(file->memory); + + file->memory = NULL; + err = ipc_attach_dataspace_align(file->ref, file_span(file), L4RE_RM_F_SEARCH_ADDR | region_flags, L4_PAGESHIFT, @@ -369,9 +373,6 @@ if (err) return err; - if (memory != NULL) - ipc_detach_dataspace(memory); - return L4_EOK; } @@ -722,20 +723,20 @@ { client_Pipe _pipe(pipe->ref); long err = _pipe.next_region(&pipe->data_end, &pipe->size); - char *memory = pipe->memory; if (err) return err; + if (pipe->memory != NULL) + ipc_detach_dataspace(pipe->memory); + pipe->end_pos = pipe->size; + pipe->memory = NULL; err = ipc_attach_dataspace(pipe->ref, file_span(pipe), (void **) &pipe->memory); if (err) return err; - if (memory != NULL) - ipc_detach_dataspace(memory); - return L4_EOK; }