diff options
author | Janak Ramakrishnan <janakr@google.com> | 2017-01-05 20:21:35 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-01-05 21:10:56 +0000 |
commit | 7be337f50d7b14205c56ec75d86bd9a7e835fbe5 (patch) | |
tree | 6518a43eba7679bd5f339d82d11f0f1c234aa6e9 /src/main/java/com/google/devtools/build/lib/server | |
parent | bf51766b1ec67159b1c55889ac55a2e37faeeb02 (diff) |
Rollback of commit 70c5790e4fb01db382d61d457596a46b68ba8d13.
(Tests kept.)
*** Reason for rollback ***
[]
*** Original change description ***
When --experimental_oom_more_eagerly is enabled, tell Bazel to exit with an OutOfMemoryError and have the JVM send Bazel a SIGUSR2 when it detects an OOM. This should help in certain pathological cases when Bazel GC thrashes for some time after an OOM has been detected.
--
PiperOrigin-RevId: 143694970
MOS_MIGRATED_REVID=143694970
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/server')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/server/signal/AbstractSignalHandler.java | 59 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/server/signal/InterruptSignalHandler.java | 32 |
2 files changed, 29 insertions, 62 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/server/signal/AbstractSignalHandler.java b/src/main/java/com/google/devtools/build/lib/server/signal/AbstractSignalHandler.java deleted file mode 100644 index 627a38311e..0000000000 --- a/src/main/java/com/google/devtools/build/lib/server/signal/AbstractSignalHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2016 The Bazel Authors. All rights reserved. -// -// Licensed 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 com.google.devtools.build.lib.server.signal; - - -import com.google.devtools.build.lib.util.Preconditions; - -import sun.misc.Signal; -import sun.misc.SignalHandler; - -/** - * A facade around {@link sun.misc.Signal} providing special-purpose signal handling. - * - * <p>We use this code in preference to using sun.misc directly since the latter is deprecated, and - * depending on it causes javac to emit an unsuppressable warning that sun.misc is - * "Sun proprietary API and may be removed in a future release". - */ -public abstract class AbstractSignalHandler { - private final Signal signal; - private SignalHandler oldHandler; - - /** - * Constructs an AbstractSignalHandler instance. Until the uninstall() method is invoked, the - * delivery of {@code signal} to this process will cause the run() method to be invoked in another - * thread. - */ - protected AbstractSignalHandler(Signal signal) { - this.signal = signal; - this.oldHandler = - Signal.handle( - signal, - new SignalHandler() { - @Override - public void handle(Signal signal) { - onSignal(); - } - }); - } - - protected abstract void onSignal(); - - /** Disables signal handling. */ - public final synchronized void uninstall() { - Preconditions.checkNotNull(oldHandler, "uninstall() already called"); - Signal.handle(signal, oldHandler); - oldHandler = null; - } -} diff --git a/src/main/java/com/google/devtools/build/lib/server/signal/InterruptSignalHandler.java b/src/main/java/com/google/devtools/build/lib/server/signal/InterruptSignalHandler.java index f2dc729cef..74196e2caa 100644 --- a/src/main/java/com/google/devtools/build/lib/server/signal/InterruptSignalHandler.java +++ b/src/main/java/com/google/devtools/build/lib/server/signal/InterruptSignalHandler.java @@ -13,18 +13,44 @@ // limitations under the License. package com.google.devtools.build.lib.server.signal; +import com.google.devtools.build.lib.util.Preconditions; import sun.misc.Signal; +import sun.misc.SignalHandler; + +/** + * A facade around sun.misc.Signal providing special-purpose SIGINT handling. + * + * <p>We use this code in preference to using sun.misc directly since the latter is deprecated, and + * depending on it causes the jdk1.6 javac to emit an unsuppressable warning that sun.misc is + * "Sun proprietary API and may be removed in a future release". + */ +public abstract class InterruptSignalHandler implements Runnable { -/** Class that can be extended to handle SIGINT in a custom way. */ -public abstract class InterruptSignalHandler extends AbstractSignalHandler { private static final Signal SIGINT = new Signal("INT"); + private SignalHandler oldHandler; + /** * Constructs an InterruptSignalHandler instance. Until the uninstall() * method is invoked, the delivery of a SIGINT signal to this process will * cause the run() method to be invoked in another thread. */ protected InterruptSignalHandler() { - super(SIGINT); + this.oldHandler = + Signal.handle( + SIGINT, + new SignalHandler() { + @Override + public void handle(Signal signal) { + run(); + } + }); + } + + /** Disables SIGINT handling. */ + public final synchronized void uninstall() { + Preconditions.checkNotNull(oldHandler, "uninstall() already called"); + Signal.handle(SIGINT, oldHandler); + oldHandler = null; } } |