From nobody Sun Feb 8 17:21:20 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=1573753603; cv=none; d=zoho.com; s=zohoarc; b=EVuiiTIrJWSe/I/oXlyOPJnYxpHovqmXZyAi3DWfw80zjx99Vjm6hiYMX6NgB4fl1FZu3haKrWc3nHK0Y5119VfjQOcK3X5wdNkmz3Djgewb2juwkRfrMrBaYePshlu3eByz6y+PKKG/TQcrixAlZQuXzNC/uYiJVdDE30GBHGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573753603; 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=eKXXsn8/GhnY/a9r3e4FzRSF/2Gtixo+cpKoeNyiMKM=; b=cE324cLS6cXRCYb62O+EZsxdJbvDyiR2kef4h+Mog0m1hxLzaBnQv3DBUcB0EdSM800lXkg6zBzSCXRp9NVDb24U+eCedguM7og2dtzqz4LhyJvWsGWBX0m43QAJsoGgRbK7w0VAkI3gGSpipc3NN51FCz6rwEYs42cpDtSY9wE= 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 1573753603875716.0928625836631; Thu, 14 Nov 2019 09:46:43 -0800 (PST) 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-15-mAU9F7BNNumrejTp-1nOgw-1; Thu, 14 Nov 2019 12:45:26 -0500 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 7CEEA189D86A; Thu, 14 Nov 2019 17:45:16 +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 155971036C85; Thu, 14 Nov 2019 17:45:16 +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 9BADE1832D73; Thu, 14 Nov 2019 17:45:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAEHisvg002270 for ; Thu, 14 Nov 2019 12:44:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88B092037E64; Thu, 14 Nov 2019 17:44:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81F8C2037E62 for ; Thu, 14 Nov 2019 17:44:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20B62800FF9 for ; Thu, 14 Nov 2019 17:44:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-1lV_8K5ONC6sJiJe8IpUjg-1; Thu, 14 Nov 2019 12:44:49 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xAEHXaQY050026 for ; Thu, 14 Nov 2019 12:44:48 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w9a9xkdw5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 12:44:47 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Nov 2019 17:44:45 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 14 Nov 2019 17:44:43 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAEHigTT60686550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Nov 2019 17:44:42 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36FD2AE04D; Thu, 14 Nov 2019 17:44:42 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10653AE051; Thu, 14 Nov 2019 17:44:42 +0000 (GMT) Received: from marcibm.boeblingen.de.ibm.com (unknown [9.152.224.228]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 14 Nov 2019 17:44:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573753602; 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=eKXXsn8/GhnY/a9r3e4FzRSF/2Gtixo+cpKoeNyiMKM=; b=ALLTUkTlRDGJTUxtOxRIg7+j98A08RgUFqkpo2Od4cX6WLcVIwCVBNLMJ1Lt6ivDVcUoh6 MlBb8UrmxiHECfILpfUQKQJWwdOyPxzQsUL5fymzUm3iK872+TXO0zUxR7RTa8Yz0lNXDn NEVbwVGZfvRf/woVsx1cwYzlge5UOIQ= From: Marc Hartmayer To: Date: Thu, 14 Nov 2019 18:44:23 +0100 In-Reply-To: <20191114174425.13583-1-mhartmay@linux.ibm.com> References: <20191114174425.13583-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19111417-0028-0000-0000-000003B6EC35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111417-0029-0000-0000-00002479FACC Message-Id: <20191114174425.13583-6-mhartmay@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-11-14_05:, , 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=881 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911140152 X-MC-Unique: 1lV_8K5ONC6sJiJe8IpUjg-1 X-MC-Unique: mAU9F7BNNumrejTp-1nOgw-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAEHisvg002270 X-loop: libvir-list@redhat.com Cc: Peter Krempa , Pavel Hrdina Subject: [libvirt] [PATCH v4 5/7] 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-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 673bb7c10c86..41226368058f 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -166,6 +166,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, @@ -175,18 +195,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