Browse Source

move read failure check outside loop

master
Alexander Avery 2 years ago
parent
commit
b52dfabc07
  1. 14
      popcorn.c

14
popcorn.c

@ -66,13 +66,15 @@ int get_movies(ssh_session session, char **buffer, size_t size) {
nbytes = ssh_channel_read(channel, read_buffer, sizeof(read_buffer), 0);
if (nbytes < 0) {
fprintf(stderr, "Failed to read bytes from channel");
ssh_channel_close(channel);
ssh_channel_free(channel);
return SSH_ERROR;
}
}
if (nbytes < 0) {
fprintf(stderr, "Failed to read bytes from channel");
ssh_channel_close(channel);
ssh_channel_free(channel);
return SSH_ERROR;
}
ssh_channel_send_eof(channel);
ssh_channel_close(channel);
ssh_channel_free(channel);

Loading…
Cancel
Save