Skip to content

Commit 88a940b

Browse files
Executing JOBs from WebTerminal fix, closes #105
1 parent d2f8d12 commit 88a940b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"printableName": "Cache Web Terminal",
66
"description": "Web-based terminal emulator for Caché administering.",
77
"author": "ZitRo",
8-
"version": "4.6.3",
8+
"version": "4.7.0",
99
"gaID": "UA-83005064-2",
1010
"releaseNumber": 26,
1111
"scripts": {

src/cls/WebTerminal/Common.cls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ClassMethod SendChunk(pid As %Numeric, flag As %String, data As %String = "") As
2929
/// Receives the chunk of data from another process. Returns the $LISTBUILD string which contains
3030
/// flag at the first position and string at the second. This method also terminates the process
3131
/// if the parent process is gone.
32-
ClassMethod ReceiveChunk(timeout As %Numeric = -1) As %String
32+
ClassMethod ReceiveChunk(timeout As %Numeric = -1, masterProcess = 0) As %String
3333
{
3434
set flag = ""
3535
set str = ""
@@ -41,10 +41,10 @@ ClassMethod ReceiveChunk(timeout As %Numeric = -1) As %String
4141
if (status <= 0) {
4242
if ($ZPARENT '= 0) && ('$data(^$Job($ZPARENT))) {
4343
do $system.Process.Terminate($JOB, 0)
44-
return $LISTBUILD(flag, str, -1)
44+
return $LISTBUILD("e", $LISTBUILD("", "Parent process "_$JOB_" is gone"), -1)
4545
}
46-
if ($ZCHILD '= 0) && ('$data(^$Job($ZCHILD))) {
47-
return $LISTBUILD(flag, str, -1)
46+
if masterProcess && ($ZCHILD '= 0) && ('$data(^$Job($ZCHILD))) {
47+
return $LISTBUILD("e", $LISTBUILD("", "Child process "_$ZCHILD_" is gone"), -1)
4848
}
4949
}
5050
if (data = "") && (timeout = 0) quit

src/cls/WebTerminal/Handlers.cls

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ClassMethod Execute (client As WebTerminal.Engine, data, bareStart As %Boolean =
2929
do client.SendChunk(client.corePID, "m", command)
3030
loop
3131
for {
32-
set message = client.ReceiveChunk(0) // we need to read from WebSocket as well: timeout = 0
32+
set message = client.ReceiveChunk(0, 1) // read from WebSocket as well: timeout = 0
3333
if ($LISTGET(message, 3) < 0) {
3434
return $$$ERROR($$$GeneralError, "%cpTerm")
3535
}
@@ -68,8 +68,15 @@ loop
6868
do client.SendChunk(client.corePID, "m", mes.d)
6969
}
7070
} elseif (flag = "e") {
71-
set client.childNamespace = $LISTGET(chunk, 1)
72-
set err = $LISTGET(chunk, 2)
71+
set err = ""
72+
if $ListValid(chunk) {
73+
if ($LISTGET(chunk, 1) '= "") {
74+
set client.childNamespace = $LISTGET(chunk, 1)
75+
}
76+
if ($LISTGET(chunk, 2) '= "") {
77+
set err = $LISTGET(chunk, 2)
78+
}
79+
}
7380
if $IsObject(data) && (data.bufferOutput = 1) {
7481
do client.outputBuffer.Write(err)
7582
quit // break for loop
@@ -114,7 +121,7 @@ ClassMethod Update (client As WebTerminal.Engine, URL As %String)
114121
ClassMethod LocalAutocomplete(client As WebTerminal.Engine, data)
115122
{
116123
do client.SendChunk(client.corePID, "a")
117-
set list = $LISTGET(client.ReceiveChunk(), 2)
124+
set list = $LISTGET(client.ReceiveChunk(, 1), 2)
118125
set obj = ##class(%ZEN.proxyObject).%New()
119126
for i=3:3:$LISTLENGTH(list) {
120127
set obj2 = ##class(%ZEN.proxyObject).%New()
@@ -153,7 +160,7 @@ ClassMethod ClassMemberAutocomplete (client As WebTerminal.Engine, data As %ZEN.
153160
ClassMethod MemberAutocomplete (client As WebTerminal.Engine, data As %ZEN.proxyObject) As %Status
154161
{
155162
do client.SendChunk(client.corePID, "a")
156-
set list = $LISTGET(client.ReceiveChunk(), 2)
163+
set list = $LISTGET(client.ReceiveChunk(, 1), 2)
157164
set isOref = 0
158165
set value = ""
159166
for i=3:3:$LISTLENGTH(list) {

0 commit comments

Comments
 (0)