direct_tcpip: Fixed channel write
There were 3 bugs in this loop: 1) Started from beginning after partial writes 2) Aborted when 0 bytes were sent 3) Ignored LIBSSH2_ERROR_EAGAIN See also: https://trac.libssh2.org/ticket/281 https://trac.libssh2.org/ticket/293
Этот коммит содержится в:
родитель
14d9ee01bc
Коммит
a1e744bb5e
@ -275,14 +275,17 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
wr = 0;
|
wr = 0;
|
||||||
do {
|
while(wr < len) {
|
||||||
i = libssh2_channel_write(channel, buf, len);
|
i = libssh2_channel_write(channel, buf + wr, len - wr);
|
||||||
|
if (LIBSSH2_ERROR_EAGAIN == i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
wr += i;
|
wr += i;
|
||||||
} while(i > 0 && wr < len);
|
}
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user