summaryrefslogtreecommitdiffstats
path: root/src/session.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-03-22 11:49:57 +0100
committerAndreas Schneider <asn@cryptomilk.org>2011-03-23 08:49:26 +0100
commitb7f6794e03f4e1f20f78967656c7a7d6d6b1940a (patch)
tree1ce9d5df4d1b0342203056b00803eef1067fc25c /src/session.c
parentcd9fc88151fb66225297ec3a278a2d9756544b38 (diff)
downloadlibssh-b7f6794e03f4e1f20f78967656c7a7d6d6b1940a.tar.gz
libssh-b7f6794e03f4e1f20f78967656c7a7d6d6b1940a.tar.xz
libssh-b7f6794e03f4e1f20f78967656c7a7d6d6b1940a.zip
Implement ssh_blocking_flush()
Based on code from Jan Willamowius (cherry picked from commit dff4e4e6d3a56123b00df48fdcd7a6de0a275aef)
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/session.c b/src/session.c
index ab7cdff9..be428889 100644
--- a/src/session.c
+++ b/src/session.c
@@ -298,6 +298,31 @@ int ssh_is_blocking(ssh_session session){
}
/**
+ * @brief Blocking flush of the outgoing buffer
+ * @param[in] session The SSH session
+ * @param[in] timeout Set an upper limit on the time for which this function
+ * will block, in milliseconds. Specifying a negative value
+ * means an infinite timeout. This parameter is passed to
+ * the poll() function.
+ * @returns SSH_OK on success, SSH_ERROR otherwise.
+ */
+
+int ssh_blocking_flush(ssh_session session, int timeout){
+ ssh_socket s;
+ if(session==NULL)
+ return SSH_ERROR;
+
+ enter_function();
+ s=session->socket;
+ while (ssh_socket_buffered_write_bytes(s) > 0 && session->alive) {
+ ssh_handle_packets(session, timeout);
+ }
+
+ leave_function();
+ return SSH_OK;
+}
+
+/**
* @brief Check if we are connected.
*
* @param[in] session The session to check if it is connected.