-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on May 9, 1986 7:49:31 am PDT by Lupine of May 23, 1985 8:38:08 am PDT
-- Source interface ComputeServerController came from file ComputeServerController.bcd, which was created on May 9, 1986 7:48:13 am PDT with version stamp 337#276#17756447420 from source of May 9, 1986 7:47:01 am PDT.

-- The RPC stub modules for ComputeServerController are:
--   ComputeServerControllerRpcControl.mesa;
--   ComputeServerControllerRpcClientImpl.mesa;
--   ComputeServerControllerRpcBinderImpl.mesa;
--   ComputeServerControllerRpcServerImpl.mesa.

-- The parameters for this translation are:
--   Target language = Cedar
--   Default parameter passing = VALUE
--   Deallocate server heap arguments = TRUE
--   Inline RpcServerImpl dispatcher stubs = FALSE
--   Declare signals = FALSE
--   Warn about short POINTER ("MDS") allocations = TRUE
--   Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50
--   Acceptable parameter protocols = VersionRange[1..1].


DIRECTORY
  BasicTime,
  ComputeServer,
  PrincOps,
  Pup,
  Rope,
  RPC,
  ComputeServerController,
  ComputeServerControllerRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle,
      -- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength,
      -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt,
      -- StartCall, StartSignal, StubPkt, UnexportInterface]--,
  LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt,
      -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones,
      -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError,
      -- MarshalingExprError, MarshalAtom, MarshalRope, NilHeader, ProtocolError,
      -- RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT,
      -- StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError,
      -- UnmarshalingError, UnmarshalingExprError, UnmarshalAtom, UnmarshalRope,
      -- WordsForChars]--,
  Atom --USING SOME OF [GetPName, MakeAtom]--;


ComputeServerControllerRpcServerImpl: MONITOR
  IMPORTS ComputeServerController, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
      Atom, Rope
  EXPORTS ComputeServerControllerRpcControl
  SHARES  ComputeServerController, ComputeServerControllerRpcControl,
      Rope
  = BEGIN OPEN ComputeServerController, RpcControl: ComputeServerControllerRpcControl,
      RpcPublic: RPC;


-- Standard remote binding routines.

  bound: BOOLEAN ← FALSE;
  myInterface: RpcPrivate.ExportHandle;
  paramZones: RpcPublic.Zones ← RpcPublic.standardZones;

  ExportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interfaceName: RpcPublic.InterfaceName,
        user: RpcPublic.Principal,
        password: RpcPublic.EncryptionKey,
        parameterStorage: RpcPublic.Zones ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
    IF bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.ExportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "ComputeServerController~337#276#17756447420",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      user: user,  password: password,
      dispatcher: ServerDispatcher,
      localOnly: RpcControl.InterMdsCallsOnly,
      stubProtocol: RpcControl.LupineProtocolVersion ];
    paramZones ← [
      gc: IF parameterStorage.gc # NIL
        THEN parameterStorage.gc ELSE Lupine.defaultZones.gc,
      heap: IF parameterStorage.heap # NIL
        THEN parameterStorage.heap ELSE Lupine.defaultZones.heap,
      mds: IF parameterStorage.mds # NIL
        THEN parameterStorage.mds ELSE Lupine.defaultZones.mds ];
    bound ← TRUE;
    END;

  UnexportInterface: PUBLIC ENTRY SAFE PROCEDURE =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IF ~bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.UnexportInterface[myInterface];
    paramZones ← RpcPublic.standardZones;
    bound ← FALSE;
    END;


