Skip Menu |
 

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 76091
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: normw [...] gknw.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.021



Subject: Socket 2.00x and gai_strerror()
Date: Wed, 28 Mar 2012 07:05:44 +1000
To: bug-Socket [...] rt.cpan.org
From: NormW <normw [...] gknw.net>
Download (untitled) / with headers
text/plain 3.3k
Hi, This is NOT a bug report. It notes that at least one OS, NetWare, (maybe others?) does not have gai_strerr() while having getaddrinfo(). Attached a patch against Socket.xs 2.001 and described here: The segment beginning at line 45 inserts an external gai_strerror.c (see below for a sample source) and also disables the 2 'defines' if building with the later Novell LibC. The changes starting at line 368 are useful(?) only if it is found that other OS also lack gai_strerr(). It assumes Socket's Makefile.PL could test for it, but am unable to confirm as the Win miniperl.exe does not support dynamic module load and cannot (therefore) actually run the Makefile.PL. HTH, Norm Show quoted text
> --- Socket.xs.orig 2012-03-27 23:40:53.000000000 +1000 > +++ Socket.xs 2012-03-28 06:13:38.343750000 +1000 > @@ -45,9 +45,15 @@ > #endif > > #ifdef NETWARE > +/* NetWare needs external source for gai_strerror() */ > +#ifndef HAS_GAI_STRERROR > +# include "gai_strerror.c" > +#endif > +#ifndef __NOVELL_LIBC__ > NETDB_DEFINE_CONTEXT > NETINET_DEFINE_CONTEXT > #endif > +#endif > > #ifdef I_SYSUIO > # include <sys/uio.h> > @@ -368,8 +374,15 @@ > (void) SvUPGRADE(ret, SVt_PVNV); > > if(err) { > +#ifdef HAS_GAI_STRERROR > const char *error = gai_strerror(err); > sv_setpv(ret, error); > +#else > + /* Report a general getaddrinfo failure plus err */ > + char error = "An error occurred in getaddrinfo(). Error: XXXXXXX"; > + sprintf(&error + 43, "%d", err); > + sv_setpv(ret, &error); > +#endif > } > else { > sv_setpv(ret, "");
A sample gai_strerror.c: Show quoted text
> #if defined(HAS_GETADDRINFO) && !defined(HAS_GAI_STRERROR) > /* getaddrinfo() is available but not gai_strerror(). */ > #include <netdb.h> > > static const char *gai_strerror(int err); > > static const char *gai_strerror(int err) > { > switch (err) > { > #ifdef EAI_ADDRFAMILY > case EAI_ADDRFAMILY: > return "Address family for hostname is not supported."; > #endif > #ifdef EAI_AGAIN > case EAI_AGAIN: > return "The name could not be resolved at this time."; > #endif > #ifdef EAI_BADFLAGS > case EAI_BADFLAGS: > return "The flags parameter has an invalid value."; > #endif > #ifdef EAI_FAIL > case EAI_FAIL: > return "A non-recoverable error occurred while resolving the name."; > #endif > #ifdef EAI_FAMILY > case EAI_FAMILY: > return "The address family was not recognized or length is invalid."; > #endif > #ifdef EAI_MEMORY > case EAI_MEMORY: > return "A memory allocation failure occurred."; > #endif > #ifdef EAI_NODATA > case EAI_NODATA: > return "No address is associated with the hostname."; > #endif > #ifdef EAI_NONAME > case EAI_NONAME: > return "The name does not resolve for the supplied parameters."; > #endif > #ifdef EAI_OVERFLOW > case EAI_OVERFLOW: > return "An argument buffer overflowed."; > #endif > #ifdef EAI_SERVICE > case EAI_SERVICE: > return "The service parameter was not recognized for the specified socket type."; > #endif > #ifdef EAI_SOCKTYPE > case EAI_SOCKTYPE: > return "The specified socket type was not recognized."; > #endif > #ifdef EAI_SYSTEM > case EAI_SYSTEM: > return "A system error occurred - see errno."; > #endif > default: > return "Unknown error in getaddrinfo()."; > } > /* show now existing. */ > #define HAS_GAI_STRERROR 1 > } > #endif /* HAS_GETADDRINFO && ! HAS_GAI_STRERROR */
Download Socket.xs.diff
text/x-diff 797b

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 300b
On Tue Mar 27 17:06:12 2012, normw@gknw.net wrote: Show quoted text
> Hi, > This is NOT a bug report. It notes that at least one OS, NetWare, > (maybe > others?) does not have gai_strerr() while having getaddrinfo().
Been a while, but I got around to applying this. Or at least, some variant on it. -- Paul Evans
Subject: rt76091.patch
Download rt76091.patch
text/x-diff 2.9k
=== modified file 'Makefile.PL' --- Makefile.PL 2015-11-18 15:44:51 +0000 +++ Makefile.PL 2015-11-18 17:06:20 +0000 @@ -14,7 +14,7 @@ { my %args = @_; return if $ENV{PERL_CORE}; - return if defined $Config{$args{confkey}}; + return if defined $args{confkey} and defined $Config{$args{confkey}}; require ExtUtils::CBuilder; $cb ||= ExtUtils::CBuilder->new( quiet => 1 ); @@ -77,12 +77,13 @@ } my %defines = ( - # -Dfoo func() $Config{key} - HAS_GETADDRINFO => [ "getaddrinfo", "d_getaddrinfo" ], - HAS_GETNAMEINFO => [ "getnameinfo", "d_getnameinfo" ], - HAS_INET_ATON => [ "inet_aton", "d_inetaton" ], - HAS_INETNTOP => [ "inet_ntop", "d_inetntop" ], - HAS_INETPTON => [ "inet_pton", "d_inetpton" ], + # -Dfoo func() $Config{key} + HAS_GETADDRINFO => [ "getaddrinfo", "d_getaddrinfo" ], + HAS_GETNAMEINFO => [ "getnameinfo", "d_getnameinfo" ], + HAS_GAI_STRERROR => [ "gai_strerror" ], + HAS_INET_ATON => [ "inet_aton", "d_inetaton" ], + HAS_INETNTOP => [ "inet_ntop", "d_inetntop" ], + HAS_INETPTON => [ "inet_pton", "d_inetpton" ], ); foreach my $define ( sort keys %defines ) { === modified file 'Socket.xs' --- Socket.xs 2015-11-18 16:42:58 +0000 +++ Socket.xs 2015-11-18 17:06:20 +0000 @@ -473,6 +473,65 @@ #include "const-c.inc" +#if defined(HAS_GETADDRINFO) && !defined(HAS_GAI_STRERROR) +static const char *gai_strerror(int err) +{ + switch (err) + { +#ifdef EAI_ADDRFAMILY + case EAI_ADDRFAMILY: + return "Address family for hostname is not supported."; +#endif +#ifdef EAI_AGAIN + case EAI_AGAIN: + return "The name could not be resolved at this time."; +#endif +#ifdef EAI_BADFLAGS + case EAI_BADFLAGS: + return "The flags parameter has an invalid value."; +#endif +#ifdef EAI_FAIL + case EAI_FAIL: + return "A non-recoverable error occurred while resolving the name."; +#endif +#ifdef EAI_FAMILY + case EAI_FAMILY: + return "The address family was not recognized or length is invalid."; +#endif +#ifdef EAI_MEMORY + case EAI_MEMORY: + return "A memory allocation failure occurred."; +#endif +#ifdef EAI_NODATA + case EAI_NODATA: + return "No address is associated with the hostname."; +#endif +#ifdef EAI_NONAME + case EAI_NONAME: + return "The name does not resolve for the supplied parameters."; +#endif +#ifdef EAI_OVERFLOW + case EAI_OVERFLOW: + return "An argument buffer overflowed."; +#endif +#ifdef EAI_SERVICE + case EAI_SERVICE: + return "The service parameter was not recognized for the specified socket type."; +#endif +#ifdef EAI_SOCKTYPE + case EAI_SOCKTYPE: + return "The specified socket type was not recognized."; +#endif +#ifdef EAI_SYSTEM + case EAI_SYSTEM: + return "A system error occurred - see errno."; +#endif + default: + return "Unknown error in getaddrinfo()."; + } +} +#endif + #ifdef HAS_GETADDRINFO static SV *err_to_SV(pTHX_ int err) {
This was released in 2.021 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.