evdev: Do not open the already opened device
authorJengHyun Kang <jhyuni.kang@samsung.com>
Mon, 22 Aug 2016 07:54:29 +0000 (16:54 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:07:31 +0000 (14:07 +0900)
Change-Id: I96ba5287f28dfa301628232a5a6a02f1baf1c7a2

src/evdev.c

index cb9badf..6cf7897 100644 (file)
@@ -2445,6 +2445,7 @@ evdev_device_create(struct libinput_seat *seat,
        const char *devnode;
        char *sysname = str_sanitize(udev_device_get_sysname(udev_device));
        char buf[STRERR_BUFSIZE] = {0, };
+       struct libinput_device *dev;
 
 #ifdef HAVE_INPUT_SET_DEFAULT_PROPERTY
        if (input_set_default_property(udev_device) < 0)
@@ -2462,6 +2463,15 @@ evdev_device_create(struct libinput_seat *seat,
                goto err;
        }
 
+       list_for_each(dev, &seat->devices_list, link) {
+               struct evdev_device *d = (struct evdev_device*)dev;
+               if (strcmp(devnode, udev_device_get_devnode(d->udev_device))== 0) {
+                       log_info(libinput,
+                               "%s device is already opened\n", d->devname);
+                       return NULL;
+               }
+       }
+
        /* Use non-blocking mode so that we can loop on read on
         * evdev_device_data() until all events on the fd are
         * read.  mtdev_get() also expects this. */