Patch Detail
Show a patch.
GET /api/1.1/patches/346/?format=api
{ "id": 346, "url": "https://patchwork.libcamera.org/api/1.1/patches/346/?format=api", "web_url": "https://patchwork.libcamera.org/patch/346/", "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": "<20190123085923.12524-3-laurent.pinchart@ideasonboard.com>", "date": "2019-01-23T08:59:21", "name": "[libcamera-devel,2/4] libcamera: event_dispatcher_poll: Handle interrupted ppoll() calls", "commit_ref": "d370c1b46e1733905fd76eec004be26475afae9d", "pull_url": null, "state": "accepted", "archived": false, "hash": "1a1f979bb00f94ce311cd30dabce737483db7499", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/346/mbox/", "series": [ { "id": 120, "url": "https://patchwork.libcamera.org/api/1.1/series/120/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=120", "date": "2019-01-23T08:59:19", "name": "Event dispatcher enhancements", "version": 1, "mbox": "https://patchwork.libcamera.org/series/120/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/346/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/346/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 6633060C98\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Jan 2019 09:59:29 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E15C023D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Jan 2019 09:59:28 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548233969;\n\tbh=agpvYX4U9f4P8YjrOd42wLo6vxSKRnt8qWskjDqQIPs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=L+thkplDUnyoK1jHB61ETTBimwQGGWQ72Dyw1gwVLfoP5hYrnc3uMqOW5+iZlS84k\n\tZHGBywjCs4MdrK9hEFz4nhhFYLH0EZnHiwnTmFVmdexBtlIy7IWyjGiz0ts73Lk2Ig\n\t5Kvi9XmCbh9tA8m9wQYyVsatTKseIzQKc2JUmp9c=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 23 Jan 2019 10:59:21 +0200", "Message-Id": "<20190123085923.12524-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190123085923.12524-1-laurent.pinchart@ideasonboard.com>", "References": "<20190123085923.12524-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/4] libcamera: event_dispatcher_poll:\n\tHandle interrupted ppoll() calls", "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": "Wed, 23 Jan 2019 08:59:29 -0000" }, "content": "The ppoll() call can be interrupted if a signal is delivered. Handle the\nEINTR error code gracefully by restarting the call. This fixes the\nevent-dispatcher test failure.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/event_dispatcher_poll.cpp | 58 +++++++++++--------\n src/libcamera/include/event_dispatcher_poll.h | 1 +\n 2 files changed, 34 insertions(+), 25 deletions(-)", "diff": "diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp\nindex eefac54ca6da..6e0609c34ddc 100644\n--- a/src/libcamera/event_dispatcher_poll.cpp\n+++ b/src/libcamera/event_dispatcher_poll.cpp\n@@ -128,32 +128,11 @@ void EventDispatcherPoll::processEvents()\n \tfor (auto notifier : notifiers_)\n \t\tpollfds.push_back({ notifier.first, notifier.second.events(), 0 });\n \n-\t/* Compute the timeout. */\n-\tTimer *nextTimer = !timers_.empty() ? timers_.front() : nullptr;\n-\tstruct timespec timeout;\n-\n-\tif (nextTimer) {\n-\t\tclock_gettime(CLOCK_MONOTONIC, &timeout);\n-\t\tuint64_t now = timeout.tv_sec * 1000000000ULL + timeout.tv_nsec;\n-\n-\t\tif (nextTimer->deadline() > now) {\n-\t\t\tuint64_t delta = nextTimer->deadline() - now;\n-\t\t\ttimeout.tv_sec = delta / 1000000000ULL;\n-\t\t\ttimeout.tv_nsec = delta % 1000000000ULL;\n-\t\t} else {\n-\t\t\ttimeout.tv_sec = 0;\n-\t\t\ttimeout.tv_nsec = 0;\n-\t\t}\n-\n-\t\tLOG(Event, Debug)\n-\t\t\t<< \"timeout \" << timeout.tv_sec << \".\"\n-\t\t\t<< std::setfill('0') << std::setw(9)\n-\t\t\t<< timeout.tv_nsec;\n-\t}\n-\n \t/* Wait for events and process notifiers and timers. */\n-\tret = ppoll(pollfds.data(), pollfds.size(),\n-\t\t nextTimer ? &timeout : nullptr, nullptr);\n+\tdo {\n+\t\tret = poll(&pollfds);\n+\t} while (ret == -1 && errno == EINTR);\n+\n \tif (ret < 0) {\n \t\tret = -errno;\n \t\tLOG(Event, Warning) << \"poll() failed with \" << strerror(-ret);\n@@ -178,6 +157,35 @@ short EventDispatcherPoll::EventNotifierSetPoll::events() const\n \treturn events;\n }\n \n+int EventDispatcherPoll::poll(std::vector<struct pollfd> *pollfds)\n+{\n+\t/* Compute the timeout. */\n+\tTimer *nextTimer = !timers_.empty() ? timers_.front() : nullptr;\n+\tstruct timespec timeout;\n+\n+\tif (nextTimer) {\n+\t\tclock_gettime(CLOCK_MONOTONIC, &timeout);\n+\t\tuint64_t now = timeout.tv_sec * 1000000000ULL + timeout.tv_nsec;\n+\n+\t\tif (nextTimer->deadline() > now) {\n+\t\t\tuint64_t delta = nextTimer->deadline() - now;\n+\t\t\ttimeout.tv_sec = delta / 1000000000ULL;\n+\t\t\ttimeout.tv_nsec = delta % 1000000000ULL;\n+\t\t} else {\n+\t\t\ttimeout.tv_sec = 0;\n+\t\t\ttimeout.tv_nsec = 0;\n+\t\t}\n+\n+\t\tLOG(Event, Debug)\n+\t\t\t<< \"timeout \" << timeout.tv_sec << \".\"\n+\t\t\t<< std::setfill('0') << std::setw(9)\n+\t\t\t<< timeout.tv_nsec;\n+\t}\n+\n+\treturn ppoll(pollfds->data(), pollfds->size(),\n+\t\t nextTimer ? &timeout : nullptr, nullptr);\n+}\n+\n void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pollfds)\n {\n \tstatic const struct {\ndiff --git a/src/libcamera/include/event_dispatcher_poll.h b/src/libcamera/include/event_dispatcher_poll.h\nindex a41926e11a11..ac3efde082b4 100644\n--- a/src/libcamera/include/event_dispatcher_poll.h\n+++ b/src/libcamera/include/event_dispatcher_poll.h\n@@ -41,6 +41,7 @@ private:\n \tstd::map<int, EventNotifierSetPoll> notifiers_;\n \tstd::list<Timer *> timers_;\n \n+\tint poll(std::vector<struct pollfd> *pollfds);\n \tvoid processNotifiers(const std::vector<struct pollfd> &pollfds);\n \tvoid processTimers();\n };\n", "prefixes": [ "libcamera-devel", "2/4" ] }