Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion idl/mdsconnect.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ endcase
end

function sockmin
if !version.os eq 'linux' then return, 0 else return, 11-(!version.os eq 'MacOS')
; 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')
end

function mds$socket,quiet=quiet,status=status,socket=socket
Expand Down
8 changes: 6 additions & 2 deletions mdstcpip/mdsipshr/Connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,17 @@ 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++; // find next free id
} while (id == INVALID_CONNECTION_ID && _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR));
id++;
} while ((id == INVALID_CONNECTION_ID) || (id == 0) || _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR));
c->id = id;
pthread_mutex_unlock(&lock);
c->state |= CON_INLIST;
Expand Down