diff mbox

[ovs-dev,2/3] ovsdb: Fix memory leak in replication logic

Message ID 1469563687-5352-2-git-send-email-azhou@ovn.org
State Accepted
Headers show

Commit Message

Andy Zhou July 26, 2016, 8:08 p.m. UTC
Release the memory of reply message of the initial "monitor" request.

Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
Signed-off-by: Andy Zhou <azhou@ovn.org>
---
 ovsdb/replication.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

William Tu July 27, 2016, 12:38 a.m. UTC | #1
thanks for fixing the memory leak!

Acked-by: William Tu <u9012063@gmail.com>

On Tue, Jul 26, 2016 at 1:08 PM, Andy Zhou <azhou@ovn.org> wrote:
> Release the memory of reply message of the initial "monitor" request.
>
> Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
> Signed-off-by: Andy Zhou <azhou@ovn.org>
> ---
>  ovsdb/replication.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/ovsdb/replication.c b/ovsdb/replication.c
> index 3d589ef..af7ae5c 100644
> --- a/ovsdb/replication.c
> +++ b/ovsdb/replication.c
> @@ -365,6 +365,10 @@ get_initial_db_state(const struct db *database)
>      if (msg->type == JSONRPC_REPLY) {
>          process_notification(msg->result, database->db);
>      }
> +
> +    if (msg) {
> +        jsonrpc_msg_destroy(msg);
> +    }
>  }
>
>  static void
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Ben Pfaff July 27, 2016, 7:43 p.m. UTC | #2
On Tue, Jul 26, 2016 at 01:08:06PM -0700, Andy Zhou wrote:
> Release the memory of reply message of the initial "monitor" request.
> 
> Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
> Signed-off-by: Andy Zhou <azhou@ovn.org>
> ---
>  ovsdb/replication.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/ovsdb/replication.c b/ovsdb/replication.c
> index 3d589ef..af7ae5c 100644
> --- a/ovsdb/replication.c
> +++ b/ovsdb/replication.c
> @@ -365,6 +365,10 @@ get_initial_db_state(const struct db *database)
>      if (msg->type == JSONRPC_REPLY) {
>          process_notification(msg->result, database->db);
>      }
> +
> +    if (msg) {
> +        jsonrpc_msg_destroy(msg);
> +    }
>  }

The 'if' isn't needed.
Andy Zhou July 27, 2016, 7:48 p.m. UTC | #3
On Wed, Jul 27, 2016 at 12:43 PM, Ben Pfaff <blp@ovn.org> wrote:

> On Tue, Jul 26, 2016 at 01:08:06PM -0700, Andy Zhou wrote:
> > Release the memory of reply message of the initial "monitor" request.
> >
> > Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
> > Signed-off-by: Andy Zhou <azhou@ovn.org>
> > ---
> >  ovsdb/replication.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/ovsdb/replication.c b/ovsdb/replication.c
> > index 3d589ef..af7ae5c 100644
> > --- a/ovsdb/replication.c
> > +++ b/ovsdb/replication.c
> > @@ -365,6 +365,10 @@ get_initial_db_state(const struct db *database)
> >      if (msg->type == JSONRPC_REPLY) {
> >          process_notification(msg->result, database->db);
> >      }
> > +
> > +    if (msg) {
> > +        jsonrpc_msg_destroy(msg);
> > +    }
> >  }
>
> The 'if' isn't needed.
>
Right,  jsonrpc_msg_destroy() checks for NULL internally.

I will drop the 'if' before pushing.  Thanks for catching it.
Andy Zhou July 27, 2016, 8:59 p.m. UTC | #4
On Wed, Jul 27, 2016 at 12:48 PM, Andy Zhou <azhou@ovn.org> wrote:

>
>
> On Wed, Jul 27, 2016 at 12:43 PM, Ben Pfaff <blp@ovn.org> wrote:
>
>> On Tue, Jul 26, 2016 at 01:08:06PM -0700, Andy Zhou wrote:
>> > Release the memory of reply message of the initial "monitor" request.
>> >
>> > Reported-at: http://openvswitch.org/pipermail/dev/2016-July/076075.html
>> > Signed-off-by: Andy Zhou <azhou@ovn.org>
>> > ---
>> >  ovsdb/replication.c | 4 ++++
>> >  1 file changed, 4 insertions(+)
>> >
>> > diff --git a/ovsdb/replication.c b/ovsdb/replication.c
>> > index 3d589ef..af7ae5c 100644
>> > --- a/ovsdb/replication.c
>> > +++ b/ovsdb/replication.c
>> > @@ -365,6 +365,10 @@ get_initial_db_state(const struct db *database)
>> >      if (msg->type == JSONRPC_REPLY) {
>> >          process_notification(msg->result, database->db);
>> >      }
>> > +
>> > +    if (msg) {
>> > +        jsonrpc_msg_destroy(msg);
>> > +    }
>> >  }
>>
>> The 'if' isn't needed.
>>
> Right,  jsonrpc_msg_destroy() checks for NULL internally.
>
> I will drop the 'if' before pushing.  Thanks for catching it.
>

Pushed to master.
diff mbox

Patch

diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index 3d589ef..af7ae5c 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -365,6 +365,10 @@  get_initial_db_state(const struct db *database)
     if (msg->type == JSONRPC_REPLY) {
         process_notification(msg->result, database->db);
     }
+
+    if (msg) {
+        jsonrpc_msg_destroy(msg);
+    }
 }
 
 static void