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
2 changes: 1 addition & 1 deletion mdstcpip/mdsip_connections.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ EXPORT Connection *PopConnection(int id);

client_t GetConnectionClientType(int id);

int GetConnectionVersion(int id);
int MdsIpGetConnectionVersion(int id);

extern void FlipData(Message *m);
extern void FlipHeader(MsgHdr *header);
Expand Down
37 changes: 31 additions & 6 deletions mdstcpip/mdsipshr/Connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,11 @@ Connection *FindConnectionSending(int id)
return c;
}

EXPORT int GetConnectionVersion(int id)
EXPORT int MdsIpGetConnectionVersion(int id)
{
MDSIPTHREADSTATIC_INIT;
int version;
Connection *c = _FindConnection(id, NULL, MDSIPTHREADSTATIC_VAR);
version = c ? (int)c->version : -1;
return version;
return (c) ? (int)c->version : -1;
}

Connection *FindConnectionWithLock(int id, con_t state)
Expand Down Expand Up @@ -483,6 +481,31 @@ int AddConnection(Connection *c)
return c->id;
}

static inline int get_max_version()
{
#define MDSIP_MAX_VERSION "MDSIP_MAX_VERSION"
static int max_version = -1;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex);
if (max_version < 0)
{
// if env not specified, use max
max_version = 0xFFFF;
char *tmp = getenv(MDSIP_MAX_VERSION);
if (tmp)
{
long max_long = strtol(tmp, &tmp, 0);
if (!*tmp && max_long >= 0 && max_long < max_version)
{
max_version = (int)max_long;
}
MDSMSG(MDSIP_MAX_VERSION " = %d", max_version);
}
}
pthread_mutex_unlock(&mutex);
return max_version;
}

