Show a patch.

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

{
    "id": 22678,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22678/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22678/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250130115001.1129305-20-pobrn@protonmail.com>",
    "date": "2025-01-30T11:51:41",
    "name": "[RFC,v3,19/21] apps: lc-compliance: Run request completion handler in \"main\" thread",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4e5907c4c12522a31ba5dafb6bb8951260505f73",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/1.1/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22678/mbox/",
    "series": [
        {
            "id": 4978,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4978/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4978",
            "date": "2025-01-30T11:50:08",
            "name": "apps: lc-compliance: Multi-stream tests",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4978/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22678/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22678/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 0AE91BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jan 2025 11:51:50 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C070F68586;\n\tThu, 30 Jan 2025 12:51:49 +0100 (CET)",
            "from mail-10631.protonmail.ch (mail-10631.protonmail.ch\n\t[79.135.106.31])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 99E8C68585\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jan 2025 12:51:47 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"iTVx9enu\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738237907; x=1738497107;\n\tbh=WA9XW3ePOxUFoUm4S12Lvq92T+nfxRnepdlU4S8fWwg=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=iTVx9enuH0bykoK+WF5Klr1yYR0D9PtOZDMgaip3jn5U+bPA+MN7j9IPmVcv/4W/r\n\tFa0cFGSiqJksgIKputaQm4TLtetbuju0k7DPPG20ymMhFJ+XrbVmfIY6VVYWIRASPj\n\tWqtIRNkT1JR3+CKPSz8ORMQdZYFLlDiQqCGrGx+0CILMO1xqCPtQhTrUU1Fj3KwLeg\n\tvETwHlYcmbUYU4J6drs0gGrdbJiKHYr2cEI7yxUWvXRGBJKHmz6/+lD8e6acmviemq\n\tTkz4CaLCr8g/g3dSkhP8JbiPjD0yJs4YtZV5ub5kugUaOdCUbPgYcSwTZ6O+WS1Yho\n\toHRjkxi6q4mYA==",
        "Date": "Thu, 30 Jan 2025 11:51:41 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Subject": "[RFC PATCH v3 19/21] apps: lc-compliance: Run request completion\n\thandler in \"main\" thread",
        "Message-ID": "<20250130115001.1129305-20-pobrn@protonmail.com>",
        "In-Reply-To": "<20250130115001.1129305-1-pobrn@protonmail.com>",
        "References": "<20250130115001.1129305-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "8d23c9458e26aa7527bad0cb73628c6c8a0e7d6f",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=utf-8",
        "Content-Transfer-Encoding": "quoted-printable",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Currently, `Capture::requestCompleted()` runs in the `CameraManager`'s\nthread. This makes it a bit more complicated to use googletest and\nreport errors in those callbacks since lc-compliance sets up\ngoogletest to throw exceptions on fatal errors / test skip, but\nthose exceptions are only caught on the \"main\" thread, the one\nrunning the test suite.\n\nTo minimize the burden of dealing with synchronization in tests,\nexecute `Capture::requestCompleted()` in the event loop's thread\nby utilizing `EventLoop::callLater()`.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/apps/lc-compliance/helpers/capture.cpp | 24 +++++++++++++---------\n src/apps/lc-compliance/helpers/capture.h   |  2 +-\n 2 files changed, 15 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp\nindex 4a8627662..5032470d9 100644\n--- a/src/apps/lc-compliance/helpers/capture.cpp\n+++ b/src/apps/lc-compliance/helpers/capture.cpp\n@@ -127,17 +127,13 @@ void Capture::prepareRequests()\n \t}\n }\n \n-int Capture::queueRequest(libcamera::Request *request)\n+void Capture::queueRequest(libcamera::Request *request)\n {\n \tif (queueLimit_ && queueCount_ >= *queueLimit_)\n-\t\treturn 0;\n-\n-\tint ret = camera_->queueRequest(request);\n-\tif (ret < 0)\n-\t\treturn ret;\n+\t\treturn;\n \n+\tASSERT_EQ(camera_->queueRequest(request), 0);\n \tqueueCount_ += 1;\n-\treturn 0;\n }\n \n void Capture::requestComplete(Request *request)\n@@ -152,8 +148,7 @@ void Capture::requestComplete(Request *request)\n \t\t<< \"Request didn't complete successfully\";\n \n \trequest->reuse(Request::ReuseBuffers);\n-\tif (queueRequest(request))\n-\t\tloop_->exit(-EINVAL);\n+\tqueueRequest(request);\n }\n \n void Capture::start()\n@@ -172,7 +167,14 @@ void Capture::start()\n \n \tASSERT_TRUE(allocator_.allocated());\n \n-\tcamera_->requestCompleted.connect(this, &Capture::requestComplete);\n+\tcamera_->requestCompleted.connect(this, [this](libcamera::Request *request) {\n+\t\t/* Runs in the CameraManager thread. */\n+\n+\t\tloop_->callLater([this, request] {\n+\t\t\t/* Run handler in the context of the event loop. */\n+\t\t\trequestComplete(request);\n+\t\t}, reinterpret_cast<std::uintptr_t>(this));\n+\t});\n \n \tASSERT_EQ(camera_->start(), 0) << \"Failed to start camera\";\n }\n@@ -188,6 +190,8 @@ void Capture::stop()\n \n \trequests_.clear();\n \n+\tloop_->cancelLater(reinterpret_cast<std::uintptr_t>(this));\n+\n \tfor (const auto &cfg : *config_) {\n \t\tint ret = allocator_.free(cfg.stream());\n \t\tEXPECT_EQ(ret, 0) << \"Failed to free buffers associated with stream\";\ndiff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h\nindex 48a8dadcb..dacce1fe2 100644\n--- a/src/apps/lc-compliance/helpers/capture.h\n+++ b/src/apps/lc-compliance/helpers/capture.h\n@@ -30,7 +30,7 @@ private:\n \tvoid stop();\n \n \tvoid prepareRequests();\n-\tint queueRequest(libcamera::Request *request);\n+\tvoid queueRequest(libcamera::Request *request);\n \tvoid requestComplete(libcamera::Request *request);\n \n \tstd::shared_ptr<libcamera::Camera> camera_;\n",
    "prefixes": [
        "RFC",
        "v3",
        "19/21"
    ]
}