mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
ovsdb: Properly handle error returned from from reset_database()
Fix a memory leak in case of error. The error object was not properly disposed. Since the error to reset DB is not expected, log it and exit. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
7724ed8d64
commit
8be420879d
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "condition.h"
|
#include "condition.h"
|
||||||
#include "openvswitch/json.h"
|
#include "openvswitch/json.h"
|
||||||
|
#include "openvswitch/vlog.h"
|
||||||
#include "jsonrpc.h"
|
#include "jsonrpc.h"
|
||||||
#include "ovsdb.h"
|
#include "ovsdb.h"
|
||||||
#include "ovsdb-error.h"
|
#include "ovsdb-error.h"
|
||||||
@ -32,6 +33,8 @@
|
|||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "transaction.h"
|
#include "transaction.h"
|
||||||
|
|
||||||
|
VLOG_DEFINE_THIS_MODULE(replication);
|
||||||
|
|
||||||
static char *active_ovsdb_server;
|
static char *active_ovsdb_server;
|
||||||
static struct jsonrpc *rpc;
|
static struct jsonrpc *rpc;
|
||||||
static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables);
|
static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables);
|
||||||
@ -88,12 +91,13 @@ replication_run(struct shash *all_dbs)
|
|||||||
/* Reset local databases. */
|
/* Reset local databases. */
|
||||||
if (reset_dbs) {
|
if (reset_dbs) {
|
||||||
struct ovsdb_error *error = reset_databases(all_dbs);
|
struct ovsdb_error *error = reset_databases(all_dbs);
|
||||||
if (!error) {
|
if (error) {
|
||||||
reset_dbs = false;
|
/* In case reset DB fails, log the error before exiting. */
|
||||||
|
char *msg = ovsdb_error_to_string(error);
|
||||||
|
ovsdb_error_destroy(error);
|
||||||
|
VLOG_FATAL("Failed to reset DB (%s).", msg);
|
||||||
}
|
}
|
||||||
/* In case of success reseting the databases,
|
reset_dbs = false;
|
||||||
* return in order to notify monitors. */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open JSON-RPC. */
|
/* Open JSON-RPC. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user