Show a patch.

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

{
    "id": 1672,
    "url": "https://patchwork.libcamera.org/api/patches/1672/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1672/",
    "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": "<20190712110428.20433-1-laurent.pinchart@ideasonboard.com>",
    "date": "2019-07-12T11:04:28",
    "name": "[libcamera-devel] libcamera: event_notifier_poll: Fix notifier unregistration during event processing",
    "commit_ref": "3e14a1bcb0557e73718d12cd7ef113940472a934",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "24a76153799727eabc388759bce667b6d85f5d55",
    "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/1672/mbox/",
    "series": [
        {
            "id": 424,
            "url": "https://patchwork.libcamera.org/api/series/424/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=424",
            "date": "2019-07-12T11:04:28",
            "name": "[libcamera-devel] libcamera: event_notifier_poll: Fix notifier unregistration during event processing",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/424/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1672/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1672/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@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 114D36156F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2019 13:05:02 +0200 (CEST)",
            "from pendragon.ideasonboard.com (softbank126209254147.bbtec.net\n\t[126.209.254.147])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 91E962B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2019 13:04:59 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562929500;\n\tbh=AxhS7VupOpgofRHankf2MzouTNyXI8dMf4Eu6a50f2s=;\n\th=From:To:Subject:Date:From;\n\tb=AC59DIyRuJNFQ4ngK2NS5EL38H11ABSLm/eHjdO8+1sz4XY+yaEbnxjfUPqo5S2Vb\n\tUI25WAqIBhgvPun4GQAFQW/NBbBtSYbjXTl2Se+LefUDNtJoc4AkM8pccilKxom6mH\n\ta7ZVUD6LMAjuFd9zOMQ10/emFQAHoTBQ/aP2lJrc=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 12 Jul 2019 14:04:28 +0300",
        "Message-Id": "<20190712110428.20433-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: event_notifier_poll: Fix\n\tnotifier unregistration during event processing",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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": "Fri, 12 Jul 2019 11:05:02 -0000"
    },
    "content": "An event notifier may be unregistered from its activated signal. This\ncan cause the notifiers set entry in notifiers_ to be deleted while\nprocessNotifiers() is looping over the notifiers_ map, leading to\nproblems.\n\nTo fix this, add a flag to the EventNotifierPoll class to indicate that\nevent processing is in progress. If the flag is set, the notifiers_\nentry is not deleted during notifier unregistration, but will be deleted\nby the event processing loop.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/event_dispatcher_poll.cpp       | 18 ++++++++++++++++++\n src/libcamera/include/event_dispatcher_poll.h |  2 ++\n 2 files changed, 20 insertions(+)",
    "diff": "diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp\nindex df9dffb2326c..4f15f3e3269b 100644\n--- a/src/libcamera/event_dispatcher_poll.cpp\n+++ b/src/libcamera/event_dispatcher_poll.cpp\n@@ -46,6 +46,7 @@ static const char *notifierType(EventNotifier::Type type)\n  */\n \n EventDispatcherPoll::EventDispatcherPoll()\n+\t: processingEvents_(false)\n {\n \t/*\n \t * Create the event fd. Failures are fatal as we can't implement an\n@@ -96,6 +97,15 @@ void EventDispatcherPoll::unregisterEventNotifier(EventNotifier *notifier)\n \t}\n \n \tset.notifiers[type] = nullptr;\n+\n+\t/*\n+\t * Don't race with event processing if this method is called from an\n+\t * event notifier. The notifiers_ entry will be erased by\n+\t * processEvents().\n+\t */\n+\tif (processingEvents_)\n+\t\treturn;\n+\n \tif (!set.notifiers[0] && !set.notifiers[1] && !set.notifiers[2])\n \t\tnotifiers_.erase(iter);\n }\n@@ -241,6 +251,8 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol\n \t\t{ EventNotifier::Exception, POLLPRI },\n \t};\n \n+\tprocessingEvents_ = true;\n+\n \tfor (const pollfd &pfd : pollfds) {\n \t\tauto iter = notifiers_.find(pfd.fd);\n \t\tASSERT(iter != notifiers_.end());\n@@ -269,7 +281,13 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol\n \t\t\tif (pfd.revents & event.events)\n \t\t\t\tnotifier->activated.emit(notifier);\n \t\t}\n+\n+\t\t/* Erase the notifiers_ entry if it is now empty. */\n+\t\tif (!set.notifiers[0] && !set.notifiers[1] && !set.notifiers[2])\n+\t\t\tnotifiers_.erase(iter);\n \t}\n+\n+\tprocessingEvents_ = false;\n }\n \n void EventDispatcherPoll::processTimers()\ndiff --git a/src/libcamera/include/event_dispatcher_poll.h b/src/libcamera/include/event_dispatcher_poll.h\nindex 14c3eea13b5e..d82b302c4aea 100644\n--- a/src/libcamera/include/event_dispatcher_poll.h\n+++ b/src/libcamera/include/event_dispatcher_poll.h\n@@ -45,6 +45,8 @@ private:\n \tstd::list<Timer *> timers_;\n \tint eventfd_;\n \n+\tbool processingEvents_;\n+\n \tint poll(std::vector<struct pollfd> *pollfds);\n \tvoid processInterrupt(const struct pollfd &pfd);\n \tvoid processNotifiers(const std::vector<struct pollfd> &pollfds);\n",
    "prefixes": [
        "libcamera-devel"
    ]
}