From nobody Sun May 5 18:13:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498478002539126.59970240916914; Mon, 26 Jun 2017 04:53:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 127D8C056782; Mon, 26 Jun 2017 11:53:20 +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 C39F17E0C1; Mon, 26 Jun 2017 11:53:19 +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 633C51804753; Mon, 26 Jun 2017 11:53:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5QBj922020933 for ; Mon, 26 Jun 2017 07:45:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B96360BE6; Mon, 26 Jun 2017 11:45:09 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92E3A18C70; Mon, 26 Jun 2017 11:45:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 127D8C056782 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 127D8C056782 From: Erik Skultety To: libvir-list@redhat.com Date: Mon, 26 Jun 2017 13:47:04 +0200 Message-Id: <786479588e7dccc17a9a890f9405831876c6b52d.1498477381.git.eskultet@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] nodedev: udev: Drop udev monitor fd check in udevEventHandleCallback 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 26 Jun 2017 11:53:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We do perform that magical check every time an event is received, but unless we explicitly unref'd or disconnected the monitor, we should not get a spurious event from a different source. Signed-off-by: Erik Skultety --- This is just a poke patch, since I also checked libudev's source and still = fail to understand why we need that check. Unless entered by *_monitor_unref with the last reference or with *monitor_disconnect, libudev doesn't change the = fd arbitrarily. So the only reason for us to check for that would be if we disconnected from our side, but didn't unregister the callback in which case it was our responsibility to clean up properly and we shouldn't get to the callback in the first place. Thanks for comments in advance. src/node_device/node_device_udev.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 174124a1b..7820c49c4 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1602,24 +1602,15 @@ nodeStateCleanup(void) static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED, - int fd, + int fd ATTRIBUTE_UNUSED, int events ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { struct udev_device *device =3D NULL; struct udev_monitor *udev_monitor =3D DRV_STATE_UDEV_MONITOR(driver); const char *action =3D NULL; - int udev_fd =3D -1; nodeDeviceLock(); - udev_fd =3D udev_monitor_get_fd(udev_monitor); - if (fd !=3D udev_fd) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("File descriptor returned by udev %d does not " - "match node device file descriptor %d"), - fd, udev_fd); - goto cleanup; - } device =3D udev_monitor_receive_device(udev_monitor); if (device =3D=3D NULL) { -- 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list