~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to modules/linux/vsock/linux/af_vsock.c

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*********************************************************
2
 
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
 
2
 * Copyright (C) 2007-2011 VMware, Inc. All rights reserved.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License as published by the
4787
4787
   struct sock *sk;
4788
4788
   VSockVmciSock *vsk;
4789
4789
   int err;
4790
 
   int target;
 
4790
   size_t target;
4791
4791
   ssize_t copied;
4792
 
   int64 ready;
4793
4792
   long timeout;
4794
4793
 
4795
4794
   VSockVmciRecvNotifyData recvData;
4862
4861
 
4863
4862
   prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
4864
4863
 
4865
 
   while ((ready = VSockVmciStreamHasData(vsk)) < target &&
4866
 
          sk->sk_err == 0 &&
4867
 
          !(sk->sk_shutdown & RCV_SHUTDOWN) &&
4868
 
          !(vsk->peerShutdown & SEND_SHUTDOWN)) {
 
4864
   while (1) {
 
4865
      int64 ready = VSockVmciStreamHasData(vsk);
4869
4866
 
4870
4867
      if (ready < 0) {
4871
4868
         /*
4874
4871
          */
4875
4872
 
4876
4873
         err = -ENOMEM;
4877
 
         goto out;
4878
 
      }
4879
 
 
4880
 
      /* Don't wait for non-blocking sockets. */
4881
 
      if (timeout == 0) {
4882
 
         err = -EAGAIN;
4883
 
         goto outWait;
4884
 
      }
4885
 
 
4886
 
      NOTIFYCALLRET(vsk, err, recvPreBlock, sk, target, &recvData);
4887
 
      if (err < 0) {
4888
 
         goto outWait;
4889
 
      }
4890
 
 
4891
 
      release_sock(sk);
4892
 
      timeout = schedule_timeout(timeout);
4893
 
      lock_sock(sk);
4894
 
 
4895
 
      if (signal_pending(current)) {
4896
 
         err = sock_intr_errno(timeout);
4897
 
         goto outWait;
4898
 
      } else if (timeout == 0) {
4899
 
         err = -EAGAIN;
4900
 
         goto outWait;
4901
 
      }
4902
 
 
4903
 
      prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
 
4874
         goto outWait;
 
4875
      } else if (ready > 0) {
 
4876
         ssize_t read;
 
4877
 
 
4878
         VSOCK_STATS_STREAM_CONSUME_HIST(vsk);
 
4879
 
 
4880
         NOTIFYCALLRET(vsk, err, recvPreDequeue, sk, target, &recvData);
 
4881
         if (err < 0) {
 
4882
            break;
 
4883
         }
 
4884
 
 
4885
         if (flags & MSG_PEEK) {
 
4886
            read = VMCIQPair_PeekV(vsk->qpair, msg->msg_iov, len - copied, 0);
 
4887
         } else {
 
4888
            read = VMCIQPair_DequeueV(vsk->qpair, msg->msg_iov, len - copied, 0);
 
4889
         }
 
4890
 
 
4891
         if (read < 0) {
 
4892
            err = -ENOMEM;
 
4893
            break;
 
4894
         }
 
4895
 
 
4896
         ASSERT(read <= INT_MAX);
 
4897
         copied += read;
 
4898
 
 
4899
         NOTIFYCALLRET(vsk, err, recvPostDequeue, sk, target, read,
 
4900
                       !(flags & MSG_PEEK), &recvData);
 
4901
         if (err < 0) {
 
4902
            goto outWait;
 
4903
         }
 
4904
 
 
4905
         if (read >= target || flags & MSG_PEEK) {
 
4906
            break;
 
4907
         }
 
4908
         target -= read;
 
4909
      } else {
 
4910
         if (sk->sk_err != 0 || (sk->sk_shutdown & RCV_SHUTDOWN) ||
 
4911
             (vsk->peerShutdown & SEND_SHUTDOWN)) {
 
4912
            break;
 
4913
         }
 
4914
         /* Don't wait for non-blocking sockets. */
 
4915
         if (timeout == 0) {
 
4916
            err = -EAGAIN;
 
4917
            break;
 
4918
         }
 
4919
 
 
4920
         NOTIFYCALLRET(vsk, err, recvPreBlock, sk, target, &recvData);
 
4921
         if (err < 0) {
 
4922
            break;
 
4923
         }
 
4924
 
 
4925
         release_sock(sk);
 
4926
         timeout = schedule_timeout(timeout);
 
4927
         lock_sock(sk);
 
4928
 
 
4929
         if (signal_pending(current)) {
 
4930
            err = sock_intr_errno(timeout);
 
4931
            break;
 
4932
         } else if (timeout == 0) {
 
4933
            err = -EAGAIN;
 
4934
            break;
 
4935
         }
 
4936
 
 
4937
         prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
 
4938
      }
4904
4939
   }
