source: WorldVistAEHR/trunk/r/VISTALINK-XOBV/XOBVLL.m@ 1154

Last change on this file since 1154 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.5 KB
Line 
1XOBVLL ;; mjk/alb - VistALink Listen and Spawn Code ; 07/27/2002 13:00
2 ;;1.5;VistALink;;Sep 09, 2005
3 ;;Foundations Toolbox Release v1.5 [Build: 1.5.0.026]
4 ;
5 QUIT
6 ;
7 ; ***deprecated*** tag ; Use START^XOBVTCP instead
8START(SOCKET) ; -- start listener
9 DO START^XOBVTCP(SOCKET)
10 QUIT
11 ;
12 ; ***deprecated*** tag ; Use UCX^XOBVTCP instead
13UCX ; -- VMS TCPIP (UCX) multi-thread entry point
14 ; -- Called from VistALink .com files
15 GOTO UCX^XOBVTCP
16 ;
17SPAWN ; -- spawned process
18 NEW X,XOBSTOP,XOBPORT,XOBHDLR,XOBLASTR
19 ;
20 SET XOBSTOP=0
21 SET XOBPORT=IO
22 SET U="^"
23 ;
24 ; -- initialize timestamp for last time request made (used for debugging)
25 SET XOBLASTR=0
26 ;
27 ; -- set error trap
28 ;Set up the error trap
29 SET $ETRAP="DO ^%ZTER HALT"
30 ;
31 ; -- attempt to share the license; must have TCP port open first
32 USE XOBPORT IF $TEXT(SHARELIC^%ZOSV)'="" DO SHARELIC^%ZOSV(1)
33 ;
34 ; -- start RUM for VistALink Handler
35 DO LOGRSRC^%ZOSV("$VISTALINK HANDLER$",2,1)
36 ;
37 ; -- cache/initialize startup request handlers
38 SET X=$$CACHE^XOBVRH(.XOBHDLR)
39 IF 'X DO RMERR^XOBVRM(184001,$PIECE(X,U,2)) QUIT
40 ;
41 ; -- initialize tcp processing variables
42 DO INIT^XOBVSKT
43 ;
44 ; -- change job name if possible
45 DO SETNM^%ZOSV("VLink_"_$$CNV^XLFUTL($J,16))
46 ;
47 ; -- loop until told to stop
48 FOR DO NXTCALL QUIT:XOBSTOP
49 ;
50 ; -- final/clean tcp processing variables
51 DO FINAL^XOBVSKT
52 ;
53 ; -- stop RUM for VistALink Handler
54 DO LOGRSRC^%ZOSV("$VISTALINK HANDLER$",2,2)
55 ;
56 QUIT
57 ;
58NXTCALL ; -- do next call
59 NEW X,XOBROOT,XOBREAD,XOBTO,XOBFIRST,XOBOK,XOBRL,XOBDATA
60 ;
61 ; -- set up error trap
62 NEW $ESTACK SET $ETRAP="DO SYSERR^XOBVLL"
63 ;
64 ; -- setup environment variables
65 NEW DIQUIET SET DIQUIET=1
66 SET U="^",DTIME=$GET(DTIME,900),DT=$$DT^XLFDT()
67 ;
68 ; -- initialize 'current' request handler to empty string
69 SET XOBHDLR=""
70 ;
71 ; -- # of chars to get on first read / read 11 for Broker initial read
72 SET XOBREAD=11
73 ;
74 ; -- get J2SE heartbet rate for timeout plus network latency factor
75 SET XOBTO=$$GETRATE^XOBVLIB()+$$GETDELTA^XOBVLIB()
76 ;
77 ; -- get J2EE timeout value for app serv environment
78 IF $GET(XOBSYS("ENV"))="j2ee" SET XOBTO=$$GETASTO^XOBVLIB()
79 ;
80 ; -- set first read flag
81 SET XOBFIRST=1
82 ;
83 ; -- setup intake global
84 SET XOBROOT=$NAME(^TMP("XOBVLL",$JOB))
85 KILL @XOBROOT
86 ;
87 ; -- read from socket port
88 USE XOBPORT
89 SET XOBOK=$$READ^XOBVSKT(XOBROOT,.XOBREAD,.XOBTO,.XOBFIRST,.XOBSTOP,.XOBDATA,.XOBHDLR)
90 ;
91 ; -- timed out ; cleanup user and exit
92 IF 'XOBOK!(XOBSTOP) DO GOTO NXTCALLQ
93 . IF $GET(DUZ) DO CLEAN^XOBSCAV1
94 . SET XOBSTOP=1
95 ;
96 ; -- need null device
97 IF '$DATA(XOBNULL) DO ERROR(181002,$$EZBLD^DIALOG(181002),XOBPORT) SET XOBSTOP=1 GOTO NXTCALLQ
98 ;
99 ; -- call request manager
100 SET XOBOK=$$EN^XOBVRM(XOBROOT,.XOBDATA,.XOBHDLR)
101 ; -- timestamp last time request made
102 SET XOBLASTR=$$NOW^XLFDT()
103 ; -- cleanup intake global
104 KILL @XOBROOT
105 ;
106NXTCALLQ ; -- exit
107 QUIT
108 ;
109 ; ----------------------------------------------------------------------------------
110 ; System Error Handler
111 ; ----------------------------------------------------------------------------------
112SYSERR ; -- send system error message
113 ; -- If we get an error in the error handler just Halt
114 SET $ETRAP="D ^%ZTER HALT"
115 ;
116 DO ERROR(181001,$$EZBLD^DIALOG(181001,$$EC^%ZOSV),XOBPORT) ; -- Get the error code
117 QUIT
118 ;
119ERROR(XOBEC,XOBMSG,XOBPORT) ; -- send error message
120 NEW XOBDAT
121 ;
122 ; -- If we get an error in the error handler just Halt
123 SET $ETRAP="D ^%ZTER HALT"
124 ;
125 ; -- set up error info
126 SET XOBDAT("MESSAGE TYPE")=3
127 SET XOBDAT("ERRORS",1,"CODE")=XOBEC
128 SET XOBDAT("ERRORS",1,"ERROR TYPE")="system"
129 SET XOBDAT("ERRORS",1,"FAULT STRING")="System Error"
130 SET XOBDAT("ERRORS",1,"CDATA")=1
131 SET XOBDAT("ERRORS",1,"MESSAGE",1)=XOBMSG
132 ;
133 ; -- if serious error, save error info, logout, and halt
134 IF XOBMSG["<READ>"!(XOBMSG["<WRITE>")!(XOBMSG["<SYSTEM>")!(XOBMSG["READERR")!(XOBMSG["WRITERR")!(XOBMSG["SYSERR") DO HALT
135 . DO ^%ZTER
136 . IF $GET(DUZ) DO CLEAN^XOBSCAV1
137 ;
138 ; -- send error back to client
139 USE XOBPORT
140 DO ERROR^XOBVLIB(.XOBDAT)
141 ;
142 ; -- just quit if no slots are available or logins are disabled
143 IF (XOBEC=181003)!(XOBEC=181004) QUIT
144 ;
145 ; -- need to make sure any locks are released since code aborted ungracefully
146 LOCK
147 ;
148 ; -- Save off the error
149 DO ^%ZTER
150 ;
151 ; -- go back to listening
152 SET $ETRAP="Q:($ESTACK&'$QUIT) Q:$ESTACK -9 S $ECODE="""" DO KILL^XOBVLL G NXTCALLQ^XOBVLL",$ECODE=",U99,"
153 QUIT
154 ;
155KILL ; -- new VistALink variables and then do big KILL
156 NEW XOBPORT,XOBSTOP,XOBNULL,XOBOS,XOBSYS,XOBHDLR,XOBOK
157 DO KILL^XUSCLEAN
158 QUIT
159 ;
Note: See TracBrowser for help on using the repository browser.