module/river: exclude seats while river is starting up

This is mainly to fix a race when river is *not* running; sometimes we
ended up allocating particles for N seats in content(), but then when
iterating the seats, run() had destroyed all, or some of the seats,
causing us to feed NULL pointers to dynlist, which crashed.
This commit is contained in:
Daniel Eklöf 2020-11-02 19:01:46 +01:00
parent 74754b0ab9
commit 074af015fb
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -90,7 +90,8 @@ content(struct module *mod)
}
}
const size_t seat_count = m->title != NULL ? tll_length(m->seats) : 0;
const size_t seat_count = m->title != NULL && !m->is_starting_up
? tll_length(m->seats) : 0;
struct exposable *tag_parts[32 + seat_count];
for (unsigned i = 0; i < 32; i++) {
@ -122,7 +123,7 @@ content(struct module *mod)
tag_set_destroy(&tags);
}
if (m->title != NULL) {
if (m->title != NULL && !m->is_starting_up) {
size_t i = 32;
tll_foreach(m->seats, it) {
const struct seat *seat = &it->item;
@ -565,6 +566,10 @@ run(struct module *mod)
}
wl_display_roundtrip(display);
bool unlock_at_exit = true;
mtx_lock(&mod->lock);
m->is_starting_up = false;
tll_foreach(m->outputs, it)
@ -572,6 +577,9 @@ run(struct module *mod)
tll_foreach(m->seats, it)
instantiate_seat(&it->item);
unlock_at_exit = false;
mtx_unlock(&mod->lock);
while (true) {
wl_display_flush(display);
@ -618,6 +626,9 @@ out:
wl_registry_destroy(registry);
if (display != NULL)
wl_display_disconnect(display);
if (unlock_at_exit)
mtx_unlock(&mod->lock);
return ret;
}