From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:27 +0000 (-0700) Subject: lib/asyncsocket/asyncSocketBase.c: X-Git-Tag: stable-10.2.0~322 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3446664945da9e57031fad8892b43b2b5a6ab76f;p=thirdparty%2Fopen-vm-tools.git lib/asyncsocket/asyncSocketBase.c: - 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. --- diff --git a/open-vm-tools/lib/asyncsocket/asyncSocketBase.c b/open-vm-tools/lib/asyncsocket/asyncSocketBase.c index 10fc2c808..2cffea909 100644 --- a/open-vm-tools/lib/asyncsocket/asyncSocketBase.c +++ b/open-vm-tools/lib/asyncsocket/asyncSocketBase.c @@ -48,6 +48,20 @@ #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) { diff --git a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c index 3c7ee8b49..786acb340 100644 --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c @@ -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, diff --git a/open-vm-tools/lib/include/asyncsocket.h b/open-vm-tools/lib/include/asyncsocket.h index 17ebe96e3..07b2b9d68 100644 --- a/open-vm-tools/lib/include/asyncsocket.h +++ b/open-vm-tools/lib/include/asyncsocket.h @@ -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(): diff --git a/open-vm-tools/lib/include/msgList.h b/open-vm-tools/lib/include/msgList.h index de0851580..db112cebd 100644 --- a/open-vm-tools/lib/include/msgList.h +++ b/open-vm-tools/lib/include/msgList.h @@ -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 diff --git a/open-vm-tools/lib/include/vm_product_versions.h b/open-vm-tools/lib/include/vm_product_versions.h index fc9ec6b43..0b1394fb6 100644 --- a/open-vm-tools/lib/include/vm_product_versions.h +++ b/open-vm-tools/lib/include/vm_product_versions.h @@ -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 @@ -160,9 +160,9 @@ * 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" @@ -401,7 +401,7 @@ # 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" @@ -483,7 +483,7 @@ #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"