Skip to Content.
Sympa Menu

freetds - [freetds] Setting ODBC timeouts

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Chris Reeves <csr2 AT st-andrews.ac.uk>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Setting ODBC timeouts
  • Date: Fri, 15 Aug 2008 17:28:45 +0100
  • Resent-date: Mon, 18 Aug 2008 14:24:17 +0100
  • Resent-date: Mon, 18 Aug 2008 14:24:17 +0100
  • Resent-from: csr2 AT st-andrews.ac.uk
  • Resent-to: freetds AT lists.ibiblio.org

Hi all,

I have been trying to set login and connection timeouts using the tdsodbc
driver, without too much success. After reading many of the threads regarding
timeouts (particularly the one around January 2007) I upgraded from 0.63-3.2
(Debian etch package) to 0.82-4 (Debian lenny package). The code in question
works correctly when there is no interruption in the connection, but I am
currently testing cases where there is an interruption.

I set the SQL_ATTR_LOGIN_TIMEOUT and SQL_ATTR_CONNECTION_TIMEOUT attributes
using SQLSetConnectAttr and later calls to SQLGetConnectAttr suggest that
these attributes have indeed been changed. Despite this, no matter what I set
these two attributes to, the login always takes 40 seconds to time out and the
connection timeout appears to be 'infinite'. The timeouts in
/etc/freetds/freetds.conf are both set to 1. The code I'm using runs along the
following lines (but with additional error checking included - all calls
return SQL_SUCCESS).

/// Begin code excerpt

SQLUINTEGER currTimeout = 0;
SQLGetConnectAttr(connHandle, SQL_ATTR_LOGIN_TIMEOUT, &currTimeout, 0, NULL);
std::cout << "Current login timeout is: " << currTimeout << std::endl;
SQLGetConnectAttr(connHandle, SQL_ATTR_CONNECTION_TIMEOUT, &currTimeout, 0,
NULL);
std::cout << "Current connect timeout is: " << currTimeout << std::endl;

SQLUINTEGER timeout = 30;
SQLSetConnectAttr(connHandle, SQL_ATTR_LOGIN_TIMEOUT, (void*)timeout, 0);
SQLGetConnectAttr(connHandle, SQL_ATTR_LOGIN_TIMEOUT, &currTimeout, 0, NULL);
std::cout << "Current login timeout is: " << currTimeout << std::endl;

SQLConnect(connHandle, DSN, SQL_NTS, user, SQL_NTS, pass, SQL_NTS);

SQLSetConnectAttr(connHandle, SQL_ATTR_CONNECTION_TIMEOUT, (void*)timeout, 0);
SQLGetConnectAttr(connHandle, SQL_ATTR_CONNECTION_TIMEOUT, &currTimeout, 0,
NULL);
std::cout << "Current connect timeout is: " << currTimeout << std::endl;

/// End code excerpt

/// Begin sample output

Current login timeout is: 15
Current connect timeout is: 0
Current login timeout is: 10
Current connect timeout is: 10

/// End sample output

Based upon the mailing list threads, I had expected the timeouts in the
latest
version of freetds to correspond to those set - if not directly, then as some
multiple of these. Can anyone suggest what I may be doing wrong here?

Thanks in advance for your help,
Chris




Archive powered by MHonArc 2.6.24.

Top of Page