Ticket #38 (closed defect)

Opened 10 years ago

Last modified 10 years ago

Blocking read from channel fails if not enough data is read

Reported by: em1 Owned by:
Priority: normal Milestone:
Component: Version:
Keywords: Cc: em1, bagder
Blocked By: Blocks:

Description

_libssh2_channel_read_ex() fails by returning PACKET_EAGAIN if libssh2_packet_read() reads less than blocksize bytes (and therefore returns PACKET_EAGAIN). This behavior is wrong for blocking mode.

Problem occurred in 0.15-20070413, but seems to be also present in 0.15-20070508.

Here's a trace showing the problem:

[libssh2] SFTP Subsystem: Requiring 101 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet: will block
[libssh2] Connection: Setting blocking mode on channel 0/225 to 1
[libssh2] Connection: Attempting to read 4 bytes from channel 0/225 stream #0
[libssh2] Connection: Setting blocking mode on channel 0/225 to 0
[libssh2] Connection: Setting blocking mode on channel 0/225 to 1
=> libssh2_packet_read() raw (11 bytes)
0000: 04 d2 1d e5 a0 9f f2 a8 e8 c4 d0 ...........
[libssh2] Failure Event: -30 - Timeout waiting for FXP packet
[libssh2] Failure Event: -30 - Timeout waiting for status message

Change History

comment:1 Changed 10 years ago by em1

There might be other instances of callers of libssh2_packet_read() not being prepared for getting PACKET_EGAIN in blocking mode. Unfortunately, libssh2_packet_read() doesn't know whether we're in blocking mode or not, so fixing the bug in libssh2_packet_read() is currently not an option.

comment:2 Changed 10 years ago by bagder

Eberhard Mattes patch has been applied

Note: See TracTickets for help on using tickets.