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
12 changes: 4 additions & 8 deletions idl/dsql.pro
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ if (debug) then $
; now execute the query
; !!! if it is a string it is a database error
;
socket_var = !MDSDB_SOCKET
count = mdsvalue(expr, socket=socket_var)
count = mdsvalue(expr, socket=!MDSDB_SOCKET)

sz = size(count)
if (sz(n_elements(sz)-2) eq 7) then begin
Expand All @@ -255,8 +254,7 @@ endif else begin
if (debug) then $
print, 'Working on arg ', i
arg = 'a'+string(i, format="(I3.3)")
socket_var = !MDSDB_SOCKET
val = MDSVALUE("_"+arg,socket=socket_var,/QUIET)
val = MDSVALUE("_"+arg,socket=!MDSDB_SOCKET,/QUIET)
ok = evaluate(arg + ' = val')
if (ok eq "OK") then status = 1L else status = 0L
if (debug) then $
Expand All @@ -277,10 +275,8 @@ endif else begin
;
; free all the tdi variables returned by DSQL
;
if (not debug) then begin
socket_var = !MDSDB_SOCKET
dummy = MdsValue("DeAllocate('_A%%%')",socket=socket_var,/QUIET)
endif
if (not debug) then $
dummy = MdsValue("DeAllocate('_A%%%')",socket=!MDSDB_SOCKET,/QUIET)
;
; return the number of row
;
Expand Down
12 changes: 4 additions & 8 deletions idl/mdsconnect.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ function mds$socket,quiet=quiet,status=status,socket=socket
status = 1
sockmin=sockmin()
sock=sockmin-1
; The arg_present() only works if the optional keyword argument
; is bound to a regular variable in the calling code.
if (arg_present(socket)) then $
if (keyword_set(socket)) then $
if (socket ge sockmin) then $
return, socket
defsysv,'!MDS_SOCKET',exists=old_sock
Expand Down Expand Up @@ -139,7 +137,7 @@ pro mds$disconnect,status=status,quiet=quiet
if status then begin
status = call_external(MdsIPImage(),'IdlDisconnectFromMds',sock,value=[1b])
if (status eq 0) then status = 1 else status = 0
!MDS_SOCKET = 0l ; Is this correct? Should it be -1?
!MDS_SOCKET = 0l
endif
return
end
Expand All @@ -155,9 +153,7 @@ end

pro mdsconnect,host,status=status,quiet=quiet,port=port,socket=socket
on_error,2
; The arg_present() only works if the optional keyword argument
; is bound to a regular variable in the calling code.
if (not arg_present(socket)) then $
if (not keyword_set(socket)) then $
mdsdisconnect,/quiet
if n_elements(port) ne 0 then begin
setenv_,'mdsip='+strtrim(port,2)
Expand All @@ -169,7 +165,7 @@ pro mdsconnect,host,status=status,quiet=quiet,port=port,socket=socket
sockmin=sockmin()
if (sock ge sockmin) then begin
status = 1
if not arg_present(socket) then $
if not keyword_set(socket) then $
!MDS_SOCKET = sock $
else $
socket = sock
Expand Down
6 changes: 2 additions & 4 deletions idl/mdsdisconnect.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ pro mdsdisconnect,status=status,quiet=quiet, socket=socket
forward_function mds$socket, MdsIPImage
image = MdsIPImage()
status = 1
; The arg_present() only works if the optional keyword argument
; is bound to a regular variable in the calling code.
if arg_present(socket) then $
if keyword_set(socket) then $
sock = socket $
else $
sock = mds$socket(status=status,quiet=quiet)
if status then begin
status = call_external(image,'DisconnectFromMds',sock,value=[1b])
if (status eq 0) then status = 1 else status = 0
if not arg_present(socket) then $
if not keyword_set(socket) then $
!MDS_SOCKET = -1l
endif
return
Expand Down
15 changes: 3 additions & 12 deletions idl/mdsisclient.pro
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
; This function is used to confirm a valid connection has been established.
function mdsisclient,socket=socket_var

; For arg_present() to work, the optional keyword argument must be bound
; to a regular variable. It will not work if bound to a system variable
; such as !MDS_SOCKET. Refer to issue #2625 for more details.
if (arg_present(socket_var)) then $
if (socket_var ge 0) then $
function mdsisclient,socket=socket
if (keyword_set(socket)) then $
if (socket ge 0) then $
return, 1 $
else $
return, 0

; If no connection specified, then assume using the most recent one.
defsysv,'!MDS_SOCKET',exists=mdsClient
if (mdsClient) then begin
value= (!MDS_SOCKET ge 0)
return,value

