{"id":13496,"url":"https://patchwork.libcamera.org/api/patches/13496/?format=json","web_url":"https://patchwork.libcamera.org/patch/13496/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210825211852.1207168-4-nicolas@ndufresne.ca>","date":"2021-08-25T21:18:52","name":"[libcamera-devel,v1,3/3] libcamerasrc: Fix deadlock on EOS","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1205a2fd40a2a0091f1b1bfab5e3c8123cb2170b","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/?format=json","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13496/mbox/","series":[{"id":2396,"url":"https://patchwork.libcamera.org/api/series/2396/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2396","date":"2021-08-25T21:18:49","name":"Fix Gnome Cheese and multiple camera","version":1,"mbox":"https://patchwork.libcamera.org/series/2396/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13496/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13496/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 DAB78BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Aug 2021 21:19:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A80EF68891;\n\tWed, 25 Aug 2021 23:19:18 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BAC9688AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Aug 2021 23:19:17 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nicolas) with ESMTPSA id 895081F435D8"],"From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 25 Aug 2021 17:18:52 -0400","Message-Id":"<20210825211852.1207168-4-nicolas@ndufresne.ca>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210825211852.1207168-1-nicolas@ndufresne.ca>","References":"<20210825211852.1207168-1-nicolas@ndufresne.ca>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 3/3] libcamerasrc: Fix deadlock on EOS","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>","Cc":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nIt's not allowed in GStreamer to push events while holding the object\nlock. This reduce the scope into which we hold the object lock. In\nfact we don't need to protect against gst_task_resume() concurrency\nwhen we stop the task as resume only do something if the task is paused.\n\nThis fixes a deadlock when running multiple instances of libcamerasrc\nand closing one of the streaming window.\n\nSigned-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n src/gstreamer/gstlibcamerasrc.cpp | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex bdd9f88c..2be44edd 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -312,12 +312,6 @@ gst_libcamera_src_task_run(gpointer user_data)\n \t}\n \n \t{\n-\t\t/*\n-\t\t * Here we need to decide if we want to pause or stop the task. This\n-\t\t * needs to happen in lock step with the callback thread which may want\n-\t\t * to resume the task.\n-\t\t */\n-\t\tGLibLocker lock(GST_OBJECT(self));\n \t\tif (ret != GST_FLOW_OK) {\n \t\t\tif (ret == GST_FLOW_EOS) {\n \t\t\t\tg_autoptr(GstEvent) eos = gst_event_new_eos();\n@@ -332,6 +326,12 @@ gst_libcamera_src_task_run(gpointer user_data)\n \t\t\treturn;\n \t\t}\n \n+\t\t/*\n+\t\t * Here we need to decide if we want to pause. This needs to\n+\t\t * happen in lock step with the callback thread which may want\n+\t\t * to resume the task and might push pending buffers.\n+\t\t */\n+\t\tGLibLocker lock(GST_OBJECT(self));\n \t\tbool do_pause = true;\n \t\tfor (GstPad *srcpad : state->srcpads_) {\n \t\t\tif (gst_libcamera_pad_has_pending(srcpad)) {\n","prefixes":["libcamera-devel","v1","3/3"]}