Subject: Re: timeouts in libssh2 blocking-mode

Re: timeouts in libssh2 blocking-mode

From: Matt Lilley <>
Date: Tue, 03 May 2011 08:12:59 +1200

> I'm happy to commit this. I would like to touch up the commit message
> slightly however. In particular it should include some variation of
> "fixes #160" so that the ticket gets closed.
> //Peter
Ok, that sounds fine to me. Daniel has commented that he'd prefer the
timeout to be the maximum time that any libssh2 function can remain
blocked, which I agree would be nice, but I'm not sure how to implement
- I guess each entry point could reset a counter, and then the recv()
could have a 1 second timeout, which increments this counter until it
reaches the specified limit, at which point the function returns with a
timeout error. This is a lot of work though; every function would have
to be modified (or perhaps the BLOCK_ADJUST macro?) and I'm not sure
there are significant gains - after all, the keepalive code does
something similar to this. All I want is a safety net to prevent our
application locking up when it connects to an ssh server that we have no
administrative control over.

If I've missed some simple way of achieving Daniel's approach, feel free
to point it out to me, and if I understand, I can have a go at
implementing it.


Matt Lilley
Software Engineer
Tel:    +64 4 912-2100
Fax:    +64 4 912-2101
This e-mail has passed our content security scan.
It is covered by the confidentiality clauses at
Received on 2011-05-02