summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2018-02-04 16:29:25 -0800
committerGitHub <noreply@github.com>2018-02-04 16:29:25 -0800
commit2442a34c3d88702109aeb90064e4da14cbdea430 (patch)
treed0497173d8d4dfd1e416a6921b6b8ccbbb8c8ad0 /Source/Core/InputCommon/ControllerInterface
parent32360e23e04a2d9fed55d061e344fe0a5cff7a16 (diff)
parent6a93223283bd0d2bef8ce9c29f5043ade49a6831 (diff)
Merge pull request #6357 from leoetlino/evdev
evdev: Minor fixes
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
index 85e4973270..2049c85237 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
@@ -72,14 +72,15 @@ static void HotplugThreadFunc()
FD_SET(monitor_fd, &fds);
FD_SET(s_wakeup_eventfd, &fds);
- int ret = select(monitor_fd + 1, &fds, nullptr, nullptr, nullptr);
+ int ret = select(std::max(monitor_fd, s_wakeup_eventfd) + 1, &fds, nullptr, nullptr, nullptr);
if (ret < 1 || !FD_ISSET(monitor_fd, &fds))
continue;
- udev_device* dev = udev_monitor_receive_device(monitor);
+ std::unique_ptr<udev_device, decltype(&udev_device_unref)> dev{
+ udev_monitor_receive_device(monitor), udev_device_unref};
- const char* action = udev_device_get_action(dev);
- const char* devnode = udev_device_get_devnode(dev);
+ const char* action = udev_device_get_action(dev.get());
+ const char* devnode = udev_device_get_devnode(dev.get());
if (!devnode)
continue;
@@ -107,7 +108,6 @@ static void HotplugThreadFunc()
s_devnode_name_map.insert(std::pair<std::string, std::string>(devnode, name));
}
}
- udev_device_unref(dev);
}
NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread stopped");
}
@@ -136,6 +136,7 @@ static void StopHotplugThread()
{
}
s_hotplug_thread.join();
+ close(s_wakeup_eventfd);
}
void Init()