list: change locking discipline
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
2cf76fd225
commit
071a5651e0
11 changed files with 61 additions and 15 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue