Exit Client-Library.
CS_RETCODE ct_exit(context, option) CS_CONTEXT *context; CS_INT option;
A pointer to a CS_CONTEXT structure.
context identifies the Client-Library context being exited.
ct_exit can behave in different ways, depending on the value specified for option. The following symbolic values are legal for option:
Value of option |
Result |
---|---|
CS_UNUSED |
ct_exit closes all open connections for which no results are pending and terminates Client-Library for this context. If results are pending on one or more connections, ct_exit returns CS_FAIL and does not terminate Client-Library. |
CS_FORCE_EXIT |
ct_exit closes all open connections for this context, whether or not any results are pending, and terminates Client-Library for this context. |
To properly exit Client-Library, wait until all asynchronous operations are complete, then call ct_exit.
If an asynchronous operation is in progress when ct_exit is called, the routine returns CS_FAIL and does not exit Client-Library properly, even when CS_FORCE_EXIT is used.
ct_exit returns the following values:
Return value |
Meaning |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
/*
** ex_ctx_cleanup()
**
** Parameters:
** context Pointer to context structure.
** status Status of last interaction with Client-
** Library.
** If not ok, this routine will perform a
** force exit.
**
** Returns:
** Result of function calls from Client-Library.
*/
CS_RETCODE CS_PUBLIC
ex_ctx_cleanup(context, status)
CS_CONTEXT* context;
CS_RETCODE status;
{
CS_RETCODE retcode;
CS_INT exit_option;
exit_option = (status != CS_SUCCEED) ? CS_FORCE_EXIT :
CS_UNUSED;
retcode = ct_exit(context, exit_option);
if (retcode != CS_SUCCEED)
{
ex_error("ex_ctx_cleanup: ct_exit() failed");
return retcode;
}
retcode = cs_ctx_drop(context);
if (retcode != CS_SUCCEED)
{
ex_error("ex_ctx_cleanup: cs_ctx_drop() failed");
return retcode;
}
return retcode;
}
This code excerpt is from the exutils.c sample program.
ct_exit terminates Client-Library for a specific context. It closes all open connections, deallocates internal data space and cleans up any platform-specific initialization.
ct_exit must be the last Client-Library routine called within a Client-Library context.
If an application finds it needs to call Client-Library routines after it has called ct_exit, it can reinitialize Client-Library by calling ct_init again.
If results are pending on any of the context’s connections and option is not passed as CS_FORCE_EXIT, ct_exit returns CS_FAIL. This means that Client-Library is not correctly terminated and that the application must call ct_exit again after handling the pending results.
ct_exit always completes synchronously, even if asynchronous network I/O has been specified for any of the context’s connections.
An application can call ct_close to close a single connection.
If ct_init is called for a context, it is an error to deallocate the context before calling ct_exit.