Re: tds_connect does too much

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
ZIGLIO, Frediano, VF-IT wrote:
> 
> Mmm... tds_send_login is not that fine, perhaps it's better to rename
> tds_login structure to  _tds_login (cause we only use TDSLOGIN) and add
> a tds_login.

Good observation. s/tds_login/tds_login_t/g perhaps? 


> auto as protocol version, now tds_connect connect and disconnect 
> as it wants...

Does the server disconnect if the login fails?  If not, we can keep
re-trying login packets on the same connection.  

Otherwise, I imagine this (simplified):


	if ((conn = tds_connect()) == NULL)
		return tdserror();
	else
		tds_login();

and in tds_login():
	
	if (tdsver == 0) {
		for( i=0; i < maxver; i++ ) {
			tdsver = versions[i];
			int fOK = tds_login(tdsver);
			if( fOK )
				return fOK;

			if ((conn = tds_connect()) == NULL)
				return tdserror();
		}
	}
	if (i == maxver)
		return tdserror();

	/* call tdsX_send/do_login function  ... */

There are other ways, too, of course.  

Regards, 

--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.