Skip to Content.
Sympa Menu

freetds - Re: error handling

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT umcc.ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: error handling
  • Date: Mon, 24 Jan 2000 07:47:30 -0500 (EST)



Take a look at the tds_client_msg() function it does pretty much what you
want (we use it for results pending messages, which are client side only
messages). check token.c at line 909 or so for a sample invocation.

Brian

On Mon, 24 Jan 2000, Geoff Winkless wrote:

> Ok, here's a tricky one.
>
> I've implemented a check in read.c:tds_read_packet for a negative return
> from the read() function. This catches a disconnected socket correctly.
>
> I thus decided to send an error to the error handler - but since that
> expects a msg_info struct, (which we obviously don't get back from the
> server, since the server is disconnected!) I build one on the fly...
>
> So we have:
>
> if (len < 0) {
>
> /* now we need to pass a fake message back to the error handler. */
> tds->msg_info->msg_number = 10018; /* is there a define for this??? */
> tds->msg_info->message="The connection was closed";
> tds->msg_info->msg_state=0;
> tds->msg_info->msg_level=9;
> tds->msg_info->priv_msg_type = 0;
> tds->msg_info->server=NULL;
> tds->msg_info->proc_name=NULL;
> tds->msg_info->line_number = 0;
> if (tds->parent) {
> fprintf (stderr, "tds->parent is valid. Calling err_handler\n");
> g_tds_err_handler(tds->parent);
> } else {
> fprintf (stderr, "tds->parent is null\n");
> tds_free_msg(tds->msg_info);
> }
>
>
> Now I'm using dblib so g_tds_err_handler gets set to
> dblib_handle_err_message.
>
> If I gdb-break my program at the point above, I can do the following:
>
> (gdb) print dblib_handle_err_message
> $2 = {int (void *)} 0x4001571c <dblib_handle_err_message>
> (gdb) print g_tds_err_handler
> $3 = (int (*)()) 0x4001571c <dblib_handle_err_message>
>
> Now if I allow this call (g_tds_err_handler(tds->parent)) to continue the
> program SIGSEGVs - it appears to be calling some random address in data
> space.
>
> However if I call dblib_handle_err_message (tds->parent) instead, the
> program runs correctly.
>
> Any thoughts?
>
> Geoff
>
>





Archive powered by MHonArc 2.6.24.

Top of Page