aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-09-24 18:51:48 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-09-25 14:37:25 +0200
commitc5cadaa9825718a46c7205bd47c3e97076db33f8 (patch)
tree7ac4b8561696c31e7d3b53c34dc6bf00179b2eb9
parentcaf50270c636717db8724c3a509b256efc9e6038 (diff)
downloadlibssh-c5cadaa9825718a46c7205bd47c3e97076db33f8.tar.gz
libssh-c5cadaa9825718a46c7205bd47c3e97076db33f8.tar.xz
libssh-c5cadaa9825718a46c7205bd47c3e97076db33f8.zip
socket: Reformat ssh_socket_unbuffered_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/socket.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/socket.c b/src/socket.c
index 82737450..12be673d 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -584,32 +584,34 @@ static ssize_t ssh_socket_unbuffered_read(ssh_socket s,
* \brief writes len bytes from buffer to socket
*/
static int ssh_socket_unbuffered_write(ssh_socket s, const void *buffer,
- uint32_t len) {
- int w = -1;
+ uint32_t len) {
+ int w = -1;
- if (s->data_except) {
- return -1;
- }
- if (s->fd_is_socket)
- w = send(s->fd_out,buffer, len, 0);
- else
- w = write(s->fd_out, buffer, len);
+ if (s->data_except) {
+ return -1;
+ }
+
+ if (s->fd_is_socket) {
+ w = send(s->fd_out,buffer, len, 0);
+ } else {
+ w = write(s->fd_out, buffer, len);
+ }
#ifdef _WIN32
- s->last_errno = WSAGetLastError();
+ s->last_errno = WSAGetLastError();
#else
- s->last_errno = errno;
+ s->last_errno = errno;
#endif
- s->write_wontblock = 0;
- /* Reactive the POLLOUT detector in the poll multiplexer system */
- if(s->poll_out){
- SSH_LOG(SSH_LOG_PACKET, "Enabling POLLOUT for socket");
- ssh_poll_set_events(s->poll_out,ssh_poll_get_events(s->poll_out) | POLLOUT);
- }
- if (w < 0) {
- s->data_except = 1;
- }
+ s->write_wontblock = 0;
+ /* Reactive the POLLOUT detector in the poll multiplexer system */
+ if (s->poll_out) {
+ SSH_LOG(SSH_LOG_PACKET, "Enabling POLLOUT for socket");
+ ssh_poll_set_events(s->poll_out,ssh_poll_get_events(s->poll_out) | POLLOUT);
+ }
+ if (w < 0) {
+ s->data_except = 1;
+ }
- return w;
+ return w;
}
/** \internal