; If things have gone awry, indicate an INVALID_CONNECTION_ID
endif else begin
defsysv,'!MDS_SOCKET',-1
return,0
Expand Down
21 changes: 7 additions & 14 deletions idl/mdssql.pro
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ pro MDSDbDisconnect
defsysv, '!MDSDB_SOCKET', -1
defsysv, '!MDSDB_HOST', ''
endif
socket_var = !MDSDB_SOCKET
MdsDisconnect, socket=socket_var
MdsDisconnect, socket=!MDSDB_SOCKET
!MDSDB_SOCKET = -1
!MDSDB_HOST = ""
end
Expand All @@ -80,8 +79,7 @@ end
pro set_database, dbname, status=status, quiet=quiet,debug=debug
status = dbinfo(dbname, host, name, user, pass, mdshost)
MDSDbconnect, mdshost
socket_var = !MDSDB_SOCKET
status = mdsvalue("DBLogin($, $, $)", host, user, pass, socket=socket_var)
status = mdsvalue("DBLogin($, $, $)", host, user, pass, socket=!MDSDB_SOCKET)
if (not status) then begin
if not (keyword_set(quiet)) then begin
Message, "Error logging on to DbHost "+host, /continue
Expand All @@ -90,8 +88,7 @@ pro set_database, dbname, status=status, quiet=quiet,debug=debug
endelse
return
endif
; socket_var = !MDSDB_SOCKET
; status = mdsvalue("SetDatabase('"+ name+"')", socket=socket_var)
; status = mdsvalue("SetDatabase('"+ name+"')", socket=!MDSDB_SOCKET)
status = dsql('USE ?', name)
if (status ne 0) then begin
if not (keyword_set(quiet)) then begin
Expand Down Expand Up @@ -245,8 +242,7 @@ if (debug) then $
; now execute the query
; !!! if it is a string it is a database error
;
socket_var = !MDSDB_SOCKET
count = mdsvalue(expr, socket=socket_var)
count = mdsvalue(expr, socket=!MDSDB_SOCKET)
sz = size(count)
if (sz(n_elements(sz)-2) eq 7) then begin

Expand All @@ -273,8 +269,7 @@ endif else begin
if (debug) then $
print, 'Working on arg ', i
arg = 'a'+string(i, format="(I3.3)")
socket_var = !MDSDB_SOCKET
cmd = arg+' = MDSVALUE("_'+arg+'",socket=socket_var)'
cmd = arg+' = MDSVALUE("_'+arg+'",socket=!MDSDB_SOCKET)'
status = execute(cmd)
if (debug) then $
print, "got back "+arg
Expand All @@ -292,10 +287,8 @@ endif else begin
;
; free all the tdi variables returned by DSQL
;
if (not debug) then begin
socket_var = !MDSDB_SOCKET
dummy = MdsValue("DeAllocate('_A%%%')",socket=socket_var)
endif
if (not debug) then $
dummy = MdsValue("DeAllocate('_A%%%')",socket=!MDSDB_SOCKET)
;
; return the number of row
;
Expand Down
2 changes: 0 additions & 2 deletions idl/mdsvalue.pro
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@


function MdsValue,expression,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,quiet=quiet,status=status,socket=socket
; Note that Issue #2625 requires the optional "socket" keyword argument
; to be bound to a regular variable in the calling code.

forward_function mdsIsClient,mdsIdlImage,mds$socket,MdsIPImage,evaluate
MdsCheckArg,expression,type="STRING",name="expression"
Expand Down
9 changes: 3 additions & 6 deletions idl/set_database.pro
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,8 @@ pro MDSDbDisconnect
defsysv, '!MDSDB_SOCKET', -1
defsysv, '!MDSDB_HOST', ''
endif
if !MDSDB_SOCKET ne -1 then begin
socket_var = !MDSDB_SOCKET
MdsDisconnect, socket=socket_var
endif
if !MDSDB_SOCKET ne -1 then $
MdsDisconnect, socket=!MDSDB_SOCKET
!MDSDB_SOCKET = -1
!MDSDB_HOST = ""
end
Expand Down Expand Up @@ -441,8 +439,7 @@ pro set_database, dbname, status=status, quiet=quiet,debug=debug, reset=reset, f
if (status eq 0) then $
return
MDSDbconnect, mdshost
socket_var = !MDSDB_SOCKET
status = mdsvalue("dblogin($, $, $)", host, user, pass, socket=socket_var)
status = mdsvalue("dblogin($, $, $)", host, user, pass, socket=!MDSDB_SOCKET)
if (not status) then begin
if not (keyword_set(quiet)) then begin
Message, mdsvalue('dsc:MdsSql->GetDBMsgText_dsc()'), /continue
Expand Down
2 changes: 1 addition & 1 deletion mdstcpip/mdsipshr/Connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ int AddConnection(Connection *c)
do
{
id++; // find next free id
} while ((id == INVALID_CONNECTION_ID) || _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR));
} while (id == INVALID_CONNECTION_ID && _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR));
c->id = id;
pthread_mutex_unlock(&lock);
c->state |= CON_INLIST;
Expand Down