From ed142442a4de15a03991915e3944e0bc6ae2b20a Mon Sep 17 00:00:00 2001 From: Tatsushi Inagaki Date: Thu, 26 Sep 2019 07:57:47 +0000 Subject: [PATCH] Enable Netty on a big endian platform Motivation: We would like to enable Netty also on a big endian platform such as s390_64. We need to fix a function which assumes that the target platform is little endian. Modifications: Modify netty_unix_socket_accept() to write an address length as jbyte instead of jsize. Result: Netty can be enabled on a big endian platform. Signed-off-by: Tatsushi Inagaki --- transport-native-unix-common/src/main/c/netty_unix_socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transport-native-unix-common/src/main/c/netty_unix_socket.c b/transport-native-unix-common/src/main/c/netty_unix_socket.c index 83a507fe60..5a50efaaa6 100644 --- a/transport-native-unix-common/src/main/c/netty_unix_socket.c +++ b/transport-native-unix-common/src/main/c/netty_unix_socket.c @@ -540,6 +540,7 @@ static jint netty_unix_socket_disconnect(JNIEnv* env, jclass clazz, jint fd, jbo static jint netty_unix_socket_accept(JNIEnv* env, jclass clazz, jint fd, jbyteArray acceptedAddress) { jint socketFd; jsize len; + jbyte len_b; int err; struct sockaddr_storage addr; socklen_t address_len = sizeof(addr); @@ -564,9 +565,10 @@ static jint netty_unix_socket_accept(JNIEnv* env, jclass clazz, jint fd, jbyteAr } len = addressLength(&addr); + len_b = (jbyte) len; // Fill in remote address details - (*env)->SetByteArrayRegion(env, acceptedAddress, 0, 4, (jbyte*) &len); + (*env)->SetByteArrayRegion(env, acceptedAddress, 0, 1, (jbyte*) &len_b); initInetSocketAddressArray(env, &addr, acceptedAddress, 1, len); if (accept4) {