]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
shutdownDgramTest fails for ubuntu9 guest
authorVMware, Inc <>
Sat, 28 May 2011 19:56:50 +0000 (12:56 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Sat, 28 May 2011 19:56:50 +0000 (12:56 -0700)
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 <mvanzin@vmware.com>
open-vm-tools/modules/linux/vsock/linux/af_vsock.c

index 1e4420ddb1855e447d2e459904f3d1b237582eca..e3b4c5e7500e5cb08bbe49c0b801e5654105989f 100644 (file)
@@ -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;
 }