Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LibOS] Add post_poll() callback to network sockets #1844

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions libos/src/fs/socket/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ static int checkin(struct libos_handle* handle) {
return 0;
}

static void post_poll(struct libos_handle* hdl, pal_wait_flags_t* pal_ret_events) {
assert(hdl->type == TYPE_SOCK);

if (*pal_ret_events & (PAL_WAIT_READ | PAL_WAIT_WRITE)) {
bool error_event = !!(*pal_ret_events & (PAL_WAIT_ERROR | PAL_WAIT_HANG_UP));
check_connect_inprogress_on_poll(hdl, error_event);
}
}

static struct libos_fs_ops socket_fs_ops = {
.close = close,
.read = read,
Expand All @@ -235,6 +244,7 @@ static struct libos_fs_ops socket_fs_ops = {
.ioctl = ioctl,
.checkout = checkout,
.checkin = checkin,
.post_poll = &post_poll,
};

struct libos_fs socket_builtin_fs = {
Expand Down
7 changes: 0 additions & 7 deletions libos/src/sys/libos_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,6 @@ static int do_epoll_wait(int epfd, struct epoll_event* events, int maxevents, in
this_item_events |= items[i]->events & (EPOLLOUT | EPOLLWRNORM);
}

/* TODO: move this to socket FS's post_poll() callback */
if (items[i]->handle->type == TYPE_SOCK &&
(pal_ret_events[i] & (PAL_WAIT_READ | PAL_WAIT_WRITE))) {
bool error_event = !!(pal_ret_events[i] & (PAL_WAIT_ERROR | PAL_WAIT_HANG_UP));
check_connect_inprogress_on_poll(items[i]->handle, error_event);
}

if (!this_item_events) {
/* This handle is not interested in events that were detected - epoll item was
* probably updated asynchronously. */
Expand Down
7 changes: 0 additions & 7 deletions libos/src/sys/libos_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,6 @@ static long do_poll(struct pollfd* fds, size_t fds_len, uint64_t* timeout_us) {
if (ret_events[i] & PAL_WAIT_WRITE)
fds[i].revents |= fds[i].events & (POLLOUT | POLLWRNORM);

/* TODO: move this to socket FS's post_poll() callback */
if (libos_handles[i]->type == TYPE_SOCK &&
(ret_events[i] & (PAL_WAIT_READ | PAL_WAIT_WRITE))) {
bool error_event = !!(ret_events[i] & (PAL_WAIT_ERROR | PAL_WAIT_HANG_UP));
check_connect_inprogress_on_poll(libos_handles[i], error_event);
}

if (fds[i].revents)
ret_events_count++;
}
Expand Down