From patchwork Fri Feb 1 05:18:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fei X-Patchwork-Id: 1034578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=126.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.b="iBRG4MCd"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43rQQG4Shpz9s4V for ; Fri, 1 Feb 2019 16:19:34 +1100 (AEDT) Received: from localhost ([127.0.0.1]:38883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpREi-0003fc-J5 for incoming@patchwork.ozlabs.org; Fri, 01 Feb 2019 00:19:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpRDp-0003fI-1g for qemu-devel@nongnu.org; Fri, 01 Feb 2019 00:18:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpRDo-0007nn-5a for qemu-devel@nongnu.org; Fri, 01 Feb 2019 00:18:37 -0500 Received: from m50-111.126.com ([123.125.50.111]:54057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpRDl-0007mB-G4 for qemu-devel@nongnu.org; Fri, 01 Feb 2019 00:18:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=He9kPS0ctQYpc0HaGI VXNkTsTzSZaSaUV20E+jss/1U=; b=iBRG4MCdY2k0IplIdpLmPQGqLdoirY3hyI DA8z92GRf9JZvKKHtsFEYh3zLaVgCmqqxf59/K+OhyskQzAVkSwrFsa96s3zt2EH Pdtujy4pY5iu3t56Hco5ET5DKDtefj79a3z7UrI2pl0HKx1PUOZLsj73N5eiI8Pd 1h4zpWW7c= Received: from bogon.bytedance.net (unknown [120.52.147.46]) by smtp5 (Coremail) with SMTP id jtKowABXEaSW1lNcujAMAA--.154S12; Fri, 01 Feb 2019 13:18:21 +0800 (CST) From: Fei Li To: qemu-devel@nongnu.org, shirley17fei@gmail.com Date: Fri, 1 Feb 2019 13:18:05 +0800 Message-Id: <20190201051806.53183-11-lifei1214@126.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190201051806.53183-1-lifei1214@126.com> References: <20190201051806.53183-1-lifei1214@126.com> X-CM-TRANSID: jtKowABXEaSW1lNcujAMAA--.154S12 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48Kw13JFWxWryfZw45trb_yoW8tFW5pr yrGry3Ars5twn7ZrW8JayjkFy5urWrGFW7JayfAw1rJw45GrsxA34rKa40vrW8Z3W3Xa1F vF4rWrWIkws2yaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jpVbkUUUUU= X-Originating-IP: [120.52.147.46] X-CM-SenderInfo: 5olivxarsrkqqrswhudrp/1tbiaA5OIVpD7wjdsAABsb X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 123.125.50.111 Subject: [Qemu-devel] [PATCH v11 for-4.0 10/11] qemu_thread: supplement error handling for vnc_start_worker_thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fei Li , Markus Armbruster , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Fei Li Supplement the error handling for vnc_thread_worker_thread: add an Error parameter for it to propagate the error to its caller to handle in case it fails, and make it return a Boolean to indicate whether it succeeds. Cc: Markus Armbruster Cc: Gerd Hoffmann Signed-off-by: Fei Li Reviewed-by: Markus Armbruster --- ui/vnc-jobs.c | 17 +++++++++++------ ui/vnc-jobs.h | 2 +- ui/vnc.c | 4 +++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 5712f1f501..1371895513 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -332,16 +332,21 @@ static bool vnc_worker_thread_running(void) return queue; /* Check global queue */ } -void vnc_start_worker_thread(void) +bool vnc_start_worker_thread(Error **errp) { VncJobQueue *q; - if (vnc_worker_thread_running()) - return ; + if (vnc_worker_thread_running()) { + return true; + } q = vnc_queue_init(); - /* TODO: let the further caller handle the error instead of abort() here */ - qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread, - q, QEMU_THREAD_DETACHED, &error_abort); + if (qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread, + q, QEMU_THREAD_DETACHED, errp) < 0) { + vnc_queue_clear(q); + return false; + } queue = q; /* Set global queue */ + + return true; } diff --git a/ui/vnc-jobs.h b/ui/vnc-jobs.h index 59f66bcc35..14640593db 100644 --- a/ui/vnc-jobs.h +++ b/ui/vnc-jobs.h @@ -37,7 +37,7 @@ void vnc_job_push(VncJob *job); void vnc_jobs_join(VncState *vs); void vnc_jobs_consume_buffer(VncState *vs); -void vnc_start_worker_thread(void); +bool vnc_start_worker_thread(Error **errp); /* Locks */ static inline int vnc_trylock_display(VncDisplay *vd) diff --git a/ui/vnc.c b/ui/vnc.c index 6002d09407..2ab920f1a7 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3255,7 +3255,9 @@ void vnc_display_init(const char *id, Error **errp) vd->connections_limit = 32; qemu_mutex_init(&vd->mutex); - vnc_start_worker_thread(); + if (!vnc_start_worker_thread(errp)) { + return; + } vd->dcl.ops = &dcl_ops; register_displaychangelistener(&vd->dcl);