Fixes: scp blocking modes, MacError abstract indirection
Additions: Channel Close callback
This commit is contained in:
@@ -734,6 +734,10 @@ LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (channel->close_cb) {
|
||||
LIBSSH2_CHANNEL_CLOSE(session, channel);
|
||||
}
|
||||
|
||||
packet[0] = SSH_MSG_CHANNEL_CLOSE;
|
||||
libssh2_htonu32(packet + 1, channel->remote.id);
|
||||
if (libssh2_packet_write(session, packet, 5)) {
|
||||
|
10
src/scp.c
10
src/scp.c
@@ -76,6 +76,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, char *pa
|
||||
LIBSSH2_FREE(session, command);
|
||||
return NULL;
|
||||
}
|
||||
/* Use blocking I/O for negotiation phase */
|
||||
libssh2_channel_set_blocking(channel, 1);
|
||||
|
||||
/* Request SCP for the desired file */
|
||||
if (libssh2_channel_process_startup(channel, "exec", sizeof("exec") - 1, command, command_len)) {
|
||||
@@ -307,7 +309,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, char *pa
|
||||
sb->st_size = size;
|
||||
sb->st_mode = mode;
|
||||
}
|
||||
/* Let the data BEGIN! */
|
||||
/* Revert to non-blocking and let the data BEGIN! */
|
||||
libssh2_channel_set_blocking(channel, 0);
|
||||
|
||||
return channel;
|
||||
}
|
||||
@@ -347,6 +350,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, char
|
||||
LIBSSH2_FREE(session, command);
|
||||
return NULL;
|
||||
}
|
||||
/* Use blocking I/O for negotiation phase */
|
||||
libssh2_channel_set_blocking(channel, 1);
|
||||
|
||||
/* Request SCP for the desired file */
|
||||
if (libssh2_channel_process_startup(channel, "exec", sizeof("exec") - 1, command, command_len)) {
|
||||
@@ -400,7 +405,8 @@ LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Ready to send file */
|
||||
/* Ready to start, switch to non-blocking and let calling app send file */
|
||||
libssh2_channel_set_blocking(channel, 0);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
Reference in New Issue
Block a user