Skip to content

Commit

Permalink
Merge pull request #17448 from JasonFengJ9/criunocache
Browse files Browse the repository at this point in the history
CRIU restore clears InetAddress.cache
  • Loading branch information
tajila authored May 26, 2023
2 parents ec0eb13 + 662d82e commit 12286f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jcl/src/java.base/share/classes/module-info.java.extra
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ uses com.ibm.gpu.spi.GPUAssist.Provider;
exports com.ibm.gpu.spi to
openj9.gpu;
/*[IF CRIU_SUPPORT]*/
/*[IF JAVA_SPEC_VERSION >= 17]*/
exports jdk.internal.access to
openj9.criu;
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
exports jdk.internal.misc to
openj9.criu;
exports openj9.internal.criu to
openj9.criu;
exports openj9.internal.criu.security to
openj9.criu;
exports jdk.internal.misc to
openj9.criu;
opens jdk.internal.misc to
openj9.criu;
opens java.lang to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/*[IF JAVA_SPEC_VERSION >= 17]*/
import jdk.internal.access.JavaNetInetAddressAccess;
import jdk.internal.access.SharedSecrets;
/*[ELSE] JAVA_SPEC_VERSION >= 17
import jdk.internal.misc.JavaNetInetAddressAccess;
import jdk.internal.misc.SharedSecrets;
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */

import openj9.internal.criu.InternalCRIUSupport;

/**
Expand Down Expand Up @@ -211,6 +219,7 @@ public static String getErrorMessage() {
/* Higher priority hooks are run last in pre-checkoint hooks, and are run
* first in post restore hooks.
*/
private static final int RESTORE_CLEAR_INETADDRESS_CACHE_PRIORITY = 100;
private static final int RESTORE_ENVIRONMENT_VARIABLES_PRIORITY = 100;
private static final int RESTORE_SYSTEM_PROPERTIES_PRIORITY = 100;
private static final int USER_HOOKS_PRIORITY = 1;
Expand Down Expand Up @@ -623,6 +632,10 @@ private static void setRestoreJavaProperties() {
}
}

private static void clearInetAddressCache() {
SharedSecrets.getJavaNetInetAddressAccess().clearInetAddressCache();
}

/**
* Checkpoint the JVM. This operation will use the CRIU options set by the
* options setters.
Expand All @@ -647,6 +660,7 @@ public synchronized void checkpointJVM() {
registerRestoreEnvVariables();
}

J9InternalCheckpointHookAPI.registerPostRestoreHook(RESTORE_CLEAR_INETADDRESS_CACHE_PRIORITY, "Clear InetAddress cache on restore", CRIUSupport::clearInetAddressCache);
J9InternalCheckpointHookAPI.registerPostRestoreHook(RESTORE_ENVIRONMENT_VARIABLES_PRIORITY, "Restore system properties", CRIUSupport::setRestoreJavaProperties);

/* Add security provider hooks. */
Expand Down

0 comments on commit 12286f5

Please sign in to comment.