From nobody Mon Feb 9 02:12:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1572629817; cv=none; d=zoho.com; s=zohoarc; b=P278620ekV9hltdthLF1g+rXO6kaPxcVL9XpFLocO6H1DQBsWoTb643myGeGeJ95zbvym4dQ6Kl6sZ/NeeqYrBSNbChwo8gHfh7UiqNvqtVC7uKFjxj0qHB/y+qWjbZNh+ZhT2Ys2HoYzmHwYrFES04UhX2DQV8Arr+e5Cg/wXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572629817; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tjDz0b32anMgL02113y5/YsDzy3gEVAeC+LMpYYOu8s=; b=ENU5alA3G95o8WKUG+J9T0miYW93FUjmKC4Cb8Ei3H/QnD2lWSLCE5Goud3UUsM55+gO0dE4FRvO3CiUkSCi4ygBLdqWpyKF2t5mS6jZId9IbvIwJM+CJQ9bV6s8pEsqx/JaMDdjhWfkSQsYKjVXu6mXYvd4MekEjU5GhF5bqBE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1572629817551430.4090863443629; Fri, 1 Nov 2019 10:36:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-vL16dZCdNh6PUwfA3N9FLA-1; Fri, 01 Nov 2019 13:36:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FDA1107ACC2; Fri, 1 Nov 2019 17:36:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 675FB1001920; Fri, 1 Nov 2019 17:36:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2307C18089D0; Fri, 1 Nov 2019 17:36:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA1HaHV8028031 for ; Fri, 1 Nov 2019 13:36:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id AEFE26012A; Fri, 1 Nov 2019 17:36:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A920160126 for ; Fri, 1 Nov 2019 17:36:14 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 311B381F13 for ; Fri, 1 Nov 2019 17:36:14 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xA1GrLbj092681 for ; Fri, 1 Nov 2019 13:36:13 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w0r29je0w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Nov 2019 13:36:13 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Nov 2019 17:36:11 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 1 Nov 2019 17:36:09 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xA1Ha8tV32965056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Nov 2019 17:36:08 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAA2642041; Fri, 1 Nov 2019 17:36:08 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DC454203F; Fri, 1 Nov 2019 17:36:08 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.5.215]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Nov 2019 17:36:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572629816; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tjDz0b32anMgL02113y5/YsDzy3gEVAeC+LMpYYOu8s=; b=B9+mNgesnD5WiLL/CqddMfvLtQ7Xn90L91mUo1DCxkifoKLu7KWhBK9SFrcg+BcMjIdwsF Zcly0vv1upeNGop5OcSQ9sKDvQ5Ri7gowdCKE1Lt9Fb5kcl1fdkixKQZZOFP4OC75Wte42 ztMQDUaR1K9VFe4c2jH597f6n3krEdE= From: Marc Hartmayer To: Date: Fri, 1 Nov 2019 18:35:47 +0100 In-Reply-To: <20191101173548.7888-1-mhartmay@linux.ibm.com> References: <20191101173548.7888-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19110117-0008-0000-0000-00000329DDE7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110117-0009-0000-0000-00004A492E44 Message-Id: <20191101173548.7888-6-mhartmay@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-11-01_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=856 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1911010158 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 01 Nov 2019 17:36:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 01 Nov 2019 17:36:14 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa , Pavel Hrdina Subject: [libvirt] [PATCH v3 5/6] rpc: Introduce virNetServerGetProgramLocked helper function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: vL16dZCdNh6PUwfA3N9FLA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This patch introduces virNetServerGetProgramLocked. It's a function to determine which program has to be used for a given @msg. This function will be reused in the next patch. Signed-off-by: Marc Hartmayer Reviewed-by: Pavel Hrdina --- src/rpc/virnetserver.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 54d0e4f31489..154747a1a097 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -171,6 +171,26 @@ static void virNetServerHandleJob(void *jobOpaque, voi= d *opaque) VIR_FREE(job); } =20 +/** + * virNetServerGetProgramLocked: + * @srv: server (must be locked by the caller) + * @msg: message + * + * Searches @srv for the right program for a given message @msg. + * + * Returns a pointer to the server program or NULL if not found. + */ +static virNetServerProgramPtr +virNetServerGetProgramLocked(virNetServerPtr srv, + virNetMessagePtr msg) +{ + size_t i; + for (i =3D 0; i < srv->nprograms; i++) { + if (virNetServerProgramMatches(srv->programs[i], msg)) + return srv->programs[i]; + } + return NULL; +} =20 static void virNetServerDispatchNewMessage(virNetServerClientPtr client, @@ -180,18 +200,12 @@ virNetServerDispatchNewMessage(virNetServerClientPtr = client, virNetServerPtr srv =3D opaque; virNetServerProgramPtr prog =3D NULL; unsigned int priority =3D 0; - size_t i; =20 VIR_DEBUG("server=3D%p client=3D%p message=3D%p", srv, client, msg); =20 virObjectLock(srv); - for (i =3D 0; i < srv->nprograms; i++) { - if (virNetServerProgramMatches(srv->programs[i], msg)) { - prog =3D srv->programs[i]; - break; - } - } + prog =3D virNetServerGetProgramLocked(srv, msg); /* we can unlock @srv since @prog can only become invalid in case * of disposing @srv, but let's grab a ref first to ensure nothing * disposes of it before we use it. */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list