mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
socket: Reformat ssh_socket_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
30
src/socket.c
30
src/socket.c
@@ -670,7 +670,8 @@ int ssh_socket_write(ssh_socket s, const void *buffer, int len) {
|
|||||||
* \brief starts a nonblocking flush of the output buffer
|
* \brief starts a nonblocking flush of the output buffer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int ssh_socket_nonblocking_flush(ssh_socket s) {
|
int ssh_socket_nonblocking_flush(ssh_socket s)
|
||||||
|
{
|
||||||
ssh_session session = s->session;
|
ssh_session session = s->session;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
int w;
|
int w;
|
||||||
@@ -678,12 +679,14 @@ int ssh_socket_nonblocking_flush(ssh_socket s) {
|
|||||||
if (!ssh_socket_is_open(s)) {
|
if (!ssh_socket_is_open(s)) {
|
||||||
session->alive = 0;
|
session->alive = 0;
|
||||||
if (s->callbacks && s->callbacks->exception) {
|
if (s->callbacks && s->callbacks->exception) {
|
||||||
s->callbacks->exception(
|
s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
|
||||||
SSH_SOCKET_EXCEPTION_ERROR,
|
s->last_errno,
|
||||||
s->last_errno,s->callbacks->userdata);
|
s->callbacks->userdata);
|
||||||
} else {
|
} else {
|
||||||
ssh_set_error(session, SSH_FATAL,
|
ssh_set_error(session,
|
||||||
"Writing packet: error on socket (or connection closed): %s",
|
SSH_FATAL,
|
||||||
|
"Writing packet: error on socket (or connection "
|
||||||
|
"closed): %s",
|
||||||
strerror(s->last_errno));
|
strerror(s->last_errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,6 +700,7 @@ int ssh_socket_nonblocking_flush(ssh_socket s) {
|
|||||||
|
|
||||||
return SSH_AGAIN;
|
return SSH_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->write_wontblock && len > 0) {
|
if (s->write_wontblock && len > 0) {
|
||||||
w = ssh_socket_unbuffered_write(s, ssh_buffer_get(s->out_buffer), len);
|
w = ssh_socket_unbuffered_write(s, ssh_buffer_get(s->out_buffer), len);
|
||||||
if (w < 0) {
|
if (w < 0) {
|
||||||
@@ -704,16 +708,20 @@ int ssh_socket_nonblocking_flush(ssh_socket s) {
|
|||||||
ssh_socket_close(s);
|
ssh_socket_close(s);
|
||||||
|
|
||||||
if (s->callbacks && s->callbacks->exception) {
|
if (s->callbacks && s->callbacks->exception) {
|
||||||
s->callbacks->exception(
|
s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
|
||||||
SSH_SOCKET_EXCEPTION_ERROR,
|
s->last_errno,
|
||||||
s->last_errno,s->callbacks->userdata);
|
s->callbacks->userdata);
|
||||||
} else {
|
} else {
|
||||||
ssh_set_error(session, SSH_FATAL,
|
ssh_set_error(session,
|
||||||
"Writing packet: error on socket (or connection closed): %s",
|
SSH_FATAL,
|
||||||
|
"Writing packet: error on socket (or connection "
|
||||||
|
"closed): %s",
|
||||||
strerror(s->last_errno));
|
strerror(s->last_errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_buffer_pass_bytes(s->out_buffer, w);
|
ssh_buffer_pass_bytes(s->out_buffer, w);
|
||||||
if (s->session->socket_counter != NULL) {
|
if (s->session->socket_counter != NULL) {
|
||||||
s->session->socket_counter->out_bytes += w;
|
s->session->socket_counter->out_bytes += w;
|
||||||
|
|||||||
Reference in New Issue
Block a user