Fixed blocking bug in channel_poll

This commit is contained in:
Aris Adamantiadis
2010-01-08 23:05:10 +01:00
parent c41e3a8e68
commit 514ab6eed2
7 changed files with 26 additions and 21 deletions

View File

@@ -265,9 +265,13 @@ void ssh_set_fd_except(ssh_session session) {
* @brief polls the current session for an event and call the
* appropriate callbacks. Will block until one event happens.
* @param session session handle.
* @param timeout An upper limit on the time for which
* ssh_handle_packets() will block, in milliseconds.
* Specifying a negative value means an infinite timeout.
* This parameter is passed to the poll() function.
* @return SSH_OK if there are no error, SSH_ERROR otherwise.
*/
int ssh_handle_packets(ssh_session session) {
int ssh_handle_packets(ssh_session session, int timeout) {
ssh_poll_handle spoll;
ssh_poll_ctx ctx;
if(session==NULL || session->socket==NULL)
@@ -279,7 +283,7 @@ int ssh_handle_packets(ssh_session session) {
ctx=ssh_get_global_poll_ctx(session);
ssh_poll_ctx_add(ctx,spoll);
}
ssh_poll_ctx_dopoll(ctx,-1);
ssh_poll_ctx_dopoll(ctx,timeout);
leave_function();
if (session->session_state != SSH_SESSION_STATE_ERROR)
return SSH_OK;