Show a patch.

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

{
    "id": 3905,
    "url": "https://patchwork.libcamera.org/api/patches/3905/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3905/",
    "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": "<20200603141609.18584-2-paul.elder@ideasonboard.com>",
    "date": "2020-06-03T14:16:05",
    "name": "[libcamera-devel,1/5] IPAManager: make IPAManager lifetime explicitly managed",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c24534b059b993971b3993d0f5c42e2781b1a9ba",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3905/mbox/",
    "series": [
        {
            "id": 946,
            "url": "https://patchwork.libcamera.org/api/series/946/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=946",
            "date": "2020-06-03T14:16:04",
            "name": "Support qv4l2 with v4l2-compat",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/946/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3905/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3905/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<paul.elder@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9C19610CD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jun 2020 16:16:23 +0200 (CEST)",
            "from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp\n\t[118.238.243.68])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 96ED327C;\n\tWed,  3 Jun 2020 16:16:22 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LWhT9JBN\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591193783;\n\tbh=AIr7wRNotOTy7U1Ar79JAo4BPF97/S2I+/BM2hurd6c=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=LWhT9JBNdM7z3OFCOCCoiJT5tIT+WhzkPwaDQMOh1tN7WZl/mEFd6DqFCrJsbiTP6\n\toj/W+xvPqr5J5Ro/M6koh0/7n3xagvOWLFeRkcxHkYxOXjopWpGoVPha5silPTPfxi\n\tC0r0laQdcMe3AoMf9vTPrrRHpjkf5jHGtmICsK48=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  3 Jun 2020 23:16:05 +0900",
        "Message-Id": "<20200603141609.18584-2-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20200603141609.18584-1-paul.elder@ideasonboard.com>",
        "References": "<20200603141609.18584-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/5] IPAManager: make IPAManager lifetime\n\texplicitly managed",
        "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, 03 Jun 2020 14:16:24 -0000"
    },
    "content": "If any ipa_context instances are destroyed before the IPAManager is\ndestroyed, then a segfault will occur when the IPAManager is\ndeconstructed, as it tries to destroy all of the IPAs that it manages.\nFix this by making the lifetime of the IPAManager explicit, and make the\nCameraManager construct and deconstruct (automatically, via a unique\npointer) the IPAManager.\n\nAlso update the IPA interface test to do the construction and\ndeconstruction of the IPAManager, as it does not use the CameraManager.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/camera_manager.h       |  4 ++++\n include/libcamera/internal/ipa_manager.h |  7 ++++---\n src/libcamera/camera_manager.cpp         |  4 +++-\n src/libcamera/ipa_manager.cpp            | 13 +++++++++++--\n test/ipa/ipa_interface_test.cpp          |  5 +++++\n 5 files changed, 27 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\nindex 079f848a..8f9398fa 100644\n--- a/include/libcamera/camera_manager.h\n+++ b/include/libcamera/camera_manager.h\n@@ -14,6 +14,8 @@\n \n #include <libcamera/object.h>\n \n+#include \"libcamera/internal/ipa_manager.h\"\n+\n namespace libcamera {\n \n class Camera;\n@@ -48,6 +50,8 @@ private:\n \n \tclass Private;\n \tstd::unique_ptr<Private> p_;\n+\n+\tstd::unique_ptr<IPAManager> ipaManager_;\n };\n \n } /* namespace libcamera */\ndiff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\nindex 2412d757..65303d6d 100644\n--- a/include/libcamera/internal/ipa_manager.h\n+++ b/include/libcamera/internal/ipa_manager.h\n@@ -22,6 +22,9 @@ namespace libcamera {\n class IPAManager\n {\n public:\n+\tIPAManager();\n+\t~IPAManager();\n+\n \tstatic IPAManager *instance();\n \n \tstd::unique_ptr<IPAProxy> createIPA(PipelineHandler *pipe,\n@@ -30,9 +33,7 @@ public:\n \n private:\n \tstd::vector<IPAModule *> modules_;\n-\n-\tIPAManager();\n-\t~IPAManager();\n+\tstatic IPAManager *self_;\n \n \tvoid parseDir(const char *libDir, unsigned int maxDepth,\n \t\t      std::vector<std::string> &files);\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 849377ad..d19348df 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -15,6 +15,7 @@\n \n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/event_dispatcher_poll.h\"\n+#include \"libcamera/internal/ipa_manager.h\"\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n #include \"libcamera/internal/thread.h\"\n@@ -246,7 +247,8 @@ void CameraManager::Private::removeCamera(Camera *camera)\n CameraManager *CameraManager::self_ = nullptr;\n \n CameraManager::CameraManager()\n-\t: p_(new CameraManager::Private(this))\n+\t: p_(new CameraManager::Private(this)), ipaManager_(new IPAManager())\n+\n {\n \tif (self_)\n \t\tLOG(Camera, Fatal)\ndiff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex 505cf610..74112cde 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -93,8 +93,14 @@ LOG_DEFINE_CATEGORY(IPAManager)\n  * plain C API, or to transmit the data to the isolated process through IPC.\n  */\n \n+IPAManager *IPAManager::self_ = nullptr;\n+\n IPAManager::IPAManager()\n {\n+\tif (self_)\n+\t\tLOG(IPAManager, Fatal)\n+\t\t\t<< \"Multiple IPAManager objects are not allowed\";\n+\n \tunsigned int ipaCount = 0;\n \n \t/* User-specified paths take precedence. */\n@@ -134,12 +140,16 @@ IPAManager::IPAManager()\n \tif (!ipaCount)\n \t\tLOG(IPAManager, Warning)\n \t\t\t<< \"No IPA found in '\" IPA_MODULE_DIR \"'\";\n+\n+\tself_ = this;\n }\n \n IPAManager::~IPAManager()\n {\n \tfor (IPAModule *module : modules_)\n \t\tdelete module;\n+\n+\tself_ = nullptr;\n }\n \n /**\n@@ -153,8 +163,7 @@ IPAManager::~IPAManager()\n  */\n IPAManager *IPAManager::instance()\n {\n-\tstatic IPAManager ipaManager;\n-\treturn &ipaManager;\n+\treturn self_;\n }\n \n /**\ndiff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nindex 2f02af49..153493ba 100644\n--- a/test/ipa/ipa_interface_test.cpp\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -39,11 +39,15 @@ public:\n \t~IPAInterfaceTest()\n \t{\n \t\tdelete notifier_;\n+\t\tipa_.reset();\n+\t\tipaManager_.reset();\n \t}\n \n protected:\n \tint init() override\n \t{\n+\t\tipaManager_ = make_unique<IPAManager>();\n+\n \t\t/* Create a pipeline handler for vimc. */\n \t\tstd::vector<PipelineHandlerFactory *> &factories =\n \t\t\tPipelineHandlerFactory::factories();\n@@ -161,6 +165,7 @@ private:\n \n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::unique_ptr<IPAProxy> ipa_;\n+\tstd::unique_ptr<IPAManager> ipaManager_;\n \tenum IPAOperationCode trace_;\n \tEventNotifier *notifier_;\n \tint fd_;\n",
    "prefixes": [
        "libcamera-devel",
        "1/5"
    ]
}