From patchwork Thu Jan 7 21:58:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 564472 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id DC3D21402B4 for ; Fri, 8 Jan 2016 08:58:32 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 042CF10AE7; Thu, 7 Jan 2016 13:58:32 -0800 (PST) X-Original-To: dev@openvswitch.com Delivered-To: dev@openvswitch.com Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by archives.nicira.com (Postfix) with ESMTPS id EA56D10AE5 for ; Thu, 7 Jan 2016 13:58:29 -0800 (PST) Received: by mail-pa0-f46.google.com with SMTP id yy13so176915774pab.3 for ; Thu, 07 Jan 2016 13:58:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=XPTzYyMy1y8zvF3rmtHoZz1YSPEVqDTmtU7uc9QAjJ4=; b=dz7V2ALaF2EanR1hp+ko5el5u9ZCNaA0QaW8u25Y/w7q1ZL3hrRYCmfuihFgy8+kQh F3Ktd59UNyJXiIdZhFoBLTlD3rC9h6KySl6u2pRakZWBaoNnw2u/Nnv+Rji1UoJCnvt1 /MrxmurPDWWSrsHEYRLLNLF+B1TfX5XW9njs4BrHVgbZ5mkPug71vsZWH94aWkTiZt6t UCCw1PfTunV9HfgZ05vFuvjkD1JKeT51ItPijrsZbIYmtK7ChfrxgHApfYpVy+8sUCaj YK7/OhWYzhN8y2jjWchCB6/gpXbu7Yfc5osASnY1D2Uz7PJHPR4/pGr/qQeKLJaFWYiF UgPw== X-Received: by 10.66.236.69 with SMTP id us5mr37526397pac.93.1452203903927; Thu, 07 Jan 2016 13:58:23 -0800 (PST) Received: from ubuntu.localdomain ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id tv6sm107847523pab.4.2016.01.07.13.58.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jan 2016 13:58:23 -0800 (PST) From: Andy Zhou To: dev@openvswitch.com Date: Thu, 7 Jan 2016 13:58:13 -0800 Message-Id: <1452203893-44471-1-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.9.1 Subject: [ovs-dev] [PATCH] ovsdb-client: fix monitored table memory leak X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Properly free memory used monitored_tables to reduce valgrind noises. Reported-by: William Tu Reported-at: http://openvswitch.org/pipermail/dev/2016-January/064161.html Signed-off-by: Andy Zhou --- ovsdb/ovsdb-client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 8c48338..c00f607 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -879,6 +879,19 @@ add_monitored_table(int argc, char *argv[], } static void +destroy_monitored_table(struct monitored_table *mts, size_t n) +{ + int i; + + for (i = 0; i < n; i++) { + struct monitored_table *mt = &mts[i]; + ovsdb_column_set_destroy(&mt->columns); + } + + free(mts); +} + +static void do_monitor__(struct jsonrpc *rpc, const char *database, enum ovsdb_monitor_version version, int argc, char *argv[]) @@ -1024,6 +1037,8 @@ do_monitor__(struct jsonrpc *rpc, const char *database, unixctl_server_wait(unixctl); poll_block(); } + + destroy_monitored_table(mts, n_mts); } static void