InitializePart1:
PUBLIC
PROC [] ~ {
Initialize the data server to the transaction manager. Part 1 gets the segments known so that logging and recovery can run (under SunOS). Part 2 does the rest.
Perform the initializaion like CamLib that corresponds to the INITIALIZE←SERVER macro and START←SERVER procedure (procedures CamlibInitServerInternal and START←SERVER in src/lib/camlib/server←struct.c).
Then do a TApplication (code from src/lib/camlib/appl←struct.c and procedure INITIALIZE𡤊PPLICATION).
fullSeqDescList: Camelot.ListOfSegmentDesc;
fullSeqPortList: Mach.ListOfPorts;
firstTime: BOOL ← FALSE;
kernCode: Mach.kernReturnT;
{ -- InitializeGlobalData calling to ServerInit
dsPort ← GetTheDSPort[];
[serverID: serverID, tsPort: tsPort, mPort: mPort, sPort: sPort, sharedMemAddr: dsqSharedMemAddr, seqDescList: InitSeqDescList, seqPortList: InitSeqPortList, kernCode: kernCode] ← Camelot.DSInitialize[dsPort: dsPort, raiseSignal: TRUE];
Camelot.DSQInit[dsqSharedMemAddr];
};
TRUSTED {Process.Detach[FORK NotifyHandlerProcess[]];}; -- CamlibInitServerInternal
[fullSeqDescList, fullSeqPortList] ← CamelotRecoverable.CamelotRecoverableInit[];
IF fullSeqDescList = NIL THEN fullSeqDescList ← InitSeqDescList
ELSE {
FOR fsdl: Camelot.ListOfSegmentDesc ← fullSeqDescList, fsdl.rest UNTIL fsdl = NIL DO
IF fsdl.rest = NIL THEN {fsdl.rest ← InitSeqDescList; EXIT};
ENDLOOP;
};
IF fullSeqPortList = NIL THEN fullSeqPortList ← InitSeqPortList
ELSE {
FOR lop: Mach.ListOfPorts ← fullSeqPortList, lop.rest UNTIL lop = NIL DO
IF lop.rest = NIL THEN {lop.rest ← InitSeqPortList; EXIT};
ENDLOOP;
};
firstTime ← RecoverSegments[fullSeqDescList, fullSeqPortList, TRUE]; -- CamlibInitServerInternal
};
InitializePart2:
PUBLIC
PROC [serverName: Rope.
ROPE, applName: Rope.
ROPE]
RETURNS [firstTime:
BOOL ←
FALSE] ~ {
firstTime ← RecoverSegments[InitSeqDescList, InitSeqPortList, FALSE]; -- CamlibInitServerInternal
[] ← Mach.portRestrict[Mach.taskSelf[], sPort, TRUE]; -- CamlibInitServerInternal
TRUSTED {Process.Detach[FORK SystemMessageHandler[]];}; -- CamlibInitServerInternal
{
-- PublicizeService
[newPort: camlibServerPort] ← Mach.portAllocate[Mach.taskSelf[], TRUE];
[] ← Mach.netnameCheckIn[Mach.nameServerPort[], serverName, Mach.taskSelf[], camlibServerPort, TRUE];
};
[] ← Mach.portUnrestrict[Mach.taskSelf[], camlibServerPort, TRUE];
TRUSTED {Process.Detach[
FORK RequestHandler[]];};
Wait for recovery to complete (maybe lots of SR messages)
ReadyForRecovery ← TRUE;
WHILE ~CamelotRecoveryComplete DO Process.Pause[Process.MsecToTicks[50]] ENDLOOP;
{
-- TApplication setup
tPortList: Mach.ListOfPorts;
[portList: tPortList] ← Camelot.CALookup[Mach.nameServerPort[], "TranPort", "", 1, 1, TRUE];
IF tPortList = NIL THEN ERROR;
IF tPortList.rest # NIL THEN ERROR;
tPort ← tPortList.first;
[newPort: atPort] ← Mach.portAllocate[Mach.taskSelf[], TRUE];
[] ← Mach.portRestrict[Mach.taskSelf[], atPort, TRUE];
[applicationID: applicationID, taPort: taPort] ← Camelot.TAAddApplication[tPort: tPort, atPort: atPort, authName: applName, raiseSignal: TRUE];
TRUSTED {Process.Detach[FORK ApplSysMsgHandler[]];};
};
YggDIDMap.InitDIDMap[firstTime]; -- call after recovery completes and TAAddApplication
};