Browse Source

net/rpmsg: return ESHUTDOWN upon Tx on errored sockets

The rpmsg proto driver uses a single rpmsg channel device
published from a remote processor to transmit all socket-based
messages intended for that remote processor. This channel will
be auto-removed and recreated if the remote processor goes
through an error recovery process. Any connected sockets are
marked with an error status, and further transmissions on these
connected sockets should gracefully return an error. This error
condition is specifically checked for and a new error ESHUTDOWN
is returned back to userspace to differentiate it from
transmissions on an unconnected socket.

Signed-off-by: Suman Anna <s-anna@ti.com>
Suman Anna 11 years ago
parent
commit
add529492d
1 changed files with 6 additions and 0 deletions
  1. 6 0
      net/rpmsg/rpmsg_proto.c

+ 6 - 0
net/rpmsg/rpmsg_proto.c

@@ -177,6 +177,12 @@ static int rpmsg_sock_sendmsg(struct socket *sock, struct msghdr *msg,
 
 	lock_sock(sk);
 
+	/* we don't support Tx on errored-out sockets */
+	if (sk->sk_state == RPMSG_ERROR) {
+		release_sock(sk);
+		return -ESHUTDOWN;
+	}
+
 	/* we don't support loopback at this point */
 	if (sk->sk_state != RPMSG_CONNECTED) {
 		release_sock(sk);