Proper procedure for logging in and out multiple times

Brian Bruns camber at ais.org
Wed Jul 3 13:32:56 EDT 2002


I applied a patch with some mem leak cleanups in it yesterday...or the day
before.  Is your snapshot version older than that?

Brian

> 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



More information about the FreeTDS mailing list