Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/fs/fusefs/mockfs.cc
Show First 20 Lines • Show All 864 Lines • ▼ Show 20 Lines | void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) { | ||||
fd_set readfds; | fd_set readfds; | ||||
pollfd fds[1]; | pollfd fds[1]; | ||||
struct kevent changes[1]; | struct kevent changes[1]; | ||||
struct kevent events[1]; | struct kevent events[1]; | ||||
struct timespec timeout_ts; | struct timespec timeout_ts; | ||||
struct timeval timeout_tv; | struct timeval timeout_tv; | ||||
const int timeout_ms = 999; | const int timeout_ms = 999; | ||||
int timeout_int, nfds; | int timeout_int, nfds; | ||||
int fuse_fd; | |||||
switch (m_pm) { | switch (m_pm) { | ||||
case BLOCKING: | case BLOCKING: | ||||
break; | break; | ||||
case KQ: | case KQ: | ||||
timeout_ts.tv_sec = 0; | timeout_ts.tv_sec = 0; | ||||
timeout_ts.tv_nsec = timeout_ms * 1'000'000; | timeout_ts.tv_nsec = timeout_ms * 1'000'000; | ||||
while (nready == 0) { | while (nready == 0) { | ||||
Show All 20 Lines | while (nready == 0) { | ||||
nready = poll(fds, 1, timeout_int); | nready = poll(fds, 1, timeout_int); | ||||
if (m_quit) | if (m_quit) | ||||
return; | return; | ||||
} | } | ||||
ASSERT_LE(0, nready) << strerror(errno); | ASSERT_LE(0, nready) << strerror(errno); | ||||
ASSERT_TRUE(fds[0].revents & POLLIN); | ASSERT_TRUE(fds[0].revents & POLLIN); | ||||
break; | break; | ||||
case SELECT: | case SELECT: | ||||
fuse_fd = m_fuse_fd; | |||||
if (fuse_fd < 0) | |||||
break; | |||||
timeout_tv.tv_sec = 0; | timeout_tv.tv_sec = 0; | ||||
timeout_tv.tv_usec = timeout_ms * 1'000; | timeout_tv.tv_usec = timeout_ms * 1'000; | ||||
nfds = m_fuse_fd + 1; | nfds = fuse_fd + 1; | ||||
while (nready == 0) { | while (nready == 0) { | ||||
FD_ZERO(&readfds); | FD_ZERO(&readfds); | ||||
FD_SET(m_fuse_fd, &readfds); | FD_SET(fuse_fd, &readfds); | ||||
nready = select(nfds, &readfds, NULL, NULL, | nready = select(nfds, &readfds, NULL, NULL, | ||||
&timeout_tv); | &timeout_tv); | ||||
if (m_quit) | if (m_quit) | ||||
return; | return; | ||||
} | } | ||||
ASSERT_LE(0, nready) << strerror(errno); | ASSERT_LE(0, nready) << strerror(errno); | ||||
ASSERT_TRUE(FD_ISSET(m_fuse_fd, &readfds)); | ASSERT_TRUE(FD_ISSET(fuse_fd, &readfds)); | ||||
break; | break; | ||||
default: | default: | ||||
FAIL() << "not yet implemented"; | FAIL() << "not yet implemented"; | ||||
} | } | ||||
res = read(m_fuse_fd, &in, sizeof(in)); | res = read(m_fuse_fd, &in, sizeof(in)); | ||||
if (res < 0 && !m_quit) { | if (res < 0 && !m_quit) { | ||||
m_quit = true; | m_quit = true; | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |