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)
committerjeon <jhyuni.kang@samsung.com>
Mon, 17 Feb 2020 06:45:32 +0000 (15:45 +0900)
Change-Id: I96ba5287f28dfa301628232a5a6a02f1baf1c7a2

src/evdev.c

index 7e18d9db986efd2a8095390b2821cada2c5e216c..ff413bc35b345f7a5ce19dbf98d3153e5f29ef18 100644 (file)
@@ -2197,6 +2197,7 @@ evdev_device_create(struct libinput_seat *seat,
        const char *devnode;
        const char *sysname = 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)
@@ -2214,6 +2215,15 @@ evdev_device_create(struct libinput_seat *seat,
                return NULL;
        }
 
+       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. */