libssh2-hs can't send 3megabyte file #10

Open
aycanirican opened this Issue Apr 12, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@aycanirican

I am able to send small files but libssh2 blocks when I try to send a 3mb file.

@grpala

This comment has been minimized.

Show comment Hide comment
@grpala

grpala Apr 20, 2013

It's not just 3MiB... a 180KiB file blocks it too... I've been trying to fix this for the past 3 hours, got no results yet. HELP!

grpala commented Apr 20, 2013

It's not just 3MiB... a 180KiB file blocks it too... I've been trying to fix this for the past 3 hours, got no results yet. HELP!

@grpala

This comment has been minimized.

Show comment Hide comment
@grpala

grpala Apr 21, 2013

OK, found the bug. I'd submit a pull request but I'm not sure of the correctness of my fix. The problem is as follows:
When sending a file and the server replies an EAGAIN (this doesn't happen for very small files), threadWaitSession will first block the thread waiting for read, but since there's nothing to read whatsoever it blocks forever.

I made transfers work (https://gist.github.com/5428276) but this doesn't feel all right since there are 3 possible states for session direction: [INBOUND], [OUTBOUND], [INBOUND, OUTBOUND] (as seen in int2dir).

During file transfers, the observed direction is the latest, and in this case it only needs to threadWaitWrite, but what if there were a case where it needed to threadWaitRead too? This "fix" would undoubtedly break.

In any case, take this patch as a proof of concept as to where the bug is.

grpala commented Apr 21, 2013

OK, found the bug. I'd submit a pull request but I'm not sure of the correctness of my fix. The problem is as follows:
When sending a file and the server replies an EAGAIN (this doesn't happen for very small files), threadWaitSession will first block the thread waiting for read, but since there's nothing to read whatsoever it blocks forever.

I made transfers work (https://gist.github.com/5428276) but this doesn't feel all right since there are 3 possible states for session direction: [INBOUND], [OUTBOUND], [INBOUND, OUTBOUND] (as seen in int2dir).

During file transfers, the observed direction is the latest, and in this case it only needs to threadWaitWrite, but what if there were a case where it needed to threadWaitRead too? This "fix" would undoubtedly break.

In any case, take this patch as a proof of concept as to where the bug is.

portnov pushed a commit that referenced this issue Mar 19, 2016

@portnov

This comment has been minimized.

Show comment Hide comment
@portnov

portnov Mar 19, 2016

Owner

Applied that patch to master for now. If anyone has better solutions, you are welcome.

Owner

portnov commented Mar 19, 2016

Applied that patch to master for now. If anyone has better solutions, you are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment