get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 101603,
    "url": "http://patches.dpdk.org/api/patches/101603/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211014104907.856490-3-bruce.richardson@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20211014104907.856490-3-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211014104907.856490-3-bruce.richardson@intel.com",
    "date": "2021-10-14T10:49:05",
    "name": "[v9,2/4] telemetry: fix socket path conflicts for in-memory mode",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "66816aa126c5693a026c5121ce476293cc11639f",
    "submitter": {
        "id": 20,
        "url": "http://patches.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20211014104907.856490-3-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 19649,
            "url": "http://patches.dpdk.org/api/series/19649/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=19649",
            "date": "2021-10-14T10:49:03",
            "name": "improve telemetry support with in-memory mode",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/19649/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/101603/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/101603/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 17A0AA0C47;\n\tThu, 14 Oct 2021 12:50:08 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3A52A4123E;\n\tThu, 14 Oct 2021 12:50:01 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n by mails.dpdk.org (Postfix) with ESMTP id 3D9494123D\n for <dev@dpdk.org>; Thu, 14 Oct 2021 12:50:00 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 14 Oct 2021 03:49:59 -0700",
            "from silpixa00399126.ir.intel.com ([10.237.223.151])\n by orsmga007.jf.intel.com with ESMTP; 14 Oct 2021 03:49:56 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10136\"; a=\"227609283\"",
            "E=Sophos;i=\"5.85,372,1624345200\"; d=\"scan'208\";a=\"227609283\"",
            "E=Sophos;i=\"5.85,372,1624345200\"; d=\"scan'208\";a=\"481214294\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Ciara Power <ciara.power@intel.com>,\n David Marchand <david.marchand@redhat.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>,\n Kevin Traynor <ktraynor@redhat.com>,\n Bruce Richardson <bruce.richardson@intel.com>,\n Conor Walsh <conor.walsh@intel.com>",
        "Date": "Thu, 14 Oct 2021 11:49:05 +0100",
        "Message-Id": "<20211014104907.856490-3-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20211014104907.856490-1-bruce.richardson@intel.com>",
        "References": "<20210915141030.23514-1-bruce.richardson@intel.com>\n <20211014104907.856490-1-bruce.richardson@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v9 2/4] telemetry: fix socket path conflicts for\n in-memory mode",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When running using in-memory mode, multiple processes can use the same\nruntime dir, leading to conflicts with the telemetry sockets in that\ndirectory. We can resolve this by appending a suffix to each socket\nbeyond the first, with the suffix being an increasing counter value.\nEach process uses the first unused socket counter value.\n\nFixes: 6dd571fd07c3 (\"telemetry: introduce new functionality\")\n\nReported-by: David Marchand <david.marchand@redhat.com>\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\nAcked-by: Ciara Power <ciara.power@intel.com>\nAcked-by: Kevin Traynor <ktraynor@redhat.com>\nTested-by: Conor Walsh <conor.walsh@intel.com>\n---\n lib/telemetry/telemetry.c | 65 +++++++++++++++++++++++++++++----------\n 1 file changed, 49 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c\nindex 48f4c7ba46..a7483167d4 100644\n--- a/lib/telemetry/telemetry.c\n+++ b/lib/telemetry/telemetry.c\n@@ -457,28 +457,45 @@ create_socket(char *path)\n \n \tstruct sockaddr_un sun = {.sun_family = AF_UNIX};\n \tstrlcpy(sun.sun_path, path, sizeof(sun.sun_path));\n-\tunlink(sun.sun_path);\n+\tTMTY_LOG(DEBUG, \"Attempting socket bind to path '%s'\\n\", path);\n+\n \tif (bind(sock, (void *) &sun, sizeof(sun)) < 0) {\n \t\tstruct stat st;\n \n-\t\tTMTY_LOG(ERR, \"Error binding socket: %s\\n\", strerror(errno));\n-\t\tif (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))\n+\t\tTMTY_LOG(DEBUG, \"Initial bind to socket '%s' failed.\\n\", path);\n+\n+\t\t/* first check if we have a runtime dir */\n+\t\tif (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode)) {\n \t\t\tTMTY_LOG(ERR, \"Cannot access DPDK runtime directory: %s\\n\", socket_dir);\n-\t\tsun.sun_path[0] = 0;\n-\t\tgoto error;\n+\t\t\tclose(sock);\n+\t\t\treturn -ENOENT;\n+\t\t}\n+\n+\t\t/* check if current socket is active */\n+\t\tif (connect(sock, (void *)&sun, sizeof(sun)) == 0) {\n+\t\t\tclose(sock);\n+\t\t\treturn -EADDRINUSE;\n+\t\t}\n+\n+\t\t/* socket is not active, delete and attempt rebind */\n+\t\tTMTY_LOG(DEBUG, \"Attempting unlink and retrying bind\\n\");\n+\t\tunlink(sun.sun_path);\n+\t\tif (bind(sock, (void *) &sun, sizeof(sun)) < 0) {\n+\t\t\tTMTY_LOG(ERR, \"Error binding socket: %s\\n\", strerror(errno));\n+\t\t\tclose(sock);\n+\t\t\treturn -errno; /* if unlink failed, this will be -EADDRINUSE as above */\n+\t\t}\n \t}\n \n \tif (listen(sock, 1) < 0) {\n \t\tTMTY_LOG(ERR, \"Error calling listen for socket: %s\\n\", strerror(errno));\n-\t\tgoto error;\n+\t\tunlink(sun.sun_path);\n+\t\tclose(sock);\n+\t\treturn -errno;\n \t}\n+\tTMTY_LOG(DEBUG, \"Socket creation and binding ok\\n\");\n \n \treturn sock;\n-\n-error:\n-\tclose(sock);\n-\tunlink_sockets();\n-\treturn -1;\n }\n \n static void\n@@ -511,8 +528,10 @@ telemetry_legacy_init(void)\n \t\treturn -1;\n \t}\n \tv1_socket.sock = create_socket(v1_socket.path);\n-\tif (v1_socket.sock < 0)\n+\tif (v1_socket.sock < 0) {\n+\t\tv1_socket.path[0] = '\\0';\n \t\treturn -1;\n+\t}\n \trc = pthread_create(&t_old, NULL, socket_listener, &v1_socket);\n \tif (rc != 0) {\n \t\tTMTY_LOG(ERR, \"Error with create legcay socket thread: %s\\n\",\n@@ -533,7 +552,9 @@ telemetry_legacy_init(void)\n static int\n telemetry_v2_init(void)\n {\n+\tchar spath[sizeof(v2_socket.path)];\n \tpthread_t t_new;\n+\tshort suffix = 0;\n \tint rc;\n \n \tv2_socket.num_clients = &v2_clients;\n@@ -544,15 +565,27 @@ telemetry_v2_init(void)\n \trte_telemetry_register_cmd(\"/help\", command_help,\n \t\t\t\"Returns help text for a command. Parameters: string command\");\n \tv2_socket.fn = client_handler;\n-\tif (strlcpy(v2_socket.path, get_socket_path(socket_dir, 2),\n-\t\t\tsizeof(v2_socket.path)) >= sizeof(v2_socket.path)) {\n+\tif (strlcpy(spath, get_socket_path(socket_dir, 2), sizeof(spath)) >= sizeof(spath)) {\n \t\tTMTY_LOG(ERR, \"Error with socket binding, path too long\\n\");\n \t\treturn -1;\n \t}\n+\tmemcpy(v2_socket.path, spath, sizeof(v2_socket.path));\n \n \tv2_socket.sock = create_socket(v2_socket.path);\n-\tif (v2_socket.sock < 0)\n-\t\treturn -1;\n+\twhile (v2_socket.sock < 0) {\n+\t\t/* bail out on unexpected error, or suffix wrap-around */\n+\t\tif (v2_socket.sock != -EADDRINUSE || suffix < 0) {\n+\t\t\tv2_socket.path[0] = '\\0'; /* clear socket path */\n+\t\t\treturn -1;\n+\t\t}\n+\t\t/* add a suffix to the path if the basic version fails */\n+\t\tif (snprintf(v2_socket.path, sizeof(v2_socket.path), \"%s:%d\",\n+\t\t\t\tspath, ++suffix) >= (int)sizeof(v2_socket.path)) {\n+\t\t\tTMTY_LOG(ERR, \"Error with socket binding, path too long\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tv2_socket.sock = create_socket(v2_socket.path);\n+\t}\n \trc = pthread_create(&t_new, NULL, socket_listener, &v2_socket);\n \tif (rc != 0) {\n \t\tTMTY_LOG(ERR, \"Error with create socket thread: %s\\n\",\n",
    "prefixes": [
        "v9",
        "2/4"
    ]
}