Show a patch.

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

{
    "id": 17939,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17939/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17939/",
    "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": "<20221202164145.30603-1-jacopo@jmondi.org>",
    "date": "2022-12-02T16:41:44",
    "name": "[libcamera-devel,1/2] libcamera: utils: Wrap usage of lockf()",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "628e5cd4db5292057939dfc9efe15c80af9f698e",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17939/mbox/",
    "series": [
        {
            "id": 3656,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3656/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3656",
            "date": "2022-12-02T16:41:44",
            "name": "[libcamera-devel,1/2] libcamera: utils: Wrap usage of lockf()",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3656/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17939/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17939/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 E72D8BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Dec 2022 16:41:54 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4DA4363336;\n\tFri,  2 Dec 2022 17:41:54 +0100 (CET)",
            "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::222])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 55EA460483\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Dec 2022 17:41:52 +0100 (CET)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id C5EC54000B;\n\tFri,  2 Dec 2022 16:41:51 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669999314;\n\tbh=c5ik94Nur3PWLQReTYSA1lR2gzW8n14wXIWHAS2qIqg=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=KbslqjJz7G4EYERgwbUHijykioNyRtjyk2TTJw9UNLsCqHw2ipEYKbvw86GzzPyZj\n\tPUcxd0mUZ1FDlBjLG/kctJRnGEYWYizvSWnvojaYNSgztiP9uV28lcvIj3dkdzVXa1\n\tODutINBJKgeOSLVjpxkpvv/dqpdkMJteOMKOxyqjhmyy5SmV8MR9VmYWMYvE8Ao1zC\n\tlAtLTU+cyfsp0c55psIekYjnbN4TffnZfFcP/MuqovnhotLuDbFK1ycIrt/VNwy4Cb\n\tRR+l3l6vaCknKzaT5f8cp2DCbpzN4gXxdR84jnOexXcnFqZmCPvD80Ar+w0tj4jU7e\n\twBPLp7Vg7IzjA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  2 Dec 2022 17:41:44 +0100",
        "Message-Id": "<20221202164145.30603-1-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.38.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: utils: Wrap usage of\n\tlockf()",
        "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": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo@jmondi.org>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The lockf() function is not implemented in the Bionic standard C\nlibrary.\n\nAs an alternative, since Linux v2.0 the flock() function is available\nas a direct system call instead of being emulated in the C library.\n\nAs lockf() is instead usually implemented as an interface to fcntl()\nlocking, locks placed by flock() and lockf() might not be detected.\n\nAs reported by the flock() function documentation:\n\nSince kernel 2.0, flock() is implemented as a system call in its own right\nrather than being emulated in the GNU C library as a call to fcntl(2).\nWith this implementation, there is no interaction between the types of\nlock placed by  flock()  and  fc‐ ntl(2), and flock() does not detect\ndeadlock.  (Note, however, that on some systems, such as the modern\nBSDs, flock() and fc‐ ntl(2) locks do interact with one another.)\n\nTo avoid risks of undetected deadlock, provide an wrapper function\nutils, which in case flock() is not available, deflects all calls to\nlockf() instead.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/media_device.cpp | 28 ++++++++++++++++++++++++++++\n 1 file changed, 28 insertions(+)",
    "diff": "diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 52c8e66e9e99..bffb241efa7c 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -20,6 +20,34 @@\n \n #include <libcamera/base/log.h>\n \n+/*\n+ * Android NDK workaround.\n+ *\n+ * Bionic does not implement the lockf function before API release 24.\n+ * If we're building for a recent enough Android release include the\n+ * correct header, if we're building for an older release, deflect\n+ * flock() on the lockf() system call.\n+ *\n+ * A note on flock()/lockf() co-existency: it would be easier to change\n+ * all usages of lockf() in libcamera to flock(). However lockf() is\n+ * implemented as an interface on fcntl() while flock() is a system call\n+ * since Linux v2.0. Locks set with lockf() won't be detected by flock()\n+ * and vice-versa, hence mixing the two is highly undesirable. For this\n+ * reason if lockf() is available prefer it, assuming all other\n+ * applications in the system will do the same. Only deflect on flock()\n+ * as last resort and only on Android systems.\n+ */\n+#if __ANDROID_API__ >= 24\n+\t#include <bits/lockf.h>\n+#elif defined(__ANDROID_API__)\n+\t#undef F_TLOCK\n+\t#undef F_ULOCK\n+\t#include <sys/file.h>\n+\t#define F_TLOCK (LOCK_EX | LOCK_NB)\n+\t#define F_ULOCK LOCK_UN\n+\t#define lockf(f, c, o) flock(f, c)\n+#endif\n+\n /**\n  * \\file media_device.h\n  * \\brief Provide a representation of a Linux kernel Media Controller device\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}