Skip to content
Closed
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
8 changes: 6 additions & 2 deletions idl/mdsconnect.pro
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ end

pro mdsconnect,host,status=status,quiet=quiet,port=port,socket=socket
on_error,2
if (not keyword_set(socket)) then $
mdsdisconnect,/quiet
; if (not keyword_set(socket)) then $
; mdsdisconnect,/quiet
defsysv, "!MDS_SOCKET", exists=has_mds_socket
if (not has_mds_socket) then begin
defsysv, "!MDS_SOCKET", -1
endif
if n_elements(port) ne 0 then begin
setenv_,'mdsip='+strtrim(port,2)
endif else if getenv('mdsip') eq '' then begin
Expand Down
2 changes: 1 addition & 1 deletion idl/mdsisclient.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function mdsisclient,socket=socket
if (keyword_set(socket)) then $
if (keyword_set(socket)) then $ ; Fails if socket = 0 (see issue 2625)
if (socket ge 0) then $
return, 1 $
else $
Expand Down
21 changes: 20 additions & 1 deletion idl/set_database.pro
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,26 @@ pro set_database, dbname, status=status, quiet=quiet,debug=debug, reset=reset, f
status = dbinfo(dbname, mdshost, host, name, user, pass, reset=reset, file=file)
if (status eq 0) then $
return
MDSDbconnect, mdshost

; For issue 2625, must ensure connection ID is greater than zero.
; Most robust solution is to open an extraneous connection if needed.
; Don't disconnect because resets !MDS_SOCKET to -1 (triggers 2625).
defsysv, "!MDS_SOCKET", exists=has_mds_socket
if (not has_mds_socket) then begin
mdsconnect, mdshost
endif

; The global !MDS_SOCKET should now definitely exist.
if (!MDS_SOCKET lt 0) then begin
if not (keyword_set(quiet)) then begin
Message, "Error connecting to MDSplus host "+mdshost, /continue
endif else begin
Message, "Error connecting to MDSplus host "+mdshost, /continue, /noprint
endelse
return
endif

MDSDbconnect, mdshost ; increments the socket
status = mdsvalue("dblogin($, $, $)", host, user, pass, socket=!MDSDB_SOCKET)
if (not status) then begin
if not (keyword_set(quiet)) then begin
Expand Down
6 changes: 1 addition & 5 deletions python/MDSplus/connection.py
Copy link
Member

Choose a reason for hiding this comment

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

Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,12 @@ def get(self, exp, *args, **kwargs):
args = kwargs['arglist']
timeout = kwargs.get('timeout', -1)
num = len(args)+1

exp = 'serializeout(`('+exp+'))'

exp = _ver.tobytes(exp)
_exc.checkStatus(_SendArg(self.conid, 0, 14, num,
len(exp), 0, 0, ctypes.c_char_p(exp)))
for i, arg in enumerate(args):
self._send_arg(arg, i+1, num)
retSerialized = self._get_answer(timeout)
return retSerialized.deserialize()
return self._get_answer(timeout)


class Connection(object):
Expand Down