You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Karl Fogel <kf...@newton.ch.collab.net> on 2002/08/14 19:18:56 UTC

[PATCH] expand apr error spaces

This patch expands the error ranges to hold 50,000 errors instead of
500, except for the USERERR range, which gets 500,000 to give apps a
lot of breathing room.

In Subversion, it was already clear that we were going to bump up
against the 500 limit eventually.  And if we're expanding, heck, we
might as well go all the way.

(APR was being extremely conservative with error ranges, when in fact
we've got plenty of room: apr_status_t is an `int', and as Greg Stein
just pointed out to me, we don't work on 16-bit int platforms anyway,
so the positive side of the 32-bit int range leaves us two billion
possible error codes.  This patch doesn't even come close to using
that up :-). )

Any objections if I commit this?


* apr/include/apr_errno.h 
  (APR_OS_ERRSPACE_SIZE): New #defined constant, init to 50000.

  (APR_OS_START_USERERR): New name for APR_OS_START_USEERR.  Leave the
  old name defined for compatibility, but mark as obsolete.

  (APR_OS_START_STATUS, APR_OS_START_USERERR, APR_OS_START_CANONERR,
  APR_OS_START_EAIERR, APR_OS_START_SYSERR): Expand ranges as per
  above, and give USERERR a range ten times larger than the others.

* apr/misc/unix/errorcodes.c 
  (apr_strerror): Adjust for the rename.


Index: include/apr_errno.h
===================================================================
RCS file: /home/cvs/apr/include/apr_errno.h,v
retrieving revision 1.94
diff -u -r1.94 apr_errno.h
--- include/apr_errno.h	4 Aug 2002 01:35:44 -0000	1.94
+++ include/apr_errno.h	14 Aug 2002 17:31:39 -0000
@@ -149,29 +149,44 @@
  */
 #define APR_OS_START_ERROR     20000
 /**
+ * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
+ *    into one of the error/status ranges below -- except for
+ *    APR_OS_START_USERERR, which see.
+ */
+#define APR_OS_ERRSPACE_SIZE 50000
+/**
  * APR_OS_START_STATUS is where the APR specific status codes start.
  */
-#define APR_OS_START_STATUS    (APR_OS_START_ERROR + 500)
+#define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
+/**
+ * APR_OS_START_USERERR are reserved for applications that use APR that
+ *     layer their own error codes along with APR's.  Note that the
+ *     error immediately following this one is set ten times farther
+ *     away than usual, so that users of apr have a lot of room in
+ *     which to declare custom error codes.
+ */
+#define APR_OS_START_USERERR    (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE)
 /**
- * APR_OS_START_USEERR are reserved for applications that use APR that
- *     layer their own error codes along with APR's.
+ * APR_OS_START_USEERR is obsolete, defined for compatibility only.
+ * Use APR_OS_START_USERERR instead.
  */
-#define APR_OS_START_USEERR    (APR_OS_START_STATUS + 500)
+#define APR_OS_START_USEERR     APR_OS_START_USERERR
 /**
  * APR_OS_START_CANONERR is where APR versions of errno values are defined
  *     on systems which don't have the corresponding errno.
  */
-#define APR_OS_START_CANONERR  (APR_OS_START_USEERR + 500)
+#define APR_OS_START_CANONERR  (APR_OS_START_USERERR \
+                                 + (APR_OS_ERRSPACE_SIZE * 10))
 /**
  * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into 
  *     apr_status_t values.
  */
-#define APR_OS_START_EAIERR    (APR_OS_START_CANONERR + 500)
+#define APR_OS_START_EAIERR    (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE)
 /**
  * APR_OS_START_SYSERR folds platform-specific system error values into 
  *     apr_status_t values.
  */
-#define APR_OS_START_SYSERR    (APR_OS_START_EAIERR + 500)
+#define APR_OS_START_SYSERR    (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE)
 
 /** no error. @see APR_STATUS_IS_SUCCESS */
 #define APR_SUCCESS 0
Index: misc/unix/errorcodes.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/errorcodes.c,v
retrieving revision 1.49
diff -u -r1.49 errorcodes.c
--- misc/unix/errorcodes.c	4 Apr 2002 16:38:59 -0000	1.49
+++ misc/unix/errorcodes.c	14 Aug 2002 17:31:39 -0000
@@ -409,7 +409,7 @@
     if (statcode < APR_OS_START_ERROR) {
         return native_strerror(statcode, buf, bufsize);
     }
-    else if (statcode < APR_OS_START_USEERR) {
+    else if (statcode < APR_OS_START_USERERR) {
         return stuffbuffer(buf, bufsize, apr_error_string(statcode));
     }
     else if (statcode < APR_OS_START_EAIERR) {

Re: [PATCH] expand apr error spaces

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
"William A. Rowe, Jr." <wr...@rowe-clan.net> writes:
> Outch.  This will hurt Win32 which has non-kernel errors going out to
> wazoo (the high-bit set is a flag in and of itself.)
> 
> However, Win32 has several ranges reserved for app errors.  If I can
> change the offsets to insert our 'apr'/'app' errors into those reservations,
> we should be fine.
> 
> Let me research in the next couple of days.

Okay, thanks; glad you spotted that.

-K

Re: [PATCH] expand apr error spaces

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 12:18 PM 8/14/2002, Karl Fogel wrote:
>This patch expands the error ranges to hold 50,000 errors instead of
>500, except for the USERERR range, which gets 500,000 to give apps a
>lot of breathing room.

Outch.  This will hurt Win32 which has non-kernel errors going out to
wazoo (the high-bit set is a flag in and of itself.)

However, Win32 has several ranges reserved for app errors.  If I can
change the offsets to insert our 'apr'/'app' errors into those reservations,
we should be fine.

Let me research in the next couple of days.

Bill