Message ID | 1386938688-22433-3-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
On Fri, Dec 13, 2013 at 10:44 PM, Igor Mammedov <imammedo@redhat.com> wrote: > From: Hervé Poussineau <hpoussin@reactos.org> > > We should not modify the type hash table while it is being iterated on. > Assert that it does not happen. > > Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > v2: > * make ver more descriptinve s/enumerating/enumerating_classes/ > [asked-by: Peter Crosthwaite] > --- > qom/object.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/qom/object.c b/qom/object.c > index 3a43186..4a0fb86 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -78,8 +78,10 @@ static GHashTable *type_table_get(void) > return type_table; > } > > +static bool enumerating_classes = false; This seems to be a change in terminology i.e. s/type/class. Should it be enumerating_types or enumerating_type_table? Also blank line here between global var decl and fn. Otherwise, Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Regards, Peter > static void type_table_add(TypeImpl *ti) > { > + assert(!enumerating_classes); > g_hash_table_insert(type_table_get(), (void *)ti->name, ti); > } > > @@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), > { > OCFData data = { fn, implements_type, include_abstract, opaque }; > > + enumerating_classes = true; > g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data); > + enumerating_classes = false; > } > > int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), > -- > 1.8.3.1 > >
Am 14.12.2013 07:53, schrieb Peter Crosthwaite: > On Fri, Dec 13, 2013 at 10:44 PM, Igor Mammedov <imammedo@redhat.com> wrote: >> From: Hervé Poussineau <hpoussin@reactos.org> >> >> We should not modify the type hash table while it is being iterated on. >> Assert that it does not happen. >> >> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> >> Signed-off-by: Igor Mammedov <imammedo@redhat.com> >> --- >> v2: >> * make ver more descriptinve s/enumerating/enumerating_classes/ >> [asked-by: Peter Crosthwaite] >> --- >> qom/object.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/qom/object.c b/qom/object.c >> index 3a43186..4a0fb86 100644 >> --- a/qom/object.c >> +++ b/qom/object.c >> @@ -78,8 +78,10 @@ static GHashTable *type_table_get(void) >> return type_table; >> } >> >> +static bool enumerating_classes = false; > > This seems to be a change in terminology i.e. s/type/class. Should it > be enumerating_types or enumerating_type_table? Too many cooks... While offline, I picked up the original version, changing to enumerating_types, which Alexey also happened to choose, and then adopted his drop of "false" assignment. > Also blank line here between global var decl and fn. Same thought here, already did in my version. :) > Otherwise, > > Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Thanks, will update while rebasing. Andreas
diff --git a/qom/object.c b/qom/object.c index 3a43186..4a0fb86 100644 --- a/qom/object.c +++ b/qom/object.c @@ -78,8 +78,10 @@ static GHashTable *type_table_get(void) return type_table; } +static bool enumerating_classes = false; static void type_table_add(TypeImpl *ti) { + assert(!enumerating_classes); g_hash_table_insert(type_table_get(), (void *)ti->name, ti); } @@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), { OCFData data = { fn, implements_type, include_abstract, opaque }; + enumerating_classes = true; g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data); + enumerating_classes = false; } int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),