get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/14994/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14994,
    "url": "https://patches.dpdk.org/api/patches/14994/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1469195044-19018-1-git-send-email-reshma.pattan@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1469195044-19018-1-git-send-email-reshma.pattan@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1469195044-19018-1-git-send-email-reshma.pattan@intel.com",
    "date": "2016-07-22T13:44:04",
    "name": "[dpdk-dev] app/pdump: cleanup rte rings upon failures",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "dcb5342ef125a0210c90087381a55276c2ceca5d",
    "submitter": {
        "id": 70,
        "url": "https://patches.dpdk.org/api/people/70/?format=api",
        "name": "Pattan, Reshma",
        "email": "reshma.pattan@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1469195044-19018-1-git-send-email-reshma.pattan@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/14994/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/14994/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id DBB7B5591;\n\tFri, 22 Jul 2016 15:44:09 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id E6F36558D\n\tfor <dev@dpdk.org>; Fri, 22 Jul 2016 15:44:08 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP; 22 Jul 2016 06:44:08 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga002.fm.intel.com with ESMTP; 22 Jul 2016 06:44:07 -0700",
            "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tu6MDi6MU001796; Fri, 22 Jul 2016 14:44:06 +0100",
            "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id u6MDi6s3019056;\n\tFri, 22 Jul 2016 14:44:06 +0100",
            "(from reshmapa@localhost)\n\tby sivswdev02.ir.intel.com with  id u6MDi6lf019052;\n\tFri, 22 Jul 2016 14:44:06 +0100"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.28,405,1464678000\"; d=\"scan'208\";\n\ta=\"1027116314\"",
        "From": "Reshma Pattan <reshma.pattan@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Reshma Pattan <reshma.pattan@intel.com>",
        "Date": "Fri, 22 Jul 2016 14:44:04 +0100",
        "Message-Id": "<1469195044-19018-1-git-send-email-reshma.pattan@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "Subject": "[dpdk-dev] [PATCH] app/pdump: cleanup rte rings upon failures",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Function create_mp_ring_vdev() for failure cases exits without\nfreeing the created rte rings, because of this pdump tool cannot be\nrerun successfully. Added rte ring cleanup logic upon failures.\n\nFixes: caa7028276b8 (\"app/pdump: add tool for packet capturing\")\n\nSigned-off-by: Reshma Pattan <reshma.pattan@intel.com>\n---\n app/pdump/main.c | 67 +++++++++++++++++++++++++++++++++++++++++---------------\n 1 file changed, 49 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/app/pdump/main.c b/app/pdump/main.c\nindex e0ff8be..b76cfd0 100644\n--- a/app/pdump/main.c\n+++ b/app/pdump/main.c\n@@ -525,6 +525,26 @@ free_ring_data(struct rte_ring *ring, uint8_t vdev_id,\n }\n \n static void\n+cleanup_rings(void)\n+{\n+\tint i;\n+\tstruct pdump_tuples *pt;\n+\n+\tfor (i = 0; i < num_tuples; i++) {\n+\t\tpt = &pdump_t[i];\n+\n+\t\tif (pt->device_id)\n+\t\t\tfree(pt->device_id);\n+\n+\t\t/* free the rings */\n+\t\tif (pt->rx_ring)\n+\t\t\trte_ring_free(pt->rx_ring);\n+\t\tif (pt->tx_ring)\n+\t\t\trte_ring_free(pt->tx_ring);\n+\t}\n+}\n+\n+static void\n cleanup_pdump_resources(void)\n {\n \tint i;\n@@ -545,16 +565,8 @@ cleanup_pdump_resources(void)\n \t\t\tfree_ring_data(pt->rx_ring, pt->rx_vdev_id, &pt->stats);\n \t\tif (pt->dir & RTE_PDUMP_FLAG_TX)\n \t\t\tfree_ring_data(pt->tx_ring, pt->tx_vdev_id, &pt->stats);\n-\n-\t\tif (pt->device_id)\n-\t\t\tfree(pt->device_id);\n-\n-\t\t/* free the rings */\n-\t\tif (pt->rx_ring)\n-\t\t\trte_ring_free(pt->rx_ring);\n-\t\tif (pt->tx_ring)\n-\t\t\trte_ring_free(pt->tx_ring);\n \t}\n+\tcleanup_rings();\n }\n \n static void\n@@ -630,10 +642,12 @@ create_mp_ring_vdev(void)\n \t\t\t\t\tMBUF_POOL_CACHE_SIZE, 0,\n \t\t\t\t\tpt->mbuf_data_size,\n \t\t\t\t\trte_socket_id());\n-\t\t\tif (mbuf_pool == NULL)\n+\t\t\tif (mbuf_pool == NULL) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\"Mempool creation failed: %s\\n\",\n \t\t\t\t\trte_strerror(rte_errno));\n+\t\t\t}\n \t\t}\n \t\tpt->mp = mbuf_pool;\n \n@@ -643,19 +657,23 @@ create_mp_ring_vdev(void)\n \t\t\tsnprintf(ring_name, SIZE, RX_RING, i);\n \t\t\tpt->rx_ring = rte_ring_create(ring_name, pt->ring_size,\n \t\t\t\t\trte_socket_id(), 0);\n-\t\t\tif (pt->rx_ring == NULL)\n+\t\t\tif (pt->rx_ring == NULL) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE, \"%s:%s:%d\\n\",\n \t\t\t\t\t\trte_strerror(rte_errno),\n \t\t\t\t\t\t__func__, __LINE__);\n+\t\t\t}\n \n \t\t\t/* create tx_ring */\n \t\t\tsnprintf(ring_name, SIZE, TX_RING, i);\n \t\t\tpt->tx_ring = rte_ring_create(ring_name, pt->ring_size,\n \t\t\t\t\trte_socket_id(), 0);\n-\t\t\tif (pt->tx_ring == NULL)\n+\t\t\tif (pt->tx_ring == NULL) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE, \"%s:%s:%d\\n\",\n \t\t\t\t\t\trte_strerror(rte_errno),\n \t\t\t\t\t\t__func__, __LINE__);\n+\t\t\t}\n \n \t\t\t/* create vdevs */\n \t\t\t(pt->rx_vdev_stream_type == IFACE) ?\n@@ -663,10 +681,12 @@ create_mp_ring_vdev(void)\n \t\t\tpt->rx_dev) :\n \t\t\tsnprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,\n \t\t\tpt->rx_dev);\n-\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0)\n+\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\"vdev creation failed:%s:%d\\n\",\n \t\t\t\t\t__func__, __LINE__);\n+\t\t\t}\n \t\t\tpt->rx_vdev_id = portid;\n \n \t\t\t/* configure vdev */\n@@ -680,10 +700,13 @@ create_mp_ring_vdev(void)\n \t\t\t\tpt->tx_dev) :\n \t\t\t\tsnprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,\n \t\t\t\tpt->tx_dev);\n-\t\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0)\n+\t\t\t\tif (rte_eth_dev_attach(vdev_args,\n+\t\t\t\t\t\t\t&portid) < 0) {\n+\t\t\t\t\tcleanup_rings();\n \t\t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\t\"vdev creation failed:\"\n \t\t\t\t\t\t\"%s:%d\\n\", __func__, __LINE__);\n+\t\t\t\t}\n \t\t\t\tpt->tx_vdev_id = portid;\n \n \t\t\t\t/* configure vdev */\n@@ -695,19 +718,23 @@ create_mp_ring_vdev(void)\n \t\t\tsnprintf(ring_name, SIZE, RX_RING, i);\n \t\t\tpt->rx_ring = rte_ring_create(ring_name, pt->ring_size,\n \t\t\t\t\trte_socket_id(), 0);\n-\t\t\tif (pt->rx_ring == NULL)\n+\t\t\tif (pt->rx_ring == NULL) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE, \"%s\\n\",\n \t\t\t\t\trte_strerror(rte_errno));\n+\t\t\t}\n \n \t\t\t(pt->rx_vdev_stream_type == IFACE) ?\n \t\t\tsnprintf(vdev_args, SIZE, VDEV_IFACE, RX_STR, i,\n \t\t\t\tpt->rx_dev) :\n \t\t\tsnprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,\n \t\t\t\tpt->rx_dev);\n-\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0)\n+\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\"vdev creation failed:%s:%d\\n\",\n \t\t\t\t\t__func__, __LINE__);\n+\t\t\t}\n \t\t\tpt->rx_vdev_id = portid;\n \t\t\t/* configure vdev */\n \t\t\tconfigure_vdev(pt->rx_vdev_id);\n@@ -717,18 +744,22 @@ create_mp_ring_vdev(void)\n \t\t\tsnprintf(ring_name, SIZE, TX_RING, i);\n \t\t\tpt->tx_ring = rte_ring_create(ring_name, pt->ring_size,\n \t\t\t\t\trte_socket_id(), 0);\n-\t\t\tif (pt->tx_ring == NULL)\n+\t\t\tif (pt->tx_ring == NULL) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE, \"%s\\n\",\n \t\t\t\t\trte_strerror(rte_errno));\n+\t\t\t}\n \n \t\t\t(pt->tx_vdev_stream_type == IFACE) ?\n \t\t\tsnprintf(vdev_args, SIZE, VDEV_IFACE, TX_STR, i,\n \t\t\t\tpt->tx_dev) :\n \t\t\tsnprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,\n \t\t\t\tpt->tx_dev);\n-\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0)\n+\t\t\tif (rte_eth_dev_attach(vdev_args, &portid) < 0) {\n+\t\t\t\tcleanup_rings();\n \t\t\t\trte_exit(EXIT_FAILURE,\n \t\t\t\t\t\"vdev creation failed\\n\");\n+\t\t\t}\n \t\t\tpt->tx_vdev_id = portid;\n \n \t\t\t/* configure vdev */\n",
    "prefixes": [
        "dpdk-dev"
    ]
}