Show a patch.

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

{
    "id": 2383,
    "url": "https://patchwork.libcamera.org/api/patches/2383/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2383/",
    "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": "<20191127084909.10612-5-laurent.pinchart@ideasonboard.com>",
    "date": "2019-11-27T08:49:09",
    "name": "[libcamera-devel,5/5] test: object-invoke: Delete InvokeObject after thread termination",
    "commit_ref": "803e592cf6ff0c58cdb99c00b1508cefd7d85fe0",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e3c8a6596652e1ebd3bbb9637ea950a327525bbd",
    "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/2383/mbox/",
    "series": [
        {
            "id": 580,
            "url": "https://patchwork.libcamera.org/api/series/580/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=580",
            "date": "2019-11-27T08:49:05",
            "name": "[libcamera-devel,1/5] test: message: Fix message handling in MessageReceiver",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/580/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2383/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2383/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 3AFD161C5C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Nov 2019 09:49:29 +0100 (CET)",
            "from pendragon.tok.corp.google.com (unknown [104.132.253.101])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 154419F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Nov 2019 09:49:27 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1574844569;\n\tbh=dggPb64g4G4E36RnOUlFO9IBTdilVFJ4kqh4Q74w8AU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=RvOa/w7ogY9Fu6UF7KtMSBgg6gYsIpPE8LJ21HE9Lh2x0HEDShAwcec0m7Ex8U+2I\n\tuwGGO0ucuqvod6FEUiM17P7ldbuWpgl5I3hVAjJ+TwcZAj0jyTXWKyF/JZmKn8H7J0\n\t+XfUBMocG8qurtfru7NSkDGNAKpKXamhJkm8Kp74=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 27 Nov 2019 10:49:09 +0200",
        "Message-Id": "<20191127084909.10612-5-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191127084909.10612-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191127084909.10612-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 5/5] test: object-invoke: Delete\n\tInvokeObject after thread termination",
        "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": "Wed, 27 Nov 2019 08:49:29 -0000"
    },
    "content": "The InvokeObject instance is created on the stack in the run() method,\nand is thus destroyed before the thread the object is bound to\nterminates. This creates a race condition as the object message handler\ncould be running when the object is deleted. Fix this by moving the\nInvokeObject to a member field.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/object-invoke.cpp | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex 6582fa75ae11..560adee14e3a 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -60,23 +60,22 @@ protected:\n \tint run()\n \t{\n \t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n-\t\tInvokedObject object;\n \n \t\t/*\n \t\t * Test that queued method invocation in the same thread goes\n \t\t * through the event dispatcher.\n \t\t */\n-\t\tobject.invokeMethod(&InvokedObject::method,\n-\t\t\t\t    ConnectionTypeQueued, 42);\n+\t\tobject_.invokeMethod(&InvokedObject::method,\n+\t\t\t\t     ConnectionTypeQueued, 42);\n \n-\t\tif (object.status() != InvokedObject::NoCall) {\n+\t\tif (object_.status() != InvokedObject::NoCall) {\n \t\t\tcerr << \"Method not invoked asynchronously\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n \t\tdispatcher->processEvents();\n \n-\t\tswitch (object.status()) {\n+\t\tswitch (object_.status()) {\n \t\tcase InvokedObject::NoCall:\n \t\t\tcout << \"Method not invoked for main thread\" << endl;\n \t\t\treturn TestFail;\n@@ -87,7 +86,7 @@ protected:\n \t\t\tbreak;\n \t\t}\n \n-\t\tif (object.value() != 42) {\n+\t\tif (object_.value() != 42) {\n \t\t\tcout << \"Method invoked with incorrect value for main thread\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -96,15 +95,15 @@ protected:\n \t\t * Move the object to a thread and verify that auto method\n \t\t * invocation is delivered in the correct thread.\n \t\t */\n-\t\tobject.reset();\n-\t\tobject.moveToThread(&thread_);\n+\t\tobject_.reset();\n+\t\tobject_.moveToThread(&thread_);\n \n \t\tthread_.start();\n \n-\t\tobject.invokeMethod(&InvokedObject::method,\n-\t\t\t\t    ConnectionTypeBlocking, 42);\n+\t\tobject_.invokeMethod(&InvokedObject::method,\n+\t\t\t\t     ConnectionTypeBlocking, 42);\n \n-\t\tswitch (object.status()) {\n+\t\tswitch (object_.status()) {\n \t\tcase InvokedObject::NoCall:\n \t\t\tcout << \"Method not invoked for custom thread\" << endl;\n \t\t\treturn TestFail;\n@@ -115,7 +114,7 @@ protected:\n \t\t\tbreak;\n \t\t}\n \n-\t\tif (object.value() != 42) {\n+\t\tif (object_.value() != 42) {\n \t\t\tcout << \"Method invoked with incorrect value for custom thread\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -131,6 +130,7 @@ protected:\n \n private:\n \tThread thread_;\n+\tInvokedObject object_;\n };\n \n TEST_REGISTER(ObjectInvokeTest)\n",
    "prefixes": [
        "libcamera-devel",
        "5/5"
    ]
}