libssh: add async event bind patch

Issue #3014.
This commit is contained in:
Josef Söntgen 2018-10-01 11:18:26 +02:00 committed by Christian Helmuth
parent 9ab288d8e3
commit 82fb76c142
3 changed files with 57 additions and 1 deletions

View File

@ -1 +1 @@
4a4abe3dbedf573e4889a6b2fa4d83c73cd8fd4c
a475cccf96aa9126ed5fd135f108996c02f448e8

View File

@ -8,3 +8,6 @@ DIR(libssh) := src/lib/libssh
DIRS := include
DIR_CONTENT(include) := src/lib/libssh/include/libssh
PATCHES := src/lib/libssh/event_bind.patch
PATCH_OPT := -p1 -d src/lib/libssh

View File

@ -0,0 +1,53 @@
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -176,6 +176,26 @@
LIBSSH_API int ssh_bind_accept_fd(ssh_bind ssh_bind_o, ssh_session session,
socket_t fd);
+/**
+ * @brief Register for non-blocking accepts of incoming ssh connections
+ *
+ * @param ssh_bind_o The ssh server bind to accept a connection.
+ * @param event A non-blocking event mainloop
+ * @see ssh_bind_accept
+ * @return SSH_OK when successfully registered
+ */
+LIBSSH_API int ssh_event_add_bind(ssh_event event, ssh_bind ssh_bind_o);
+
+/**
+ * @brief Remove bind from the event
+ *
+ * @param ssh_bind_o The ssh server bind to accept a connection.
+ * @param event A non-blocking event mainloop
+ * @see ssh_bind_accept
+ * @return SSH_OK when successfully registered
+ */
+LIBSSH_API int ssh_event_remove_bind(ssh_event event, ssh_bind ssh_bind_o);
+
LIBSSH_API ssh_gssapi_creds ssh_gssapi_get_creds(ssh_session session);
/**
--- a/src/bind.c
+++ b/src/bind.c
@@ -532,6 +532,21 @@
return rc;
}
+int ssh_event_add_bind(ssh_event event, ssh_bind sshbind) {
+ ssh_poll_handle h = ssh_bind_get_poll(sshbind);
+ if (h == NULL)
+ return SSH_ERROR;
+ return ssh_event_add_poll(event, h);
+}
+
+int ssh_event_remove_bind(ssh_event event, ssh_bind sshbind) {
+ ssh_poll_handle h = ssh_bind_get_poll(sshbind);
+ if (h == NULL)
+ return SSH_ERROR;
+ ssh_event_remove_poll(event, h);
+ return SSH_OK;
+}
+
/**
* @}