cURL / Mailing Lists / curl-library / Single Mail

curl-library

LIBSSH2_ERROR_EAGAIN infinite loop

From: Anton Bychkov <bychkov.anton_at_gmail.com>
Date: Wed, 9 Dec 2009 17:08:42 +0300

Hi!

I use curl version 7.19.5 and libssh2 version 1.2.2 under windows 7.

I have run into problem with LIBSSH2_ERROR_EAGAIN message returned
from LibSSH2 library.
Curl goes to infinite loop if it gets LIBSSH2_ERROR_EAGAIN status code
from libssh2_sftp_write() in Curl_sftp_send() function.

Here is the code from ssh.c:2599, Curl_sftp_send():
   nwrite = libssh2_sftp_write(conn->proto.sshc.sftp_handle, mem, len);
   ssh_block2waitfor(conn, (nwrite == LIBSSH2_ERROR_EAGAIN)?TRUE:FALSE);
   if(nwrite == LIBSSH2_ERROR_EAGAIN)
     return 0;

And here is the code from ssh.c:288, Curl_write():
  bytes_written = Curl_sftp_send(conn, num, mem, len);
  ...
  *written = bytes_written;
   retcode = (-1 != bytes_written)?CURLE_OK:CURLE_SEND_ERROR;

It looks like curl doen't handle this case properly and goes in loop
because upload byte counter doesn't change.

Call stack inside curl is:
a.exe!Curl_sftp_send(connectdata * conn=0x06772c70, int sockindex=0,
const void * mem=0x0676e192, unsigned int len=16355)
a.exe!Curl_write(connectdata * conn=0x06772c70, unsigned int
sockfd=1812, const void * mem=0x0676e192, unsigned int len=16355, int
* written=0x0580f88c)
a.exe!readwrite_upload(SessionHandle * data=0x06769d08, connectdata *
conn=0x06772c70, SingleRequest * k=0x06769d20, int *
didwhat=0x0580f8dc)
a.exe!Curl_readwrite(connectdata * conn=0x06772c70, unsigned char *
done=0x0580f93b)
a.exe!Transfer(connectdata * conn=0x06772c70)
a.exe!Curl_perform(SessionHandle * data=0x06769d08)
a.exe!curl_easy_perform(void * curl=0x06769d08)

This problem seems to be known:
http://curl.haxx.se/mail/archive-2008-09/0109.html
Current source code differs from Vlad pathces, but it handles blocking
direction in ssh_block2waitfor() function.
So I guess, you already worked on this.

However, Vlad points that function ssh_statemach_act() needs to be
patched in order to make everything work.
But in my case this function doen't get called.

That's all I can say up to now. Please, help solve this issue.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-09