commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r820601 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/exception/ native/include/ native/os/unix/ native/os/win32/ native/shared/
Date Thu, 01 Oct 2009 10:47:39 GMT
Author: mturk
Date: Thu Oct  1 10:47:38 2009
New Revision: 820601

URL: http://svn.apache.org/viewvc?rev=820601&view=rev
Log:
Add two new exceptions for faulty descriptors

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java
  (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java
  (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/ClosedDescriptorException.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/shared/fco.c

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java?rev=820601&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java
Thu Oct  1 10:47:38 2009
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.exception;
+
+/**
+ * AsyncClosedDescriptorException thrown when an attempt is made to
+ * invoke an operation on closed {@code Descriptor}.
+ *
+ * @since Runtime 1.0
+ */
+public class AsyncClosedDescriptorException
+    extends ClosedDescriptorException
+{
+
+    public AsyncClosedDescriptorException()
+    {
+        super();
+    }
+
+    public AsyncClosedDescriptorException(String msg)
+    {
+        super(msg);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/AsyncClosedDescriptorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/ClosedDescriptorException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/ClosedDescriptorException.java?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/ClosedDescriptorException.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/ClosedDescriptorException.java
Thu Oct  1 10:47:38 2009
@@ -23,7 +23,6 @@
  *
  * @since Runtime 1.0
  */
-
 public class ClosedDescriptorException extends IOException
 {
 

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java?rev=820601&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java
Thu Oct  1 10:47:38 2009
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.exception;
+import java.io.IOException;
+
+/**
+ * InvalidDescriptorException thrown when an attempt is made to
+ * invoke an operation on invalid {@code Descriptor}.
+ *
+ * @since Runtime 1.0
+ */
+public class InvalidDescriptorException extends IOException
+{
+
+    public InvalidDescriptorException()
+    {
+        super();
+    }
+
+    public InvalidDescriptorException(String msg)
+    {
+        super(msg);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/InvalidDescriptorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Thu Oct  1 10:47:38
2009
@@ -53,7 +53,9 @@
     ACR_EX_EIO,             /* java/io/IOException */
     ACR_EX_ESYNC,           /* java/io/SyncFailedException */
     ACR_EX_ESOCK,           /* java/net/SocketException */
-    ACR_EX_CLSOSED_DESC,    /* exception/ClosedDescriptorException */
+    ACR_EX_CLOSED_DESC,     /* exception/ClosedDescriptorException */
+    ACR_EX_ACLOSED_DESC,    /* exception/AsyncClosedDescriptorException */
+    ACR_EX_INVALID_DESC,    /* exception/InvalidDescriptorException */
     ACR_EX_ENOENT,          /* exception/NoSuchObjectException */
     ACR_EX_OSERR,           /* exception/OperatingSystemException */
     ACR_EX_UNALIGNED,       /* exception/UnalignedMemoryException */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Thu Oct  1 10:47:38 2009
@@ -554,11 +554,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -587,6 +587,9 @@
         case 0:
         case ACR_TIMEUP:
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -610,11 +613,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -671,6 +674,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -694,11 +700,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -735,6 +741,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -759,11 +768,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -803,6 +812,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -820,11 +832,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     wr = r_write(f->fd, &c, 1);
@@ -846,6 +858,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -867,11 +882,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     bb = (*_E)->GetByteArrayElements(_E, buf, NULL);
@@ -899,6 +914,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -921,11 +939,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
@@ -956,6 +974,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -980,11 +1001,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)(*_E)->GetDirectBufferAddress(_E, dbb);
@@ -1018,6 +1039,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -1045,11 +1069,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pl = (size_t)(*_E)->GetArrayLength(_E, vec);
@@ -1108,6 +1132,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -1132,11 +1159,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pl = (size_t)(*_E)->GetArrayLength(_E, vec);
@@ -1182,6 +1209,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -1205,11 +1235,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     bb = (*_E)->GetByteArrayElements(_E, buf, NULL);
@@ -1246,6 +1276,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -1269,11 +1302,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
@@ -1314,6 +1347,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;
@@ -1339,11 +1375,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)(*_E)->GetDirectBufferAddress(_E, dbb);
@@ -1387,6 +1423,9 @@
         case ACR_TIMEUP:
             return 0;
         break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
         default:
             ACR_THROW_IO_IF_ERR(rc);
         break;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c Thu Oct  1 10:47:38 2009
@@ -487,11 +487,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     switch (where) {
@@ -657,16 +657,16 @@
 {
     unsigned char c;
     DWORD rd = 0;
-    DWORD rc;
+    DWORD rc = 0;
     LPOVERLAPPED lpo = NULL;
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -701,7 +701,6 @@
         lpo->Offset     = (DWORD)(f->pos);
         lpo->OffsetHigh = (DWORD)(f->pos >> 32);
     }
-    f->err = 0;
     if (ReadFile(f->fd, &c, 1, &rd, lpo)) {
         /* All done. Update the position and return
          */
@@ -714,10 +713,10 @@
             return -1;
         }
     }
-    switch (f->err = GetLastError()) {
+    switch (rcr = GetLastError()) {
         case ERROR_HANDLE_EOF:
         case ERROR_BROKEN_PIPE:
-            f->err = 0;
+            rc     = 0;
             f->eof = 1;
         break;
         case ERROR_IO_PENDING:
@@ -733,24 +732,30 @@
                 break;
                 case ERROR_HANDLE_EOF:
                 case ERROR_BROKEN_PIPE:
-                    f->err = 0;
+                    rc     = 0;
                     f->eof = 1;
                 break;
-                case ACR_TIMEUP:
-                    f->err = ACR_TIMEUP;
-                break;
                 default:
-                    f->err = rc;
                 break;
             }
         break;
         default:
         break;
     }
-    if (f->err && f->err != ACR_TIMEUP) {
-        /* Throw only if not TIMEUP
-         */
-        ACR_THROW_IO_IF_ERR(f->err);
+    if (f->eof)
+        return -1;
+    switch (f->err = rc) {
+        case 0:
+        case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
+            return 0;
+        break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
+        default:
+            ACR_THROW_IO_IF_ERR(rc);
+        break;
     }
     return -1;
 }
@@ -766,17 +771,17 @@
     DWORD   po = (DWORD)off;
     DWORD   cs = (DWORD)len;
     DWORD   rd = 0;
-    DWORD   rc;
+    DWORD   rc = 0;
     LPOVERLAPPED lpo = NULL;
     jbyte   onstack[ACR_PBUFF_SIZ];
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -834,7 +839,7 @@
         /* Exception was already thrown */
         return -1;
     }
-    f->err = 0;
+    rc = 0;
     if (ReadFile(f->fd, bb, cs, &rd, lpo)) {
         /* All done. Update the position and return
          */
@@ -844,16 +849,15 @@
             f->eof = 1;
         goto finally;
     }
-    switch (f->err = GetLastError()) {
+    switch (rc = GetLastError()) {
         case ERROR_HANDLE_EOF:
         case ERROR_BROKEN_PIPE:
-            f->err = 0;
+            rc     = 0;
             f->eof = 1;
         break;
         case ERROR_IO_PENDING:
             switch (rc = overlapped_wait(f, &rd)) {
                 case 0:
-                    f->err = 0;
                     if (rd) {
                         f->pos += rd;
                         goto finally;
@@ -863,14 +867,10 @@
                 break;
                 case ERROR_HANDLE_EOF:
                 case ERROR_BROKEN_PIPE:
-                    f->err = 0;
+                    rc     = 0;
                     f->eof = 1;
                 break;
-                case ACR_TIMEUP:
-                    f->err = ACR_TIMEUP;
-                break;
                 default:
-                    f->err = rc;
                 break;
             }
         break;
@@ -894,12 +894,24 @@
         else
             x_free(bb);
     }
+    if (rd > 0)
+        return (jint)rd;
     if (f->eof)
         return -1;
-    if (f->err) {
-        return f->err == ACR_TIMEUP ? 0 : -1;
+    switch (f->err = rc) {
+        case 0:
+        case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
+            return 0;
+        break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
+        default:
+            ACR_THROW_IO_IF_ERR(rc);
+        break;
     }
-    return (jint)rd;
+    return -1;
 }
 
 ACR_IO_EXPORT_DECLARE(jint, FileSystem, read2)(ACR_JNISTDARGS,
@@ -912,17 +924,17 @@
     DWORD   po = (DWORD)off;
     DWORD   cs = (DWORD)len;
     DWORD   rd = 0;
-    DWORD   rc;
+    DWORD   rc = 0;
     LPOVERLAPPED lpo = NULL;
     jbyte  *pb;
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -974,7 +986,7 @@
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
         return -1;
     }
-    f->err = 0;
+    rc = 0;
     if (ReadFile(f->fd, pb + po, cs, &rd, lpo)) {
         /* All done. Update the position and return
          */
@@ -987,13 +999,12 @@
     switch (f->err = GetLastError()) {
         case ERROR_HANDLE_EOF:
         case ERROR_BROKEN_PIPE:
-            f->err = 0;
+            rc     = 0;
             f->eof = 1;
         break;
         case ERROR_IO_PENDING:
             switch (rc = overlapped_wait(f, &rd)) {
                 case 0:
-                    f->err = 0;
                     if (rd) {
                         f->pos += rd;
                         goto finally;
@@ -1003,14 +1014,10 @@
                 break;
                 case ERROR_HANDLE_EOF:
                 case ERROR_BROKEN_PIPE:
-                    f->err = 0;
+                    rc     = 0;
                     f->eof = 1;
                 break;
-                case ACR_TIMEUP:
-                    f->err = ACR_TIMEUP;
-                break;
                 default:
-                    f->err = rc;
                 break;
             }
         break;
@@ -1019,10 +1026,23 @@
     }
 
 finally:
-    if (rd)
+    if (rd > 0)
         return (jint)rd;
-    if (f->err)
-        return f->err == ACR_TIMEUP ? 0 : -1;
+    if (f->eof)
+        return -1;
+    switch (f->err = rc) {
+        case 0:
+        case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
+            return 0;
+        break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
+        default:
+            ACR_THROW_IO_IF_ERR(rc);
+        break;
+    }
     return -1;
 }
 
@@ -1038,17 +1058,17 @@
     DWORD   po = (DWORD)off;
     DWORD   cs = (DWORD)len;
     DWORD   rd = 0;
-    DWORD   rc;
+    DWORD   rc = 0;
     LPOVERLAPPED lpo = NULL;
     jbyte  *pb;
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->eof) {
@@ -1103,7 +1123,6 @@
         return -1;
     }
 #endif
-    f->err = 0;
     if (ReadFile(f->fd, pb + po, cs, &rd, lpo)) {
         /* All done. Update the position and return
          */
@@ -1116,7 +1135,7 @@
     switch (f->err = GetLastError()) {
         case ERROR_HANDLE_EOF:
         case ERROR_BROKEN_PIPE:
-            f->err = 0;
+            rc     = 0;
             f->eof = 1;
         break;
         case ERROR_IO_PENDING:
@@ -1132,14 +1151,10 @@
                 break;
                 case ERROR_HANDLE_EOF:
                 case ERROR_BROKEN_PIPE:
-                    f->err = 0;
+                    rc     = 0;
                     f->eof = 1;
                 break;
-                case ACR_TIMEUP:
-                    f->err = ACR_TIMEUP;
-                break;
                 default:
-                    f->err = rc;
                 break;
             }
         break;
@@ -1148,10 +1163,23 @@
     }
 
 finally:
-    if (rd)
+    if (rd > 0)
         return (jint)rd;
-    if (f->err)
-        return f->err == ACR_TIMEUP ? 0 : -1;
+    if (f->eof)
+        return -1;
+    switch (f->err = rc) {
+        case 0:
+        case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
+            return 0;
+        break;
+        case EBADF:
+            ACR_THROW_EX_IF_ERR(ACR_EX_ACLOSED_DESC, rc);
+        break;
+        default:
+            ACR_THROW_IO_IF_ERR(rc);
+        break;
+    }
     return -1;
 }
 
@@ -1167,11 +1195,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->flags & ACR_FOPEN_APPEND) {
@@ -1243,6 +1271,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -1269,11 +1298,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
 
@@ -1354,6 +1383,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -1381,11 +1411,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->flags & ACR_FOPEN_APPEND) {
@@ -1471,6 +1501,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -1500,11 +1531,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->flags & ACR_FOPEN_APPEND) {
@@ -1592,6 +1623,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -1623,14 +1655,13 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
-
     pl = (DWORD)(*_E)->GetArrayLength(_E, vec);
     if ((po + cs) > pl) {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
@@ -1749,14 +1780,13 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
-
     pl = (DWORD)(*_E)->GetArrayLength(_E, vec);
     if ((po + cs) > pl) {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
@@ -1844,6 +1874,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -1872,11 +1903,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     if (f->flags & ACR_FOPEN_APPEND) {
@@ -1997,11 +2028,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
@@ -2097,6 +2128,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 
@@ -2127,11 +2159,11 @@
     acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
     if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
-        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        ACR_THROW_EX_IF_ERR(ACR_EX_INVALID_DESC, ACR_EFTYPE);
         return -1;
     }
     if (IS_INVALID_HANDLE(f)) {
-        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        ACR_THROW_EX_IF_ERR(ACR_EX_CLOSED_DESC, ACR_EBADF);
         return -1;
     }
     pb = (jbyte *)(*_E)->GetDirectBufferAddress(_E, dbb);
@@ -2230,6 +2262,7 @@
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
+        case ERROR_OPERATION_ABORTED:
             return 0;
         break;
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Thu Oct  1 10:47:38 2009
@@ -41,6 +41,8 @@
     "java/io/SyncFailedException",
     "java/net/SocketException",
     ACR_EXCEPTION_CLASS_PATH "ClosedDescriptorException",
+    ACR_EXCEPTION_CLASS_PATH "AsyncClosedDescriptorException",
+    ACR_EXCEPTION_CLASS_PATH "InvalidDescriptorException",
     ACR_EXCEPTION_CLASS_PATH "NoSuchObjectException",
     ACR_EXCEPTION_CLASS_PATH "OperatingSystemException",
     ACR_EXCEPTION_CLASS_PATH "UnalignedMemoryException",

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/fco.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/fco.c?rev=820601&r1=820600&r2=820601&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/fco.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/fco.c Thu Oct  1 10:47:38 2009
@@ -21,6 +21,7 @@
 
 #include "acr.h"
 #include "acr_private.h"
+#include "acr_arch.h"
 #include "acr_error.h"
 #include "acr_string.h"
 #include "acr_clazz.h"



Mime
View raw message