$INCLUDE UNIVERSE.INCLUDE MTF.INCL.H
$INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
$INCLUDE UNIVERSE.INCLUDE FILENAMES.H
******************************************************************************
*
* Routine to handle Deadlock Administration
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description........................................
* 10/14/98 23801 SAP Change copyrights.
* 10/11/96 19412 JEM Fixed uvlockd.log viewing
* 09/30/96 19315 PEJ On NT use uvbootd to start uvdlockd
* 07/11/96 18812 ALC Ported to NT
* 06/17/96 18403 DTM Changes due to testing
* 06/13/96 18403 DTM Initial programming
*
*******************************************************************************
* This subroutine will accept as an argument the value of the operation
* to perform. It can perform the following functions on spooler jobs:
******************************************************************************
id = "%W%"
******************************************************************************
* Various Prompts and Help string values
******************************************************************************
equ PRMPT.LOC to 2
equ SHRT.HELP to 4
equ LONG.HELP to 5
******************************************************************************
* Various other variables
******************************************************************************
equ PAINT to 1 ;* flag to paint forms
equ Yes to 1
equ No to 0
equ Default to 1
******************************************************************************
* Strings representing shell scripts to be executed and files used
******************************************************************************
temp=NULL
CALL *ISUSER.B(0,temp)
IF temp=0 THEN
TPRINT UVREADMSG(071000,"")
SLEEP 3
STOP
END
OPTION = FIELD( @SENTENCE, " ", 4 )
GOSUB init.messages ;* Initialize messages
BEGIN CASE
CASE OPTION = 1 ;* Examine the logfile
GOTO examine.log
CASE OPTION = 2 ;* start the daemon
GOSUB init.form.1
CASE OPTION = 3 ;* stop the daemon
GOTO stop.daemon
CASE OPTION = 4 ;* Purge the logfile
GOTO purge.log
CASE OPTION = 5 ;* check for deadlock
GOTO check.deadlock
CASE OPTION = 6 ;* select single victim
GOSUB init.form.2
END CASE
******************************************************************************
* In this section, we draw the first screen, print the menu bar and help
* areas, and put up the first title and form to fill out.
******************************************************************************
GOSUB init.menu
GOSUB init.screen
******************************************************************************
* Starting point for routines actual activity. Paint help message and
* continue
******************************************************************************
help.loop:
CALL *HELP.PRINT.B(form
,1)
******************************************************************************
* Starting point for actual data input. Here we position the cursor to the
* place of the secondary prompt and get the input character, which is returned
* in special, if a special character was encountered, or in temp, is data
* was entered.
******************************************************************************
input.loop:
TPRINT form: ;* position cursor
temp=temp.form
CALL *CINPUT.B(SEC.PRMPT,temp,special,form,form)
******************************************************************************
* First section handles all the special characters.
******************************************************************************
IF special # 0 THEN ;* if special character encountered
BEGIN CASE
******************************************************************************
* Up arrow was pressed.
******************************************************************************
CASE special = UP.ARROW ;* Up arrow was pressed
TPRINT form:PRMPT:
TPRINT temp.form:
TPRINT STR(SPACE,form-LEN(temp.form))
form.line-=1
IF form.line < 1 THEN
form.line=form.size
END
GOTO help.loop ;* get more input
******************************************************************************
* Down arrow was pressed.
******************************************************************************
CASE special = DOWN.ARROW ;* Down arrow was pressed
TPRINT form:PRMPT:
TPRINT temp.form:
TPRINT STR(SPACE,form-LEN(temp.form))
form.line+=1
IF form.line > form.size THEN
form.line=1
END
GOTO help.loop ;* get more input
******************************************************************************
* Function key F1 was pushed. This key is used to display more involved
* Help messages
******************************************************************************
CASE special=F.1
CALL *HELP.PRINT.B(form,3)
GOTO input.loop ;* get more input
******************************************************************************
* Escape key pressed. This is the systems signal to return to the calling
* procedure. First clear the screen however
******************************************************************************
CASE special = ESCAPE ;* escape was pressed
STOP @(-1)
CASE special = F.4
temp="*"
GOTO new.enter
CASE special = F.10
action.value=1
CALL *DO.MNU.BAR.B(Menu.Bar,action.value,form.size,form,temp.form)
BEGIN CASE
CASE action.value = 1
STOP @(-1)
CASE action.value = 2
STOP @(-1)
CASE action.value = 3
message=msg.app.help
CONVERT @FM TO " " IN message
CALL *HELP.BOX.B(3,10,60,message)
CASE action.value = 4
message=UVREADMSG(076001,"")
CONVERT @FM TO " " IN message
CALL *HELP.BOX.B(3,10,60,message)
CASE action.value = 5
CALL *HELP.BOX.B(3,10,45,UVREADMSG(076000,""))
END CASE
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
GOTO help.loop
CASE Default
GOTO help.loop
END CASE ;* end of case
END ;* end of if statement
******************************************************************************
* If we reach here, we must have had data input, which is returned from
* *NINPUT in the variable temp. Therefore, process it and execute the
* desired operation.
******************************************************************************
ELSE
new.enter:
CALL *HELP.PRINT.B(NULL,3)
sel.val=1
BEGIN CASE
CASE form.line=1 ;* timer value || victim sig
IF NOT(NUM(temp)) THEN
CALL *HELP.BOX.B(10,5,30,msg.error2)
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
GOTO help.loop
END
IF OPTION = 6 THEN
victim.sig = temp
GOTO victim.kill
END
timer = temp
temp.form< form.line > = temp
CASE form.line=2 ;* resolution strategy
IF NOT(NUM(temp)) THEN
CALL *HELP.BOX.B(10,5,30,msg.error2)
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
GOTO help.loop
END
IF temp < 0 OR temp > 3 THEN
GOTO help.loop
END
res.strategy = temp
temp.form< form.line > = temp
CASE form.line=3 ;* log directory
log.directory = temp
temp.form< form.line > = temp
CASE form.line = 4 ;* Should we boot up with daemon started
boot.option = UPCASE(temp)
IF boot.option # "Y" AND boot.option # "N" THEN
CALL *HELP.BOX.B(10,5,25,msg.error3)
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
GOTO help.loop
END
temp.form< form.line > = temp
CASE form.line = 5 ;* Should we store values in config file
config.option = UPCASE(temp)
IF config.option # "Y" AND config.option # "N" THEN
CALL *HELP.BOX.B(10,5,25,msg.error3)
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
GOTO help.loop
END
temp.form< form.line > = temp
END CASE
jump.spot:
TPRINT form:PRMPT:temp.form:
TPRINT STR(SPACE,form-LEN(temp.form)):
form.line +=1
IF form.line <= form.size THEN
GOTO help.loop
END
IF config.option = "Y" THEN
GOSUB store.config.file
END
flag=0
LockOptions = "-t " : timer : " -r " : res.strategy : " -l " : log.directory
if OS.TYPE = "MSWIN" then
LockCommand = UV.BIN : UV.FSEP : "uvdlockd.exe"
LockCommand = UV.BIN : UV.FSEP : "uvbootd " : LockCommand
end else
LockCommand = UV.BIN : UV.FSEP : "uvdlockd"
end
ExecCommand = OS.EXEC : " " : squote( LockCommand : " " : LockOptions )
EXECUTE ExecCommand CAPTURING details
IF details = "" THEN
details = UVREADMSG( 074028, "" )
END
CALL *HELP.BOX.B( 10,5, 50, details )
END
******************************************************************************
* Init.form
* This routine initializes all the positional parameters, help strings,
* text strings, and default values for the two forms used in this subroutine
******************************************************************************
init.form.1:
temp.form=NULL
form=NULL
form.size=5
form<1,1>=@(2,5)
form<1,2>=@(38,5)
form<1,3>=UVREADMSG(074009,"")
form<1,4>=UVREADMSG(074010,"")
form<1,5>=form<1,4>
form<1,6>=10
form<1,7>=0
form<2,1>=@(2,7)
form<2,2>=@(38,7)
form<2,3>=UVREADMSG(074011,"")
form<2,4>=UVREADMSG(074012,"")
form<2,5>=form<2,4>
form<2,6>=1
form<2,7>=0
form<3,1>=@(2,9)
form<3,2>=@(38,9)
form<3,3>=UVREADMSG(074013,"")
form<3,4>=UVREADMSG(074014,"")
form<3,5>=form<3,4>
form<3,6>=35
form<3,7>=0
form<4,1>=@(2,11)
form<4,2>=@(52,11)
form<4,3>=UVREADMSG(074015,"")
form<4,4>=UVREADMSG(074016,"")
form<4,5>=form<4,4>
form<4,6>=1
form<4,7>=0
form<5,1>=@(2,13)
form<5,2>=@(65,13)
form<5,3>=UVREADMSG(074017,"")
form<5,4>=form<5,3>
form<5,5>=form<5,4>
form<5,6>=1
form<5,7>=0
form.line=1
temp.form<1>=60
temp.form<2>=0
temp.form<3>=UV.ROOT:UV.FSEP:"uvdlockd.log"
temp.form<4>="Y"
temp.form<5>="Y"
RETURN
init.form.2:
temp.form=NULL
form=NULL
form.size=1
form.line=1
form<1,1>=@(2,5)
form<1,2>=@(55,5)
form<1,3>=UVREADMSG(074018,"")
form<1,4>=UVREADMSG(074019,"")
form<1,5>=form<1,4>:UVREADMSG(074020,"")
form<1,6>=10
form<1,7>=0
RETURN
***************************************************************************
* init.menu - initializes menu bar
***************************************************************************
init.menu:
scratch=UVREADMSG(073087,"")
Menu.Bar = NULL
Menu.Bar<1,1> = 3 ;* Number of Items in Menu.Bar
Menu.Bar<1,2> = 1 ;* Line # on which to print the Menu Bar
* First Item
Menu.Bar<2,1,1>=scratch<1> ;* SubMenu Title
Menu.Bar<2,1,2>=1 ;* # of items in SubMenu
* SubMenu #1
Menu.Bar<2,2,1>=scratch<6> ;* SubMenu Item
Menu.Bar<2,2,2>=1 ;* Action Code (Returned to calling process)
Menu.Bar<2,2,3>=scratch<7>
* Second Item
Menu.Bar<3,1,1>=scratch<8> ;* SubMenu Title
Menu.Bar<3,1,2>=1 ;* # of items in SubMenu
* SubMenu #1
Menu.Bar<3,2,1>=scratch<6> ;* SubMenu Item
Menu.Bar<3,2,2>=2 ;* Action Code
Menu.Bar<3,2,3>=scratch<7>
scratch=UVREADMSG(073089,"")
Menu.Bar<4,1,1>=scratch<1>
Menu.Bar<4,1,2>=3
Menu.Bar<4,2,1>=scratch<2>
Menu.Bar<4,2,2>=3
Menu.Bar<4,2,3>=scratch<3>
Menu.Bar<4,3,1>=scratch<4>
Menu.Bar<4,3,2>=4
Menu.Bar<4,3,3>=scratch<5>
Menu.Bar<4,4,1>=scratch<6>
Menu.Bar<4,4,2>=5
Menu.Bar<4,4,3>=scratch<7>
RETURN
******************************************************************************
* Strings from help messages and such
******************************************************************************
init.messages:
msg.header = UVREADMSG(074000,"")
msg.stop = UVREADMSG(074001,"")
msg.purge = UVREADMSG(074002,"")
msg.details = UVREADMSG(074003,"")
msg.error1 = UVREADMSG(074005,"")
msg.error2 = UVREADMSG(074006,"")
msg.error3 = UVREADMSG(074007,"")
msg.error4 = UVREADMSG(074021, "")
msg.app.help = UVREADMSG(074008,"")
msg.nopurge = UVREADMSG(074022,"")
msg.nostop = UVREADMSG(074023,"")
msg.noexist = UVREADMSG(074024,"")
msg.store1 = UVREADMSG(074027,"")
RETURN
******************************************************************************
* init.screen - used for initial painint of screen
******************************************************************************
init.screen:
CALL *DRAW.SCRN.B(msg.header,1)
CALL *HELP.PRINT.B(UVREADMSG(073009,""),2)
CALL *PUT.FORM.B(form.size,form,temp.form,PRMPT,PAINT)
CALL *MNU.BAR.PR.B(Menu.Bar,1)
RETURN
******************************************************************************
* stop.daemon - stop the deadlock daemon
******************************************************************************
stop.daemon:
flag = No
CALL *YES.NO.BOX.B( 10, msg.stop, flag )
IF flag = Yes THEN
ExecCommand = OS.EXEC:" '":UV.BIN:UV.FSEP:"uvdlockd -stop":" '"
EXECUTE ExecCommand CAPTURING details
CALL *HELP.BOX.B(10,5,50,details)
END
ELSE
CALL *HELP.BOX.B(10,5,50,msg.nostop)
END
STOP @(-1)
RETURN
examine.log:
logrec = ''
linecnt = 0
OPEN '&UFD&' TO Fvar THEN
READ logrec FROM Fvar, 'uvdlockd.log' ELSE
CALL *HELP.BOX.B( 10, 5, 50,msg.noexist )
STOP @(-1)
END
lines = DCOUNT(logrec, @AM)
FOR i = 1 to lines
PRINT logrec
linecnt += 1
if linecnt = 20 then
linecnt = 1
print "Press any key to Continue or Q to quit ... ":
prompt ""
input ans
if (ans = "q") or (ans = "Q") then stop
end
NEXT i
CLOSE Fvar
input WAIT,1
END
STOP @(-1)
purge.log:
flag = No
logrec = ''
CALL *YES.NO.BOX.B( 10, msg.purge, flag )
IF flag = Yes THEN
OPEN '&UFD&' TO Fvar THEN
READV logrec FROM Fvar, 'uvdlockd.log',0 ELSE
CALL *HELP.BOX.B( 10, 5, 50,msg.noexist )
STOP @(-1)
END
logrec = ''
WRITE logrec TO Fvar, 'uvdlockd.log' ELSE
CALL *HELP.BOX.B(10,5,50, msg.nopurge )
STOP @(-1)
END
CLOSE Fvar
END
END
ELSE
CALL *HELP.BOX.B(10,5,50, msg.nopurge )
END
STOP @(-1)
check.deadlock:
TPRINT @(-1)
ExecCommand = OS.EXEC:" '":UV.BIN:UV.FSEP:"uvdlockd -query":" '"
EXECUTE ExecCommand
CALL *HELP.BOX.B( 10,5,50, UVREADMSG( 001069, "" ) )
STOP @(-1)
victim.kill:
flag = No
msg.victim = UVREADMSG(074004,victim.sig)
CALL *YES.NO.BOX.B( 10, msg.victim, flag )
IF flag = Yes THEN
ExecCommand = OS.EXEC:" '":UV.BIN:UV.FSEP:"uvdlockd -victim ":victim.sig:" '"
EXECUTE ExecCommand CAPTURING details
CALL *HELP.BOX.B(10,5,50, UVREADMSG( 074025, victim.sig))
END
ELSE
CALL *HELP.BOX.B(10,5,50, UVREADMSG( 074026, victim.sig ))
END
STOP @(-1)
store.config.file:
config.file=UV.ROOT:UV.FSEP:"uvdlockd.config"
OPENSEQ config.file TO OUTPUT ELSE
CALL *HELP.BOX.B( 10,5,50, msg.error1 )
flag = 1
CALL *YES.NO.BOX.B( 10, msg.store1, flag )
IF flag=0 THEN
STOP @(-1)
END
ELSE
CREATE OUTPUT ELSE STOP @(-1)
rec=""
IF boot.option = 'Y' THEN
rec<1>="start=1"
END
ELSE
rec<1>="start=0"
END
rec<2>="timer=":timer
rec<3>="res=":res.strategy
rec<4>="log=":log.directory
CONVERT @FM TO CHAR(10) in rec
WRITESEQ rec TO OUTPUT ELSE STOP @(-1)
CLOSE OUTPUT
STOP @(-1)
END
END
rec=""
line.no = 0
line = ""
eof = 0
a1 = 0
a2 = 0
a3 = 0
a4 = 0
loop
READSEQ line FROM OUTPUT else eof = 1
until eof do
BEGIN CASE
CASE line[1,3]='sta'
if boot.option = 'Y' THEN
line="start=1"
END
ELSE
line="start=0"
END
a1 = 1
CASE line[1,3]='tim'
line="timer=":timer
a2 = 1
CASE line[1,3]='res'
line="res=":res.strategy
a3 = 1
CASE line[1,3]='log'
line="log=":log.directory
a4 = 1
CASE 1
line=line
END CASE
line.no += 1
rec< line.no > = line
repeat
CLOSE OUTPUT
IF a1 = 0 THEN
if boot.option = 'Y' THEN
rec< line.no > = "start=1"
end
else
rec< line.no > = "start=0"
end
line.no += 1
END
IF a2 = 0 THEN
rec = "timer=":timer
line.no += 1
END
IF a3 = 0 THEN
rec = "res=":res.strategy
line.no += 1
END
IF a4 = 0 THEN
rec = "log=":log.directory
line.no += 1
END
OPENSEQ config.file TO OUTPUT ELSE
CALL *HELP.BOX.B( 10,5,50, msg.error1 )
END
FOR i = 1 TO line.no
WRITESEQ rec< i > TO OUTPUT else
CALL *HELP.BOX.B( 10,5,50,msg.error4)
STOP @(-1)
END
NEXT i
RETURN
STOP @(-1)
END