[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sftp functions hanging if connection to the server is lost


Hi,

I have developed a sample program which uses libssh to read a remote file.
The program iteratively calls sftp_open, then sftp_read and finally sftp_close.
After successful connection I have simulated a network disconnection by deactivating the remote machine network interface (ifconfig <interface> down) prior to each of the calls above (using debugger for determining the exact location in the code when the connection is lost).

Each of the functions above (sftp_open, sftp_read and sftp_close) hung for about 15 minutes before returning an error ("No route to host").
As far as I understood from other correspondences, the issue was resolved lately (please correct me if I'm wrong).

I'm developing on Red Hat 7 which has libssh 0.7.1 as its latest version, and using the latest libssh version available (0.8.7 as far as I know) is a bit problematic.
This is a very serious bug, as my program might hang for a very long time if the server is suddenly down.

My questions:

1.       Is it possible to apply the fix to libssh 0.7.1?

2.       Is there a workaround to this issue I could use? (e.g. forcing a timeout somehow, efficiently checking the connection to the remote machine is not lost, etc.)

3.       Is there a time limit to which the sftp functions can wait before returning an error?

Thanks,
Sagi
-------------------------------------------
NOTICE:
This email and all attachments are confidential, may be proprietary, and may be privileged or otherwise protected from disclosure. They are intended solely for the individual or entity to whom the email is addressed. However, mistakes sometimes happen in addressing emails. If you believe that you are not an intended recipient, please stop reading immediately. Do not copy, forward, or rely on the contents in any way. Notify the sender and/or Imperva, Inc. by telephone at +1 (650) 832-6006 and then delete or destroy any copy of this email and its attachments. The sender reserves and asserts all rights to confidentiality, as well as any privileges that may apply. Any disclosure, copying, distribution or action taken or omitted to be taken by an unintended recipient in reliance on this message is prohibited and may be unlawful.
Please consider the environment before printing this email.

Archive administrator: postmaster@lists.cynapses.org