Subject: Re: proper buffer size for libssh2_sftp_read()

Re: proper buffer size for libssh2_sftp_read()

From: zl liu <xieepp_at_gmail.com>
Date: Thu, 16 Jun 2011 11:05:21 +0800

在 2011年6月15日 下午7:56,Daniel Stenberg <daniel_at_haxx.se>写道:

> On Wed, 15 Jun 2011, zl liu wrote:
>
> yes,1.2.8. the test is running on windows 7 .
>>
>
> Ok. We have received bug reports previously on Windows that we haven't been
> able to repeat elsewhere and afaik nobody has fixed.
>
>
> after i modify the misc.c::445 like : fprintf(stderr, "%s, %d\n", buffer,
>> GetLastError()); when -7, the system errno is 10035.
>>
>
> Can you see if you can figure out how that can happen?
>
-7 haven't return to the caller. just the internal errno.

>
> 10035 is WSAEWOULDBLOCK from what I understand, and
> src/misc.c:_libssh2_send() is written so that it converts such an error to
> return -EAGAIN. The code in src/transport.c that use _libssh2_send() then
> checks the return code for -EAGAIN and should not return anoter error than
> LIBSSH2_ERROR_EAGAIN (-37) for that case.
>
> I think we should focus on the first error that happens as I suspect the
> ones following may be results of the first problem.

after debug the libssh2,i get the following information:
the function call stack:
> libssh2.dll!send_existing(_LIBSSH2_SESSION * session=0x017d0068, const
unsigned char * data=0x014f1e00, unsigned int data_len=9, long *
ret=0x00035410) 行605 C
  libssh2.dll!_libssh2_transport_send(_LIBSSH2_SESSION * session=0x017d0068,
const unsigned char * data=0x014f1e00, unsigned int data_len=9, const
unsigned char * data2=0x00000000, unsigned int data2_len=0) 行696 + 0x15 字节
C
  libssh2.dll!_libssh2_channel_receive_window_adjust(_LIBSSH2_CHANNEL *
channel=0x014f1c10, unsigned int adjustment=3932160, unsigned char force=0,
unsigned int * store=0x00000000) 行1581 + 0x1b 字节 C
  libssh2.dll!_libssh2_channel_read(_LIBSSH2_CHANNEL * channel=0x014f1c10,
int stream_id=0, char * buf=0x017dda08, unsigned int buflen=4) 行1882 + 0x12
字节 C
  libssh2.dll!sftp_packet_read(_LIBSSH2_SFTP * sftp=0x017dd9e8) 行193 + 0x25
字节 C
  libssh2.dll!sftp_packet_requirev(_LIBSSH2_SFTP * sftp=0x017dd9e8, int
num_valid_responses=2, const unsigned char * valid_responses=0x1002c03c,
unsigned int request_id=1, unsigned char * * data=0x000359ec, unsigned int *
data_len=0x000359e0) 行404 + 0x9 字节 C
  libssh2.dll!sftp_read(_LIBSSH2_SFTP_HANDLE * handle=0x017dd3c0, char *
buffer=0x00035e68, unsigned int buffer_size=1024000) 行1204 + 0x25 字节 C
  libssh2.dll!libssh2_sftp_read(_LIBSSH2_SFTP_HANDLE * hnd=0x017dd3c0, char
* buffer=0x00035e68, unsigned int buffer_maxlen=1024000) 行1311 + 0x11 字节 C

the value in this point:
data:
0x01391E00 5d 00 00 00 00 00 3c 00 ].....<.
0x01391E08 00 00 00 00 0b 00 00 00 ........

p->odata:
0x01391E18 5e 00 00 00 00 00 00 00 ^.......
0x01391E20 1d 00 00 00 00 00 00 00 ........

data_len = p->olen = 9

i haven't send anything, it is a internal mistake?

> another question , why not define the MACRO :LIBSSH2DEBUG in the debug
>>>> mode. when i want to enable trace,i must define the macro LIBSSH2DEBUG
>>>> manually and compile it again.
>>>>
>>>> That's what we have "./configure --enable-debug" for!
>>>
>>> i compile on win32 .it can not execute ./configure.
>>
>
> Ok. But how is defining LIBSSH2DEBUG somewhere not roughly the equivalent?
> What can we do to make it even simpler?
>
> --
>
thanks!

>
> / daniel.haxx.se
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>
>

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-06-16