Skip to Content.
Sympa Menu

freetds - Re: WARNING: Changing tds_connect() API

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: TDS Development Group <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: WARNING: Changing tds_connect() API
  • Date: Wed, 11 Sep 2002 22:17:49 -0400 (EDT)



On second look maybe we should simply do it like:

dbproc->tds_socket = tds_alloc_socket(g_dblib_ctx->tds_ctx, 512);
tds_set_parent(dbproc->tds_socket, (void *) dbproc);

if (tds_connect(login->tds_login, dbproc->tds_socket)==TDS_FAIL)
tds_free_socket(dbproc->tds_socket);

The only changes required to tds_connect is to

1) remove the context and parent arguments
2) add TDSSOCKET * argument
3) remove the calls to tds_alloc_socket and tds_set_parent from inside
4) reference tds->context instead of using the context argument
5) change the return of tds_connect to simple TDS_SUCCEED/TDS_FAIL

It adds very little work for the API, and simplifies tds_connect a bit.
Also, if we end up doing it this way, we should change the signature to
int tds_connect(TDSSOCKET *tds, TDSLOGIN *login) for consistancy (that is
put TDSSOCKET * as the first parameter like all the other functions).

Thoughts?

Brian

On Wed, 11 Sep 2002, Castellano, Nicholas wrote:

> I will be changing the API for tds_connect(). Currently, this function
> returns the TDSSOCKET * to its caller. However, in dblib we need this
> information in the dbproc before tds_connect() returns. When error or
> message handlers are invoked during login, the dbproc currently appears to
> be DBDEAD() since the socket is not set up. In the new scheme, tds_connect
> will take a TDSSOCKET ** parameter, and will fill in the new TDSSOCKET **
> when it has been connected to the database server.
>
> So instead of:
>
> dbproc->tds_socket = (void *) tds_connect(login->tds_login,
> g_dblib_ctx->tds_ctx, (void *)dbproc);
>
> We will now have:
>
> tds_connect(&(dbproc->tds_socket), login->tds_login, g_dblib_ctx->tds_ctx,
> (void *)dbproc);
>
> Of course all the other calls throughout the tree will be updated as well,
> to use the new API.
>
> I intend to commit this early tomorrow (along with a while bunch of other
> error/message handler fixes), unless there are any serious objections.
>
> Cheers,
> --nick
>





Archive powered by MHonArc 2.6.24.

Top of Page