X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-generate-io-struct.c;h=ff5ae052abc0aa0f40ea7ade402d9c4dfa05ce81;hp=1947aa5e931b4602bb772d7b5183df1668b67e12;hb=00f7c1a52a30cca0157ebc2c39a4d52022cba215;hpb=2e0c6b58a2a718d99e75a06f6b73688c537390ae diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 1947aa5e..ff5ae052 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -1957,7 +1957,6 @@ int ctf_trace_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace int ret = 0; struct ctf_node *iter; -restart: if (trace->declaration_scope) return -EEXIST; trace->declaration_scope = new_declaration_scope(trace->root_declaration_scope); @@ -2000,15 +1999,13 @@ restart: return 0; error: - if (trace->packet_header_decl) + if (trace->packet_header_decl) { declaration_unref(&trace->packet_header_decl->p); + trace->packet_header_decl = NULL; + } g_ptr_array_free(trace->streams, TRUE); free_declaration_scope(trace->declaration_scope); trace->declaration_scope = NULL; - /* byte order changed while creating types, retry. */ - if (ret == -EINTR) { - goto restart; - } return ret; } @@ -2064,9 +2061,11 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, struct ctf_node *iter; printf_verbose("CTF visitor: metadata construction... "); - trace->root_declaration_scope = new_declaration_scope(NULL); trace->byte_order = byte_order; +retry: + trace->root_declaration_scope = new_declaration_scope(NULL); + switch (node->type) { case NODE_ROOT: cds_list_for_each_entry(iter, &node->u.root.declaration_list, @@ -2079,6 +2078,15 @@ int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node, } cds_list_for_each_entry(iter, &node->u.root.trace, siblings) { ret = ctf_trace_visit(fd, depth + 1, iter, trace); + if (ret == -EINTR) { + free_declaration_scope(trace->root_declaration_scope); + /* + * Need to restart creation of type + * definitions, aliases and + * trace header declarations. + */ + goto retry; + } if (ret) { fprintf(fd, "[error] %s: trace declaration error\n", __func__); goto error;