Module: xenomai-3 Branch: stable-3.0.x Commit: 0291656b5e12f89afd4bb86acb195e7cf245d281 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0291656b5e12f89afd4bb86acb195e7cf245d281
Author: Jan Kiszka <jan.kis...@siemens.com> Date: Thu Apr 12 11:03:00 2018 +0200 boilerplate: Do not allow cancellation in hash_enter/search_probe It's not really safe to allow a potentially modifying operation to be canceled in the middle, just dropping the lock during rollback. Better defer cancellation until the lock is dropped. Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- lib/boilerplate/hash.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/boilerplate/hash.c b/lib/boilerplate/hash.c index 17beb38..9ce1b7c 100644 --- a/lib/boilerplate/hash.c +++ b/lib/boilerplate/hash.c @@ -277,6 +277,7 @@ int __hash_enter_probe(struct hash_table *t, { struct hash_bucket *bucket; struct hashobj *obj, *tmp; + struct service svc; int ret; holder_init(&newobj->link); @@ -285,7 +286,7 @@ int __hash_enter_probe(struct hash_table *t, return ret; bucket = do_hash(t, key, len); - push_cleanup_lock(&t->lock); + CANCEL_DEFER(svc); write_lock(&t->lock); if (!list_empty(&bucket->obj_list)) { @@ -311,7 +312,7 @@ int __hash_enter_probe(struct hash_table *t, list_append(&newobj->link, &bucket->obj_list); out: write_unlock(&t->lock); - pop_cleanup_lock(&t->lock); + CANCEL_RESTORE(svc); return ret; } @@ -322,10 +323,11 @@ struct hashobj *hash_search_probe(struct hash_table *t, { struct hash_bucket *bucket; struct hashobj *obj, *tmp; + struct service svc; bucket = do_hash(t, key, len); - push_cleanup_lock(&t->lock); + CANCEL_DEFER(svc); write_lock(&t->lock); if (!list_empty(&bucket->obj_list)) { @@ -345,7 +347,7 @@ struct hashobj *hash_search_probe(struct hash_table *t, obj = NULL; out: write_unlock(&t->lock); - pop_cleanup_lock(&t->lock); + CANCEL_RESTORE(svc); return obj; } _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git