cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl is wasting CPU time when libssh2 returns LIBSSH2_ERROR_EAGAIN

From: Vlad Grachov <fmot.fics_at_gmail.com>
Date: Thu, 25 Sep 2008 18:04:13 +0900

Hi!
While investigating how SFTP is supported in curl I figured out the
following.

When libssh2 is set to non-blocking mode its functions return
LIBSSH2_ERROR_EAGAIN
if recv/send returned EAGAIN. Upon receiving LIBSSH2_ERROR_EAGAIN curl's
state machine just repeats the same step (without a call to select/poll).
This leads to lots of recv/send calls that return EAGAIN and finally waste
CPU time. I wrote a small TCP tunneling code that waits for user input after
receiving 2600 bytes. And curl used 100% CPU while testing. CURL did not
release the CPU and continued to infinitely call recv until I let the tunnel
program transfer the remaining data.

Can this be considered a bug?

I used the most recent available versions of libssh2 and curl. Tested under
windows & linux - the same result.

Best regards, Vlad.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-09-25