cURL / Mailing Lists / curl-library / Single Mail

curl-library

"100% CPU usage during SFTP transfer" bugfix

From: Vourhey <vourhey_at_gmail.com>
Date: Tue, 18 Aug 2009 12:46:52 +0400

Hi all,

I use lubcurl 7.19.5 with libssh2-1.2 on Linux. I can see 100% CPU
usage when I try to upload any file by SFTP. This bug is already
described on the tracker:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=2816745&group_id=976
This bug is due to using non-blocking mode enabled by default.
Infinite loop (invoking of clock_gettime, poll, recv functions) loads
CPU.
I found the following in the libcurl code:
In file lib/ssh.c, function ssh_statemach_act:

    /* Set libssh2 to non-blocking, since cURL is all non-blocking */
    libssh2_session_set_blocking(sshc->ssh_session, 0);

"libssh2_session_set_blocking" function enables/disables non-blocking
mode. So, I've change this code to enable blocking mode for the
libssh2:

    libssh2_session_set_blocking(sshc->ssh_session, 1);

After libcurl recompiling, file uploading by SFTP loads CPU to ~9%.
And looks like everything is ok: downloading/uploading files by SFTP
work fine.

Could you please tell me, can these changes cause any issues in
libcurl work? Are there any plans to submit fix for this bug in the
next version of libcurl? Can the fix described above be included?

Thanks,
Pavel
Received on 2009-08-18