From: VMware, Inc <> Date: Sat, 28 May 2011 19:56:50 +0000 (-0700) Subject: shutdownDgramTest fails for ubuntu9 guest X-Git-Tag: 2011.05.27-420096~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80901d02a1dfab943a3a404eae575f5a14b56afd;p=thirdparty%2Fopen-vm-tools.git shutdownDgramTest fails for ubuntu9 guest We fixed shutdown() recently so that it kicks DGRAM sockets even if they are unconnected. But to be truly consistent with UDP, we should still return an error if they are unconnected. Fixed so that we kick the socket and then fail. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/linux/vsock/linux/af_vsock.c b/open-vm-tools/modules/linux/vsock/linux/af_vsock.c index 1e4420ddb..e3b4c5e75 100644 --- a/open-vm-tools/modules/linux/vsock/linux/af_vsock.c +++ b/open-vm-tools/modules/linux/vsock/linux/af_vsock.c @@ -4118,6 +4118,7 @@ static int VSockVmciShutdown(struct socket *sock, // IN int mode) // IN { + int32 err; struct sock *sk; /* @@ -4133,13 +4134,24 @@ VSockVmciShutdown(struct socket *sock, // IN return -EINVAL; } + /* + * If this is a STREAM socket and it is not connected then bail out + * immediately. If it is a DGRAM socket then we must first kick the socket + * so that it wakes up from any sleeping calls, for example recv(), and then + * afterwards return the error. + */ + sk = sock->sk; - if (sk->sk_type == SOCK_STREAM && sock->state == SS_UNCONNECTED) { - return -ENOTCONN; + if (sock->state == SS_UNCONNECTED) { + err = -ENOTCONN; + if (sk->sk_type == SOCK_STREAM) { + return err; + } + } else { + sock->state = SS_DISCONNECTING; + err = 0; } - sock->state = SS_DISCONNECTING; - /* Receive and send shutdowns are treated alike. */ mode = mode & (RCV_SHUTDOWN | SEND_SHUTDOWN); if (mode) { @@ -4154,7 +4166,7 @@ VSockVmciShutdown(struct socket *sock, // IN VSOCK_SEND_SHUTDOWN(sk, mode); } - return 0; + return err; }