From cecfd7580ebd83f3213dea5d77a0b237cb793d36 Mon Sep 17 00:00:00 2001 From: Stephen Lane-Walsh Date: Thu, 28 Sep 2023 15:56:31 -0400 Subject: [PATCH] Revert "Fix: 2625 - start connection IDs at 1 (not zero) (#2626)" This reverts commit 389ed8679a61c6907be9d3cf0b4ae0cb72bcd57f. --- idl/mdsconnect.pro | 3 +-- mdstcpip/mdsipshr/Connections.c | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/idl/mdsconnect.pro b/idl/mdsconnect.pro index 1b0398e13a..77e5fea488 100644 --- a/idl/mdsconnect.pro +++ b/idl/mdsconnect.pro @@ -6,8 +6,7 @@ endcase end function sockmin - ; Connection IDs start at 1 (see Issue #2625 for details). - if !version.os eq 'linux' then return, 1 else return, 11-(!version.os eq 'MacOS') + if !version.os eq 'linux' then return, 0 else return, 11-(!version.os eq 'MacOS') end function mds$socket,quiet=quiet,status=status,socket=socket diff --git a/mdstcpip/mdsipshr/Connections.c b/mdstcpip/mdsipshr/Connections.c index 90fe125436..297614d235 100644 --- a/mdstcpip/mdsipshr/Connections.c +++ b/mdstcpip/mdsipshr/Connections.c @@ -465,17 +465,13 @@ static inline int authorize_client(Connection *c, char *username) int AddConnection(Connection *c) { MDSIPTHREADSTATIC_INIT; - - // Connection IDs are issued in sequence. - // Issue #2625 requires connection IDs starting at 1 to avoid IDL issues. - // Use of _FindConnection() is an integrity check of the data structures. static int id = INVALID_CONNECTION_ID; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&lock); do { - id++; - } while ((id == INVALID_CONNECTION_ID) || (id == 0) || _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR)); + id++; // find next free id + } while (id == INVALID_CONNECTION_ID && _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR)); c->id = id; pthread_mutex_unlock(&lock); c->state |= CON_INLIST;