Show a patch.

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

{
    "id": 19426,
    "url": "https://patchwork.libcamera.org/api/patches/19426/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19426/",
    "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": "<20240121035948.4226-6-laurent.pinchart@ideasonboard.com>",
    "date": "2024-01-21T03:59:41",
    "name": "[libcamera-devel,05/12] test: event-thread: Destroy Object from correct thread context",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "516cb0899b024a3249cfdd6ebb0e44596e6d6b1b",
    "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/19426/mbox/",
    "series": [
        {
            "id": 4149,
            "url": "https://patchwork.libcamera.org/api/series/4149/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4149",
            "date": "2024-01-21T03:59:36",
            "name": "libcamera: Hardening against thread race conditions",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4149/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19426/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19426/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 84310C32BC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Jan 2024 03:59:57 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 253F562945;\n\tSun, 21 Jan 2024 04:59:57 +0100 (CET)",
            "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 A00946293E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Jan 2024 04:59:52 +0100 (CET)",
            "from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8DD798D4;\n\tSun, 21 Jan 2024 04:58:40 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705809597;\n\tbh=ezRIQuCZBnWVllkKVhQA2PQQBoAV/G8PQmQ/Z/WIfGs=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=vUZuDwqpo7g+zhmfSf05JOpv3OIqN4nl/8oBh27lP45AoNXs7vvnxW7WHIzVqLvCM\n\t82RlIHrvHxWJukUuc9Ch9dvuV5dY1sYW09pECkA+9dAtl23nh5bbiJGU/Pg73BMVfe\n\tHnLXaSUgXFVwUpS/rRfLbRIrFJNxTr724uH7B7irJDaWtLC1USAKUNeffrriGRnvdp\n\tIhAlMg8wREEjLgo8WvAK2amWIzKBjQQn2fSO5Wl2g8pKcOQqgqzB5cPy57BPtQubBd\n\tDjnOmTVoK7x7btdi24yAWKNXbD3x+21pHJZZtJG2xOsSkF5IvzQQQqynnAOxKK5ELS\n\t7EG71x/658CGw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1705809520;\n\tbh=ezRIQuCZBnWVllkKVhQA2PQQBoAV/G8PQmQ/Z/WIfGs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=c9s0JG50zOgsJ9VKKgzV83VYFtU1rRNDiMxqO5XYugRO6+4MXFNfQJZMHHxNCBgd4\n\t9I2nT7X4jakbXYBXGfPtxqMfOZ6fiAzRykwhvD1lit2qTqAwS+WTpK2xW5+37oCeZS\n\tgV2+xWSg//DznIv0AuIT/nOGRUpSp9XF1o9z4qto="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"c9s0JG50\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 21 Jan 2024 05:59:41 +0200",
        "Message-ID": "<20240121035948.4226-6-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240121035948.4226-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20240121035948.4226-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 05/12] test: event-thread: Destroy Object\n\tfrom correct thread context",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The EventHandler used in the test is destroyed from the main thread,\nwhich is invalid for a thread-bound object bound to a different thread.\nFix it by destroying it with deleteLater().\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/event-thread.cpp | 37 +++++++++++++++++++++++++++----------\n 1 file changed, 27 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/test/event-thread.cpp b/test/event-thread.cpp\nindex 88a8c07ef9f0..d6e5d27af185 100644\n--- a/test/event-thread.cpp\n+++ b/test/event-thread.cpp\n@@ -85,10 +85,17 @@ private:\n class EventThreadTest : public Test\n {\n protected:\n+\tint init()\n+\t{\n+\t\tthread_.start();\n+\n+\t\thandler_ = new EventHandler();\n+\n+\t\treturn TestPass;\n+\t}\n+\n \tint run()\n \t{\n-\t\tThread thread;\n-\t\tthread.start();\n \n \t\t/*\n \t\t * Fire the event notifier and then move the notifier to a\n@@ -98,23 +105,33 @@ protected:\n \t\t * different thread will correctly process already pending\n \t\t * events in the new thread.\n \t\t */\n-\t\tEventHandler handler;\n-\t\thandler.notify();\n-\t\thandler.moveToThread(&thread);\n+\t\thandler_->notify();\n+\t\thandler_->moveToThread(&thread_);\n \n \t\tthis_thread::sleep_for(chrono::milliseconds(100));\n \n-\t\t/* Must stop thread before destroying the handler. */\n-\t\tthread.exit(0);\n-\t\tthread.wait();\n-\n-\t\tif (!handler.notified()) {\n+\t\tif (!handler_->notified()) {\n \t\t\tcout << \"Thread event handling test failed\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n \t\treturn TestPass;\n \t}\n+\n+\tvoid cleanup()\n+\t{\n+\t\t/*\n+\t\t * Object class instances must be destroyed from the thread\n+\t\t * they live in.\n+\t\t */\n+\t\thandler_->deleteLater();\n+\t\tthread_.exit(0);\n+\t\tthread_.wait();\n+\t}\n+\n+private:\n+\tEventHandler *handler_;\n+\tThread thread_;\n };\n \n TEST_REGISTER(EventThreadTest)\n",
    "prefixes": [
        "libcamera-devel",
        "05/12"
    ]
}