Customizing the DB2 thread management exit
Customizing the DB2® thread management exit enables you to validate clients and control the duration of CAF connections.
If your installation has special processing requirements that can be addressed by a DB2 thread management exit, you can update the exit IBM® delivers or create a custom exit of your own. The following table describes the DB2 thread management parameter list and processing options for developing your own custom DB2 thread management exit.
- Initialization: Each time a new DB2 CAF service is started from the region controller, an initialization call is made to perform any one-time initialization processing for the started task. If your exit must allocate any storage for use throughout the life of the task, your exit can allocate the storage in this call and place the address of that storage in the user field DB2TUSRW supplied in the exit parameter structure.
- Client Connection: Called each time a new client has acquired a CAF subtask. Typically, this call is made immediately before connecting to DB2 on behalf of the client. The one exception is when the exit is set to leave connections to DB2 active even when clients disconnect.
- After Connection to DB2: Called after each attempt is made to connect to DB2. This call is made regardless of whether the connect was successful. The parameters field DB2STAT indicates whether the connection attempt was successful.
- Client Disconnection: Called each time a client has released its connection to the CAF subtask.
- Termination: Called once at subtask termination. If you allocated any exit memory at initialization, this is when it needs to be freed.
Field | Description |
---|---|
DB2TUSRW | Initialized to binary zeros prior to the initialization call and left unchanged after that point in processing. Use of this field is determined by the user exit. |
DB2TUSRP | Points to a NULL terminated user parameter as
defined on the service definition for the DB2 CAF
task. This parameter includes any text included after the exit name
itself in the task data field. For example, to pass the string USERPARM
to the exit from the service definition, the task data for the exit
is: CACPLAN,CACSX07 USERPARM |
DB2TSSN | Points to the four-character subsystem name as defined in the Service Name field of the service definition the task. In most cases, this field is for informational purposes only. However, the exit can change this field on client connection calls to designate a new subsystem to connect to, if necessary. If this field is updated, it will remain updated until the thread disconnects from DB2. At that point, it will be changed back to its original service information entry value. |
DB2TPLAN | Points to the 8-character DB2 PLAN name as defined in the Task Data field of the service definition for the task. In most cases, this field is for informational purposes only. However, the exit can change this field on client connection calls to designate a new DB2 PLAN to open a DB2 connection. If this field is updated, it remains updated until the thread disconnects from DB2. At that point, it is changed back to its original service definition value. |
DB2TUID | Points to the user ID provided by the client when the client connected to the data server. This field is binary zeros on initialization and termination calls, as no user is available when these calls are issued. This field is for reference purposes only and must not be changed by the exit. |
DB2UPWD | The DB2UPWD field points to the user password provided by the client when it connected to the data server. This field is binary zeros on initialization and termination calls, as no user is available when these calls are issued. This field is used for reference purposes only and must not be changed by the exit. |
DB2TSTAT | The DB2TSTAT field identifies whether a current CAF connection exists to DB2. This field is used for reference purposes only. |
DB2TFUNC | The DB2TFUNC field identifies the function of
the call as described previously. Defined values for this field are:
|
DB2TRFNC | The DB2TRFNC field can be used by the exit to:
|
The return code (register 15 value) for successful completion of the user exit should always be set to 0. Any other value causes an error message to be returned to the requesting client.
Activating a customized exit
You can follow the instructions for activating the DB2 thread management exit to activate your customized exit with the following modifications:
- Replace the system default exit name CACSX07 with the name of your customized exit.
- If your exit does not create a TCB level ACEE for the DB2 primary authorization ID setting, skip the instructions for updating and reassembling DSN3SATH.