list: change locking discipline

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 14:50:47 -04:00
commit 071a5651e0
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
11 changed files with 61 additions and 15 deletions

View file

@ -33,7 +33,9 @@ struct tty *tty_tee_create(const char *name)
struct tty *ret = tty_create(name, list);
if (!ret) {
list_lock(list);
list_destroy(list);
list_unlock(list);
kfree(list);
return NULL;
}
@ -49,7 +51,9 @@ void tty_tee_add(struct tty *tee, struct tty *child)
return;
list_t *list = tee->priv;
list_lock(list);
list_insert(list, child);
list_unlock(list);
}
void tty_tee_remove(struct tty *tee, struct tty *child)
@ -58,13 +62,18 @@ void tty_tee_remove(struct tty *tee, struct tty *child)
if (!list)
return;
list_lock(list);
list_item_t *item = list->head;
while (item) {
if (item->ptr == child) {
list_remove(item);
list_unlock(list);
return;
}
item = item->next;
}
list_unlock(list);
}