int AcceptConnection(char *protocol, char *info_name, SOCKET readfd, void *info,
size_t info_len, int *id, char **usr)
{
Expand Down Expand Up @@ -516,10 +539,12 @@ int AcceptConnection(char *protocol, char *info_name, SOCKET readfd, void *info,
// SET COMPRESSION //
if (STATUS_OK)
{
const int max_version = get_max_version();
c->compression_level = msg->h.status & 0xf;
c->client_type = msg->h.client_type;
if (msg->h.ndims > 0)
c->version = msg->h.dims[0];
c->version = msg->h.ndims > 0 ? msg->h.dims[0] : 0;
if (c->version > max_version)
c->version = max_version;
fprintf(stderr, "Connected: %s\n", user_p);
}
else
Expand Down
17 changes: 10 additions & 7 deletions mdstcpip/mdsipshr/MdsValue.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ EXPORT int MdsIpGetDescriptor(int id, const char *expression, int nargs,
{
int dim = 0;
int i, status;
int version = GetConnectionVersion(id);
int version = MdsIpGetConnectionVersion(id);
const int expect_serial = version >= MDSIP_VERSION_DSC_ARGS;
if (expect_serial)
{
Expand Down Expand Up @@ -104,12 +104,15 @@ EXPORT int MdsIpGetDescriptor(int id, const char *expression, int nargs,
status = GetAnswerInfoTS(id, (char *)&ser.dtype, (short int *)&ser.length,
&ndims, dims, (int *)&ser.arsize,
(void **)&ser.pointer, &mem);
ser.class = CLASS_A;
if ((expect_serial && ser.dtype == DTYPE_SERIAL) || ser.dtype == DTYPE_B)
status = MdsSerializeDscIn(ser.pointer, ans_ptr);
else
status = MdsCopyDxXd((mdsdsc_t *)&ser, ans_ptr);
free(mem);
if(STATUS_OK)
{
ser.class = CLASS_A;
if ((expect_serial && ser.dtype == DTYPE_SERIAL) || ser.dtype == DTYPE_B)
status = MdsSerializeDscIn(ser.pointer, ans_ptr);
else
status = MdsCopyDxXd((mdsdsc_t *)&ser, ans_ptr);
free(mem);
}
}
return status;
}
Expand Down
5 changes: 3 additions & 2 deletions tditest/testing/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TESTS = \
test-tdishr.tdi \
test-treeshr.tdi \
test-mdsip.tdi \
test-mdsip0.tdi \
test-mdsmisc.tdi \
test-dev-py.tdi \
test-tab.tdi
Expand Down Expand Up @@ -45,13 +46,13 @@ VALGRIND_FLAGS = \
MOSTLYCLEANFILES = \
./*.log ./*.tap \
tditst.tmp shotid.sys \
main_*.characteristics* main_*.datafile* main_*.tree*
*_*.characteristics* *_*.datafile* *_*.tree*
## ////////////////////////////////////////////////////////////////////////// ##
## // TARGETS ////////////////////////////////////////////////////////////// ##
## ////////////////////////////////////////////////////////////////////////// ##


#clean-local: clean-local-tests

check_PROGRAMS =
check_PROGRAMS =
check_SCRIPTS = $(TESTS)
7 changes: 4 additions & 3 deletions tditest/testing/do_tditests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ status=0

run() {
eval $1 2>&1 | tee ${2-/dev/null} |
grep -v -e '^[DIWE],' \
-e '^\s*Data inserted:' \
grep -v -e '^[DIWE],'\
-e '^\s*Data inserted:'\
-e '^Connected:'\
-e 'Length:'
}

Expand All @@ -35,7 +36,7 @@ if [ ! -z $1 ]; then
# fixes [?1034h for old readline verisons, rhel5/6/7, fc17/18/20
export TERM=vt100
else
cmd="$TDITEST $zdrv$srcdir/$test.tdi 1 2 3"
cmd="$TDITEST $zdrv$srcdir/$test.tdi $zdrv$(pwd) 2 3"
fi

if [ -z ${MDSPLUS_DIR} ]; then
Expand Down
17 changes: 15 additions & 2 deletions tditest/testing/test-mdsip.ans
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mdsconnect("local://1")
0
mdsconnect("thread://0")>=0
1BU
mdsvalue("$",[1,2,3])
[1,2,3]
mdsvalue("DECOMPILE($)",[[1,2],[3,4]])
Expand All @@ -10,6 +10,19 @@ mdsvalue("$",[[[[[[[[1]]]]]]]])
[[[[[[[[1]]]]]]]]
mdsvalue("$",[[[[[[[[1,2]]]]]]],[[[[[[[3,4]]]]]]]])
[[[[[[[[1,2]]]]]]], [[[[[[[3,4]]]]]]]]
FOR(_i=1;_i<=3;_i++){setenv("mdsip_path=thread://"//char(0x30+_i)//"::.");treeopennew('MDSIP', _i);}
3
treeaddnode('A', _, 0)
265389633
treewrite()
265389633
treeputrecord('A',RANGE(3))
265389633
tcl('deco A')
RANGE(3)
1
WHILE(treeclose() & 1);mdsdisconnect()
65545
cat - > /tmp/test-mdsip.hosts << EOF
unknown@* | MAP_TO_LOCAL
known@1.* | SELF
Expand Down
12 changes: 11 additions & 1 deletion tditest/testing/test-mdsip.tdi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mdsconnect("local://1")
mdsconnect("thread://0")>=0
# 0 dims ; TODO: locks up next mdsvalue: CONNECTIONLIST_LOCK
#mdsvalue("$",[])
# 1 dim
Expand All @@ -11,6 +11,16 @@ mdsvalue("$",[[[[[[[1]]]]]]])
mdsvalue("$",[[[[[[[[1]]]]]]]])
# 8 dims dim[i] != 1 for first and last
mdsvalue("$",[[[[[[[[1,2]]]]]]],[[[[[[[3,4]]]]]]]])
FOR(_i=1;_i<=3;_i++)\
{\
setenv("mdsip_path=thread://"//char(0x30+_i)//"::.");\
treeopennew('MDSIP', _i);\
}
treeaddnode('A', _, 0)
treewrite()
treeputrecord('A',RANGE(3))
tcl('deco A')
WHILE(treeclose() & 1);mdsdisconnect()
# test CheckClient
@public _hostfile = "/tmp/test-mdsip.hosts";\
fun set_hostfile(in _lines) {\
Expand Down
27 changes: 27 additions & 0 deletions tditest/testing/test-mdsip0.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
setenv("MDSIP_MAX_VERSION=0")
65545
mdsconnect("thread://0")>=0
1BU
mdsvalue("$",[1,2,3])
[1,2,3]
mdsvalue("DECOMPILE($)",[[1,2],[3,4]])
"[[1,2], [3,4]]"
mdsvalue("$",[[[[[[[1]]]]]]])
[[[[[[[1]]]]]]]
mdsvalue("$",[[[[[[[[1]]]]]]]])
[[[[[[[[1]]]]]]]]
mdsvalue("$",[[[[[[[[1,2]]]]]]],[[[[[[[3,4]]]]]]]])
[[[[[[[[1,2]]]]]]], [[[[[[[3,4]]]]]]]]
FOR(_i=1;_i<=3;_i++){setenv("mdsip0_path=thread://"//char(0x30+_i)//"::.");treeopennew('MDSIP0', _i);}
3
treeaddnode('A', _, 0)
265389633
treewrite()
265389633
treeputrecord('A',RANGE(3))
265389633
tcl('deco A')
RANGE(3)
1
WHILE(treeclose() & 1);mdsdisconnect()
65545
24 changes: 24 additions & 0 deletions tditest/testing/test-mdsip0.tdi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
setenv("MDSIP_MAX_VERSION=0")
mdsconnect("thread://0")>=0
# 0 dims ; TODO: locks up next mdsvalue: CONNECTIONLIST_LOCK
#mdsvalue("$",[])
# 1 dim
mdsvalue("$",[1,2,3])
# 2 dims; deco
mdsvalue("DECOMPILE($)",[[1,2],[3,4]])
# 7 dims
mdsvalue("$",[[[[[[[1]]]]]]])
# 8 dims dim[i] == 1 for all i<8
mdsvalue("$",[[[[[[[[1]]]]]]]])
# 8 dims dim[i] != 1 for first and last
mdsvalue("$",[[[[[[[[1,2]]]]]]],[[[[[[[3,4]]]]]]]])
FOR(_i=1;_i<=3;_i++)\
{\
setenv("mdsip0_path=thread://"//char(0x30+_i)//"::.");\
treeopennew('MDSIP0', _i);\
}
treeaddnode('A', _, 0)
treewrite()
treeputrecord('A',RANGE(3))
tcl('deco A')
WHILE(treeclose() & 1);mdsdisconnect()
7 changes: 3 additions & 4 deletions tditest/testing/test-tdishr.ans
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EXTRACT(len(_$0)-16,16,_$0)
"/test-tdishr.tdi"
deallocate(_$0)
1
deallocate(_$0)+deallocate(_$1)
2
_a=1
1
allocated(_a)
Expand All @@ -10,11 +10,10 @@ show_private(_a)
Private _A = 1
1
show_private()
Private _$1 = "1"
Private _$2 = "2"
Private _$3 = "3"
Private _A = 1
4
3
deallocate()
*
allocated(_a)
Expand Down
4 changes: 2 additions & 2 deletions tditest/testing/test-tdishr.tdi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# allocations _$0 should end with "/test-tdishr.tdi"
EXTRACT(len(_$0)-16,16,_$0)
# deallocate _$0 as it varies with os in tests
deallocate(_$0)
# deallocate _$0 and _$1 as they vary with os in tests
deallocate(_$0)+deallocate(_$1)
_a=1
allocated(_a)
show_private(_a)
Expand Down
Loading