-- Public procedure dispatcher and public signal and error catcher.

  ServerDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength,
      -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength:
      -- DataLength]-- RpcPrivate.Dispatcher =
    BEGIN

    -- Catch public signals.

      ENABLE BEGIN

      END;  -- Catch public signals.


    -- Call public procedures (still in dispatcher).

    SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM
      FindService => RETURN[
        FindServiceStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      FindServiceWithQueueing => RETURN[
        FindServiceWithQueueingStub[pkt: pkt, callLength: callLength,
            lastPkt: lastPkt, localConversation: localConversation]];
      NewStats => RETURN[
        NewStatsStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      BestServerStats => RETURN[
        BestServerStatsStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      NoticeNewPackage => RETURN[
        NoticeNewPackageStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      RemoveOldPackage => RETURN[
        RemoveOldPackageStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      GetSomeInfo => RETURN[
        GetSomeInfoStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      CommandUnavailable => RETURN[
        CommandUnavailableStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      ExtraCommandAvailable => RETURN[
        ExtraCommandAvailableStub[pkt: pkt, callLength: callLength,
            lastPkt: lastPkt, localConversation: localConversation]];
      MightAcceptQueuedCommand => RETURN[
        MightAcceptQueuedCommandStub[pkt: pkt, callLength: callLength,
            lastPkt: lastPkt, localConversation: localConversation]];
      GenericToController => RETURN[
        GenericToControllerStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ServerDispatcher


-- Public procedure dispatcher stubs.

  FindServiceStub: --PROCEDURE [service: Rope.ROPE, userName: RPC.ShortROPE]
      -- RETURNS [found: BOOL, instance: RPC.ShortROPE]-- RpcPrivate.Dispatcher
      =
    BEGIN
    service: Rope.ROPE;
    userName: RPC.ShortROPE;
    instance: RPC.ShortROPE;
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        found (0): BOOL];
    resPkt: LONG POINTER TO ResultOverlay;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal service: Rope.ROPE from pkt.data[pktLength].
      [service, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, FALSE];
      END;  -- Unmarshal service.
    BEGIN  -- Unmarshal userName: RPC.ShortROPE from pkt.data[pktLength].
      [userName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal userName.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    resPkt ← @pkt.data[0];
    [resPkt.found, instance] ←
      FindService[service, userName];
    pktLength ← 1;
    BEGIN  -- Marshal instance: RPC.ShortROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[instance, pkt, pktLength, TRUE];
      END;  -- Marshal instance.
    RETURN[returnLength: pktLength];
    END;  -- FindServiceStub.

  FindServiceWithQueueingStub: --PROCEDURE [service: Rope.ROPE, userName:
      -- RPC.ShortROPE, version: RPC.ShortROPE, timeToWait: INT, clientMachineName:
      -- RPC.ShortROPE, streamPupAddress: Pup.Address, needListener: BOOL]
    -- RETURNS [found: ATOM, instance: RPC.ShortROPE, serverPupAddress:
        -- Pup.Address, errMsg: Rope.ROPE]-- RpcPrivate.Dispatcher =
    BEGIN
    service: Rope.ROPE;
    userName: RPC.ShortROPE;
    version: RPC.ShortROPE;
    timeToWait: INT;
    clientMachineName: RPC.ShortROPE;
    streamPupAddress: Pup.Address;
    needListener: BOOL;
    found: ATOM;
    instance: RPC.ShortROPE;
    errMsg: Rope.ROPE;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, timeToWait (1): INT,
        streamPupAddress (3): Pup.Address, needListener (6): BOOL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        serverPupAddress (0): Pup.Address];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay;
    pktLength: RpcPrivate.DataLength ← 7;
    BEGIN  -- OnePkt.
    onePkt: BOOLEAN = lastPkt;
    IF ~onePkt THEN BEGIN  -- Must move statics from pkt now.
      [timeToWait: timeToWait, streamPupAddress: streamPupAddress,
          needListener: needListener] ← argPkt↑;
      END;
    BEGIN  -- Unmarshal service: Rope.ROPE from pkt.data[pktLength].
      [service, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, FALSE];
      END;  -- Unmarshal service.
    BEGIN  -- Unmarshal userName: RPC.ShortROPE from pkt.data[pktLength].
      [userName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal userName.
    BEGIN  -- Unmarshal version: RPC.ShortROPE from pkt.data[pktLength].
      [version, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal version.
    BEGIN  -- Unmarshal clientMachineName: RPC.ShortROPE from pkt.data[pktLength].
      [clientMachineName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal clientMachineName.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    resPkt ← @pkt.data[0];
    IF onePkt
      THEN [found, instance, resPkt.serverPupAddress, errMsg] ←
          FindServiceWithQueueing[service, userName, version, argPkt.timeToWait,
              clientMachineName, argPkt.streamPupAddress, argPkt.needListener]
      ELSE [found, instance, resPkt.serverPupAddress, errMsg] ←
          FindServiceWithQueueing[service, userName, version, timeToWait,
              clientMachineName, streamPupAddress, needListener];
    END;  -- OnePkt.
    pktLength ← 3;
    BEGIN  -- Marshal found: ATOM to pkt.data[pktLength].
      pktLength ← Lupine.MarshalAtom[found, pkt, pktLength];
      END;  -- Marshal found.
    BEGIN  -- Marshal instance: RPC.ShortROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[instance, pkt, pktLength, TRUE];
      END;  -- Marshal instance.
    BEGIN  -- Marshal errMsg: Rope.ROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[errMsg, pkt, pktLength, FALSE];
      END;  -- Marshal errMsg.
    RETURN[returnLength: pktLength];
    END;  -- FindServiceWithQueueingStub.

  NewStatsStub: --PROCEDURE [serverMachineName: RPC.ShortROPE, serverMachinePupAddress:
      -- RPC.ShortROPE, serverUP: BOOL, firstCall: BOOL, machineType: PrincOps.MachineType,
      -- mainMemory: CARDINAL, numberCPUs: CARDINAL, diskPartionSize: INT,
      -- freePagesOnDisk: INT, freeboard: INT, freeGFI: CARDINAL, freeMDS:
      -- CARDINAL, freeVM: CARDINAL, oldestLRUFileDate: BasicTime.GMT,
      -- CPULoad: REAL, nonBackgroundCPULoad: REAL, reclamationRate: REAL,
      -- freeProcesses: CARDINAL, userName: RPC.ShortROPE, currentRequests:
      -- LIST OF ComputeServer.Request, aveBackgroundLoad: REAL]
    -- RETURNS [terminateService: BOOL, newPackage: BOOL, queueingCommands:
        -- LIST OF Rope.ROPE]-- RpcPrivate.Dispatcher =
    BEGIN
    serverMachineName: RPC.ShortROPE;
    serverMachinePupAddress: RPC.ShortROPE;
    serverUP: BOOL;
    firstCall: BOOL;
    machineType: PrincOps.MachineType;
    mainMemory: CARDINAL;
    numberCPUs: CARDINAL;
    diskPartionSize: INT;
    freePagesOnDisk: INT;
    freeboard: INT;
    freeGFI: CARDINAL;
    freeMDS: CARDINAL;
    freeVM: CARDINAL;
    oldestLRUFileDate: BasicTime.GMT;
    CPULoad: REAL;
    nonBackgroundCPULoad: REAL;
    reclamationRate: REAL;
    freeProcesses: CARDINAL;
    userName: RPC.ShortROPE;
    currentRequests: LIST OF ComputeServer.Request;
    aveBackgroundLoad: REAL;
    queueingCommands: LIST OF Rope.ROPE;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, serverUP (1): BOOL,
        firstCall (2): BOOL, machineType (3): PrincOps.MachineType, mainMemory
        (4): CARDINAL, numberCPUs (5): CARDINAL, diskPartionSize (6): INT,
        freePagesOnDisk (8): INT, freeboard (10): INT, freeGFI (12): CARDINAL,
        freeMDS (13): CARDINAL, freeVM (14): CARDINAL, oldestLRUFileDate
        (15): BasicTime.GMT, CPULoad (17): REAL, nonBackgroundCPULoad (19):
        REAL, reclamationRate (21): REAL, freeProcesses (23): CARDINAL,
        aveBackgroundLoad (24): REAL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        terminateService (0): BOOL, newPackage (1): BOOL];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay;
    pktLength: RpcPrivate.DataLength ← 26;
    BEGIN  -- OnePkt.
    onePkt: BOOLEAN = lastPkt;
    IF ~onePkt THEN BEGIN  -- Must move statics from pkt now.
      [serverUP: serverUP, firstCall: firstCall, machineType: machineType,
          mainMemory: mainMemory, numberCPUs: numberCPUs, diskPartionSize:
          diskPartionSize, freePagesOnDisk: freePagesOnDisk, freeboard:
          freeboard, freeGFI: freeGFI, freeMDS: freeMDS, freeVM: freeVM,
          oldestLRUFileDate: oldestLRUFileDate, CPULoad: CPULoad, nonBackgroundCPULoad:
          nonBackgroundCPULoad, reclamationRate: reclamationRate, freeProcesses:
          freeProcesses, aveBackgroundLoad: aveBackgroundLoad] ← argPkt↑;
      END;
    BEGIN  -- Unmarshal serverMachineName: RPC.ShortROPE from pkt.data[pktLength].
      [serverMachineName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal serverMachineName.
    BEGIN  -- Unmarshal serverMachinePupAddress: RPC.ShortROPE from
        -- pkt.data[pktLength].
      [serverMachinePupAddress, pktLength] ← Lupine.UnmarshalRope[pkt,
          pktLength, TRUE];
      END;  -- Unmarshal serverMachinePupAddress.
    BEGIN  -- Unmarshal userName: RPC.ShortROPE from pkt.data[pktLength].
      [userName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal userName.
    BEGIN  -- Unmarshal currentRequests: LIST OF ComputeServer.Request
        -- from pkt.data[pktLength].
      lastNode: LIST OF ComputeServer.Request ← (currentRequests ←
          NIL);
      listLength: Lupine.ListHeader;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
            pktLength];
      listLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      WHILE listLength > 0 DO
        thisNode1: LIST OF ComputeServer.Request = paramZones.gc.CONS[--DefaultValue--,NIL];
        BEGIN  -- Unmarshal thisNode1.first: ComputeServer.Request
            -- from pkt.data[pktLength].
          pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: @thisNode1.first, dataLength: SIZE[ComputeServer.Request],
              alwaysOnePkt: FALSE];
          -- Restore garbled REFs to NIL following copy.
          BEGIN OPEN record: thisNode1.first;
          LOOPHOLE[record.service, LONG POINTER] ← NIL;
          LOOPHOLE[record.userName, LONG POINTER] ← NIL;
          END;  -- OPEN record: thisNode1.first.
          BEGIN OPEN record: thisNode1.first;
          BEGIN  -- Unmarshal record.service: Rope.ROPE from pkt.data[pktLength].
            [record.service, pktLength] ← Lupine.UnmarshalRope[pkt,
                pktLength, FALSE];
            END;  -- Unmarshal record.service.
          BEGIN  -- Unmarshal record.userName: RPC.ShortROPE from pkt.data[pktLength].
            [record.userName, pktLength] ← Lupine.UnmarshalRope[pkt,
                pktLength, TRUE];
            END;  -- Unmarshal record.userName.
          END;  -- OPEN record: thisNode1.first.
          END;  -- Unmarshal thisNode1.first.
        IF lastNode # NIL
          THEN lastNode ← (lastNode.rest ← thisNode1)
          ELSE lastNode ← (currentRequests ← thisNode1);
        listLength ← listLength - 1;
        ENDLOOP;  -- WHILE listLength > 0.
      END;  -- Unmarshal currentRequests.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    resPkt ← @pkt.data[0];
    IF onePkt
      THEN [resPkt.terminateService, resPkt.newPackage, queueingCommands]
          ←
          NewStats[serverMachineName, serverMachinePupAddress, argPkt.serverUP,
              argPkt.firstCall, argPkt.machineType, argPkt.mainMemory,
              argPkt.numberCPUs, argPkt.diskPartionSize, argPkt.freePagesOnDisk,
              argPkt.freeboard, argPkt.freeGFI, argPkt.freeMDS, argPkt.freeVM,
              argPkt.oldestLRUFileDate, argPkt.CPULoad, argPkt.nonBackgroundCPULoad,
              argPkt.reclamationRate, argPkt.freeProcesses, userName, currentRequests,
              argPkt.aveBackgroundLoad]
      ELSE [resPkt.terminateService, resPkt.newPackage, queueingCommands]
          ←
          NewStats[serverMachineName, serverMachinePupAddress, serverUP,
              firstCall, machineType, mainMemory, numberCPUs, diskPartionSize,
              freePagesOnDisk, freeboard, freeGFI, freeMDS, freeVM, oldestLRUFileDate,
              CPULoad, nonBackgroundCPULoad, reclamationRate, freeProcesses,
              userName, currentRequests, aveBackgroundLoad];
    END;  -- OnePkt.
    pktLength ← 2;
    BEGIN  -- Marshal queueingCommands: LIST OF Rope.ROPE to pkt.data[pktLength].
      thisNode1: LIST OF Rope.ROPE;
      listLength: Lupine.ListHeader ← 0;
      FOR thisNode1 ← queueingCommands, thisNode1.rest UNTIL thisNode1
          = NIL DO
        listLength ← listLength + 1;  ENDLOOP;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
      pktLength ← pktLength + 2;
      FOR thisNode1 ← queueingCommands, thisNode1.rest UNTIL thisNode1
          = NIL DO
        BEGIN  -- Marshal thisNode1.first: Rope.ROPE to pkt.data[pktLength].
          pktLength ← Lupine.MarshalRope[thisNode1.first, pkt, pktLength,
              FALSE];
          END;  -- Marshal thisNode1.first.
        ENDLOOP;  -- FOR thisNode1.
      END;  -- Marshal queueingCommands.
    RETURN[returnLength: pktLength];
    END;  -- NewStatsStub.

  BestServerStatsStub: --PROCEDURE RETURNS [instance: RPC.ShortROPE,
      -- FOM: REAL]-- RpcPrivate.Dispatcher =
    BEGIN
    instance: RPC.ShortROPE;
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        FOM (0): REAL];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    [instance, resPkt.FOM] ←
      BestServerStats[];
    pktLength ← 2;
    BEGIN  -- Marshal instance: RPC.ShortROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[instance, pkt, pktLength, TRUE];
      END;  -- Marshal instance.
    RETURN[returnLength: pktLength];
    END;  -- BestServerStatsStub.

  NoticeNewPackageStub: --PROCEDURE [package: RPC.ShortROPE] RETURNS
      -- [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE]--
      RpcPrivate.Dispatcher =
    BEGIN
    package: RPC.ShortROPE;
    msg: Rope.ROPE;
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        error (0): BOOL, tryDifferentController (1): BOOL];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal package: RPC.ShortROPE from pkt.data[pktLength].
      [package, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal package.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.error, resPkt.tryDifferentController, msg] ←
      NoticeNewPackage[package];
    pktLength ← 2;
    BEGIN  -- Marshal msg: Rope.ROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[msg, pkt, pktLength, FALSE];
      END;  -- Marshal msg.
    RETURN[returnLength: pktLength];
    END;  -- NoticeNewPackageStub.

  RemoveOldPackageStub: --PROCEDURE [package: RPC.ShortROPE] RETURNS
      -- [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE]--
      RpcPrivate.Dispatcher =
    BEGIN
    package: RPC.ShortROPE;
    msg: Rope.ROPE;
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        error (0): BOOL, tryDifferentController (1): BOOL];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal package: RPC.ShortROPE from pkt.data[pktLength].
      [package, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal package.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.error, resPkt.tryDifferentController, msg] ←
      RemoveOldPackage[package];
    pktLength ← 2;
    BEGIN  -- Marshal msg: Rope.ROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[msg, pkt, pktLength, FALSE];
      END;  -- Marshal msg.
    RETURN[returnLength: pktLength];
    END;  -- RemoveOldPackageStub.

  GetSomeInfoStub: --PROCEDURE RETURNS [error: BOOL, tryDifferentController:
      -- BOOL, msg: Rope.ROPE, serverList: LIST OF Rope.ROPE, bestFOM:
      -- REAL]-- RpcPrivate.Dispatcher =
    BEGIN
    msg: Rope.ROPE;
    serverList: LIST OF Rope.ROPE;
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        error (0): BOOL, tryDifferentController (1): BOOL, bestFOM (2):
        REAL];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    [resPkt.error, resPkt.tryDifferentController, msg, serverList,
        resPkt.bestFOM] ←
      GetSomeInfo[];
    pktLength ← 4;
    BEGIN  -- Marshal msg: Rope.ROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[msg, pkt, pktLength, FALSE];
      END;  -- Marshal msg.
    BEGIN  -- Marshal serverList: LIST OF Rope.ROPE to pkt.data[pktLength].
      thisNode1: LIST OF Rope.ROPE;
      listLength: Lupine.ListHeader ← 0;
      FOR thisNode1 ← serverList, thisNode1.rest UNTIL thisNode1 =
          NIL DO
        listLength ← listLength + 1;  ENDLOOP;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
      pktLength ← pktLength + 2;
      FOR thisNode1 ← serverList, thisNode1.rest UNTIL thisNode1 =
          NIL DO
        BEGIN  -- Marshal thisNode1.first: Rope.ROPE to pkt.data[pktLength].
          pktLength ← Lupine.MarshalRope[thisNode1.first, pkt, pktLength,
              FALSE];
          END;  -- Marshal thisNode1.first.
        ENDLOOP;  -- FOR thisNode1.
      END;  -- Marshal serverList.
    RETURN[returnLength: pktLength];
    END;  -- GetSomeInfoStub.

  CommandUnavailableStub: --PROCEDURE [serverMachineName: RPC.ShortROPE,
      -- commandName: Rope.ROPE, version: RPC.ShortROPE]-- RpcPrivate.Dispatcher
      =
    BEGIN
    serverMachineName: RPC.ShortROPE;
    commandName: Rope.ROPE;
    version: RPC.ShortROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal serverMachineName: RPC.ShortROPE from pkt.data[pktLength].
      [serverMachineName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal serverMachineName.
    BEGIN  -- Unmarshal commandName: Rope.ROPE from pkt.data[pktLength].
      [commandName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal commandName.
    BEGIN  -- Unmarshal version: RPC.ShortROPE from pkt.data[pktLength].
      [version, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal version.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    CommandUnavailable[serverMachineName, commandName, version];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- CommandUnavailableStub.

  ExtraCommandAvailableStub: --PROCEDURE [serverMachineName: RPC.ShortROPE,
      -- commandName: Rope.ROPE, version: RPC.ShortROPE]-- RpcPrivate.Dispatcher
      =
    BEGIN
    serverMachineName: RPC.ShortROPE;
    commandName: Rope.ROPE;
    version: RPC.ShortROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal serverMachineName: RPC.ShortROPE from pkt.data[pktLength].
      [serverMachineName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          TRUE];
      END;  -- Unmarshal serverMachineName.
    BEGIN  -- Unmarshal commandName: Rope.ROPE from pkt.data[pktLength].
      [commandName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal commandName.
    BEGIN  -- Unmarshal version: RPC.ShortROPE from pkt.data[pktLength].
      [version, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal version.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    ExtraCommandAvailable[serverMachineName, commandName, version];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- ExtraCommandAvailableStub.

  MightAcceptQueuedCommandStub: --PROCEDURE [serverMachineAddress:
      -- RPC.ShortROPE, commandName: Rope.ROPE]-- RpcPrivate.Dispatcher
      =
    BEGIN
    serverMachineAddress: RPC.ShortROPE;
    commandName: Rope.ROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal serverMachineAddress: RPC.ShortROPE from pkt.data[pktLength].
      [serverMachineAddress, pktLength] ← Lupine.UnmarshalRope[pkt,
          pktLength, TRUE];
      END;  -- Unmarshal serverMachineAddress.
    BEGIN  -- Unmarshal commandName: Rope.ROPE from pkt.data[pktLength].
      [commandName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal commandName.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    MightAcceptQueuedCommand[serverMachineAddress, commandName];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- MightAcceptQueuedCommandStub.

  GenericToControllerStub: --PROCEDURE [requestCode: ATOM, requestString:
      -- Rope.ROPE] RETURNS [resultCode: ATOM, resultString: Rope.ROPE]--
      RpcPrivate.Dispatcher =
    BEGIN
    requestCode: ATOM;
    requestString: Rope.ROPE;
    resultCode: ATOM;
    resultString: Rope.ROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal requestCode: ATOM from pkt.data[pktLength].
      [requestCode, pktLength] ← Lupine.UnmarshalAtom[pkt, pktLength];
      END;  -- Unmarshal requestCode.
    BEGIN  -- Unmarshal requestString: Rope.ROPE from pkt.data[pktLength].
      [requestString, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal requestString.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resultCode, resultString] ←
      GenericToController[requestCode, requestString];
    pktLength ← 0;
    BEGIN  -- Marshal resultCode: ATOM to pkt.data[pktLength].
      pktLength ← Lupine.MarshalAtom[resultCode, pkt, pktLength];
      END;  -- Marshal resultCode.
    BEGIN  -- Marshal resultString: Rope.ROPE to pkt.data[pktLength].
      pktLength ← Lupine.MarshalRope[resultString, pkt, pktLength,
          FALSE];
      END;  -- Marshal resultString.
    RETURN[returnLength: pktLength];
    END;  -- GenericToControllerStub.


-- Marshall/Unmarshal procedures.


-- No module initialization.

END.  -- ComputeServerControllerRpcServerImpl.