Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 6
Opening a File With a Specified Sync Depth
After receiving messages sent by __ns_start_backup, the backup process
automatically does the following:
Processes the startup, assign, and param messages in the same manner as the
primary process.
For any of the standard files stdin, stdout, and stderr the primary opened
during its initialization, performs backup opens for the same files.
Only the standard files stdin, stdout, and stderr can have backup opens
automatically performed. Other files that the primary process may have opened must
be explicitly opened in the backup process by a call to __ns_backup_fopen.
Note that when the standard files are backup opened, the file states in the backup
process are not automatically set to the corresponding file states in the primary
process. If operations are performed on a standard file before __ns_start_backup
is called, it is your responsibility to ensure that the file state is up to date in the backup
process. (Refer to Retrieving File State Information in the Primary Process and
Updating File State Information in the Backup Process, later in this section.)
Opening a File With a Specified Sync Depth
Normally, you use the fopen function to open files in the primary process. The
__ns_fopen_special function performs the same operation as the fopen function,
but it also allows a sync depth to be specified.
The sync depth is the number of nonretryable write requests that must be remembered
by the opened process (server). It is used for writing operations that cannot be
repeated in the backup process without changing the results of the operation. For
more information about sync depth and nonretryable writes, see Updating File State
Information, later in this section.
After calling __ns_fopen_special, the primary process calls
__ns_fget_file_open_state to get the open state of the file, then passes the
information to the backup process through interprocess communication.
Retrieving File Open State Information in the Primary Process
After opening any files required by the application, the primary process calls
__ns_fget_file_open_state function to retrieve open state information for an
open file. The primary process sends the open state information to the backup
process through interprocess communication. The backup process receives the
information through $RECEIVE, then calls the __ns_backup_fopen function to do a
backup open of the file.
Opening Files in the Backup Process
The backup process opens files that have been opened by the primary process by
performing a backup open. A backup open is a form of file open that permits a file to