qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a loc


From: Paolo Bonzini
Subject: Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock
Date: Tue, 11 May 2021 10:37:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 07/05/21 17:29, Eric Blake wrote:
+    qemu_mutex_lock(&s->lock);
      QLIST_FOREACH(r, &s->suspended_reqs, next) {
          if (!strcmp(r->tag, tag)) {
+            qemu_mutex_unlock(&s->lock);
              return true;
          }
      }
+    qemu_mutex_unlock(&s->lock);
      return false;
Would code like this be easier to write by using QEMU_LOCK_GUARD from
lockable.h?

Yes, this one would. In other cases (rule_check) it's not so clear cut. It depends whether you prefer to have the simplest code, or rather to have homogeneous use of either guards or lock/unlock.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]