util: unified and enhanced zombie handing in wl_map

servers and clients now both use zombies.  Zombies are
interface pointers, so that they retain info for
demarshalling fds AND new_id args, which must be turned
into other zombies.

Demarshalling messages to zombies is handled by the
same wl_connection_demarshal code used for messages
to live objects.

Server zombies are eventually reaped after moving
through FIFO zombie ring, because there is no delete_id
request in the protocol.

Signed-off-by: Jonathan Leivent <jleivent@comcast.net>
This commit is contained in:
Jonathan Leivent 2024-01-26 18:42:14 -05:00
parent 0db836ebc8
commit dcd5996175
7 changed files with 436 additions and 180 deletions

View file

@ -393,6 +393,7 @@ demarshal(struct marshal_data *data, const char *format,
assert(closure);
wl_closure_invoke(closure, WL_CLOSURE_INVOKE_SERVER, &object, 0, data);
wl_closure_destroy(closure);
wl_map_release(&objects);
}
TEST(connection_demarshal)
@ -476,6 +477,7 @@ marshal_demarshal(struct marshal_data *data,
assert(closure);
wl_closure_invoke(closure, WL_CLOSURE_INVOKE_SERVER, &object, 0, data);
wl_closure_destroy(closure);
wl_map_release(&objects);
}
TEST(connection_marshal_demarshal)
@ -540,6 +542,7 @@ expected_fail_demarshal(struct marshal_data *data, const char *format,
assert(closure == NULL);
assert(errno == expected_error);
wl_map_release(&objects);
}
TEST(connection_demarshal_null_strings)

View file

@ -89,7 +89,8 @@ TEST(map_remove)
assert(wl_map_lookup(&map, j) == &b);
assert(wl_map_lookup(&map, k) == &c);
wl_map_remove(&map, j);
wl_map_mark_deleted(&map, j);
wl_map_zombify(&map, j, NULL);
assert(wl_map_lookup(&map, j) == NULL);
/* Verify that we insert d at the hole left by removing b */
@ -107,15 +108,18 @@ TEST(map_flags)
wl_map_init(&map, WL_MAP_SERVER_SIDE);
i = wl_map_insert_new(&map, 0, &a);
j = wl_map_insert_new(&map, 1, &b);
uint32_t flag_value = 0xabcdef10;
/* 3 bits of flags are used internally, so we lose the high 3 here: */
uint32_t high_truncated_flag_value = (flag_value << 3) >> 3;
j = wl_map_insert_new(&map, high_truncated_flag_value, &b);
assert(i == WL_SERVER_ID_START);
assert(j == WL_SERVER_ID_START + 1);
assert(wl_map_lookup(&map, i) == &a);
assert(wl_map_lookup(&map, j) == &b);
assert(wl_map_lookup_flags(&map, i) == 0);
assert(wl_map_lookup_flags(&map, j) == 1);
assert(wl_map_lookup_flags(&map, i) == 0);
assert(wl_map_lookup_flags(&map, j) == high_truncated_flag_value);
wl_map_release(&map);
}