OpenTP1 Version 7 Programming Reference C Language

[Contents][Index][Back][Next]

Create a service function (SPP)

Format

ANSI C, C++

void function-name (char *in, DCULONG *in_len, char *out,
                 DCULONG *out_len)
 {
  Service processing
  }

K&R C

void function-name (in, in_len, out, out_len)
char             *in;
DCULONG          *in_len;
char             *out;
DCULONG          *out_len;
{
Service processing
}

Description

The SPP service function executes a service and returns the execution results. The SPP service function is called by the function dc_rpc_call() of the client UAP. Create the service function in the above format as required.

The service function name corresponds to the entry point name of the service function. Specify this correspondence at execution environment setup for a UAP. The method of execution environment setup for a UAP is as follows:

Argument specification

The values listed below are passed as arguments to the service function. These values are specified in the function dc_rpc_call() of the client UAP.

For the service function, set the following values for arguments:

A response is sent to the service client UAP regardless of whether the service function was executed as a transaction or whether commitment or rollback processing was executed. Create a response with which the service function informs the client UAP of the occurrence of an error if necessary.

Arguments whose values are passed from the client UAP

in

The input parameter specified in the client UAP is passed.

in_len

The input parameter length specified in the client UAP is passed.

out_len

The response length specified in the client UAP is passed.

Arguments whose values are set in the UAP

out

Specify the response from the service function. Return the service function after specifying the processing results for out.

out_len

Specify the length of the actual response from the service function. Set a numeric value which is equal to or smaller than the out_len value passed from the client UAP.

Notes on service function processing

  1. The service function called by the function dc_rpc_call() of an nonresponse-type RPC (DCRPC_NOREPLY specified for flags) cannot reference out and out_len.
  2. If the service function is written in C language, the value upon the previous service request remains in the static variable. Thus, initialize the value before using it if necessary.
  3. The following functions cannot be used from the service function:
    • The function dc_rpc_open(), the function dc_rpc_close(), and the function dc_rpc_mainloop() cannot be called. Also, do not use exit() in the service function. The UAP operation is not ensured if any of the functions or exit() is used.
    • After system calls such as fork(), exec(), and system() are called to create a child process, all the OpenTP1 functions cannot be called from the child process.
  4. Before an SPP service function can call a message exchange function (dc_mcf_ ~), the main function must call the functions dc_mcf_open() and dc_mcf_close().
  5. The function dc_mcf_receive() cannot be called from SPP service functions.
  6. Do not execute an operation or reference that extends beyond the area of the input parameter length passed to in_len, for the input parameter passed to in. If you execute such an operation or reference, operation cannot be guaranteed. The process may terminate abnormally.

Relationship between transactions and the service function

The service function is executed as a transaction branch upon the request of a service in the following case:

In the above case, do not use the function dc_trn_begin() in the service function.

Commitment or rollback processing is ensured for all global transaction services. When the service function operating as a transaction branch issues return, the service function is assumed to request normal termination of the transaction branch.

The service function is not executed as a transaction in the following case:

To execute the service function as a transaction, use the function dc_trn_begin() and the function dc_trn_unchained_commit() from the service function at any time in order to start the transaction and acquire a synchronization point.

When no transaction attribute is specified in the user service definition, the service function cannot be executed as a transaction by using the function dc_trn_begin() from the service function.

Return value

No return value. The value specified with return() is not returned to the client UAP. OpenTP1 does not also reference any return value. Specifying -1 as a return value does not request rollback processing.