am 886630c0: Merge "Switch shutdownInput / shutdownOutput to using Os.shutdown."

* commit '886630c0d8adc17c494edf19a30b06473a687fcb':
  Switch shutdownInput / shutdownOutput to using Os.shutdown.
This commit is contained in:
Neil Fuller
2015-07-13 15:11:11 +00:00
committed by Android Git Automerger
2 changed files with 10 additions and 27 deletions

View File

@@ -201,7 +201,6 @@ class LocalSocketImpl
int namespace) throws IOException;
private native void bindLocal(FileDescriptor fd, String name, int namespace)
throws IOException;
private native void shutdown(FileDescriptor fd, boolean shutdownInput);
private native Credentials getPeerCredentials_native(
FileDescriptor fd) throws IOException;
@@ -405,7 +404,11 @@ class LocalSocketImpl
throw new IOException("socket not created");
}
shutdown(fd, true);
try {
Os.shutdown(fd, OsConstants.SHUT_RD);
} catch (ErrnoException e) {
throw e.rethrowAsIOException();
}
}
/**
@@ -419,7 +422,11 @@ class LocalSocketImpl
throw new IOException("socket not created");
}
shutdown(fd, false);
try {
Os.shutdown(fd, OsConstants.SHUT_WR);
} catch (ErrnoException e) {
throw e.rethrowAsIOException();
}
}
protected FileDescriptor getFileDescriptor()

View File

@@ -112,29 +112,6 @@ socket_bind_local (JNIEnv *env, jobject object, jobject fileDescriptor,
}
}
/* private native void shutdown(FileDescriptor fd, boolean shutdownInput) */
static void
socket_shutdown (JNIEnv *env, jobject object, jobject fileDescriptor,
jboolean shutdownInput)
{
int ret;
int fd;
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (env->ExceptionCheck()) {
return;
}
ret = shutdown(fd, shutdownInput ? SHUT_RD : SHUT_WR);
if (ret < 0) {
jniThrowIOException(env, errno);
return;
}
}
/**
* Processes ancillary data, handling only
* SCM_RIGHTS. Creates appropriate objects and sets appropriate
@@ -523,7 +500,6 @@ static JNINativeMethod gMethods[] = {
{"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V",
(void*)socket_connect_local},
{"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local},
{"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown},
{"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read},
{"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba},
{"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba},