static struct table_style table_style = TABLE_STYLE_DEFAULT;
static void vsctl_cmd_init(void);
+
+/* The IDL we're using and the current transaction, if any.
+ * This is for use by vsctl_exit() only, to allow it to clean up.
+ * Other code should use its context arguments. */
+static struct ovsdb_idl *the_idl;
+static struct ovsdb_idl_txn *the_idl_txn;
+OVS_NO_RETURN static void vsctl_exit(int status);
+
OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[], struct shash *local_options);
static void run_prerequisites(struct ctl_command[], size_t n_commands,
NULL,
{&ovsrec_open_vswitch_col_manager_options,
&ovsrec_open_vswitch_col_bridges,
- &ovsrec_open_vswitch_col_ovs_version},
- false},
+ &ovsrec_open_vswitch_col_ovs_version}
+ },
{&ovsrec_table_bridge,
&ovsrec_bridge_col_name,
{&ovsrec_bridge_col_controller,
&ovsrec_bridge_col_fail_mode,
- &ovsrec_bridge_col_ports},
- false},
+ &ovsrec_bridge_col_ports}
+ },
{&ovsrec_table_port,
&ovsrec_port_col_name,
{&ovsrec_port_col_tag,
&ovsrec_port_col_trunks,
- &ovsrec_port_col_interfaces},
- false},
+ &ovsrec_port_col_interfaces}
+ },
{&ovsrec_table_interface,
&ovsrec_interface_col_name,
{&ovsrec_interface_col_type,
&ovsrec_interface_col_options,
- &ovsrec_interface_col_error},
- false},
+ &ovsrec_interface_col_error}
+ },
{&ovsrec_table_controller,
&ovsrec_controller_col_target,
{&ovsrec_controller_col_is_connected,
NULL,
- NULL},
- false},
+ NULL}
+ },
{&ovsrec_table_manager,
&ovsrec_manager_col_target,
{&ovsrec_manager_col_is_connected,
NULL,
- NULL},
- false},
+ NULL}
+ },
- {NULL, NULL, {NULL, NULL, NULL}, false}
+ {NULL, NULL, {NULL, NULL, NULL}}
};
static void
vsctl_context_populate_cache(ctx);
if (!find_bridge(vsctl_ctx, ctx->argv[1], false)) {
- ctl_exit(2);
+ vsctl_exit(2);
}
}
free(error);
}
+/* Frees the current transaction and the underlying IDL and then calls
+ * exit(status).
+ *
+ * Freeing the transaction and the IDL is not strictly necessary, but it makes
+ * for a clean memory leak report from valgrind in the normal case. That makes
+ * it easier to notice real memory leaks. */
+static void
+vsctl_exit(int status)
+{
+ if (the_idl_txn) {
+ ovsdb_idl_txn_abort(the_idl_txn);
+ ovsdb_idl_txn_destroy(the_idl_txn);
+ }
+ ovsdb_idl_destroy(the_idl);
+ exit(status);
+}
+
/*
* Developers who add new commands to the 'struct ctl_command_syntax' must
* define the 'arguments' member of the struct. The following keywords are
static void
vsctl_cmd_init(void)
{
- ctl_init(tables);
+ ctl_init(tables, vsctl_exit);
ctl_register_commands(vsctl_commands);
}