commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r825981 - in /commons/sandbox/runtime/trunk/src/main/native/os: unix/fsysio.c win32/fsysio.c
Date Fri, 16 Oct 2009 16:18:33 GMT
Author: mturk
Date: Fri Oct 16 16:18:33 2009
New Revision: 825981

URL: http://svn.apache.org/viewvc?rev=825981&view=rev
Log:
On noclose cleanup don't close the OS file object

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c

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=825981&r1=825980&r2=825981&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 Fri Oct 16 16:18:33 2009
@@ -55,7 +55,7 @@
     return rc;
 }
 
-static int file_cclose(void *file, int type, unsigned int flags)
+static int file_noclose(void *file, int type, unsigned int flags)
 {
     int rc = ACR_SUCCESS;
     acr_file_t *fp = (acr_file_t *)file;
@@ -71,13 +71,8 @@
         x_free(fp);
     else {
         /* This is from Descriptor.close() call
+         *  Only invalidate the file without closing it.
          */
-        if (fp->fd >= 0) {
-            if (close(fp->fd))
-                rc = ACR_GET_OS_ERROR();
-        }
-        else
-            rc = ACR_EBADF;
         fp->fd = -1;
     }
     return rc;
@@ -246,7 +241,7 @@
         fp->timeout  = -1;
     }
     if (flags & ACR_FOPEN_NOCLEANUP)
-        fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_cclose);
+        fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_noclose);
     else
         fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_cleanup);
     if (fo < 0) {

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=825981&r1=825980&r2=825981&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 Fri Oct 16 16:18:33 2009
@@ -41,13 +41,14 @@
             rc = ACR_GET_OS_ERROR();
         else
             rc = ACR_SUCCESS;
+        fp->fd = INVALID_HANDLE_VALUE;
+    }
+    if (fp->name) {
+        x_free(fp->name);
+        fp->name = NULL;
     }
-    x_free(fp->name);
-    fp->name = NULL;
     if (flags & ACR_IOH_CLEAR)
         x_free(fp);
-    else
-        fp->fd = INVALID_HANDLE_VALUE;
     return rc;
 }
 
@@ -55,7 +56,7 @@
 static LONG volatile _std_out = 1;
 static LONG volatile _std_err = 1;
 
-static int file_cclose(void *file, int type, unsigned int flags)
+static int file_noclose(void *file, int type, unsigned int flags)
 {
     int rc = ACR_SUCCESS;
     acr_file_t *fp = (acr_file_t *)file;
@@ -67,36 +68,13 @@
         x_free(fp->name);
         fp->name = NULL;
     }
-    if (flags & ACR_IOH_CLEAR)
+    if (flags & ACR_IOH_CLEAR) {
         x_free(fp);
+    }
     else {
         /* This is from Descriptor.close() call
+         * Only invalidate the file without closing it.
          */
-        if (IS_VALID_HANDLE(fp->fd)) {
-            if  (fp->flags & ACR_STDFILE_FLAGS) {
-                switch (fp->flags & ACR_STDFILE_FLAGS) {
-                    case ACR_STDIN_FLAG:
-                        if (InterlockedExchange(&_std_in, 0))
-                            _close(0);
-                        SetStdHandle(STD_INPUT_HANDLE, INVALID_HANDLE_VALUE);
-                    break;
-                    case ACR_STDOUT_FLAG:
-                        if (InterlockedExchange(&_std_out, 0))
-                            _close(1);
-                        SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
-                    break;
-                    case ACR_STDERR_FLAG:
-                        if (InterlockedExchange(&_std_err, 0))
-                            _close(2);
-                        SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
-                    break;
-                }
-            }
-            else if (!CloseHandle(fp->fd))
-                rc = ACR_GET_OS_ERROR();
-        }
-        else
-            rc = ACR_EBADF;
         fp->fd = INVALID_HANDLE_VALUE;
     }
     return rc;
@@ -253,7 +231,7 @@
         fp->timeout  = INFINITE;
     }
     if (flags & ACR_FOPEN_NOCLEANUP)
-        fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_cclose);
+        fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_noclose);
     else
         fo = acr_ioh_open(fp, ACR_DT_FILE, 0, file_cleanup);
     if (fo < 0) {



Mime
View raw message