5.1 Oracle Tuxedo System main( )

To facilitate the development of ATMI servers, the Oracle Tuxedo system provides a predefined main() routine for server load modules. When you execute the buildserver command, the main() routine is automatically included as part of the server.

Note:

The main() routine that the system provides is a closed abstraction; you cannot modify it.

In addition to joining and exiting from an application, the predefined main() routine accomplishes the following tasks on behalf of the server.

  • Executes the process ignoring any hangups (that is, it ignores the SIGHUP signal).
  • Initiates the cleanup process on receipt of the standard operating system software termination signal (SIGTERM). The server is shut down and must be rebooted if needed again.
  • Attaches to shared memory for bulletin board services.
  • Creates a message queue for the process.
  • Advertises the initial services to be offered by the server. The initial services are either all the services link edited with the predefined main(), or a subset specified by the Oracle Tuxedo system administrator in the configuration file.
  • Processes command-line arguments up to the double dash (--), which indicates the end of system-recognized arguments.
  • Calls the function tpsvrinit() to process any command-line arguments listed after the double dash (--) and optionally to open the resource manager. These command-line arguments are used for application-specific initialization.
  • Until ordered to halt, checks its request queue for service request messages.
  • When a service request message arrives on the request queue, main() performs the following tasks until ordered to halt:
    • If the -r option is specified, records the starting time of the service request.
    • Updates the bulletin board to indicate that the server is BUSY.
    • Allocates a buffer for the request message and dispatches the service; that is, calls the service subroutine.
  • When the service returns from processing its input, main() performs the following tasks until ordered to halt:
    • If the -r option is specified, records the ending time of the service request.
    • Updates statistics.
    • Updates the bulletin board to indicate that the server is IDLE; that is, that the server is ready for work.
    • Checks its queue for the next service request.
  • When the server is required to halt, calls tpsvrdone() to perform any required shutdown operations.

As indicated above, the main() routine handles all of the details associated with joining and exiting from an application, managing buffers and transactions, and handling communication.

Note:

Because the system-supplied main() accomplishes the work of joining and leaving the application, you should not include calls to the tpinit() or tpterm() function in your code. If you do, the function encounters an error and returns TPEPROTO in tperrno. For more information on the tpinit() or tpterm() function, refer to Writing Clients.