Commit 1d835874 authored by Ying Xue's avatar Ying Xue Committed by Paul Gortmaker

tipc: Add support for SO_SNDTIMEO socket option

Adds support for the SO_SNDTIMEO socket option. (This complements the
existing support for SO_RCVTIMEO that is already present.)
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent 9aa88c2a
...@@ -525,6 +525,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -525,6 +525,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
struct tipc_port *tport = tipc_sk_port(sk); struct tipc_port *tport = tipc_sk_port(sk);
struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
int needs_conn; int needs_conn;
long timeout_val;
int res = -EINVAL; int res = -EINVAL;
if (unlikely(!dest)) if (unlikely(!dest))
...@@ -564,6 +565,8 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -564,6 +565,8 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
reject_rx_queue(sk); reject_rx_queue(sk);
} }
timeout_val = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
do { do {
if (dest->addrtype == TIPC_ADDR_NAME) { if (dest->addrtype == TIPC_ADDR_NAME) {
res = dest_name_check(dest, m); res = dest_name_check(dest, m);
...@@ -600,16 +603,14 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -600,16 +603,14 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
sock->state = SS_CONNECTING; sock->state = SS_CONNECTING;
break; break;
} }
if (m->msg_flags & MSG_DONTWAIT) { if (timeout_val <= 0L) {
res = -EWOULDBLOCK; res = timeout_val ? timeout_val : -EWOULDBLOCK;
break; break;
} }
release_sock(sk); release_sock(sk);
res = wait_event_interruptible(*sk_sleep(sk), timeout_val = wait_event_interruptible_timeout(*sk_sleep(sk),
!tport->congested); !tport->congested, timeout_val);
lock_sock(sk); lock_sock(sk);
if (res)
break;
} while (1); } while (1);
exit: exit:
...@@ -636,6 +637,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, ...@@ -636,6 +637,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_port *tport = tipc_sk_port(sk); struct tipc_port *tport = tipc_sk_port(sk);
struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
long timeout_val;
int res; int res;
/* Handle implied connection establishment */ /* Handle implied connection establishment */
...@@ -650,6 +652,8 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, ...@@ -650,6 +652,8 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
if (iocb) if (iocb)
lock_sock(sk); lock_sock(sk);
timeout_val = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
do { do {
if (unlikely(sock->state != SS_CONNECTED)) { if (unlikely(sock->state != SS_CONNECTED)) {
if (sock->state == SS_DISCONNECTING) if (sock->state == SS_DISCONNECTING)
...@@ -663,16 +667,14 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, ...@@ -663,16 +667,14 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
total_len); total_len);
if (likely(res != -ELINKCONG)) if (likely(res != -ELINKCONG))
break; break;
if (m->msg_flags & MSG_DONTWAIT) { if (timeout_val <= 0L) {
res = -EWOULDBLOCK; res = timeout_val ? timeout_val : -EWOULDBLOCK;
break; break;
} }
release_sock(sk); release_sock(sk);
res = wait_event_interruptible(*sk_sleep(sk), timeout_val = wait_event_interruptible_timeout(*sk_sleep(sk),
(!tport->congested || !tport->connected)); (!tport->congested || !tport->connected), timeout_val);
lock_sock(sk); lock_sock(sk);
if (res)
break;
} while (1); } while (1);
if (iocb) if (iocb)
......
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