Deallocate a CS_CONNECTION structure.
CS_RETCODE ct_con_drop(connection)
CS_CONNECTION *connection;
A pointer to a CS_CONNECTION structure. A CS_CONNECTION structure contains information about a particular client/server connection.
ct_con_drop returns the following values:
Return value |
Meaning |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
CS_BUSY |
An asynchronous operation is already pending for this connection. See “Asynchronous programming”. |
The most common reason for a ct_con_drop failure is that the connection is still open.
/* ex_con_cleanup() */
CS_RETCODE CS_PUBLIC
ex_con_cleanup(connection, status)
CS_CONNECTION *connection;
CS_RETCODE status;
{
CS_RETCODE retcode;
CS_INT close_option;
/* Close connection */
...CODE DELETED.....
retcode = ct_con_drop(connection);
if (retcode != CS_SUCCEED)
{
ex_error("ex_con_cleanup: ct_con_drop()
failed");
return retcode;
}
return retcode;
}
This code excerpt is from the exutils.c sample program.
When a CS_CONNECTION structure is deallocated, all CS_COMMAND structures associated with it are deallocated.
A CS_CONNECTION structure contains information about a particular client/server connection.
Once a CS_CONNECTION has been deallocated, it cannot be reused. To allocate a new CS_CONNECTION, an application can call ct_con_alloc.
An application cannot deallocate a CS_CONNECTION structure until the connection it represents is closed. To close a connection, an application can call ct_close.
A connection can become unusable due to error. If this occurs, Client-Library marks the connection as “dead.” An application can use the CS_CON_STATUS property to determine if a connection has been marked dead.
If a connection has been marked dead, an application must call ct_close(CS_FORCE_CLOSE) to close the connection and ct_con_drop to drop its CS_CONNECTION structure.
An exception to this rule occurs for certain types of results-processing errors. If a connection is marked dead while processing results, the application can try calling ct_cancel(CS_CANCEL_ALL or CS_CANCEL_ATTN) to revive the connection. If this fails, the application must close the connection and drop its CS_CONNECTION structure.