Skip to content

Commit 0cea345

Browse files
narayankJessica Wagantall
authored and
Jessica Wagantall
committed
System: Close log sockets prior to a fork.
Calling __android_log_close sometimes isn't sufficient because some libraries statically link in liblog. This may not be a complete or a clean change, but it's sufficient to get whitelisting working on Lollipop and Marshmallow. CYNGNOS-3303 bug: 30963384 Change-Id: I38cdfc17e9d942417ca57154776bd28e5b78b807 (cherry picked from commit b754a98)
1 parent 20c23b8 commit 0cea345

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

dalvik/src/main/java/dalvik/system/ZygoteHooks.java

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void preFork() {
3838
Daemons.stop();
3939
waitUntilAllThreadsStopped();
4040
token = nativePreFork();
41+
System.closeLogSockets();
4142
}
4243

4344
/**

luni/src/main/java/java/lang/System.java

+3
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@ public static void setSecurityManager(SecurityManager sm) {
11011101
}
11021102
}
11031103

1104+
/** @hide */
1105+
public static native void closeLogSockets();
1106+
11041107
/**
11051108
* Returns the platform specific file name format for the shared library
11061109
* named by the argument. On Android, this would turn {@code "MyLibrary"} into

luni/src/main/native/java_lang_System.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ static void System_log(JNIEnv* env, jclass, jchar type, jstring javaMessage, jth
6262
}
6363
}
6464

65+
static void System_closeLogSockets(JNIEnv*, jclass) {
66+
__android_log_close();
67+
}
68+
6569
// Sets a field via JNI. Used for the standard streams, which are read-only otherwise.
6670
static void System_setFieldImpl(JNIEnv* env, jclass clazz,
6771
jstring javaName, jstring javaSignature, jobject object) {
@@ -133,6 +137,7 @@ static jstring System_mapLibraryName(JNIEnv* env, jclass, jstring javaName) {
133137
}
134138

135139
static JNINativeMethod gMethods[] = {
140+
NATIVE_METHOD(System, closeLogSockets, "()V"),
136141
NATIVE_METHOD(System, currentTimeMillis, "!()J"),
137142
NATIVE_METHOD(System, log, "(CLjava/lang/String;Ljava/lang/Throwable;)V"),
138143
NATIVE_METHOD(System, mapLibraryName, "(Ljava/lang/String;)Ljava/lang/String;"),

0 commit comments

Comments
 (0)