Jinoh Kang (@iamahuman) commented about server/mapping.c:
- SHARED_WRITE_END;
- for (i = 0; i < session.object_count; i++)
- {
const session_obj_t *object = &session.shared->objects[i];
SHARED_WRITE_BEGIN( object, session_obj_t )
{
shared->obj.invalid = 1;
}
SHARED_WRITE_END;
- }
- munmap( (void *)session.shared, session_mapping->size );
- release_object( session_mapping->fd );
- session_mapping->size = size;
- session_mapping->fd = fd;
Replacing the backing memory/fd of a mapping object is unprecedented and I'm afraid this might cause regressing due to existing assumptions on a mapping object.
Instead, I suggest that you remove `OBJ_PERMANENT` flag[^perma], unlink the existing mapping[^unlink], and call `create_mapping` to construct a new one.
This will also solve the query size race condition automatically.
[^perma]: This requires you to make `session_mapping` a reference: see the suggestion about `session_mapping = (struct mapping *)grab_object( &mapping->obj );`. [^unlink]: See `unlink_named_object`.