Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 9
Writing a Requester Program: An Example
The requesters’ primary process handle
The requesters’ backup process handle
The file numbers the requester used for the opens (each open has a distinct file
number, although normally the backup’s file number is the same as the primary’s
file number)
The sync-depth value of the open
The last sync ID value received
Buffers to store responses (sync ID, error code, reply size, and reply data)
The primary and backup process handles are subject to change during the lifetime of
the open. The process handles can change if one or more of the following occurs:
CPU or process failures. If the primary CPU fails, the backup’s process handle
must be copied into the primary’s process handle slot and the backup’s process
handle must be reset. If the backup CPU fails, its process handle must be reset.
Notification of CPU failures are obtained using the MONITORCPUS and the
MONITORNET procedures. Process failures cause a close to be received from
either the primary process or the backup process. Note that a request can be
received from the backup process before you receive a close from the primary
process or a CPU failure message, depending on the timing.
Voluntary switches in the requester process. If a requester calls CHECKSWITCH,
the next request comes from the backup process. The process handles for the
primary and backup’s processes need to swap places.
File close.
Call FILE_GETRECEIVEINFO_ each time a request is read from $RECEIVE. The
process handle and file number must match an opener table entry. If no match is
found, reply with error 60 (ZFIL_ERR_WRONGID). This error indicates that the
requester had a server with the same name open, that server terminated, and a new
server with the same name was started. The OPEN in the requester is still valid, which
is why messages might be received even if no preceding OPEN message has been
received. You can perform requester error recovery by closing the server file and
opening it again, which causes the allocation of a new open control block in the server.
Writing a Requester Program: An Example
The sample requester program given here forms part of a sales-ordering application
involving some inventory control and order processing. This part of the application
performs three functions:
Queries the inventory database to find out how much of a given item is on hand.
Processes an order by updating the inventory database and creating an order
record.