mturk       2005/06/10 00:06:10

  Modified:    jni/java/org/apache/tomcat/jni Status.java
               jni/native/include tcn.h
               jni/native/src network.c poll.c
  Log:
  Use macros for portable wrapping of APR_STATUS_IS to
  user error messages for most common return values
  
  Revision  Changes    Path
  1.8       +4 -1      
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Status.java
  
  Index: Status.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Status.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Status.java       9 Jun 2005 11:13:40 -0000       1.7
  +++ Status.java       10 Jun 2005 07:06:10 -0000      1.8
  @@ -177,6 +177,9 @@
   
       public static final int TIMEUP            = (APR_OS_START_USERERR + 1);
       public static final int EAGAIN            = (APR_OS_START_USERERR + 2);
  +    public static final int EINTR             = (APR_OS_START_USERERR + 3);
  +    public static final int EINPROGRESS       = (APR_OS_START_USERERR + 4);
  +    public static final int ETIMEDOUT         = (APR_OS_START_USERERR + 5);
   
       private static native boolean is(int err, int idx);
       /**
  
  
  
  1.15      +20 -3     jakarta-tomcat-connectors/jni/native/include/tcn.h
  
  Index: tcn.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/include/tcn.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- tcn.h     9 Jun 2005 11:13:40 -0000       1.14
  +++ tcn.h     10 Jun 2005 07:06:10 -0000      1.15
  @@ -39,8 +39,25 @@
   #define APR_MAX_IOVEC_SIZE 1024
   #endif
   
  -#define TCN_TIMEUP  APR_OS_START_USERERR + 1
  -#define TCN_EAGAIN  APR_OS_START_USERERR + 2
  +#define TCN_TIMEUP      APR_OS_START_USERERR + 1
  +#define TCN_EAGAIN      APR_OS_START_USERERR + 2
  +#define TCN_EINTR       APR_OS_START_USERERR + 3
  +#define TCN_EINPROGRESS APR_OS_START_USERERR + 4
  +#define TCN_ETIMEDOUT   APR_OS_START_USERERR + 5
  +
  +#define TCN_ERROR_WRAP(E)                   \
  +    if (APR_STATUS_IS_TIMEUP(E))            \
  +        (E) = TCN_TIMEUP;                   \
  +    else if (APR_STATUS_IS_EAGAIN(E))       \
  +        (E) = TCN_EAGAIN;                   \
  +    else if (APR_STATUS_IS_EINTR(E))        \
  +        (E) = TCN_EINTR;                    \
  +    else if (APR_STATUS_IS_EINPROGRESS(E))  \
  +        (E) = TCN_EINPROGRESS;              \
  +    else if (APR_STATUS_IS_ETIMEDOUT(E))    \
  +        (E) = TCN_ETIMEDOUT;                \
  +    else                                    \
  +        (E) = (E)
   
   #define TCN_CLASS_PATH  "org/apache/tomcat/jni/"
   #define TCN_FINFO_CLASS TCN_CLASS_PATH "FileInfo"
  
  
  
  1.25      +11 -21    jakarta-tomcat-connectors/jni/native/src/network.c
  
  Index: network.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/network.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- network.c 9 Jun 2005 11:13:40 -0000       1.24
  +++ network.c 10 Jun 2005 07:06:10 -0000      1.25
  @@ -292,8 +292,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -315,8 +314,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -351,8 +349,7 @@
       if (ss == APR_SUCCESS)
           return (jint)written;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -386,8 +383,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -410,8 +406,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -444,8 +439,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -468,8 +462,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -501,8 +494,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -527,8 +519,7 @@
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jint)ss;
       }
   }
  @@ -656,8 +647,7 @@
       if (ss == APR_SUCCESS)
           return (jlong)written;
       else {
  -        if (APR_STATUS_IS_EAGAIN(ss))
  -            ss = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(ss);
           return -(jlong)ss;
       }
   }
  
  
  
  1.18      +2 -5      jakarta-tomcat-connectors/jni/native/src/poll.c
  
  Index: poll.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/poll.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- poll.c    9 Jun 2005 11:13:40 -0000       1.17
  +++ poll.c    10 Jun 2005 07:06:10 -0000      1.18
  @@ -250,10 +250,7 @@
        p->sp_poll++;
   #endif
       if ((rv = apr_pollset_poll(p->pollset, J2T(timeout), &num, &fd)) != 
APR_SUCCESS) {
  -        if (APR_STATUS_IS_TIMEUP(rv))
  -            rv = TCN_TIMEUP;
  -        else if (APR_STATUS_IS_EAGAIN(rv))
  -            rv = TCN_EAGAIN;
  +        TCN_ERROR_WRAP(rv);
   #ifdef TCN_DO_STATISTICS
           if (rv == TCN_TIMEUP)
               p->sp_poll_timeout++;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to