You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@locus.apache.org on 2000/10/09 08:46:49 UTC

cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

bjh         00/10/08 23:46:49

  Modified:    src/lib/apr/include apr_errno.h
               src/lib/apr/network_io/os2 os2calls.h
  Added:       src/lib/apr/network_io/os2 os2nerrno.h
  Log:
  Sort out OS/2 APR error handling with new canonical test macro.
  
  Revision  Changes    Path
  1.41      +5 -6      apache-2.0/src/lib/apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_errno.h,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- apr_errno.h	2000/10/06 17:08:27	1.40
  +++ apr_errno.h	2000/10/09 06:46:48	1.41
  @@ -347,16 +347,15 @@
   #endif
   
   
  -#if defined(OS2) /* endif !defined(WIN32) && !defined(OS2) */
  +#if defined(OS2)
   
  -/*  uhhh... I dunno
  - */
   #define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
   #define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
   
  -#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
  -#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
  -
  +#define INCL_DOSERRORS
  +#define INCL_DOS
  +#include <os2.h>
  +#include "../network_io/os2/os2nerrno.h"
   /* And this needs to be greped away for good:
    */
   #define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
  
  
  
  1.4       +1 -48     apache-2.0/src/lib/apr/network_io/os2/os2calls.h
  
  Index: os2calls.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/os2calls.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- os2calls.h	2000/03/31 08:36:12	1.3
  +++ os2calls.h	2000/10/09 06:46:49	1.4
  @@ -54,6 +54,7 @@
   
   #include <sys/types.h>
   #include <sys/socket.h>
  +#include "os2nerrno.h"
   
   extern int (*apr_os2_socket)(int, int, int);
   extern int (*apr_os2_select)(int *, int, int, int, long);
  @@ -90,51 +91,3 @@
   #define shutdown apr_os2_shutdown
   #define soclose apr_os2_soclose
   #define writev apr_os2_writev
  -
  -
  -/* Error codes returned by above calls */
  -#define SOCBASEERR              10000
  -
  -#define SOCEPERM                (SOCBASEERR+1)             /* Not owner */
  -#define SOCESRCH                (SOCBASEERR+3)             /* No such process */
  -#define SOCEINTR                (SOCBASEERR+4)             /* Interrupted system call */
  -#define SOCENXIO                (SOCBASEERR+6)             /* No such device or address */
  -#define SOCEBADF                (SOCBASEERR+9)             /* Bad file number */
  -#define SOCEACCES               (SOCBASEERR+13)            /* Permission denied */
  -#define SOCEFAULT               (SOCBASEERR+14)            /* Bad address */
  -#define SOCEINVAL               (SOCBASEERR+22)            /* Invalid argument */
  -#define SOCEMFILE               (SOCBASEERR+24)            /* Too many open files */
  -#define SOCEPIPE                (SOCBASEERR+32)            /* Broken pipe */
  -#define SOCEOS2ERR              (SOCBASEERR+100)           /* OS/2 Error */
  -#define SOCEWOULDBLOCK          (SOCBASEERR+35)            /* Operation would block */
  -#define SOCEINPROGRESS          (SOCBASEERR+36)            /* Operation now in progress */
  -#define SOCEALREADY             (SOCBASEERR+37)            /* Operation already in progress */
  -#define SOCENOTSOCK             (SOCBASEERR+38)            /* Socket operation on non-socket */
  -#define SOCEDESTADDRREQ         (SOCBASEERR+39)            /* Destination address required */
  -#define SOCEMSGSIZE             (SOCBASEERR+40)            /* Message too long */
  -#define SOCEPROTOTYPE           (SOCBASEERR+41)            /* Protocol wrong type for socket */
  -#define SOCENOPROTOOPT          (SOCBASEERR+42)            /* Protocol not available */
  -#define SOCEPROTONOSUPPORT      (SOCBASEERR+43)            /* Protocol not supported */
  -#define SOCESOCKTNOSUPPORT      (SOCBASEERR+44)            /* Socket type not supported */
  -#define SOCEOPNOTSUPP           (SOCBASEERR+45)            /* Operation not supported on socket */
  -#define SOCEPFNOSUPPORT         (SOCBASEERR+46)            /* Protocol family not supported */
  -#define SOCEAFNOSUPPORT         (SOCBASEERR+47)            /* Address family not supported by protocol family */
  -#define SOCEADDRINUSE           (SOCBASEERR+48)            /* Address already in use */
  -#define SOCEADDRNOTAVAIL        (SOCBASEERR+49)            /* Can't assign requested address */
  -#define SOCENETDOWN             (SOCBASEERR+50)            /* Network is down */
  -#define SOCENETUNREACH          (SOCBASEERR+51)            /* Network is unreachable */
  -#define SOCENETRESET            (SOCBASEERR+52)            /* Network dropped connection on reset */
  -#define SOCECONNABORTED         (SOCBASEERR+53)            /* Software caused connection abort */
  -#define SOCECONNRESET           (SOCBASEERR+54)            /* Connection reset by peer */
  -#define SOCENOBUFS              (SOCBASEERR+55)            /* No buffer space available */
  -#define SOCEISCONN              (SOCBASEERR+56)            /* Socket is already connected */
  -#define SOCENOTCONN             (SOCBASEERR+57)            /* Socket is not connected */
  -#define SOCESHUTDOWN            (SOCBASEERR+58)            /* Can't send after socket shutdown */
  -#define SOCETOOMANYREFS         (SOCBASEERR+59)            /* Too many references: can't splice */
  -#define SOCETIMEDOUT            (SOCBASEERR+60)            /* Connection timed out */
  -#define SOCECONNREFUSED         (SOCBASEERR+61)            /* Connection refused */
  -#define SOCELOOP                (SOCBASEERR+62)            /* Too many levels of symbolic links */
  -#define SOCENAMETOOLONG         (SOCBASEERR+63)            /* File name too long */
  -#define SOCEHOSTDOWN            (SOCBASEERR+64)            /* Host is down */
  -#define SOCEHOSTUNREACH         (SOCBASEERR+65)            /* No route to host */
  -#define SOCENOTEMPTY            (SOCBASEERR+66)            /* Directory not empty */
  
  
  
  1.1                  apache-2.0/src/lib/apr/network_io/os2/os2nerrno.h
  
  Index: os2nerrno.h
  ===================================================================
  #ifndef __OS2NERRNO_H
  #define __OS2NERRNO_H
  
  /* Error codes returned by above calls */
  #define SOCBASEERR              10000
  
  #define SOCEPERM                (SOCBASEERR+1)             /* Not owner */
  #define SOCESRCH                (SOCBASEERR+3)             /* No such process */
  #define SOCEINTR                (SOCBASEERR+4)             /* Interrupted system call */
  #define SOCENXIO                (SOCBASEERR+6)             /* No such device or address */
  #define SOCEBADF                (SOCBASEERR+9)             /* Bad file number */
  #define SOCEACCES               (SOCBASEERR+13)            /* Permission denied */
  #define SOCEFAULT               (SOCBASEERR+14)            /* Bad address */
  #define SOCEINVAL               (SOCBASEERR+22)            /* Invalid argument */
  #define SOCEMFILE               (SOCBASEERR+24)            /* Too many open files */
  #define SOCEPIPE                (SOCBASEERR+32)            /* Broken pipe */
  #define SOCEOS2ERR              (SOCBASEERR+100)           /* OS/2 Error */
  #define SOCEWOULDBLOCK          (SOCBASEERR+35)            /* Operation would block */
  #define SOCEINPROGRESS          (SOCBASEERR+36)            /* Operation now in progress */
  #define SOCEALREADY             (SOCBASEERR+37)            /* Operation already in progress */
  #define SOCENOTSOCK             (SOCBASEERR+38)            /* Socket operation on non-socket */
  #define SOCEDESTADDRREQ         (SOCBASEERR+39)            /* Destination address required */
  #define SOCEMSGSIZE             (SOCBASEERR+40)            /* Message too long */
  #define SOCEPROTOTYPE           (SOCBASEERR+41)            /* Protocol wrong type for socket */
  #define SOCENOPROTOOPT          (SOCBASEERR+42)            /* Protocol not available */
  #define SOCEPROTONOSUPPORT      (SOCBASEERR+43)            /* Protocol not supported */
  #define SOCESOCKTNOSUPPORT      (SOCBASEERR+44)            /* Socket type not supported */
  #define SOCEOPNOTSUPP           (SOCBASEERR+45)            /* Operation not supported on socket */
  #define SOCEPFNOSUPPORT         (SOCBASEERR+46)            /* Protocol family not supported */
  #define SOCEAFNOSUPPORT         (SOCBASEERR+47)            /* Address family not supported by protocol family */
  #define SOCEADDRINUSE           (SOCBASEERR+48)            /* Address already in use */
  #define SOCEADDRNOTAVAIL        (SOCBASEERR+49)            /* Can't assign requested address */
  #define SOCENETDOWN             (SOCBASEERR+50)            /* Network is down */
  #define SOCENETUNREACH          (SOCBASEERR+51)            /* Network is unreachable */
  #define SOCENETRESET            (SOCBASEERR+52)            /* Network dropped connection on reset */
  #define SOCECONNABORTED         (SOCBASEERR+53)            /* Software caused connection abort */
  #define SOCECONNRESET           (SOCBASEERR+54)            /* Connection reset by peer */
  #define SOCENOBUFS              (SOCBASEERR+55)            /* No buffer space available */
  #define SOCEISCONN              (SOCBASEERR+56)            /* Socket is already connected */
  #define SOCENOTCONN             (SOCBASEERR+57)            /* Socket is not connected */
  #define SOCESHUTDOWN            (SOCBASEERR+58)            /* Can't send after socket shutdown */
  #define SOCETOOMANYREFS         (SOCBASEERR+59)            /* Too many references: can't splice */
  #define SOCETIMEDOUT            (SOCBASEERR+60)            /* Connection timed out */
  #define SOCECONNREFUSED         (SOCBASEERR+61)            /* Connection refused */
  #define SOCELOOP                (SOCBASEERR+62)            /* Too many levels of symbolic links */
  #define SOCENAMETOOLONG         (SOCBASEERR+63)            /* File name too long */
  #define SOCEHOSTDOWN            (SOCBASEERR+64)            /* Host is down */
  #define SOCEHOSTUNREACH         (SOCBASEERR+65)            /* No route to host */
  #define SOCENOTEMPTY            (SOCBASEERR+66)            /* Directory not empty */
  
  #endif
  
  
  

RE: cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
> They may be macros or functions, depending.  I'd guess:
> >
> >   #define apr_get_os_error()    (errno)
> >   #define apr_set_os_error(e)   (errno = (e))
> >   #define apr_get_netos_error() (APR_FROM_OS_ERROR(sock_errno()))
> >
> >would be appropriate for OS2?
> 
> There is no equivalent. All OS/2 API calls return their error codes
> directly, there's no global variable that holds the last error code (the
> socket functions are an exception to this rule as they're a direct port
> from BSD). I personally see such globals as bad and I don't think I'm alone
> in that which is why APR works in the same way as OS/2 API calls. Every
> apr_* function returns its error code directly.

After I wrote that message... I spent some time in the OS2 tree (and fell in
the TPF tree as well.)  And after thinking about this...

No later than Release Candidiate 1 (post beta) - these macros should become 
apr internal handlers.  Client code (Apache) should not be playing with the 
errno it doesn't understand.  This might not be realistic for the MPM's if
they can't (shouldn't) be apr-ized.  But good design says that APR -already- 
created all the errors, not Apache.  And if they aren't used, they can be
dumped.

As far as the OS/2 flavors of apr_get_os_error() and apr_set_os_error(), 
this would be fun:

#define apr_get_os_error()    (\
#error Fatal assumption in __LINE__ of __FILE__, that we support apr_get_os_error\
}

But I doubt it would compile the way I expect.

> >Of course you can suggest I'm out of my mind trying to
> >introduce this sort of portability.
> 
> I wouldn't go that far :) but I don't understand what you're trying to
> achieve.
> 
> If you're wanting to be able to use the generic unix code on Win32 I think
> these macros aren't necessary. The problem there was the incompatible error
> code mapping which I think you've already fixed. It might help if you post
> a patch showing what you intend to do to the unix code. 

I was trying to distill errno / APR_FROM_OS_ERROR(WSAGetLastError()) and, I
suppose, APR_OS2_ERROR(sock_error()) into a single readable format.  It may
never be used on unix and could be deleted soon at the end of the alpha
series, this just assured I could build upon some ideas.  Right now the only
applications of apr_xxxos_error are within src/lib/apr/xxx/win32/, 
src/modules/mpm/winnt and src/os/mod_isapi.c  That may not change at all,
and these symbols can then go away.  But we have many errno symbols throughout
Apache, and these hurt OS2 as well as Win32.




RE: cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Mon, 9 Oct 2000 08:32:56 -0500, William A. Rowe, Jr. wrote:

>Questions
>
>> From: bjh@locus.apache.org [mailto:bjh@locus.apache.org]
>> Sent: Monday, October 09, 2000 1:47 AM
>> 
>> bjh         00/10/08 23:46:49
>> 
>>   Modified:    src/lib/apr/include apr_errno.h
>> 
>>   -#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
>>   -#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
>
>Please see the default case (errno) and Win32, and invent something
>appropriate here.  These should be defined on all platforms.  Since
>Win32 (and perhaps others) won't support lhs assignment, but we are
>trying very hard to share code in the unix tree, this is a very simple 
>wrapper.  They may be macros or functions, depending.  I'd guess:
>
>   #define apr_get_os_error()    (errno)
>   #define apr_set_os_error(e)   (errno = (e))
>   #define apr_get_netos_error() (APR_FROM_OS_ERROR(sock_errno()))
>
>would be appropriate for OS2?

There is no equivalent. All OS/2 API calls return their error codes
directly, there's no global variable that holds the last error code (the
socket functions are an exception to this rule as they're a direct port
from BSD). I personally see such globals as bad and I don't think I'm alone
in that which is why APR works in the same way as OS/2 API calls. Every
apr_* function returns its error code directly.



>I missed that late breaking detail, apr_get_netos_err(), which should
>be a wrapper for socket errors.  The neat trick to these macros is that 
>we can trust them to move an apr_ system error in or out of the platform
>errno or similar.  Of course, I doubt there are set actions for the socket
>WSAGetLastError() or sock_errno() functions.
>
>The cool thing about apr_get_netos_error() is that it's declared for
>Unix, and could make big chunks of the MPMs more legible where they are 
>shared by OS2.  Of course you can suggest I'm out of my mind trying to
>introduce this sort of portability.

I wouldn't go that far :) but I don't understand what you're trying to
achieve.

If you're wanting to be able to use the generic unix code on Win32 I think
these macros aren't necessary. The problem there was the incompatible error
code mapping which I think you've already fixed. It might help if you post
a patch showing what you intend to do to the unix code.

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


RE: cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Footnote

>  #define apr_get_os_error()    (errno)
>  #define apr_set_os_error(e)   (errno = (e))
>  
> +/* A special case to share sock error handling: */
> +#ifdef TPF
> +#define apr_get_netos_error()    (sock_errno())
> +#else
> +#define apr_get_netos_error()    (errno)
> +#endif

I am not married to any symbol names.  These made sense when I was
cleaning.  apr_get_sock_error() makes more sense in retrospect.

RE: cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Brian (and others)...  before you blast apr_get/set_os_error

would this make more sense?

Index: apr_errno.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_errno.h,v
retrieving revision 1.41
diff -u -r1.41 apr_errno.h
--- apr_errno.h	2000/10/09 06:46:48	1.41
+++ apr_errno.h	2000/10/09 13:48:35
.
.This is the OS2 case:
.
@@ -356,6 +356,13 @@
 #define INCL_DOS
 #include <os2.h>
 #include "../network_io/os2/os2nerrno.h"
+
+#define apr_get_os_error()   (errno)
+#define apr_set_os_error(e)  (errno)
+
+/* A special case to share sock error handling: */
+#define apr_get_netos_error() (APR_FROM_OS_ERROR(sock_errno()))
+
 /* And this needs to be greped away for good:
  */
 #define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
.
.This is the WIN32 case:
.
@@ -444,8 +451,7 @@
 #define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
 #define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
 
-/* A special case, only Win32 winsock calls require this:
- */
+/* A special case to share sock error handling: */
 #define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
 
 #define APR_STATUS_IS_SUCCESS           ((s) == APR_SUCCESS \
.
.This could be the unix (TPF) case 
.
@@ -504,6 +510,12 @@
 #define apr_get_os_error()    (errno)
 #define apr_set_os_error(e)   (errno = (e))
 
+/* A special case to share sock error handling: */
+#ifdef TPF
+#define apr_get_netos_error()    (sock_errno())
+#else
+#define apr_get_netos_error()    (errno)
+#endif
 #define APR_STATUS_IS_SUCCESS           ((s) == APR_SUCCESS)
 
 /* APR CANONICAL ERROR TESTS */

RE: cvs commit: apache-2.0/src/lib/apr/network_io/os2 os2nerrno.h os2calls.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Questions

> From: bjh@locus.apache.org [mailto:bjh@locus.apache.org]
> Sent: Monday, October 09, 2000 1:47 AM
> 
> bjh         00/10/08 23:46:49
> 
>   Modified:    src/lib/apr/include apr_errno.h
> 
>   -#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
>   -#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))

Please see the default case (errno) and Win32, and invent something
appropriate here.  These should be defined on all platforms.  Since
Win32 (and perhaps others) won't support lhs assignment, but we are
trying very hard to share code in the unix tree, this is a very simple 
wrapper.  They may be macros or functions, depending.  I'd guess:

   #define apr_get_os_error()    (errno)
   #define apr_set_os_error(e)   (errno = (e))
   #define apr_get_netos_error() (APR_FROM_OS_ERROR(sock_errno()))

would be appropriate for OS2?

I missed that late breaking detail, apr_get_netos_err(), which should
be a wrapper for socket errors.  The neat trick to these macros is that 
we can trust them to move an apr_ system error in or out of the platform
errno or similar.  Of course, I doubt there are set actions for the socket
WSAGetLastError() or sock_errno() functions.

The cool thing about apr_get_netos_error() is that it's declared for
Unix, and could make big chunks of the MPMs more legible where they are 
shared by OS2.  Of course you can suggest I'm out of my mind trying to
introduce this sort of portability.

>   +#define INCL_DOSERRORS
>   +#define INCL_DOS
>   +#include <os2.h>
>   +#include "../network_io/os2/os2nerrno.h"

Ok... I follow this, cool.