Commit b89741a0 authored by Allan Stephens's avatar Allan Stephens Committed by David S. Miller

[TIPC]: Cosmetic changes to TIPC connect() code

This patch fixes TIPC's connect routine to conform to Linux
kernel style norms of indentation, line length, etc.
Signed-off-by: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4934c69a
...@@ -1248,77 +1248,78 @@ static void wakeupdispatch(struct tipc_port *tport) ...@@ -1248,77 +1248,78 @@ static void wakeupdispatch(struct tipc_port *tport)
static int connect(struct socket *sock, struct sockaddr *dest, int destlen, static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
int flags) int flags)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest; struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest;
struct msghdr m = {NULL,}; struct msghdr m = {NULL,};
struct sk_buff *buf; struct sk_buff *buf;
struct tipc_msg *msg; struct tipc_msg *msg;
int res; int res;
/* For now, TIPC does not allow use of connect() with DGRAM or RDM types */ /* For now, TIPC does not allow use of connect() with DGRAM/RDM types */
if (sock->state == SS_READY) if (sock->state == SS_READY)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* For now, TIPC does not support the non-blocking form of connect() */ /* For now, TIPC does not support the non-blocking form of connect() */
if (flags & O_NONBLOCK) if (flags & O_NONBLOCK)
return -EWOULDBLOCK; return -EWOULDBLOCK;
/* Issue Posix-compliant error code if socket is in the wrong state */ /* Issue Posix-compliant error code if socket is in the wrong state */
if (sock->state == SS_LISTENING) if (sock->state == SS_LISTENING)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (sock->state == SS_CONNECTING) if (sock->state == SS_CONNECTING)
return -EALREADY; return -EALREADY;
if (sock->state != SS_UNCONNECTED) if (sock->state != SS_UNCONNECTED)
return -EISCONN; return -EISCONN;
/* /*
* Reject connection attempt using multicast address * Reject connection attempt using multicast address
* *
* Note: send_msg() validates the rest of the address fields, * Note: send_msg() validates the rest of the address fields,
* so there's no need to do it here * so there's no need to do it here
*/ */
if (dst->addrtype == TIPC_ADDR_MCAST) if (dst->addrtype == TIPC_ADDR_MCAST)
return -EINVAL; return -EINVAL;
/* Send a 'SYN-' to destination */ /* Send a 'SYN-' to destination */
m.msg_name = dest; m.msg_name = dest;
m.msg_namelen = destlen; m.msg_namelen = destlen;
if ((res = send_msg(NULL, sock, &m, 0)) < 0) { res = send_msg(NULL, sock, &m, 0);
sock->state = SS_DISCONNECTING; if (res < 0) {
return res; sock->state = SS_DISCONNECTING;
} return res;
}
if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS; if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
/* Wait for destination's 'ACK' response */
/* Wait for destination's 'ACK' response */
res = wait_event_interruptible_timeout(*sock->sk->sk_sleep,
skb_queue_len(&sock->sk->sk_receive_queue), res = wait_event_interruptible_timeout(*sock->sk->sk_sleep,
sock->sk->sk_rcvtimeo); skb_queue_len(&sock->sk->sk_receive_queue),
buf = skb_peek(&sock->sk->sk_receive_queue); sock->sk->sk_rcvtimeo);
if (res > 0) { buf = skb_peek(&sock->sk->sk_receive_queue);
msg = buf_msg(buf); if (res > 0) {
res = auto_connect(sock, tsock, msg); msg = buf_msg(buf);
if (!res) { res = auto_connect(sock, tsock, msg);
if (!msg_data_sz(msg)) if (!res) {
advance_queue(tsock); if (!msg_data_sz(msg))
} advance_queue(tsock);
} else { }
if (res == 0) { } else {
res = -ETIMEDOUT; if (res == 0)
} else res = -ETIMEDOUT;
{ /* leave "res" unchanged */ } else
sock->state = SS_DISCONNECTING; ; /* leave "res" unchanged */
} sock->state = SS_DISCONNECTING;
}
mutex_unlock(&tsock->lock);
return res; mutex_unlock(&tsock->lock);
return res;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment