DIRECTORY DebuggerSwap USING [CallDebugger], PrincOps USING [PsbIndex, PsbNull], PrincOpsUtils USING [BITAND, BITXOR, LongCopy, PsbHandleToIndex, ReadPSB], Process USING [Detach], PupBuffer USING [Buffer], PupWKS USING [rpc], RPC USING [CallFailed, Conversation, unencrypted], RPCInternal USING [AllocBuffer, ConversationObject, DecryptPkt, EncryptPkt, EnqueueAgain, exportTable, firstConversation, GetConnectionState, GiveBackBuffer, IdleReceive, ImportInstance, IsDecrypted, PktExchange, pktLengthOverhead, SendBuffer, SetDecrypted, SetupResponse], RPCLupine USING [ DataLength, Dispatcher, GetRPCPkt, Header, maxDataLength, maxPupWords, pktOverhead, RPCPkt ], RPCPkt USING [CallCount, ConnectionID, DispatcherDetails, Header, Machine, noDispatcher, Outcome], SafeStorage USING [CantEstablishFinalization, EnableFinalization, EstablishFinalization, FinalizationQueue, FQNext, NewFQ, ReEstablishFinalization], VM USING [AddressForPageNumber, Interval, nullInterval, PagesForWords, Pin, SimpleAllocate, Unpin]; RPCPktStreams: MONITOR IMPORTS DebuggerSwap, PrincOpsUtils, Process, RPC, RPCLupine, RPCInternal, SafeStorage, VM EXPORTS RPC, --Header,ConversationObject RPCInternal, --DoSignal, ServerMain RPCLupine -- others SHARES RPCLupine = { Header: PUBLIC TYPE = RPCPkt.Header; HeaderPtr: TYPE = LONG POINTER TO Header; LupineHeader: TYPE = RPCLupine.Header; LupineHeaderPtr: TYPE = LONG POINTER TO LupineHeader; ConcreteHeader: PROC [abstract: LupineHeaderPtr] RETURNS [HeaderPtr] = INLINE { RETURN [abstract]; }; myHost: RPCPkt.Machine; CallDestHint: TYPE = ARRAY PrincOps.PsbIndex OF PrincOps.PsbIndex; lastCallDest: REF CallDestHint = NEW[CallDestHint _ ALL[PrincOps.PsbNull]]; RecordCallDest: ENTRY PROC [header: HeaderPtr] = INLINE { lastCallDest[header.destPSB--myPSB--] _ header.srcePSB; }; ImportInstance: PUBLIC TYPE = RPCInternal.ImportInstance; ConversationObject: PUBLIC TYPE = RPCInternal.ConversationObject; Conversation: TYPE = REF ConversationObject; MisusedConversation: ERROR = CODE; StartCall: PUBLIC ENTRY PROC [callPkt: RPCLupine.RPCPkt, interface: REF ImportInstance, localConversation: Conversation _ RPC.unencrypted] = { ENABLE UNWIND => NULL; myPSB: PrincOps.PsbIndex = PrincOpsUtils.PsbHandleToIndex[PrincOpsUtils.ReadPSB[]]; header: HeaderPtr = @callPkt.header; header.destHost _ interface.host; header.destSoc _ PupWKS.rpc; header.destPSB _ lastCallDest[myPSB]; callPkt.convHandle _ localConversation; IF localConversation = RPC.unencrypted THEN header.conv _ RPCInternal.firstConversation ELSE { header.conv _ [localConversation.id.count.ls, caller, localConversation.id.count.ms]; IF localConversation.id.originator # myHost THEN { IF header.destHost # localConversation.id.originator THEN ERROR MisusedConversation[]; header.conv.originator _ callee; }; }; header.pktID.activity _ myPSB; header.pktID.pktSeq _ 0; -- => new call -- header.dispatcher _ interface.dispatcher; }; Call: PUBLIC PROC [pkt: RPCLupine.RPCPkt, callLength: RPCLupine.DataLength, maxReturnLength: RPCLupine.DataLength, signalHandler: RPCLupine.Dispatcher _ NIL] RETURNS [ returnLength: RPCLupine.DataLength, lastPkt: BOOL] = { recvdHeader: HeaderPtr = @pkt.header; returnLength _ RPCInternal.PktExchange[pkt, callLength, maxReturnLength, call, signalHandler ].newLength; RecordCallDest[recvdHeader]; SELECT recvdHeader.outcome FROM result => NULL; unbound => ERROR RPC.CallFailed[unbound]; protocol => ERROR RPC.CallFailed[runtimeProtocol]; signal => ERROR -- handled inside RPCPkt.PktExchange --; unwind => { RPCInternal.SetupResponse[recvdHeader]; ERROR UnwindRequested[]; }; ENDCASE => ERROR RPC.CallFailed[runtimeProtocol]; RPCInternal.SetupResponse[recvdHeader]; RETURN[ returnLength, recvdHeader.type.eom = end ] }; SendPrelimPkt: PUBLIC PROC [pkt: RPCLupine.RPCPkt, length: RPCLupine.DataLength] = { [] _ RPCInternal.PktExchange[pkt, length, 0, sending]; }; ReceiveExtraPkt: PUBLIC PROC [pkt: RPCLupine.RPCPkt] RETURNS [length: RPCLupine.DataLength, lastPkt: BOOL] = { recvdHeader: HeaderPtr; length _ RPCInternal.PktExchange[pkt, 0, RPCLupine.maxDataLength, receiving].newLength; recvdHeader _ @pkt.header; RPCInternal.SetupResponse[recvdHeader]; RETURN[ length, recvdHeader.type.eom = end ] }; idlerAckCount: CARDINAL _ 0; idlerRequeueCount: CARDINAL _ 0; GenerateIdlerResponse: PROC [recvd: RPCLupine.RPCPkt] = { ackPkt: PupBuffer.Buffer = RPCInternal.AllocBuffer[]; header: HeaderPtr = LOOPHOLE[@ackPkt.byteLength]; recvdHeader: HeaderPtr = @recvd.header; workerPSB: PrincOps.PsbIndex = recvdHeader.destPSB; -- as adjusted by FindCallee -- idlerAckCount _ idlerAckCount+1; RPCInternal.SetupResponse[recvdHeader]; header^ _ recvdHeader^; header.length _ recvdHeader.length; header.oddByte _ no; header.type _ [0,rpc,end,dontAck,ack]; header.srceHost _ myHost; header.srceSoc _ PupWKS.rpc; header.srcePSB _ workerPSB; RPCInternal.SendBuffer[ackPkt]; }; EnqueueForNewPSB: PROC [recvd: RPCLupine.RPCPkt] = { pupPkt: PupBuffer.Buffer = RPCInternal.AllocBuffer[]; header: HeaderPtr = LOOPHOLE[@pupPkt.byteLength]; recvdHeader: HeaderPtr = @recvd.header; idlerRequeueCount _ idlerRequeueCount+1; PrincOpsUtils.LongCopy[from: recvdHeader, to: header, nwords: recvdHeader.length]; RPCInternal.EnqueueAgain[pupPkt]; }; CalleeState: TYPE = REF CalleeStateRec; CalleeStateRec: TYPE = RECORD [ entered: BOOL _ FALSE, free: BOOL _ FALSE, next: CalleeState _ NIL, callee: PrincOps.PsbIndex _ PrincOps.PsbNull, state: HeaderPtr _ NIL, space: VM.Interval _ VM.nullInterval]; callees: CalleeState _ NIL; calleesCount: INT _ 0; freeCallees: CalleeState _ NIL; freeCount: INT _ 0; worldSwap: BOOL _ FALSE; RPCInternalFailure: ERROR = CODE; Crash: PROC = { IF worldSwap THEN DebuggerSwap.CallDebugger["RPC internal failure!"L] ELSE ERROR RPCInternalFailure; }; AllocCalleeState: ENTRY PROC RETURNS [CalleeState] = { myPSB: PrincOps.PsbIndex = PrincOpsUtils.PsbHandleToIndex[PrincOpsUtils.ReadPSB[]]; state: CalleeState _ freeCallees; space: VM.Interval _ VM.nullInterval; IF freeCallees # NIL THEN { freeCallees _ state.next; freeCount _ freeCount - 1; space _ state.space; } ELSE { state _ NEW[CalleeStateRec]; }; IF space.count = 0 THEN space _ VM.SimpleAllocate[ VM.PagesForWords[serverDataLength+RPCLupine.pktOverhead]]; VM.Pin[space]; state^ _ [free: FALSE, entered: FALSE, next: NIL, callee: myPSB, state: NIL, space: space]; SafeStorage.EnableFinalization[state]; RETURN [state]; }; FreeCalleeState: ENTRY PROC [state: CalleeState] = { IF state.free THEN RETURN; IF state.entered THEN RemoveCalleeInternal[state]; VM.Unpin[state.space]; state.free _ TRUE; state.next _ freeCallees; freeCallees _ state; freeCount _ freeCount + 1; }; AddCallee: ENTRY PROC [state: CalleeState] = INLINE { AddCalleeInternal[state]; }; AddCalleeInternal: INTERNAL PROC [state: CalleeState] = { IF state.entered THEN Crash[]; state.entered _ TRUE; state.next _ callees; callees _ state; calleesCount _ calleesCount + 1; }; RemoveCallee: ENTRY PROC [state: CalleeState] = INLINE { RemoveCalleeInternal[state]; }; RemoveCalleeInternal: INTERNAL PROC [state: CalleeState] = { lag: CalleeState _ NIL; IF state # NIL AND state.entered THEN FOR p: CalleeState _ callees, p.next WHILE p # NIL DO SELECT p FROM state => { IF lag = NIL THEN callees _ p.next ELSE lag.next _ p.next; state.entered _ FALSE; calleesCount _ calleesCount - 1; RETURN; }; NIL => Crash[]; ENDCASE; lag _ p; ENDLOOP; Crash[]; }; FindCallee: ENTRY PROC [given: HeaderPtr] RETURNS [BOOL] = { IF ~RPCInternal.IsDecrypted[given] THEN ERROR; IF given # NIL THEN FOR p: CalleeState _ callees, p.next WHILE p # NIL DO state: HeaderPtr _ p.state; SELECT TRUE FROM state = NIL => {}; state.conv = given.conv --AND same originator .... -- AND state.pktID.activity = given.pktID.activity AND state.pktID.callSeq = given.pktID.callSeq => { given^.destPSB _ p.callee; RETURN [TRUE]; }; ENDCASE; ENDLOOP; RETURN [FALSE]; }; FinalizeCalleeBlocks: PROC [fq: SafeStorage.FinalizationQueue] = { DO WITH SafeStorage.FQNext[fq] SELECT FROM state: CalleeState => FreeCalleeState[state]; ENDCASE; ENDLOOP; }; HashKey: TYPE = [0..127]; ConnectionData: TYPE = RECORD[next: Connection, id: RPCPkt.ConnectionID, call: RPCPkt.CallCount, conv: RPC.Conversation -- NB: opaque type --]; Connection: TYPE = REF ConnectionData; connections: REF ARRAY HashKey OF Connection = NEW[ARRAY HashKey OF Connection _ ALL[NIL]]; ForgetConnections: INTERNAL PROC = { FOR hash: HashKey IN HashKey DO connections[hash] _ NIL ENDLOOP; }; serverDataLength: RPCLupine.DataLength = RPCLupine.maxDataLength; ServerMain: PUBLIC PROC = { myStateBlock: CalleeState _ AllocCalleeState[]; pktSpace: VM.Interval = myStateBlock.space; myPkt: RPCLupine.RPCPkt = RPCLupine.GetRPCPkt[VM.AddressForPageNumber[pktSpace.page]]; recvdHeader: HeaderPtr _ myStateBlock.state _ @myPkt.header; newPkt: BOOL _ FALSE; -- Whether packet is valid -- newLength: RPCLupine.DataLength; -- iff "newPkt" and "decrypted", pkt's length -- connection: Connection; LookupCaller: ENTRY PROC [id: RPCPkt.ConnectionID] RETURNS [{new, old, phoney, unknown}] = { ENABLE UNWIND => Crash[]; connection _ connections[ PrincOpsUtils.BITAND[ PrincOpsUtils.BITXOR[LOOPHOLE[id.caller, WORD], id.activity], LAST[HashKey]]]; DO IF recvdHeader.type.class # call THEN RETURN[old]; SELECT TRUE FROM connection = NIL => { RETURN[unknown]; }; id.conv = connection.id.conv AND id.caller = connection.id.caller AND recvdHeader.srcePSB = connection.id.activity => { myPkt.convHandle _ connection.conv; IF ~RPCInternal.IsDecrypted[recvdHeader] THEN { IF connection.conv # RPC.unencrypted THEN { ok: BOOL; [ok, newLength] _ RPCInternal.DecryptPkt[recvdHeader, myPkt.convHandle]; IF ~ok THEN RETURN[phoney]; } ELSE newLength _ recvdHeader.length - RPCInternal.pktLengthOverhead; RPCInternal.SetDecrypted[recvdHeader]; }; IF recvdHeader.pktID.activity # recvdHeader.srcePSB THEN RETURN[phoney]; IF recvdHeader.pktID.callSeq > connection.call THEN { IF recvdHeader.pktID.pktSeq # 1 THEN RETURN[phoney]; connection.call _ recvdHeader.pktID.callSeq; AddCalleeInternal[myStateBlock]; RETURN[new] } ELSE RETURN[old] }; ENDCASE => connection _ connection.next; ENDLOOP; }; NoteConnection: ENTRY PROC [id: RPCPkt.ConnectionID, call: RPCPkt.CallCount, conv: RPC.Conversation] = { prev: Connection _ NIL; hash: HashKey = PrincOpsUtils.BITAND[PrincOpsUtils.BITXOR[LOOPHOLE[id.caller, WORD], id.activity], LAST[HashKey]]; connection _ connections[hash]; DO SELECT TRUE FROM connection = NIL => { connection _ NEW[ConnectionData _ [next: NIL, id: id, call: call-1, conv: conv] ]; IF prev = NIL THEN connections[hash] _ connection ELSE prev.next _ connection; EXIT }; id.conv = connection.id.conv AND id.caller = connection.id.caller AND id.activity = connection.id.activity => -- already there! -- EXIT; ENDCASE => { prev _ connection; connection _ connection.next }; ENDLOOP; }; DO ENABLE { ABORTED => EXIT; UNWIND => FreeCalleeState[myStateBlock] }; IF NOT newPkt THEN { RPCInternal.IdleReceive[myPkt, RPCLupine.maxPupWords]; newPkt _ TRUE; }; SELECT LookupCaller[[recvdHeader.conv, recvdHeader.srceHost, recvdHeader.srcePSB]] FROM new => { target: RPCPkt.DispatcherDetails = recvdHeader.dispatcher; resultLength: RPCLupine.DataLength; RPCInternal.SetupResponse[recvdHeader]; IF target.dispatcherHint >= RPCInternal.exportTable.used OR target.dispatcherID = RPCPkt.noDispatcher OR target.dispatcherID # RPCInternal.exportTable[target.dispatcherHint].id THEN { Reject[myPkt, unbound]; resultLength _ 0 } ELSE resultLength _ RPCInternal.exportTable[target.dispatcherHint].dispatcher[ myPkt, newLength, recvdHeader.type.eom = end, connection.conv ! RPC.CallFailed => TRUSTED { newPkt _ FALSE; RemoveCallee[myStateBlock]; LOOP; }; UnwindRequested => { resultLength _ 0; CONTINUE; }; RejectUnbound => { Reject[myPkt, unbound]; resultLength _ 0; CONTINUE; }; RejectProtocol => { Reject[myPkt, protocol]; resultLength _ 0; CONTINUE; }; ]; RemoveCallee[myStateBlock]; [newPkt, newLength] _ RPCInternal.PktExchange[myPkt, resultLength, serverDataLength, endCall ! RPC.CallFailed => TRUSTED {newPkt _ FALSE; CONTINUE}]; }; unknown => { ok: BOOL; id: RPCPkt.ConnectionID; call: RPCPkt.CallCount; conv: RPC.Conversation; [ok, id, call, conv, newLength] _ RPCInternal.GetConnectionState[--decrypted,-- myPkt ! RPC.CallFailed => TRUSTED {newPkt_FALSE; LOOP}]; IF ~ok THEN newPkt _ FALSE ELSE IF ~newPkt THEN ERROR ELSE NoteConnection[id, call, conv]; }; phoney => newPkt _ FALSE; old => { oldDest: PrincOps.PsbIndex = recvdHeader.destPSB; knownCallee: BOOL = RPCInternal.IsDecrypted[recvdHeader] AND FindCallee[recvdHeader]--may alter destPSB--; IF knownCallee AND recvdHeader.destPSB # oldDest THEN { EnqueueForNewPSB[myPkt]; } ELSE { IF recvdHeader.type.ack = pleaseAck AND recvdHeader.type.eom = end AND( recvdHeader.type.class = data OR knownCallee ) THEN { recvdHeader.length _ IF ~RPCInternal.IsDecrypted[recvdHeader] OR myPkt.convHandle = RPC.unencrypted THEN RPCInternal.pktLengthOverhead ELSE RPCInternal.EncryptPkt[myPkt, 0]; GenerateIdlerResponse[myPkt]; }; }; newPkt _ FALSE; }; ENDCASE => ERROR; ENDLOOP; FreeCalleeState[myStateBlock]; }; StartSignal: PUBLIC PROC [signalPkt: RPCLupine.RPCPkt] = { ConcreteHeader[@signalPkt.header].outcome _ signal; }; UnwindRequested: ERROR = CODE; -- internal: remote machine is unwinding a signal PktData: TYPE = REF PktSpace; PktSpace: TYPE = ARRAY [1..serverDataLength + RPCLupine.pktOverhead] OF WORD; DoSignal: PUBLIC PROC [b: PupBuffer.Buffer, pktLength: RPCLupine.DataLength, signalHandler: RPCLupine.Dispatcher, convHandle: RPC.Conversation] RETURNS [resumePkt: RPCLupine.RPCPkt _ NIL, resumeLength: RPCLupine.DataLength _ 0, myLocalFrame: POINTER _ NIL] = { IF pktLength > serverDataLength THEN { RPCInternal.GiveBackBuffer[b]; ERROR RPC.CallFailed[runtimeProtocol] } ELSE { myStateBlock: CalleeState _ AllocCalleeState[]; pktSpace: VM.Interval = myStateBlock.space; pkt: RPCLupine.RPCPkt = RPCLupine.GetRPCPkt[VM.AddressForPageNumber[pktSpace.page]]; recvdHeader: HeaderPtr _ myStateBlock.state _ @pkt.header; PrincOpsUtils.LongCopy[from: @b.byteLength, to: recvdHeader, nwords: pktLength+SIZE[Header]]; { ENABLE UNWIND => FreeCalleeState[myStateBlock]; handlerFailed: BOOL _ FALSE; -- CallFailed raised inside signalHandler! -- pkt.convHandle _ convHandle; RPCInternal.GiveBackBuffer[b]; AddCallee[myStateBlock]; RPCInternal.SetupResponse[recvdHeader]; IF signalHandler = NIL THEN { Reject[pkt, unbound]; resumeLength _ 0 } ELSE resumeLength _ signalHandler[ pkt, pktLength, recvdHeader.type.eom = end, convHandle ! RPC.CallFailed => TRUSTED {handlerFailed _ TRUE}; UNWIND => IF NOT handlerFailed THEN { recvdHeader.outcome _ unwind; resumeLength _ RPCInternal.PktExchange[pkt, 0, serverDataLength, call, signalHandler].newLength; SELECT recvdHeader.outcome FROM result => NULL -- let our UNWIND propagate --; signal => ERROR -- handled inside RPCInternal.PktExchange--; ENDCASE => ERROR RPC.CallFailed[runtimeProtocol]; RPCInternal.SetupResponse[recvdHeader]; }; UnwindRequested => { resumeLength _ 0; CONTINUE; }; RejectUnbound => { Reject[pkt, unbound]; resumeLength _ 0; CONTINUE }; RejectProtocol => { Reject[pkt, protocol]; resumeLength _ 0; CONTINUE }; ]; }; FreeCalleeState[myStateBlock]; }; }; RejectUnbound: PUBLIC ERROR = CODE; RejectProtocol: PUBLIC ERROR = CODE; Reject: PROC [pkt: RPCLupine.RPCPkt, rejection: RPCPkt.Outcome] = { header: HeaderPtr = @pkt.header; UNTIL header.type.eom = end DO [,] _ ReceiveExtraPkt[pkt ! RPC.CallFailed => TRUSTED {rejection _ protocol; EXIT}] ENDLOOP; header.outcome _ rejection; }; StartRPCPktStreams: PUBLIC ENTRY PROC [me: RPCPkt.Machine] = { fq: SafeStorage.FinalizationQueue _ SafeStorage.NewFQ[48]; SafeStorage.EstablishFinalization[CODE[CalleeStateRec], 0, fq ! SafeStorage.CantEstablishFinalization => { SafeStorage.ReEstablishFinalization[CODE[CalleeStateRec], 0, fq] }]; myHost _ me; Process.Detach[FORK FinalizeCalleeBlocks[fq]]; }; RollbackRPCPktStreams: PUBLIC ENTRY PROC = { ForgetConnections[] }; }. ΘRPCPktStreams.mesa - Call-oriented packet streams, based on PktExchange Copyright Σ 1985, 1986, 1987 by Xerox Corporation. All rights reserved. Andrew Birrell September 7, 1983 3:52 pm Bob Hagmann February 11, 1985 4:36:22 pm PST Russ Atkinson (RRA) April 25, 1986 10:08:15 am PST Hal Murray, May 13, 1986 3:05:20 am PDT Swinehart, January 17, 1987 2:14:20 pm PST ******** Caller ******** For each PSB that initiates a call, record last callee PSB, and use that PSB as destPSB hint for next call, to obtain implicit ack of last result packet. The fact that the destPSB will be wrong of we next talk to a different server host is only a slight pessimization. During a call, a single packet is used for buffering all data sent and received. Whenever the client of RPCLupine has possesion of the buffer (after StartCall), the buffer is set up correctly for transmitting. I.e. buffer.header.dest = the remote machine. Thus, this is true on exit from StartCall, and on entry and exit to/from SendPrelimPkt, ReceiveExtraPkt, Call, and the dispatchers. This causes an extra call of SetupResponse in Call in the case where there will be no subsequent call of ReceiveExtraPkt, but it preserves my sanity. ?? header.conv _ RPCInternal.GetPktConversation[localConversation] header.pktID.callSeq gets filled in by PktExchange -- This is legal only if we were called to raise a remote signal; UnwindRequested should be caught where we called the dispatcher that noticed the signal unwind,garbage ******** Protocol implementation: multi-packet case ******** -- ******** Protocol implementation: callee and packets-while-notWanting ******** -- packet is encrypted if need be! packet may or may not be encrypted. This status will be retained as the packet is requeued. We must maintain globally accessible state indicating current calls in the callee, so that the callee can respond to pings. This flag can be used to force world-swap debugging (teledebugging) for really delicate errors. Most bugs can be found just due to RPCInternalFailure being raised. This one can be called multiple times, since it is involved in cleanup activity Remove has been called for something that is not on the callee chain. This should not happen! Returns TRUE iff there is a current callee for this call, even if the callee's pktSeq differs. If result is TRUE, updates "given"s destPSB to match callee's. Assumes pkt has been decrypted. For each calling RPCPkt.ConnectionID we must maintain a sequence number, being the last call initiated on that conversation, so that we can eliminate duplicate call request packets. This information is maintained as a hash table with linked overflow. The hash function is (connection.caller XOR connection.activity) MOD 128. The hash table is altered by LookupCaller and EndConnection, which are nested inside ServerMain for sordid efficiency reasons, and by NoteCaller. Forget connection state, so that subsequent calls will cause an RFA Received packets are dispatched to "ServerMain" processes (through IdleReceive) if the addressed process is not wanting to receive any packets at the time, or if the destPSB is PsbNull. Thus ServerMain serves both as the listener waiting for RFC's on a conventional rendezvous protocol, and as the process listening to the incoming per-connection socket in more heavyweight protocols. There are several cases. The packet may be the first packet of a new call - in this case, this process will handle the call. The packet may be an old duplicate packet from a dead call - in this case the packet can be ignored. The packet may be a retransmission in a current call - in this case an ack may be required. Remember that packets can arrive here in both the caller and callee hosts! decrypted: BOOL _ FALSE; -- if "newPkt", whether it's been decrypted -- Implicitly, recvdHeader is a parameter of LookupCaller. IF pkt is not a call packet, returns "old" -- DCS January 16, 1987; If pkt starts call and ConnectionID is unknown, returns "unknown"; If pkt starts call and isn't duplicate, adds us as callee, returns "new"; If pkt is part of some previously initiated call, returns "old"; If pkt is part of some call with unknown ConnectionID, returns "phoney" If decrypted pkt is inconsistent, returns "phoney". Otherwise, returns "old". On entry, packet has previously been decrypted iff "decrypted". On exit if result is "new", pkt is decrypted On exit if "decrypted", then myPkt.convHandle is set. Note that if result is "old", pkt may or may not be decrypted. ^^ Near as I can tell, the tests and descriminations made here are only interesting for call packets arriving at the callee. The connections table exists only for callees, not callers, so we should be uninterested in whether the connection is known when we are a caller (the packet is a reverse-direction packet). The previous tests mis-processed some non-call packets when both parties were on the same host. I'm still a little worried about rare situations like signal-packet handling. DCS January 15, 1987. IF recvdHeader.type.class # call THEN RETURN[old]; --DCS January 16, 1987 see above IF recvdHeader.type.class # call THEN RETURN[old]; --DCS January 16, 1987 see above newPkt = TRUE at top of loop iff we have the first pkt of next call already. At top of loop, myPkt is decrypted if newPkt = TRUE. Obsolete statement, DCS, January 16, 1987 decrypted _ FALSE; start of new call The dispatcher raised a remote signal which the remote machine is unwinding The dispatcher wants caller to get CallFailed[unbound] The dispatcher wants caller to get CallFailed[badProtocol] IF newPkt THEN decrypted _ TRUE; now newPkt=FALSE or myPkt is decrypted and contains start of new call need to ask other end for connection state ignorable packet Pkt may or may not have been decrypted. If the packet came to us because it had an incorrect destPSB, we should try correcting it and giving it to the correct process. This ensures that destPSB is only a hint. Also, because of the restrictions on generating ack's (described below), there are cases where an ack is required but only the correct worker process is allowed to generate it. destPSB his was wrong: requeue pkt for correct process; note that if correct process doesn't want the packet right now, it may come back to an idler process, but it will have correct destPSB IF decrypted THEN -- no need to re-encrypt; that it is already decrypted is encoded in the packet, and this encoding will be retained. recvdHeader.length _ IF myPkt.convHandle = RPC.unencrypted THEN RPCInternal.pktLengthOverhead + newLength ELSE RPCInternal.EncryptPkt[myPkt, newLength]; We're here because the packet doesn't start a new call. We should respond if the packet is a retransmission or a ping. We generate an ack only if the packet has eom-end. Therefore, the last packet in any direction may only be sent when the worker process has generated the ack for the preceding packet in that direction. Therefore, the last packet in any direction comes to an idler process only after the worker process has received a previous transmission of that packet (because of the way "wanting" is set in PktExchange). We assume that class=data isn't used for pings. If we're still working on the call, we generate an ack containing the worker process's PSBIndex. Beware when caller and callee are on the same host! ******** Remote signalling ******** We must register as a callee, in case other end pings during signal. See comments in ServerMain. unbound,protocol,unwind,garbage ELSE the UNWIND was in response to us raising CallFailed, so there's no point in talking to the other machine The signalHandler raised a remote signal which the remote machine is unwinding! ******** Remote call failure ******** ******** Initialization ******** Bob Hagmann February 8, 1985 4:08:52 pm PST changes to: ServerMain Bob Hagmann February 11, 1985 4:36:22 pm PST changes to: GiveBackBuffer Swinehart, January 16, 1987 4:00:10 pm PST Repairs to LookupCaller. Avoids misprocessing packets when caller and callee are on the same machine. changes to: LookupCaller (local of ServerMain) Swinehart, January 17, 1987 1:49:29 pm PST Carry information about whether packet has been encrypted along with the packet. See RPCInternal.IsEncrypted. changes to: GenerateIdlerResponse, EnqueueForNewPSB, FindCallee, ServerMain, LookupCaller (local of ServerMain) Κώ˜codešœG™GKšœH™HKšœ)™)K™,K™2K™'K™*—˜šΟk ˜ Kšœ œ˜"Kšœ œ˜#Kšœœœœ'˜JKšœœ ˜Kšœ œ ˜Kšœœ˜Kšœœ)˜2Kšœ œ€˜‘Kšœ œ`˜oKšœœV˜bKšœ œƒ˜”Kšœœ[˜c——headšœ˜Kšœ'œ'˜Zš˜KšœΟc˜ Kšœ ž˜#Kšœ ž ˜—Kšœ˜—˜Kšœœœ˜$Kš œ œœœœ˜)Kšœœ˜&Kš œœœœœ˜5—˜šΟnœœœœ˜OKšœ ˜Kšœ˜K˜—K˜K˜—šœ™K˜Kšœ™K˜Kšœœœœ˜Bšœœœœ˜KK˜—šŸœœœœ˜9Kšœž œ˜7Kšœ˜K˜—Kšœœœ˜9K˜Kšœ™K˜Kšœœœ"˜AK˜Kšœœœ˜,K˜Kšœœœ˜"K˜š Ÿ œœœœ(œ3œ˜ŽKšœœœ˜KšœS˜SKšœ$˜$K˜!K˜K˜%K˜'šœœ ˜&Kšœ-˜1šœ˜KšœB™BK˜Ušœ)œ˜2šœ2˜9Kšœ˜—K˜ Kšœ˜—Kšœ˜——K˜Kšœ5™5Kšœž˜*K˜)Kšœ˜K˜—š Ÿœœœˆœœ0œ˜ήKšœ%˜%˜7K˜1—K˜šœ˜Kšœ œ˜Kšœ œœ˜)Kšœ œœ˜2Kšœ œž'œ˜8šœ ˜ Kšœ–™–Kšœ'˜'Kšœ˜Kšœ˜—šœ˜ Kšœ™Kšœœ˜&——K˜'Kšœ,˜2Kšœ˜K˜——šœ?™?K˜šŸ œœœ:˜TKšœ6˜6Kšœ˜K˜—š Ÿœœœœ)œ˜nKšœ˜KšœW˜WK˜Kšœ'˜'Kšœ&˜,Kšœ˜K˜——šœQ™QK˜Kšœœ˜Kšœœ˜ K˜šŸœœ˜9Kšœ™K˜5Kšœœ˜1Kšœ'˜'Kšœ4ž˜SK˜ K˜'K˜K˜#K˜K˜&K˜K˜K˜K˜Kšœ˜K˜—šŸœœ˜4Kšœ\™\Kšœ5˜5Kšœœ˜1Kšœ'˜'K˜(KšœR˜RKšœ!˜!Kšœ˜K˜—Kšœ{™{K˜Kšœ œœ˜'šœœœ˜Kšœ œœ˜Kšœœœ˜Kšœœ˜Kšœ-˜-Kšœœ˜Kšœœ œ˜&K˜—Kšœœ˜Kšœœ˜Kšœœ˜Kšœ œ˜šœ œœ˜Kšœ€™€—K˜KšŸœœœ˜!K˜šŸœœ˜šœ ˜ Kšœ4˜8Kšœœ˜—K˜—K˜šŸœœœœ˜6KšœS˜SKšœ!˜!Kšœœ œ˜%šœ˜šœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜—šœ˜Kšœœ˜K˜——šœ˜šœœ˜Kšœ8˜:——Kšœ ˜Kš œœ œœœ˜[Kšœ&˜&Kšœ ˜K˜K˜—šŸœœœ˜4KšœO™OKšœ œœ˜Kšœœ˜2Kšœ˜Kšœ œ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜—K˜šŸ œœœœ˜5Kšœ˜Kšœ˜K˜—šŸœœœ˜9Kšœœ ˜Kšœœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜K˜—šŸ œœœœ˜8Kšœ˜Kšœ˜K˜—šŸœœœ˜™>Kšœœ ˜˜Kš œœœœ œœ ˜d—š˜šœœœ˜2K™—šœœ˜šœ œ˜Kšœœœ'™SKšœ ˜Kšœ˜—šœœ!œ2˜wK˜#šœ'œ˜/šœœ œ˜+Kšœœ˜ K˜HKšœœœ ˜Kšœ˜—Kšœ@˜DK˜&Kšœ˜—Kšœ1œœ ˜HKšœœœ'™Sšœ,˜.šœ˜Kšœœœ ˜4K˜,Kšœ ˜ Kšœ˜ Kšœ˜—Kšœœ˜—Kšœ˜—Kšœ!˜(—Kšœ˜—Kšœ˜K˜—šŸœœœ9œ˜hKšœœ˜Kš œœœœ œœ ˜rKšœ˜š˜šœœ˜šœ œ˜Kšœ œœ&˜Ršœ˜ Kšœ˜#Kšœ˜—Kš˜Kšœ˜—Kš œœ!œ(žœœ˜ˆKšœ8˜?—Kšœ˜—Kšœ˜K˜—KšœL™LKšž^™^š˜Kšœœœœ$˜Dšœœœ˜Kšœ6˜6Kšœ œ˜Kšœ œ™Kšœ˜—šœM˜Wšœ˜Kšœ™K˜:K˜#Kšœ'˜'šœ6˜8Kšœ*˜,KšœH˜JKšœ-˜1šœŠ˜Žšœœ˜Kšœ œ˜Kšœ˜Kšœ˜Kšœ˜—šœ˜Kšœ>™>Kšœ ™ Kšœ˜Kšœ˜ Kšœ˜—šœ˜Kšœ6™6Kšœ˜Kšœ˜Kšœ˜ Kšœ˜—šœ˜Kšœ:™:Kšœ˜Kšœ˜Kšœ˜ Kšœ˜—K˜——K˜šœB˜BK˜Kš œœœ œœ˜8—Kšœœ œ™ KšœE™EKšœ˜—šœ ˜ Kšœ*™*Kšœœ˜ K˜K˜Kšœœ˜˜!šœžœ˜5Kšœœœœ˜0——Kšœœ ˜Kšœ œ˜Kšœ ˜$Kšœ˜—šœ ˜ Kšœ™Kšœ œ˜—šœ˜Kšœ…™…Kšœ1˜1Kšœ œ(œžœ˜jšœ œœ˜7KšœzžD™Ύšœ†™†šœ™šœœ ™%Kšœ*™.Kšœ*™.———K˜Kšœ˜—šœ˜KšœΪ™Ϊš œ!œœ œœ˜}˜Kšœ'œœ ˜NKšœ˜"Kšœ#˜'—K˜Kšœ˜—Kšœ˜—Kšœ œ˜Kšœ˜—Kšœœ˜—Kšœ˜—Kšœ˜Kšœ˜K˜——šœ#™#K˜šŸ œœœ"˜:Kšœ3˜3Kšœ˜K˜—Kšœœœž1˜PK˜Kšœ œœ ˜Kš œ œœ/œœ˜MK˜šŸœœœiœœ œ8œœ˜„šœ˜šœ˜K˜Kšœœ˜%K˜—šœ˜Kšœ/˜/Kšœ œ˜+Kšœ,œ&˜TKšœ:˜:Kšœ`™`KšœOœ ˜]šœ˜Kšœœ"˜/Kšœœœž-˜JK˜K˜Kšœ˜K˜'šœ˜Kšœ+˜/šœ˜"K˜8Kšœœœ˜1šœ˜ šœœœ˜K˜K˜`šœ˜Kšœ œžœ˜.Kšœ œžœ žœ˜<šœ˜ Kšœ™Kšœœ˜&——Kšœ'˜'Kšœ˜—Kšœ<ž1™m—šœ˜KšœO™OKšœ˜Kšœ˜ Kšœ˜—Kšœ;œ˜FKšœ=œ˜HK˜——Kšœ˜—Kšœ˜K˜——Kšœ˜K˜——šœ%™%K˜Kšœœœœ˜$Kšœœœœ˜$K˜šŸœœ7˜CKšœ ˜ šœ˜Kšœœœœ˜SKšœ˜—K˜Kšœ˜K˜——šœ ™ K˜šŸœœœœ˜>Kšœ:˜:šœ"œ˜=šœ,˜,Kšœ$œ˜@Kšœ˜——Kšœ ˜ Kšœœ˜.Kšœ˜K˜—šŸœœœœ˜,K˜Kšœ˜—K˜—Kšœ˜™+Kšœ Οr ™—™,Kšœ  ™—™*K™fKšœ   œ™.—™*K™nKšœ  Mœ™o—K™—…—>ŠtP