mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-21 20:05:42 +02:00
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:
parent
74754b0ab9
commit
074af015fb
1 changed files with 13 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue