You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/11/26 14:21:16 UTC
svn commit: r884552 -
/commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
Author: mturk
Date: Thu Nov 26 13:21:15 2009
New Revision: 884552
URL: http://svn.apache.org/viewvc?rev=884552&view=rev
Log:
Fix posix pipe cleanup during creation error
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c?rev=884552&r1=884551&r2=884552&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c Thu Nov 26 13:21:15 2009
@@ -200,13 +200,11 @@
finally:
if (rc) {
- if (fp && fp->descriptor)
- (*_E)->DeleteWeakGlobalRef(_E, fp->descriptor);
- if (fd >= 0)
+ if (fp)
+ file_cleanup(fp, ACR_DT_FILE, ACR_IOH_CLEAR);
+ else
close(fd);
- x_free(fp);
}
-
return rc;
}
@@ -214,32 +212,25 @@
jint flags)
{
int rc = 0;
- jobject fd[2];
- int pd[2] = { -1, -1 };
+ jobject fd[2] = {NULL, NULL };
+ int pd[2] = { -1, -1 };
if (pipe(pd) == -1) {
ACR_THROW_IO_ERRNO();
return NULL;
}
- rc = do_popen(_E, pd[0], flags & ACR_PIPE_RD, &fd[0]);
+ rc = do_popen(_E, pd[0], flags & ACR_PIPE_RD, &fd[0]);
if (rc) {
- goto cleanup;
+ goto finally;
}
rc = do_popen(_E, pd[1], flags & ACR_PIPE_WR, &fd[1]);
if (rc) {
- /* ### fd[0] will be closed by GC ?
- */
- pd[0] = -1;
- goto cleanup;
+ ACR_DescriptorCleanup(_E, fd[0]);
+ goto finally;
}
return ACR_NewPipeObject(_E, flags, fd[0], fd[1], NULL);
-cleanup:
- if (pd[0] != -1)
- close(pd[0]);
- if (pd[1] != -1)
- close(pd[1]);
-
+finally:
ACR_THROW_IO_IF_ERR(rc);
return NULL;
}