Skip to Content.
Sympa Menu

freetds - Re: network unreachable with freetds

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: network unreachable with freetds
  • Date: Thu, 8 Aug 2002 23:03:37 -0400 (EDT)


James,

Instead of dumping to stderr which might not be desirable in some
applications (PHP for instance) is it possible to use tds_client_msg() to
alert the upper layer app of the problem?

I've just checked in all my changes for the connectionless client message
handling stuff-thing-whatchamacallit. So we should be all set here
whether we have a socket allocated at this time or not.

Bill, we should be able to fix all the convert errors now, sorry it took
so long.

Brian

On 9 Aug 2002, James Cameron wrote:

> I'm yet to understand exactly how Casey's environment led to a failure
> to report hostname resolution followed by a bogus IP address being used
> ... I've asked them for more detail.
>
> On Fri, 2002-08-09 at 09:09, Brian Bruns wrote:
> > I'm going to take part of the blame for this as well. Our reporting of
> > hostname resolution problems needs to be much better. I'm not sure when
> > I
> > can get to rolling up a patch, anyone else up for it?
>
> I've changed the code to report the failure of gethostbyname() to stderr
> and the TDSDUMP log. Here are the changes I'm proposing. I haven't
> committed them yet. Could I have a review please?
>
> diff -u -r1.108 ChangeLog
> --- ChangeLog 8 Aug 2002 04:33:55 -0000 1.108
> +++ ChangeLog 9 Aug 2002 01:57:16 -0000
> @@ -1,3 +1,12 @@
> +Fri Aug 9 11:56:01 2002 James Cameron <quozl AT us.netrek.org>
> +
> + * src/tds/config.c (lookup_host): report failure of
> gethostbyname
> + to stderr and TDSDUMP log, and return a null string as result.
> +
> + * src/tds/threadsafe.c (tds_gethostbyname_r): adjust the
> + non-reentrant version of the code to return h_errno now that it
> is
> + required by lookup_host().
> +
> Thu Aug 8 00:13:30 EDT 2002 JK Lowden <jklowden AT schemamania.org>
> + include/tds.h.in tdsmoney now a union of TDS_INT8 and
> TDS_OLD_MONEY
> + src/tds/convert.c reinstituted numeric-based money
> handling.
>
>
>
> diff -u -r1.18 config.c
> --- src/tds/config.c 7 Jul 2002 04:33:15 -0000 1.18
> +++ src/tds/config.c 9 Aug 2002 01:57:30 -0000
> @@ -569,8 +569,32 @@
> This call take a while and is useless for an ip address.
> mlilback 3/2/02 */
> ip_addr = inet_addr(servername);
> - if (ip_addr == INADDR_NONE)
> + if (ip_addr == INADDR_NONE) {
> host = tds_gethostbyname_r(servername, &result, buffer, buflen,
> &h_errnop);
> + /* check result of gethostbyname and propogate any failure */
> + if (host == NULL) {
> + char *reason = "unknown";
> + switch (h_errnop) {
> + case HOST_NOT_FOUND:
> + reason = "specified name is unknown";
> + break;
> + case NO_ADDRESS:
> + case NO_DATA:
> + reason = "name is valid but has no IP address";
> + break;
> + case NO_RECOVERY:
> + reason = "non-recoverable name server error occurred";
> + break;
> + case TRY_AGAIN:
> + reason = "temporary error on authoritative name server";
> + break;
> + }
> + fprintf(stderr, "src/tds/config.c: lookup_host: gethostbyname:
> %s, %s\n", servername, rea
> son);
> + tdsdump_log(TDS_DBG_ERROR, "%L gethostbyname(%s) failed with
> \"%s\".\n",servername,reaso
> n);
> + ip[0] = '\0';
> + return;
> + }
> + }
>
> #ifndef NOREVERSELOOKUPS
> /* froy AT singleentry.com 12/21/2000 */
>
>
>
>
> diff -u -r1.5 threadsafe.c
> --- src/tds/threadsafe.c 9 Jul 2002 01:55:05 -0000 1.5
> +++ src/tds/threadsafe.c 9 Aug 2002 01:57:45 -0000
> @@ -78,8 +78,10 @@
> tds_gethostbyname_r(const char *servername, struct hostent *result,
> char *buffer, int buflen, int
> *h_errnop)
> {
> #ifndef _REENTRANT
> - return gethostbyname(servername);
> -
> + extern int h_errno;
> + struct hostent *result = gethostbyname(servername);
> + h_errnop = &h_errno;
> + return result;
> #else
>
> #if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
>
>
>





Archive powered by MHonArc 2.6.24.

Top of Page