freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Andrew Victor <avictor.za AT gmail.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] ct_cancel() issue
- Date: Tue, 12 Nov 2013 15:56:56 +0200
hi,
I'm busy updating an application from FreeTDS 0.82 to the latest
(0.91.96), and am running into an issue a change to the ct_cancel()
function.
The application is a long-running daemon that makes use of a
connection-pool of persistent connections to a MS-SQL server. Before
returning a connection back to the pool a ct_cancel(CS_CANCEL_ALL) is
issued to ensure that incomplete commands are terminated, and any
unread result-sets discarded - ie, the server and connection are in a
"known" state.
With FreeTDS 0.91.96, the ct_cancel() call returns but the
"cancel_state" remains in _CS_CANCEL_PENDING state:
tds_send_cancel(conn->tds_socket);
tds_process_cancel(conn->tds_socket);
_ct_initialise_cmd(conn_cmd);
conn_cmd->cancel_state = _CS_CANCEL_PENDING;
Note: the other types of cs_cancel() don't call tds_process_cancel().
When the connection is later re-used from the pool, the subsequent
calls to ct_send() fails due to this code:
if (cmd->cancel_state == _CS_CANCEL_PENDING) {
_ct_cancel_cleanup(cmd);
return CS_CANCELED;
}
and _ct_cancel_cleanup() basically just calls:
tds_process_cancel(con->tds_socket);
Therefore tds_process_cancel() gets called twice, and the
"cancel_state" stays in _CS_CANCEL_PENDING state.
The change seems related to this post on the mailing-list:
https://lists.ibiblio.org/sympa/arc/freetds/2008q2/023233.html
and this commit:
https://gitorious.org/freetds/freetds/commit/96a34d413e02095a4c9c90a6a3936bd57f4d6073
Commenting the two lines:
conn_cmd->cancel_state = _CS_CANCEL_PENDING;
seems to solve the issue.
I did also try the latest git version.
Regards,
Andrew Victor
- [freetds] ct_cancel() issue, Andrew Victor, 11/12/2013
Archive powered by MHonArc 2.6.24.