Patch Detail
Show a patch.
GET /api/patches/16412/?format=api
{ "id": 16412, "url": "https://patchwork.libcamera.org/api/patches/16412/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16412/", "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": "<20220629070416.17550-7-tomi.valkeinen@ideasonboard.com>", "date": "2022-06-29T07:04:08", "name": "[libcamera-devel,v2,06/14] py: Use UniqueFD", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a8cd8f5ff68e02b51772f645f7aa76bf7b84cc48", "submitter": { "id": 109, "url": "https://patchwork.libcamera.org/api/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16412/mbox/", "series": [ { "id": 3230, "url": "https://patchwork.libcamera.org/api/series/3230/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3230", "date": "2022-06-29T07:04:02", "name": "Python bindings event handling", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3230/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16412/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16412/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 1E6D9BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jun 2022 07:04:53 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BDC2165653;\n\tWed, 29 Jun 2022 09:04:52 +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 B813F65637\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jun 2022 09:04:43 +0200 (CEST)", "from deskari.lan (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 00A786D1;\n\tWed, 29 Jun 2022 09:04:42 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656486292;\n\tbh=eCXWxXuGWl5r0HMuik1XEkAxHOfVyvYcsHvaM+5SdA8=;\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=ZqsHrosGcd1hByBFUH7N2WT0Ii8w2NvNn5y9Js5cNyfo/XW14gLue/3FQURkEg0JR\n\tbPLEEkgSNdVcVgZRBBCzCXxjY6JkW3E6BNuryRhejmUZ5z4GV1YIJYlf+Zjd3lV/n7\n\teJKMY5Hxis/ogMbJ9y25Iu9NmQVmqjcbo7+Y+Bf08TaV+6XI9lYazDr7drqVyKB65N\n\tQGOHdXNkOl5wRHbbXya4nnT/NDxytHXSEB7c7pDpm/PCfVGSS7Sq2zdi+hJMNUkfp9\n\ta6682zV381nvJvNTxhK5QDXHGpvVv4hMxj3t+psZYnx/eycFTsy5hDK7kqP1JJp6Hd\n\tFVIO6khn9C5Qg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656486283;\n\tbh=eCXWxXuGWl5r0HMuik1XEkAxHOfVyvYcsHvaM+5SdA8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=bE4ErwcfkE4emc2rUBusoqD4ImIZFxnLLDscJEapXntVV/aOUpinwRi+Izh2i+1AA\n\txzaFKHOBAZtDo4s6BnsMAgO1Hy/MIYlYbdksJxp2hL8dhBMEg16gYey2wi129yzzhW\n\tjzdm3Z7Ot8/qGmfSG0bLyhQxRLxrVStI8v2CbHGA=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"bE4Erwcf\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>", "Date": "Wed, 29 Jun 2022 10:04:08 +0300", "Message-Id": "<20220629070416.17550-7-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220629070416.17550-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220629070416.17550-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 06/14] py: Use UniqueFD", "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": "Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Use UniqueFD to automate the eventfd lifetime management.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n---\n src/py/libcamera/py_camera_manager.cpp | 16 ++++------------\n src/py/libcamera/py_camera_manager.h | 4 ++--\n 2 files changed, 6 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/py/libcamera/py_camera_manager.cpp b/src/py/libcamera/py_camera_manager.cpp\nindex ad47271d..51a890c8 100644\n--- a/src/py/libcamera/py_camera_manager.cpp\n+++ b/src/py/libcamera/py_camera_manager.cpp\n@@ -27,25 +27,17 @@ PyCameraManager::PyCameraManager()\n \t\tthrow std::system_error(errno, std::generic_category(),\n \t\t\t\t\t\"Failed to create eventfd\");\n \n-\teventFd_ = fd;\n+\teventFd_ = UniqueFD(fd);\n \n \tint ret = cameraManager_->start();\n-\tif (ret) {\n-\t\tclose(fd);\n-\t\teventFd_ = -1;\n+\tif (ret)\n \t\tthrow std::system_error(-ret, std::generic_category(),\n \t\t\t\t\t\"Failed to start CameraManager\");\n-\t}\n }\n \n PyCameraManager::~PyCameraManager()\n {\n \tLOG(Python, Debug) << \"~PyCameraManager()\";\n-\n-\tif (eventFd_ != -1) {\n-\t\tclose(eventFd_);\n-\t\teventFd_ = -1;\n-\t}\n }\n \n py::list PyCameraManager::cameras()\n@@ -93,7 +85,7 @@ void PyCameraManager::writeFd()\n {\n \tuint64_t v = 1;\n \n-\tsize_t s = write(eventFd_, &v, 8);\n+\tsize_t s = write(eventFd_.get(), &v, 8);\n \t/*\n \t * We should never fail, and have no simple means to manage the error,\n \t * so let's log a fatal error.\n@@ -106,7 +98,7 @@ void PyCameraManager::readFd()\n {\n \tuint8_t buf[8];\n \n-\tif (read(eventFd_, buf, 8) != 8)\n+\tif (read(eventFd_.get(), buf, 8) != 8)\n \t\tthrow std::system_error(errno, std::generic_category());\n }\n \ndiff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h\nindex 9c15f814..710163e8 100644\n--- a/src/py/libcamera/py_camera_manager.h\n+++ b/src/py/libcamera/py_camera_manager.h\n@@ -24,7 +24,7 @@ public:\n \n \tstatic const std::string &version() { return CameraManager::version(); }\n \n-\tint eventFd() const { return eventFd_; }\n+\tint eventFd() const { return eventFd_.get(); }\n \n \tstd::vector<pybind11::object> getReadyRequests();\n \n@@ -33,7 +33,7 @@ public:\n private:\n \tstd::unique_ptr<CameraManager> cameraManager_;\n \n-\tint eventFd_ = -1;\n+\tUniqueFD eventFd_;\n \tstd::mutex completedRequestsMutex_;\n \tstd::vector<Request *> completedRequests_;\n \n", "prefixes": [ "libcamera-devel", "v2", "06/14" ] }