On 03/17/2011 09:22 AM, Jiri Denemark wrote:
Calling most hash APIs is not safe from inside of an iterator
callback.
Exceptions are APIs that do not modify the hash table and removing
current hash entry from virHashFroEach callback.
This patch make all APIs which are not safe fail instead of just relying
on the callback being nice not calling any unsafe APIs.
---
src/util/hash.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/util/hash.c b/src/util/hash.c
index 2a9a9cf..48a94ad 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -35,6 +35,12 @@
/* #define DEBUG_GROW */
+#define virHashIterationError(ret) \
+ do { \
+ VIR_ERROR0(_("Hash operation not allowed during iteration")); \
+ return ret; \
+ } while (0)
ACK; nice helper macro.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org