channels: fix embarrasing channel_read_nonblocking bug
Этот коммит содержится в:
родитель
744b7720af
Коммит
dad35304b6
@ -2604,7 +2604,7 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
|||||||
ssh_buffer stdbuf;
|
ssh_buffer stdbuf;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
struct ssh_channel_read_termination_struct ctx;
|
struct ssh_channel_read_termination_struct ctx;
|
||||||
int ret, rc;
|
int rc;
|
||||||
|
|
||||||
if(channel == NULL) {
|
if(channel == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
@ -2617,11 +2617,6 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
|
|||||||
session = channel->session;
|
session = channel->session;
|
||||||
stdbuf = channel->stdout_buffer;
|
stdbuf = channel->stdout_buffer;
|
||||||
enter_function();
|
enter_function();
|
||||||
if(!ssh_is_blocking(session)){
|
|
||||||
ret = ssh_channel_read_nonblocking(channel, dest, count, is_stderr);
|
|
||||||
leave_function();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
leave_function();
|
leave_function();
|
||||||
@ -2708,6 +2703,7 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
|
|||||||
ssh_session session;
|
ssh_session session;
|
||||||
int to_read;
|
int to_read;
|
||||||
int rc;
|
int rc;
|
||||||
|
int blocking;
|
||||||
|
|
||||||
if(channel == NULL) {
|
if(channel == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
@ -2730,8 +2726,10 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
|
|||||||
if (to_read > (int)count) {
|
if (to_read > (int)count) {
|
||||||
to_read = (int)count;
|
to_read = (int)count;
|
||||||
}
|
}
|
||||||
|
blocking = ssh_is_blocking(session);
|
||||||
|
ssh_set_blocking(session, 0);
|
||||||
rc = ssh_channel_read(channel, dest, to_read, is_stderr);
|
rc = ssh_channel_read(channel, dest, to_read, is_stderr);
|
||||||
|
ssh_set_blocking(session,blocking);
|
||||||
leave_function();
|
leave_function();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user