Re: Connection timeout
"James K. Lowden" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
Suren A. Chilingaryan wrote: > > The FreeTDS library (src/tds/login.c, 'tds_connect' function) uses > 'connection->connect_timeout' to define timeout for tds_connect. This > 'connection->connect_timeout' is defined by FreeTDS configuration file > or by FreeTDS ODBC driver (src/odbc/odbc.c, 'odbc_connect' function). > > In the last case the 'dbc->attr.connection_timeout' is used. However, > 'connection_timeout' is actually related 'SQL_ATTR_CONNECTION_TIMEOUT' > ODBC connection attribute. > > From my point of view, the 'dbc->attr.login_timeout' (related to > 'SQL_ATTR_LOGIN_TIMEOUT') should be used instead. It's funny you should mention this just now, when I happen to be thinking about connecting and logging in. You seem to have identified an error, but IMO yours is not the correct fix. The trick is to distinguish in the code between connecting and logging in and use separate timeouts for each one. We have nowhere to store a login timeout; we have only connect timeout and query timeout (in TDSLOGIN). I would keep connect timeout for connections, and initially set query_timeout to be the login timeout. The login function could use that. Then, after logging in, reset query_timeout to its original configured value (taken from freetds.conf or the built-in 0). Or something like that. --jkl