-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Affiliation
MIT PSFC
Version(s) Affected
client and server = alpha-7-157-0, but likely exists in all recent versions
Platform(s)
macOS (Apple Silicon) but surely exists on all other platforms
Installation Method(s)
developer build
Describe the bug
MDSplus provides an API for the IDL programming language. The API uses an internal "system variable" (i.e., global variable) named !MDS_SOCKET. The conjecture is that it is supposed to have the "connection ID" of the most recent connection to an mdsip process. However, it is not being updated consistently.
This output illustrates the issue. (Note that socket=conn_id means that the socket keyword to the procedure will return the new socket in the conn_id variable. In IDL, keyword variables can be input and/or output.)
IDL>
IDL> ; The system variable belongs to the MDSplus API for IDL, thus doesn’t exist
IDL> ; prior to calling the API.
IDL> print, !MDS_SOCKET
% Not a legal system variable: !MDS_SOCKET.
% Execution halted at: $MAIN$
IDL>
IDL> ; Valid connection IDs start at 0, and then increment
IDL> mdsconnect, 'localhost'
% Compiled module: MDSCONNECT.
% Compiled module: MDS_KEYWORD_SET.
% Compiled module: MDSDISCONNECT.
IDL> print, !MDS_SOCKET
0
IDL>
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET
1
IDL>
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET
2
IDL>
IDL> ; Note that the current connection is 3, but !MDS_SOCKET is stuck at 2
IDL> conn_id = -1
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
2 3
IDL>
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
2 4
IDL>
IDL> ; Disconnected from connection 4
IDL> mdsdisconnect, socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
2 4
IDL>
IDL> ; Connection 4 no longer exists, thus surprising not reused when reconnect
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
2 5
IDL>
IDL> ; Disconnecting this way resets !MDS_SOCKET to -1 = INVALID_CONNECTION_ID .
IDL> ; Furthermore, it is unclear which connection ID was disconnected.
IDL> mdsdisconnect
IDL> print, !MDS_SOCKET, conn_id
-1 5
IDL> .
IDL> ; !MDS_SOCKET still indicates INVALID_CONNECTION_ID even though just reconnected
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
-1 6
IDL>
IDL> ; Now, !MDS_SOCKET jumps to 7 simply because didn’t use the “socket” keyword
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET, conn_id
7 6
To Reproduce
- If running mdsip on the same computer that has IDL, then use 'localhost' as the server. Otherwise, use the name of the remote archive server.
- Run the commands as shown in the above example.
Expected behavior
Conjecture is that the !MDS_SOCKET variable should always be set to the most recently created connection ID.
Screenshots
n/a
Additional context
When investigating this issue, first determine where !MDS_SOCKET is used and read. In particular, determine if there is a reason for !MDS_SOCKET to not track the current connection ID.