Skip to content

Conversation

@mwinkel-dev
Copy link
Contributor

Fixes issue #2996.

The IDL API has a system variable (i.e., global), !MDS_SOCKET, used to store the most recent connection ID. It is now updated whenever mdsconnect establishes a mdsip connection.

Example output follows . . .

IDL> CD, '/usr/local/mdsplus/lib'
IDL> mdsconnect, 'localhost'
% Compiled module: MDSCONNECT.
% Compiled module: MDS_KEYWORD_SET.
% Compiled module: MDSDISCONNECT.
IDL> print, !MDS_SOCKET
       0
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET
       1
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET
       2
IDL> conn_id = -1
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
       3           3
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
       4           4
IDL> mdsdisconnect, socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
       4           4
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
       5           5
IDL> mdsdisconnect
IDL> print, !MDS_SOCKET, conn_id
      -1           5
IDL> mdsconnect, 'localhost', socket=conn_id
IDL> print, !MDS_SOCKET, conn_id
       6           6
IDL> mdsconnect, 'localhost'
IDL> print, !MDS_SOCKET, conn_id
       7           6
IDL> 

@mwinkel-dev mwinkel-dev self-assigned this Dec 16, 2025
@mwinkel-dev mwinkel-dev added the api/idl Relates to the IDL API label Dec 16, 2025
return
end

; This procedure is likely obsolete
Copy link
Contributor Author

@mwinkel-dev mwinkel-dev Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This procedure is not used anywhere in the MDSplus source code. Plus it appears to be replaced by the mdsconnect procedure.

However, there is a chance that customers have old IDL programs that use this routine.

We should select one of these options:

  • delete the procedure, or
  • keep the procedure, or
  • add a print statement to it indicating that it is deprecated and the user should instead use mdsconnect

end


; This procedure is likely obsolete
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete, keep or deprecate?

@mwinkel-dev
Copy link
Contributor Author

This draft PR will probably be cancelled after some additional investigation. For more information, refer to the post on Issue #2996.

#2996 (comment)

@mwinkel-dev
Copy link
Contributor Author

Adding an optional database keyword to the MdsConnect procedure enables proper updating of !MDS_SOCKET and !MDSDB_SOCKET.

Even though this draft PR now passes the automated builds, it is debatable whether bug #2996 should be fixed or not.

@mwinkel-dev
Copy link
Contributor Author

This draft PR and the original code both pass the unmodified automated test, which proves that they are functionally equivalent. However, any change to existing code brings with it the risk of unintended consequences; an innocuous change can inadvertently introduce a subtle bug.

An alternate approach is to add comments to the original code explaining that the optional socket keyword to the MdsConnect procedure is reserved for use by the MdsDbConnect procedure. The presence of the socket keyword causes !MDSDB_SOCKET to be updated; its absence causes !MDS_SOCKET to be updated. Thus, user programs must not use the socket keyword when using MdsConnect to access a remote MDSplus archive server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api/idl Relates to the IDL API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant