Retry needs to recreate type def and aliases too
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-generate-io-struct.c
index bba15b684ffcc9bf3fa6abbeea56e9550cbb7897..ff5ae052abc0aa0f40ea7ade402d9c4dfa05ce81 100644 (file)
@@ -1898,7 +1898,6 @@ int ctf_trace_declaration_visit(FILE *fd, int depth, struct ctf_node *node, stru
                                ret = -EPERM;
                                goto error;
                        } else {
-                               CTF_TRACE_SET_FIELD(trace, byte_order);
                                if (byte_order != trace->byte_order) {
                                        trace->byte_order = byte_order;
                                        /*
@@ -1906,9 +1905,13 @@ int ctf_trace_declaration_visit(FILE *fd, int depth, struct ctf_node *node, stru
                                         * construction of the
                                         * intermediate representation.
                                         */
-                                       return -EINTR;
+                                       trace->field_mask = 0;
+                                       CTF_TRACE_SET_FIELD(trace, byte_order);
+                                       ret = -EINTR;
+                                       goto error;
                                }
                        }
+                       CTF_TRACE_SET_FIELD(trace, byte_order);
                } else if (!strcmp(left, "packet.header")) {
                        struct declaration *declaration;
 
@@ -1954,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);
@@ -1997,14 +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;
 }
 
@@ -2060,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,
@@ -2075,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;
This page took 0.023436 seconds and 4 git commands to generate.