Frees up a previously allocated TDPROC structure after returning results to a client.
%INCLUDE SYGWPLI;
01 TDPROC PTR, 01 RETCODE FIXED BIN(31);
CALL TDFREE (TDPROC, RETCODE);
(I) Handle for this client/server connection. This must be the same value specified in the associated TDACCEPT call. The TDPROC handle corresponds to the connection and command handles in Open Client Client-Library.
(O) Variable where the result of function execution is returned. Its value is one of the codes listed in Table 3-8.
The RETCODE argument can contain any of the return values listed in Table 3-8.
Return value |
Meaning |
---|---|
TDS_OK (0) |
Function completed successfully. |
TDS_CONNECTION_TERMINATED (-4997) |
Connection closed. The remote partner closed (deallocated) the client/server connection. |
TDS_INVALID_TDPROC (-18) |
Error in specifying a value for the TDPROC argument. |
The following code fragment illustrates the use of TDINIT, TDACCEPT, TDSNDDON, and TDFREE at the beginning and end of a Gateway-Library program. This example is taken from the sample program in Appendix B, “Sample RPC Application for CICS.”
/*------------------------------------------------------------------*/ INITIALIZE_PROGRAM: /*------------------------------------------------------------------*/ /* ------------------------------------------------------------*/ /* reset db2 error handlers */ /* ------------------------------------------------------------*/ EXEC SQL WHENEVER SQLWARNING CONTINUE; EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL WHENEVER NOT FOUND CONTINUE; /* ------------------------------------------------------------*/ /* establish gateway environment */ /* ------------------------------------------------------------*/ CALL TDINIT (DFHEIBLK, GWL_RC, GWL_INIT_HANDLE); /* ------------------------------------------------------------*/ /* accept client request */ /* ------------------------------------------------------------*/ CALL TDACCEPT (GWL_PROC, GWL_RC, GWL_INIT_HANDLE, SNA_CONNECTION_NAME, SNA_SUBC); /*------------------------------------------------------------------*/ /* (BODY OF PROGRAM) */ /*------------------------------------------------------------------*/ GO TO END_PROGRAM; /*------------------------------------------------------------------*/ END_PROGRAM: /*------------------------------------------------------------------*/ IF SEND_DONE = SEND_DONE_OK THEN WRK_DONE_STATUS = TDS_DONE_COUNT; ELSE DO; WRK_DONE_STATUS = TDS_DONE_ERROR; PARM_RETURN_ROWS = 0; END; CALL TDSNDDON (GWL_PROC, GWL_RC, WRK_DONE_STATUS, PARM_RETURN_ROWS, TDS_ZERO, TDS_ENDRPC); CALL TDFREE (GWL_PROC, GWL_RC); EXEC CICS RETURN; END SYSAMP1;
The following code fragment illustrates the use of TDFREE and TDTERM at the end of a Gateway-Library program. This example is taken from the sample program SYIXSAM1, listed in Appendix D, “Sample RPC Application for IMS TM (Explicit).”
FREE_STORAGE: PROC; CALL TDFREE (GWL_PROC, GWL_RC); IF GWL_RC ^= 0 THEN DO; CALL_NAME = ‘TDFREE ‘; CALL_MSG = ‘ERROR IN CALL RC=’; CALL_RC = GWL_RC; PUT FILE(SYSPRINT) DATA(ERROR_MSG); END; CALL TDTERM (GWL_INIT_HANDLE, GWL_RC); IF GWL_RC ^= 0 THEN DO; CALL_NAME = ‘TDTERM ‘; CALL_MSG = ‘ERROR IN CALL RC=’; CALL_RC = GWL_RC; PUT FILE(SYSPRINT) DATA(ERROR_MSG); END; END FREE_STORAGE;
An application calls this function to clean up and deallocate the TDPROC structure defined for this connection in TDACCEPT (For TCP/IP applications, this closes the socket).
TDFREE does not free up the IHANDLE.
Under CICS: the IHANDLE is automatically freed when the transaction ends.
Under IMS TM and MVS: the transaction must call TDTERM to free the IHANDLE.
Typically, a transaction calls TDFREE either at the end of a transaction or after TDRESULT returns TDS_CONNECTION_TERMINATED or TDS_CONNECTION_FAILED.
The last call in an IMS TM program after it processes all requests must be TDTERM. It frees all remaining resources, including the IHANDLE, in preparation for program termination. We strongly recommend ending all programs with a TDTERM call.
Related functions
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |