Skip to Content.
Sympa Menu

freetds - Proper procedure for logging in and out multiple times

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Coleman, Dave" <DColeman AT US.TIAuto.com>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: Proper procedure for logging in and out multiple times
  • Date: Wed, 3 Jul 2002 12:05:51 -0400


I have an application using the freetds C-API that needs to have a
non-persistant connection to a MS-SQL 7.0 Server. I have configured freetds
to use TDS v4.2, and I have tried both version 0.53 and the latest snapshot.

This application is a manufacturing systems control program and it must use
a non-persistant connection, as machine operators can shut power off at any
time (no, they really shouldn't, but they do), orphaning open connections to
the SQL server. Using the code examples in the unittest directory, I
constructed a package with non-persistant behaviour for this purpose. I
have been experiencing a memory leak with my application, however; and after
careful and thorough debugging traced it back to the tds_login(),
tds_connect(), tds_free_socket(), tds_free_login() function group.

I modified t0001.c to log in and out multiple times.

This is the main() function from my modified unit test.

int main()
{
TDSLOGIN *login;
TDSSOCKET *tds;
int ret;
int verbose = 0;
int i = 0;
while( i++<1000 )
{
fprintf(stdout, "%s: Testing login, logout\n", __FILE__);
ret = try_tds_login(&login, &tds, __FILE__, verbose);
if( ret != TDS_SUCCEED )
{
fprintf(stderr, "try_tds_login() failed\n");
return 1;
}

try_tds_logout(login, tds, verbose);
}
return 0;
}

Is there some clean-up call that I need to make for this code to be
re-usable? The unit test code leaks exactly the same memory as my
application. I have verified my own memory operations by commenting out the
freetds function calls in my object and running the same loop on my code,
new'ing and delet'ing every time. It doesn't leak.

Thank you in advance for your help,

Dave Coleman
Software Engineer
TI Automotive - Meriden, CT
dColeman AT us.tiauto.com






Archive powered by MHonArc 2.6.24.

Top of Page