4905
4940
 
4906
4941
   if (sk->sk_err) {
4907
4942
      err = -sk->sk_err;
4908
 
      goto outWait;
4909
4943
   } else if (sk->sk_shutdown & RCV_SHUTDOWN) {
4910
4944
      err = 0;
4911
 
      goto outWait;
4912
 
   } else if ((vsk->peerShutdown & SEND_SHUTDOWN) &&
4913
 
              VSockVmciStreamHasData(vsk) < target) {
4914
 
      err = 0;
4915
 
      goto outWait;
4916
 
   }
4917
 
 
4918
 
   VSOCK_STATS_STREAM_CONSUME_HIST(vsk);
4919
 
 
4920
 
   NOTIFYCALLRET(vsk, err, recvPreDequeue, sk, target, &recvData);
4921
 
   if (err < 0) {
4922
 
      goto outWait;
4923
 
   }
4924
 
 
4925
 
   if (flags & MSG_PEEK) {
4926
 
      copied = VMCIQPair_PeekV(vsk->qpair, msg->msg_iov, len, 0);
4927
 
   } else {
4928
 
      copied = VMCIQPair_DequeueV(vsk->qpair, msg->msg_iov, len, 0);
4929
 
   }
4930
 
 
4931
 
   if (copied < 0) {
4932
 
      err = -ENOMEM;
4933
 
      goto outWait;
4934
 
   }
4935
 
 
4936
 
   ASSERT(copied >= target);
4937
 
 
4938
 
   /*
4939
 
    * We only do these additional bookkeeping/notification steps if we actually
4940
 
    * copied something out of the queue pair instead of just peeking ahead.
4941
 
    */
4942
 
   if (!(flags & MSG_PEEK)) {
4943
 
 
 
4945
   }
 
4946
 
 
4947
   if (copied > 0) {
4944
4948
      /*
4945
 
       * If the other side has shutdown for sending and there is nothing more to
4946
 
       * read, then modify the socket state.
 
4949
       * We only do these additional bookkeeping/notification steps if we
 
4950
       * actually copied something out of the queue pair instead of just peeking
 
4951
       * ahead.
4947
4952
       */
4948
 
      if (vsk->peerShutdown & SEND_SHUTDOWN) {
4949
 
         if (VSockVmciStreamHasData(vsk) <= 0) {
4950
 
            sk->sk_state = SS_UNCONNECTED;
4951
 
            sock_set_flag(sk, SOCK_DONE);
4952
 
            sk->sk_state_change(sk);
 
4953
 
 
4954
      if (!(flags & MSG_PEEK)) {
 
4955
         /*
 
4956
          * If the other side has shutdown for sending and there is nothing more
 
4957
          * to read, then modify the socket state.
 
4958
          */
 
4959
         if (vsk->peerShutdown & SEND_SHUTDOWN) {
 
4960
            if (VSockVmciStreamHasData(vsk) <= 0) {
 
4961
               sk->sk_state = SS_UNCONNECTED;
 
4962
               sock_set_flag(sk, SOCK_DONE);
 
4963
               sk->sk_state_change(sk);
 
4964
            }
4953
4965
         }
4954
4966
      }
4955
 
   }
4956
 
 
4957
 
   NOTIFYCALLRET(vsk, err, recvPostDequeue, sk, target, copied,
4958
 
                 !(flags & MSG_PEEK), &recvData);
4959
 
   if (err < 0) {
4960
 
      goto outWait;
4961
 
   }
4962
 
 
4963
 
   ASSERT(copied <= INT_MAX);
4964
 
   err = copied;
 
4967
      err = copied;
 
4968
   }
4965
4969
 
4966
4970
outWait:
4967
4971
   finish_wait(sk_sleep(sk), &wait);