Show a patch.

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

{
    "id": 2684,
    "url": "https://patchwork.libcamera.org/api/patches/2684/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2684/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200118213348.16561-2-laurent.pinchart@ideasonboard.com>",
    "date": "2020-01-18T21:33:47",
    "name": "[libcamera-devel,1/2] libcamera: thread: Add a method to return the ID of the current thread",
    "commit_ref": "1d929967b7d5623ec49f0bbed3abe4fea480011e",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "389a77180acbf0dee1684b93765eaf84abfc5d69",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2684/mbox/",
    "series": [
        {
            "id": 639,
            "url": "https://patchwork.libcamera.org/api/series/639/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=639",
            "date": "2020-01-18T21:33:46",
            "name": "Make log messages more thread-friendly",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/639/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2684/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2684/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A18DE607B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Jan 2020 22:34:07 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3DF939A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Jan 2020 22:34:07 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579383247;\n\tbh=TiQBI0GaiwpcgqVcUXxfoMW34+niDcTNiXYKy8/iTw0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=WEdLel0AU/2w37T5/hDKmpiEGDs9hcE2FlVLwMYP7RDQ2uZtmfagf55IMUFJhQPiI\n\t/iky0QjYHS6Y45ChuhXvp6nT15CaAQOwBk253DYbLYp+bjMlPb9X7PsQWcxiJKZb5Y\n\tTimlR/2vwFRn52TQv55DU7X6Wv/G4nGB4LFzxMcQ=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 18 Jan 2020 23:33:47 +0200",
        "Message-Id": "<20200118213348.16561-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200118213348.16561-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200118213348.16561-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: thread: Add a method to\n\treturn the ID of the current thread",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "X-List-Received-Date": "Sat, 18 Jan 2020 21:34:08 -0000"
    },
    "content": "The current thread ID is useful when logging message to debug\nconcurrency issues. Add a method to retrieve it.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/thread.h |  2 ++\n src/libcamera/thread.cpp       | 20 ++++++++++++++++++++\n 2 files changed, 22 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/thread.h b/src/libcamera/include/thread.h\nindex 37edd4f5138b..819a9879ac56 100644\n--- a/src/libcamera/include/thread.h\n+++ b/src/libcamera/include/thread.h\n@@ -9,6 +9,7 @@\n \n #include <memory>\n #include <mutex>\n+#include <sys/types.h>\n #include <thread>\n \n #include <libcamera/signal.h>\n@@ -39,6 +40,7 @@ public:\n \tSignal<Thread *> finished;\n \n \tstatic Thread *current();\n+\tstatic pid_t currentId();\n \n \tEventDispatcher *eventDispatcher();\n \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\ndiff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp\nindex 18ebd16a7e2f..fe32cd677596 100644\n--- a/src/libcamera/thread.cpp\n+++ b/src/libcamera/thread.cpp\n@@ -9,6 +9,9 @@\n \n #include <atomic>\n #include <list>\n+#include <unistd.h>\n+#include <sys/syscall.h>\n+#include <sys/types.h>\n \n #include <libcamera/event_dispatcher.h>\n \n@@ -62,6 +65,7 @@ private:\n \n \tThread *thread_;\n \tbool running_;\n+\tpid_t tid_;\n \n \tMutex mutex_;\n \n@@ -108,6 +112,7 @@ ThreadData *ThreadData::current()\n \t * started, set it here.\n \t */\n \tThreadData *data = mainThread.data_;\n+\tdata->tid_ = syscall(SYS_gettid);\n \tcurrentThreadData = data;\n \treturn data;\n }\n@@ -189,6 +194,7 @@ void Thread::startThread()\n \t */\n \tthread_local ThreadCleaner cleaner(this, &Thread::finishThread);\n \n+\tdata_->tid_ = syscall(SYS_gettid);\n \tcurrentThreadData = data_;\n \n \trun();\n@@ -308,6 +314,20 @@ Thread *Thread::current()\n \treturn data->thread_;\n }\n \n+/**\n+ * \\brief Retrieve the ID of the current thread\n+ *\n+ * The thread ID corresponds to the Linux thread ID (TID) as returned by the\n+ * gettid system call.\n+ *\n+ * \\return The ID of the current thread\n+ */\n+pid_t Thread::currentId()\n+{\n+\tThreadData *data = ThreadData::current();\n+\treturn data->tid_;\n+}\n+\n /**\n  * \\brief Set the event dispatcher\n  * \\param[in] dispatcher Pointer to the event dispatcher\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}