Page MenuHomePhabricator

Add session method to handle poll events
Open, Needs TriagePublic

Description

libssh provides a method to query what events an external event loop should poll for: ssh_get_poll_flags:

A bitmask including SSH_READ_PENDING or SSH_WRITE_PENDING. For SSH_READ_PENDING, your invocation of poll() should include POLLIN. For SSH_WRITE_PENDING, your invocation of poll() should include POLLOUT.

This is a feature request to add a method to call once the poll has completed:

void ssh_handle_poll_events(ssh_session session, int events)

The events can be

#define SSH_POLLIN    SSH_READ_PENDING
#define SSH_POLLOUT   SSH_WRITE_PENDING
#define SSH_POLLERR   0x10

@Jakuje @ansasaki wdyt?

Event Timeline

tmds added a project: Restricted Project.Jan 23 2021, 6:20 AM

Sorry, I did not get email notification about this issue so thank you for the ping on IRC.

I do not have strong opinion as I do not have a use for that at this moment. The question is whether this could be handled in the main loop (without poll, but I assume that it would be cumbersome) or whether it is something that could be handled in separate thread of your application.

In this use-case, the application already has a poll loop that allows getting read/write/error notifications for file descriptors.

ssh_get_poll_flags (+ssh_get_fd) can be used to configure the poll loop for an ssh session.

This new function can then be used to tell libssh what events happened.

When I find some time, I'll work on an implementation.