diff options
author | Elliott Hughes <enh@google.com> | 2014-08-26 14:14:22 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-09-03 16:33:30 -0700 |
commit | 8f3b150cd86c2eb35229806fda6928501da27cac (patch) | |
tree | 7c2f6d3fd297aace39fa95422151478276291239 /luni/src/main/native | |
parent | 4f10651fff7200d688e5dda1508448f8b34e4d9f (diff) | |
download | libcore-8f3b150cd86c2eb35229806fda6928501da27cac.zip libcore-8f3b150cd86c2eb35229806fda6928501da27cac.tar.gz libcore-8f3b150cd86c2eb35229806fda6928501da27cac.tar.bz2 |
Keep qtaguid quiet by not trying to untag non-sockets.
(cherry-pick of f6cf9efb212e572dcd2e902ca461af6323793dbf.)
Bug: 17203955
Change-Id: I0999fc0ff295986b92e31568d96e321b9e7ffb2c
Diffstat (limited to 'luni/src/main/native')
-rw-r--r-- | luni/src/main/native/Register.cpp | 1 | ||||
-rw-r--r-- | luni/src/main/native/java_io_FileDescriptor.cpp | 35 | ||||
-rw-r--r-- | luni/src/main/native/sub.mk | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp index 4aaa905..6a2c939 100644 --- a/luni/src/main/native/Register.cpp +++ b/luni/src/main/native/Register.cpp @@ -35,6 +35,7 @@ jint JNI_OnLoad(JavaVM* vm, void*) { #define REGISTER(FN) extern void FN(JNIEnv*); FN(env) REGISTER(register_android_system_OsConstants); REGISTER(register_java_io_File); + REGISTER(register_java_io_FileDescriptor); REGISTER(register_java_io_ObjectStreamClass); REGISTER(register_java_lang_Character); REGISTER(register_java_lang_Double); diff --git a/luni/src/main/native/java_io_FileDescriptor.cpp b/luni/src/main/native/java_io_FileDescriptor.cpp new file mode 100644 index 0000000..fe7e07e --- /dev/null +++ b/luni/src/main/native/java_io_FileDescriptor.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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. + */ + +#define LOG_TAG "FileDescriptor" + +#include "JniConstants.h" + +#include <sys/socket.h> +#include <sys/types.h> + +static jboolean FileDescriptor_isSocket(JNIEnv*, jclass, jint fd) { + int error; + socklen_t error_length = sizeof(error); + return TEMP_FAILURE_RETRY(getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &error_length)); +} + +static JNINativeMethod gMethods[] = { + NATIVE_METHOD(FileDescriptor, isSocket, "(I)Z"), +}; +void register_java_io_FileDescriptor(JNIEnv* env) { + jniRegisterNativeMethods(env, "java/io/FileDescriptor", gMethods, NELEM(gMethods)); +} diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk index 5b581f3..079ecd2 100644 --- a/luni/src/main/native/sub.mk +++ b/luni/src/main/native/sub.mk @@ -15,6 +15,7 @@ LOCAL_SRC_FILES := \ canonicalize_path.cpp \ cbigint.cpp \ java_io_File.cpp \ + java_io_FileDescriptor.cpp \ java_io_ObjectStreamClass.cpp \ java_lang_Character.cpp \ java_lang_Double.cpp \ |