[igt-dev] [PATCH i-g-t] testdisplay: Don't double-close udev fd
Saarinen, Jani
jani.saarinen at intel.com
Mon Sep 23 14:47:43 UTC 2019
Hi,
> -----Original Message-----
> From: Latvala, Petri
> Sent: maanantai 23. syyskuuta 2019 16.06
> To: igt-dev at lists.freedesktop.org
> Cc: Latvala, Petri <petri.latvala at intel.com>; Saarinen, Jani
> <jani.saarinen at intel.com>; Hiler, Arkadiusz <arkadiusz.hiler at intel.com>
> Subject: [PATCH i-g-t] testdisplay: Don't double-close udev fd
>
> testdisplay uses GIO for polling the udev fd for events. When shutting down, both
> the GIO channel and libudev want to close their respective fds, leading to a double
> close.
>
> Since version 240 (as used by Ubuntu 19.04), libudev has complained loudly if close()
> fails with EBADF. Previously the error has flown under the radar.
>
> Calling g_io_channel_shutdown() will call close() on the fd regardless of
> g_io_channel_set_close_on_unref, so opencode the flush and unref instead to avoid
> double closing.
>
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> Cc: Jani Saarinen <jani.saarinen at intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Tested-by: Jani Saarinen <jani.saarinen at intel.com>
> ---
> tests/testdisplay_hotplug.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tests/testdisplay_hotplug.c b/tests/testdisplay_hotplug.c index
> 581d987e..cd784895 100644
> --- a/tests/testdisplay_hotplug.c
> +++ b/tests/testdisplay_hotplug.c
> @@ -117,8 +117,10 @@ out:
>
> void testdisplay_cleanup_hotplug(void)
> {
> - if (udevchannel)
> - g_io_channel_shutdown(udevchannel, TRUE, NULL);
> + if (udevchannel) {
> + g_io_channel_flush(udevchannel, NULL);
> + g_io_channel_unref(udevchannel);
> + }
> if (uevent_monitor)
> udev_monitor_unref(uevent_monitor);
> if (udev)
> --
> 2.19.1
More information about the igt-dev
mailing list