]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/asyncsocket/asyncSocketBase.c:
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:27 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:27 +0000 (11:23 -0700)
  - Avoid infinite recursion with ASOCKLOG() and DecRef.

lib/asyncsocket/asynsocket.c:
lib/include/asyncsocket.h:
  - Fix race between AsyncSocket_DoOneMsg and the read callbac.k

Changes to common header files: not applicable to open-vm-tools.

open-vm-tools/lib/asyncsocket/asyncSocketBase.c
open-vm-tools/lib/asyncsocket/asyncsocket.c
open-vm-tools/lib/include/asyncsocket.h
open-vm-tools/lib/include/msgList.h
open-vm-tools/lib/include/vm_product_versions.h

index 10fc2c808db9e40f6d05c2dd8e034bd622beeb8d..2cffea909ace5475e9689b3759ac5b99147a5f62 100644 (file)
 #define LOGLEVEL_MODULE asyncsocket
 #include "loglevel_user.h"
 
+/*
+ * A version of ASOCKLOG() which is safe to call from inside IncRef,
+ * DecRef or any of the other functions which the regular ASOCKLOG()
+ * implicitly calls.  We don't log fd as that isn't available at the
+ * base class level.
+ */
+#define ASOCKLOG_NORECURSION(_level, _asock, _logargs)                  \
+   do {                                                                 \
+      if (((_level) == 0) || DOLOG_BYNAME(asyncsocket, (_level))) {     \
+         Log(ASOCKPREFIX "%d ", (_asock)->id);                          \
+         Log _logargs;                                                  \
+      }                                                                 \
+   } while(0)
+
 
 /*
  *-----------------------------------------------------------------------------
@@ -111,10 +125,10 @@ AsyncSocketInternalDecRef(AsyncSocket *s, // IN
 
    ASSERT(count >= 0);
    if (UNLIKELY(count == 0)) {
-      ASOCKLOG(1, s, ("Final release; freeing asock struct\n"));
+      ASOCKLOG_NORECURSION(1, s, ("Final release; freeing asock struct\n"));
       VT(s)->destroy(s);
    } else {
-      ASOCKLOG(1, s, ("Release (count now %d)\n", count));
+      ASOCKLOG_NORECURSION(1, s, ("Release (count now %d)\n", count));
    }
 }
 
@@ -753,6 +767,8 @@ AsyncSocket_MsgError(int asyncSockError)   // IN
    case ASOCKERR_ADDRUNRESV:
       result = MSGID(asyncsocket.addrunresv) "Address unresolvable";
       break;
+   case ASOCKERR_BUSY:
+      result = MSGID(asyncsocket.busy) "Concurrent operations on socket";
    }
 
    if (!result) {
index 3c7ee8b490329c03425e1fc6a465dfa9a48e64e8..786acb340d61a7362357c91f099c9f5dcdb695f6 100644 (file)
@@ -3864,6 +3864,15 @@ AsyncTCPSocketDoOneMsg(AsyncSocket *base, // IN
    ASSERT(AsyncTCPSocketGetState(s) == AsyncSocketConnected);
 
    if (read) {
+      if (s->inRecvLoop) {
+         /*
+          * The recv loop would read the data if there is any and it is
+          * not safe to proceed and race with the recv loop.
+          */
+         TCPSOCKLG0(s, ("busy: another thread in recv loop\n"));
+         return ASOCKERR_BUSY;
+      }
+
       /*
        * Bug 158571: There could other threads polling on the same asyncsocket.
        * If two threads land up polling  on the same socket at the same time,
index 17ebe96e3edc8f50f3c7100464271ea79df0892c..07b2b9d6890e25917d5d104cca9df04ec586548c 100644 (file)
@@ -72,6 +72,7 @@ extern "C" {
 #define ASOCKERR_CONNECTSSL        13
 #define ASOCKERR_NETUNREACH        14
 #define ASOCKERR_ADDRUNRESV        15
+#define ASOCKERR_BUSY              16
 
 /*
  * Cross-platform codes for AsyncSocket_GetGenericError():
index de08515803a8ef79d459e713cba1b2430a40d8c8..db112cebdc1e04c7ce44d764a046b98d5df16697 100644 (file)
@@ -76,6 +76,13 @@ const char *MsgList_GetMsgID(const MsgList *messages);
 
 Bool MsgList_Present(const MsgList *messages);
 
+static INLINE void
+MsgList_LogAndFree(MsgList *messages)
+{
+   MsgList_Log(messages);
+   MsgList_Free(messages);
+}
+
 #if defined(__cplusplus)
 }  // extern "C"
 #endif
index fc9ec6b4392c637895fdd0d3b1ec768702757be7..0b1394fb62350d89689bb2ec8c45b699b5f241bb 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -56,7 +56,7 @@
 // VMX86_DESKTOP must be last because it is the default and is always defined.
 #elif defined(VMX86_DESKTOP)
    // WORKSTATION_VERSION_NUMBER below has to match this
-   #define PRODUCT_VERSION    12,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
+   #define PRODUCT_VERSION    13,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #else
    /* Generic catch-all. */
    #define PRODUCT_VERSION    0,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
  * ALSO, leave FOO_VERSION at e.x.p on all EXCEPT release branches.
  * lmclient.h has a FLEX_VERSION struct so the versionPrefix can't be FLEX
  */
-#define WORKSTATION_VERSION_NUMBER "12.0.0" /* this version number should always match real WS version number */
+#define WORKSTATION_VERSION_NUMBER "13.0.0" /* this version number should always match real WS version number */
 #define WORKSTATION_VERSION "e.x.p"
-#define PLAYER_VERSION_NUMBER "12.0.0" /* this version number should always match real Player version number */
+#define PLAYER_VERSION_NUMBER "13.0.0" /* this version number should always match real Player version number */
 #define PLAYER_VERSION "e.x.p"
 #define VMRC_VERSION_NUMBER "9.0.0" /* this version number should always match real VMRC version number */
 #define VMRC_VERSION "9.0.0"
 #  define PRODUCT_VERSION_STRING_FOR_LICENSE PRODUCT_LICENSE_VERSION
 #endif
 #define PRODUCT_ESX_LICENSE_VERSION "6.0"
-#define PRODUCT_ESX_LICENSE_FILE_VERSION "6.5.0.2"
+#define PRODUCT_ESX_LICENSE_FILE_VERSION "6.6.0.0"
 #define PRODUCT_VSAN_LICENSE_VERSION "5.0"
 #define PRODUCT_VSAN_LICENSE_FILE_VERSION "6.5.0.0"
 
 #define PRODUCT_VERSION_WORKSTATION_90 PRODUCT_WORKSTATION_BRIEF_NAME " 9.x"
 #define PRODUCT_VERSION_WORKSTATION_100 PRODUCT_WORKSTATION_BRIEF_NAME " 10.x"
 #define PRODUCT_VERSION_WORKSTATION_110 PRODUCT_WORKSTATION_BRIEF_NAME " 11.x"
-#define PRODUCT_VERSION_WORKSTATION_120 PRODUCT_WORKSTATION_BRIEF_NAME " 12.0"
+#define PRODUCT_VERSION_WORKSTATION_120 PRODUCT_WORKSTATION_BRIEF_NAME " 12.x"
 #define PRODUCT_VERSION_WORKSTATION_130 PRODUCT_WORKSTATION_BRIEF_NAME " 2017"
 #define PRODUCT_VERSION_WORKSTATION_ENTERPRISE_1 "ACE 1.x"
 #define PRODUCT_VERSION_WORKSTATION_ENTERPRISE_2 "ACE 2.0"