Re: [HACKERS] Proposed patch to getaddrinfo.c to support - Mailing list pgsql-patches

From Petr Jelinek
Subject Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Date
Msg-id 430D9266.1080101@seznam.cz
Whole thread Raw
In response to Re: [HACKERS] Proposed patch to getaddrinfo.c to support  ("Dave Page" <dpage@vale-housing.co.uk>)
Responses Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Re: [HACKERS] Proposed patch to getaddrinfo.c to support
List pgsql-patches
Dave Page wrote:
> It, or some related patch appears to have broken the build on buildfarm member snake.
>
> I haven't had time to  investigate.
>
> /D

Atached patch fixes it and also adds proper gai_strerror for windows.
(It's patch against CVS *after* Chucks patch was aplied)

--
Regards
Petr Jelinek (PJMODOS)
Index: src/include/getaddrinfo.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/getaddrinfo.h,v
retrieving revision 1.15
diff -c -r1.15 getaddrinfo.h
*** src/include/getaddrinfo.h    27 Jul 2005 12:44:10 -0000    1.15
--- src/include/getaddrinfo.h    25 Aug 2005 09:39:09 -0000
***************
*** 30,35 ****
--- 30,46 ----

  /* Various macros that ought to be in <netdb.h>, but might not be */

+ #ifdef WIN32
+ #define EAI_AGAIN    WSATRY_AGAIN
+ #define EAI_BADFLAGS    WSAEINVAL
+ #define EAI_FAIL    WSANO_RECOVERY
+ #define EAI_FAMILY    WSAEAFNOSUPPORT
+ #define EAI_MEMORY    WSA_NOT_ENOUGH_MEMORY
+ #define EAI_NODATA    WSANO_DATA
+ #define EAI_NONAME    WSAHOST_NOT_FOUND
+ #define EAI_SERVICE    WSATYPE_NOT_FOUND
+ #define EAI_SOCKTYPE    WSAESOCKTNOSUPPORT
+ #else
  #ifndef EAI_FAIL
  #define EAI_BADFLAGS    (-1)
  #define EAI_NONAME        (-2)
***************
*** 40,46 ****
  #define EAI_SERVICE        (-8)
  #define EAI_MEMORY        (-10)
  #define EAI_SYSTEM        (-11)
! #endif

  #ifndef AI_PASSIVE
  #define AI_PASSIVE        0x0001
--- 51,58 ----
  #define EAI_SERVICE        (-8)
  #define EAI_MEMORY        (-10)
  #define EAI_SYSTEM        (-11)
! #endif /* !EAI_FAIL */
! #endif /* !WIN32 */

  #ifndef AI_PASSIVE
  #define AI_PASSIVE        0x0001
Index: src/port/getaddrinfo.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/port/getaddrinfo.c,v
retrieving revision 1.18
diff -c -r1.18 getaddrinfo.c
*** src/port/getaddrinfo.c    24 Aug 2005 22:13:23 -0000    1.18
--- src/port/getaddrinfo.c    25 Aug 2005 09:39:25 -0000
***************
*** 104,110 ****
          /* We found a dll, so now get the addresses of the routines */

          getaddrinfo_ptr = GetProcAddress(hLibrary, "getaddrinfo");
!         freeaddrinfo_ptr = GetProcAddress(hLibrary, "freeaddrinfo");
          getnameinfo_ptr = GetProcAddress(hLibrary, "getnameinfo");

          /*
--- 104,110 ----
          /* We found a dll, so now get the addresses of the routines */

          getaddrinfo_ptr = GetProcAddress(hLibrary, "getaddrinfo");
!         freeaddrinfo_ptr = (freeaddrinfo_ptr_t)GetProcAddress(hLibrary, "freeaddrinfo");
          getnameinfo_ptr = GetProcAddress(hLibrary, "getnameinfo");

          /*
***************
*** 277,283 ****
           */
          if (haveNativeWindowsIPv6routines())
          {
!             (*freeaddrinfo_ptr) (node, service, hintp, res);
              return;
          }
  #endif
--- 277,283 ----
           */
          if (haveNativeWindowsIPv6routines())
          {
!             (*freeaddrinfo_ptr) (res);
              return;
          }
  #endif
***************
*** 292,298 ****
  const char *
  gai_strerror(int errcode)
  {
! #ifdef HAVE_HSTRERROR
      int            hcode;

      switch (errcode)
--- 292,298 ----
  const char *
  gai_strerror(int errcode)
  {
! #ifdef    HAVE_HSTRERROR
      int            hcode;

      switch (errcode)
***************
*** 318,323 ****
--- 318,336 ----
              return "Unknown host";
          case EAI_AGAIN:
              return "Host name lookup failure";
+         /* Errors below are probably WIN32 only */
+         case EAI_BADFLAGS:
+             return "Invalid argument";
+         case EAI_FAMILY:
+             return "Address family not supported";
+         case EAI_MEMORY:
+             return "Not enough memory";
+         case EAI_NODATA:
+             return "No host data of that type was found";
+         case EAI_SERVICE:
+             return "Class type not found";
+         case EAI_SOCKTYPE:
+             return "Socket type not supported";
          case EAI_FAIL:
          default:
              return "Unknown server error";

pgsql-patches by date:

Previous
From: "Dave Page"
Date:
Subject: Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Next
From: "Ilia Kantor"
Date:
Subject: CRC32 function