2018-06-26 21:22:51 +02:00
|
|
|
diff --git base/files/file_path_watcher_linux.cc base/files/file_path_watcher_linux.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
index 4e231b615e8f..a5100c0bf1c8 100644
|
2018-06-26 21:22:51 +02:00
|
|
|
--- base/files/file_path_watcher_linux.cc
|
|
|
|
+++ base/files/file_path_watcher_linux.cc
|
|
|
|
@@ -5,6 +5,7 @@
|
|
|
|
#include "base/files/file_path_watcher.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
+#include <poll.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/inotify.h>
|
|
|
|
@@ -13,6 +14,7 @@
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
+#include <array>
|
2019-07-16 19:59:21 +02:00
|
|
|
#include <fstream>
|
2018-06-26 21:22:51 +02:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2020-03-30 22:13:42 +02:00
|
|
|
@@ -263,8 +265,10 @@ void InotifyReaderThreadDelegate::ThreadMain() {
|
2018-06-26 21:22:51 +02:00
|
|
|
PlatformThread::SetName("inotify_reader");
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
// Make sure the file descriptors are good for use with select().
|
2018-06-26 21:22:51 +02:00
|
|
|
- CHECK_LE(0, inotify_fd_);
|
|
|
|
- CHECK_GT(FD_SETSIZE, inotify_fd_);
|
|
|
|
+ std::array<pollfd, 1> fdarray
|
|
|
|
+ { {
|
|
|
|
+ { inotify_fd_, POLLIN, 0 }
|
|
|
|
+ } };
|
|
|
|
|
|
|
|
while (true) {
|
2020-03-30 22:13:42 +02:00
|
|
|
fd_set rfds;
|
|
|
|
@@ -272,10 +276,9 @@ void InotifyReaderThreadDelegate::ThreadMain() {
|
|
|
|
FD_SET(inotify_fd_, &rfds);
|
|
|
|
|
|
|
|
// Wait until some inotify events are available.
|
2018-06-26 21:22:51 +02:00
|
|
|
- int select_result =
|
|
|
|
- HANDLE_EINTR(select(inotify_fd_ + 1, &rfds, nullptr, nullptr, nullptr));
|
|
|
|
- if (select_result < 0) {
|
|
|
|
- DPLOG(WARNING) << "select failed";
|
|
|
|
+ int poll_result = HANDLE_EINTR(poll(fdarray.data(), fdarray.size(), -1));
|
|
|
|
+ if (poll_result < 0) {
|
|
|
|
+ DPLOG(WARNING) << "poll failed";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|