rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / runtime / openjdk-24 / patches / illumos-port-16.patch
blobca812d5cc7d60b01c0d7dc41eba06f4909371a91
1 This all looks very broken, but the SunOS-specific code calls this.
2 Should investigate if it actually needs to.
4 --- jdk-jdk-19-7/src/java.base/unix/classes/java/lang/ProcessImpl.java Thu Jan 27 08:31:11 2022
5 +++ jdk-jdk-19-6/src/java.base/unix/classes/java/lang/ProcessImpl.java Thu Jan 20 08:53:40 2022
6 @@ -45,6 +45,7 @@
7 import java.security.AccessController;
8 import java.security.PrivilegedActionException;
9 import java.security.PrivilegedExceptionAction;
10 +import java.util.Properties;
11 import jdk.internal.access.JavaIOFileDescriptorAccess;
12 import jdk.internal.access.SharedSecrets;
13 import jdk.internal.util.OperatingSystem;
14 @@ -712,6 +713,109 @@
18 + // A FileInputStream that supports the deferment of the actual close
19 + // operation until the last pending I/O operation on the stream has
20 + // finished. This is required on Solaris because we must close the stdin
21 + // and stdout streams in the destroy method in order to reclaim the
22 + // underlying file descriptors. Doing so, however, causes any thread
23 + // currently blocked in a read on one of those streams to receive an
24 + // IOException("Bad file number"), which is incompatible with historical
25 + // behavior. By deferring the close we allow any pending reads to see -1
26 + // (EOF) as they did before.
27 + //
28 + private static class DeferredCloseInputStream extends PipeInputStream {
29 + DeferredCloseInputStream(FileDescriptor fd) {
30 + super(fd);
31 + }
33 + private Object lock = new Object(); // For the following fields
34 + private boolean closePending = false;
35 + private int useCount = 0;
36 + private InputStream streamToClose;
38 + private void raise() {
39 + synchronized (lock) {
40 + useCount++;
41 + }
42 + }
44 + private void lower() throws IOException {
45 + synchronized (lock) {
46 + useCount--;
47 + if (useCount == 0 && closePending) {
48 + streamToClose.close();
49 + }
50 + }
51 + }
53 + // stc is the actual stream to be closed; it might be this object, or
54 + // it might be an upstream object for which this object is downstream.
55 + //
56 + private void closeDeferred(InputStream stc) throws IOException {
57 + synchronized (lock) {
58 + if (useCount == 0) {
59 + stc.close();
60 + } else {
61 + closePending = true;
62 + streamToClose = stc;
63 + }
64 + }
65 + }
67 + public void close() throws IOException {
68 + synchronized (lock) {
69 + useCount = 0;
70 + closePending = false;
71 + }
72 + super.close();
73 + }
75 + public int read() throws IOException {
76 + raise();
77 + try {
78 + return super.read();
79 + } finally {
80 + lower();
81 + }
82 + }
84 + public int read(byte[] b) throws IOException {
85 + raise();
86 + try {
87 + return super.read(b);
88 + } finally {
89 + lower();
90 + }
91 + }
93 + public int read(byte[] b, int off, int len) throws IOException {
94 + raise();
95 + try {
96 + return super.read(b, off, len);
97 + } finally {
98 + lower();
99 + }
102 + public long skip(long n) throws IOException {
103 + raise();
104 + try {
105 + return super.skip(n);
106 + } finally {
107 + lower();
111 + public int available() throws IOException {
112 + raise();
113 + try {
114 + return super.available();
115 + } finally {
116 + lower();
122 * A buffered input stream for a subprocess pipe file descriptor
123 * that allows the underlying file descriptor to be reclaimed when
124 @@ -725,7 +829,7 @@
125 * will block if another thread is at the same time blocked in a file
126 * operation (e.g. 'read()') on the same file descriptor. We therefore
127 * combine 'ProcessPipeInputStream' approach used on Linux and Bsd
128 - * with the deferring 'close' of InputStream. This means
129 + * with the DeferredCloseInputStream approach used on Solaris. This means
130 * that every potentially blocking operation on the file descriptor
131 * increments a counter before it is executed and decrements it once it
132 * finishes. The 'close()' operation will only be executed if there are