Message ID | 1469563687-5352-1-git-send-email-azhou@ovn.org |
---|---|
State | Accepted |
Headers | show |
Hi Andy, Thanks for fixing the memory leak! I've tested it and it solved the issue. btw, I think we don't have to assign "NULL" to static variable, C99 standard assume all static variable initializes to 0. Acked-by: William Tu <u9012063@gmail.com> On Tue, Jul 26, 2016 at 1:08 PM, Andy Zhou <azhou@ovn.org> wrote: > This patch removes rpc related memory leak reported below. > > Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html > Signed-off-by: Andy Zhou <azhou@ovn.org> > --- > ovsdb/ovsdb-server.c | 1 + > ovsdb/replication.c | 5 +++-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c > index 239cca8..1c6ddca 100644 > --- a/ovsdb/ovsdb-server.c > +++ b/ovsdb/ovsdb-server.c > @@ -202,6 +202,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, struct shash *all_dbs, > } > } > > + disconnect_remote_server(); > free(remotes_error); > } > > diff --git a/ovsdb/replication.c b/ovsdb/replication.c > index 52b7085..3d589ef 100644 > --- a/ovsdb/replication.c > +++ b/ovsdb/replication.c > @@ -32,8 +32,8 @@ > #include "table.h" > #include "transaction.h" > > -static char *remote_ovsdb_server; > -static struct jsonrpc *rpc; > +static char *remote_ovsdb_server = NULL; > +static struct jsonrpc *rpc = NULL; > static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables); > static struct sset tables_blacklist = SSET_INITIALIZER(&tables_blacklist); > static bool reset_dbs = true; > @@ -391,6 +391,7 @@ check_for_notifications(struct shash *all_dbs) > if (error == EAGAIN) { > return; > } else if (error) { > + jsonrpc_close(rpc); > rpc = open_jsonrpc(remote_ovsdb_server); > if (!rpc) { > /* Remote server went down. */ > -- > 1.9.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev
On Tue, Jul 26, 2016 at 5:37 PM, William Tu <u9012063@gmail.com> wrote: > Hi Andy, > > Thanks for fixing the memory leak! I've tested it and it solved the > issue. btw, I think we don't have to assign "NULL" to static variable, > C99 standard assume all static variable initializes to 0. > Right, I will drop the NULL initializations. > > Acked-by: William Tu <u9012063@gmail.com> > Thanks for the review. I will push to master in a minute. > > On Tue, Jul 26, 2016 at 1:08 PM, Andy Zhou <azhou@ovn.org> wrote: > > This patch removes rpc related memory leak reported below. > > > > Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html > > Signed-off-by: Andy Zhou <azhou@ovn.org> > > --- > > ovsdb/ovsdb-server.c | 1 + > > ovsdb/replication.c | 5 +++-- > > 2 files changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c > > index 239cca8..1c6ddca 100644 > > --- a/ovsdb/ovsdb-server.c > > +++ b/ovsdb/ovsdb-server.c > > @@ -202,6 +202,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, > struct shash *all_dbs, > > } > > } > > > > + disconnect_remote_server(); > > free(remotes_error); > > } > > > > diff --git a/ovsdb/replication.c b/ovsdb/replication.c > > index 52b7085..3d589ef 100644 > > --- a/ovsdb/replication.c > > +++ b/ovsdb/replication.c > > @@ -32,8 +32,8 @@ > > #include "table.h" > > #include "transaction.h" > > > > -static char *remote_ovsdb_server; > > -static struct jsonrpc *rpc; > > +static char *remote_ovsdb_server = NULL; > > +static struct jsonrpc *rpc = NULL; > > static struct sset monitored_tables = > SSET_INITIALIZER(&monitored_tables); > > static struct sset tables_blacklist = > SSET_INITIALIZER(&tables_blacklist); > > static bool reset_dbs = true; > > @@ -391,6 +391,7 @@ check_for_notifications(struct shash *all_dbs) > > if (error == EAGAIN) { > > return; > > } else if (error) { > > + jsonrpc_close(rpc); > > rpc = open_jsonrpc(remote_ovsdb_server); > > if (!rpc) { > > /* Remote server went down. */ > > -- > > 1.9.1 > > > > _______________________________________________ > > dev mailing list > > dev@openvswitch.org > > http://openvswitch.org/mailman/listinfo/dev >
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 239cca8..1c6ddca 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -202,6 +202,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, struct shash *all_dbs, } } + disconnect_remote_server(); free(remotes_error); } diff --git a/ovsdb/replication.c b/ovsdb/replication.c index 52b7085..3d589ef 100644 --- a/ovsdb/replication.c +++ b/ovsdb/replication.c @@ -32,8 +32,8 @@ #include "table.h" #include "transaction.h" -static char *remote_ovsdb_server; -static struct jsonrpc *rpc; +static char *remote_ovsdb_server = NULL; +static struct jsonrpc *rpc = NULL; static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables); static struct sset tables_blacklist = SSET_INITIALIZER(&tables_blacklist); static bool reset_dbs = true; @@ -391,6 +391,7 @@ check_for_notifications(struct shash *all_dbs) if (error == EAGAIN) { return; } else if (error) { + jsonrpc_close(rpc); rpc = open_jsonrpc(remote_ovsdb_server); if (!rpc) { /* Remote server went down. */
This patch removes rpc related memory leak reported below. Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html Signed-off-by: Andy Zhou <azhou@ovn.org> --- ovsdb/ovsdb-server.c | 1 + ovsdb/replication.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)