[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ssh_poll_ctx_dopoll: Sometimes returns 1 instead of SSH_{OK,ERROR,AGAIN}
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: ssh_poll_ctx_dopoll: Sometimes returns 1 instead of SSH_{OK,ERROR,AGAIN}
- From: poptsov.artyom@xxxxxxxxx (Artyom V. Poptsov)
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 31 Dec 2019 11:52:29 +0300
- To: libssh@xxxxxxxxxx
Hello,
I found that in some cases 'ssh_poll_ctx_dopoll' procedure from 'poll.c'
(libssh 0.9.0) returns 1 instead of a valid SSH_{OK,ERROR,AGAIN} code.
This seems to be wrong according to the commentary written above the
procedure.
My application (Guile-SSH) fails approximately 4 out of 5 times due to
this libssh behavior as I do 'assert (0)' on the cases when
'ssh_channel_open_forward' returns unknown value (1, in my case.)
I'm investigating the problem and it seems that there are situations
when 'ssh_poll' returns 1 as the result, and 'used = ctx->polls_used'
yields to zero, so this loop[1] never executes and thus 'rc' value never
decreases to zero:
--8<---------------cut here---------------start------------->8---
for (i = 0; i < used && rc > 0; ) {
if (!ctx->pollfds[i].revents || ctx->pollptrs[i]->lock) {
i++;
} else {
// ... skipped ...
rc--;
}
}
--8<---------------cut here---------------end--------------->8---
In such case, the procedure returns 1.
I observe the same problem on the 'master' branch (c6460cc9).
I can prepare a patch when I figure out what is the right solution for
this. Any help with that would be appreciated.
Thanks!
- Artyom
[1] https://git.libssh.org/projects/libssh.git/tree/src/poll.c?h=libssh-0.9.0#n690
--
Artyom V. Poptsov <poptsov.artyom@xxxxxxxxx>
Home page: http://poptsov-artyom.narod.ru/
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE B57C E9C5 A2D9 0898 A02F
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
Archive administrator: postmaster@lists.cynapses.org