Show a patch.

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

{
    "id": 9529,
    "url": "https://patchwork.libcamera.org/api/patches/9529/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9529/",
    "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": "<20200908075406.14039-1-laurent.pinchart@ideasonboard.com>",
    "date": "2020-09-08T07:54:06",
    "name": "[libcamera-devel] libcamera: camera: Optimize camera deletion",
    "commit_ref": "54557e25f2d478623839fe17f82700bb97fff0b2",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c8dec1c551020947e1f0d309651d3ae8724841e9",
    "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/9529/mbox/",
    "series": [
        {
            "id": 1272,
            "url": "https://patchwork.libcamera.org/api/series/1272/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1272",
            "date": "2020-09-08T07:54:06",
            "name": "[libcamera-devel] libcamera: camera: Optimize camera deletion",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1272/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9529/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9529/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 0DAB6BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Sep 2020 07:54:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A67CF62931;\n\tTue,  8 Sep 2020 09:54:38 +0200 (CEST)",
            "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 C817E60534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Sep 2020 09:54:36 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 57F6239;\n\tTue,  8 Sep 2020 09:54:36 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"m/93tI17\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1599551676;\n\tbh=WQmF94xBZ6D8cdYlZg7HAx0zeHGTIbkWaMjB3lSg1xM=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=m/93tI17JsVPsTH9TBr3m8qAMb7kGTMd61ipN+B72lQP3OoUBvESit/co4zdP9BkX\n\t2faYyS0n/8fei58YF/H67AP1msZkxCpWXWRc8m5akG92weBlbkxegU0v54RXHj6eUV\n\t2Amdp4U7obA4WBaBfjpR5e+oc2QDiXqC/INzu8OI=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  8 Sep 2020 10:54:06 +0300",
        "Message-Id": "<20200908075406.14039-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH] libcamera: camera: Optimize camera\n\tdeletion",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "In most cases the last reference to a Camera instance will be the one\nheld by the CameraManager. That reference gets released when the\nCameraManager thread cleans up, just before it stops. There's no need to\ndelete the camera with deleteLater() in that case.\n\nTo optimize this case, use deleteLater() only when the camera gets\ndeleted from a different thread, and delete is synchronously otherwise.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nUmang, would you be able to test this patch with the Android HAL ?\n\n src/libcamera/camera.cpp | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 4a9c19c33cfb..ae16a64a3b44 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -16,6 +16,7 @@\n \n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n+#include \"libcamera/internal/thread.h\"\n #include \"libcamera/internal/utils.h\"\n \n /**\n@@ -470,7 +471,10 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n \tstruct Deleter : std::default_delete<Camera> {\n \t\tvoid operator()(Camera *camera)\n \t\t{\n-\t\t\tcamera->deleteLater();\n+\t\t\tif (Thread::current() == camera->thread())\n+\t\t\t\tdelete camera;\n+\t\t\telse\n+\t\t\t\tcamera->deleteLater();\n \t\t}\n \t};\n \n",
    "prefixes": [
        "libcamera-devel"
    ]
}