Skip to content

Commit 430e9cc

Browse files
committed
Try to make linux watchdog working
1 parent 2d500f6 commit 430e9cc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/yup_core/native/yup_Watchdog_linux.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,25 @@ class Watchdog::Impl final
150150

151151
void threadCallback()
152152
{
153-
constexpr std::size_t bufferSize = (10 * (sizeof (struct inotify_event) + NAME_MAX + 1));
153+
constexpr std::size_t bufferSize = (32 * (sizeof (struct inotify_event) + NAME_MAX + 1));
154154
std::vector<char> buffer (bufferSize, 0);
155155

156156
auto lastRenamedPath = std::optional<File> {};
157157

158-
struct pollfd pfd;
159-
pfd.fd = fd;
160-
pfd.events = POLLIN;
161-
162158
while (! threadShouldExit)
163159
{
164-
const int pollResult = poll (&pfd, 1, 200);
160+
fd_set fileDescriptorSet;
161+
FD_ZERO (&fileDescriptorSet);
162+
FD_SET (fd, &fileDescriptorSet);
163+
if (select (FD_SETSIZE, &fileDescriptorSet, nullptr, nullptr, nullptr) <= 0)
164+
{
165+
std::this_thread::sleep_for (std::chrono::milliseconds (50));
166+
continue;
167+
}
165168

166169
if (threadShouldExit)
167170
break;
168171

169-
if (pollResult <= 0 || (pfd.revents & POLLIN) == 0)
170-
continue;
171-
172172
const ssize_t numRead = read (fd, buffer.data(), bufferSize);
173173

174174
if (threadShouldExit)

0 commit comments

Comments
 (0)