diff options
author | Ben Pfaff <blp@nicira.com> | 2010-02-02 14:41:00 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-02-02 15:21:09 -0800 |
commit | 23935e8bcb5be3e82ed2fb16333fdbea36eedfcd (patch) | |
tree | 8f4ade451f0c9cbb1d236f6326aeac2b93321071 /ovsdb | |
parent | e084f69017bc840cd7aed4cc9ed2e13f3fb6747e (diff) | |
download | openvswitch-23935e8bcb5be3e82ed2fb16333fdbea36eedfcd.tar.gz |
ovsdb-server: Free memory on exit.
It is not really important to free memory on program exit, but it makes it
easier to see real memory leaks.
Found with valgrind.
Diffstat (limited to 'ovsdb')
-rw-r--r-- | ovsdb/jsonrpc-server.c | 12 | ||||
-rw-r--r-- | ovsdb/jsonrpc-server.h | 3 | ||||
-rw-r--r-- | ovsdb/ovsdb-server.c | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 6f2a656e5..936dd1db3 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -100,6 +100,18 @@ ovsdb_jsonrpc_server_create(struct ovsdb *db) return server; } +void +ovsdb_jsonrpc_server_destroy(struct ovsdb_jsonrpc_server *svr) +{ + struct shash_node *node, *next; + + SHASH_FOR_EACH_SAFE (node, next, &svr->remotes) { + ovsdb_jsonrpc_server_del_remote(node); + } + shash_destroy(&svr->remotes); + free(svr); +} + /* Sets 'svr''s current set of remotes to the names in 'new_remotes'. The data * values in 'new_remotes' are ignored. * diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h index b6f837d5e..6c4acd7f3 100644 --- a/ovsdb/jsonrpc-server.h +++ b/ovsdb/jsonrpc-server.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 Nicira Networks +/* Copyright (c) 2009, 2010 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ struct ovsdb; struct shash; struct ovsdb_jsonrpc_server *ovsdb_jsonrpc_server_create(struct ovsdb *); +void ovsdb_jsonrpc_server_destroy(struct ovsdb_jsonrpc_server *); void ovsdb_jsonrpc_server_set_remotes(struct ovsdb_jsonrpc_server *, const struct shash *); diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 900f4eccb..ab7e6c348 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -112,6 +112,10 @@ main(int argc, char *argv[]) ovsdb_trigger_wait(db, time_msec()); poll_block(); } + ovsdb_jsonrpc_server_destroy(jsonrpc); + ovsdb_destroy(db); + shash_destroy(&remotes); + unixctl_server_destroy(unixctl); return 0; } |