Not directly call getsockopt but use exported helper function
Motivation:
To better isolate OS system calls we should not call getsockopt directly but use our netty_unix_socket_getOption0 function. See is a followup of f115bf5
.
Modifications:
Export netty_unix_socket_getOption0 by declaring it in the header file and use it
Result:
Better isolation of system calls.
This commit is contained in:
parent
7f4ade7e7d
commit
b1cc5835ac
@ -256,9 +256,8 @@ static jint netty_epoll_linuxsocket_isTcpQuickAck(JNIEnv* env, jclass clazz, jin
|
||||
|
||||
static jint netty_epoll_linuxsocket_isTcpFastOpenConnect(JNIEnv* env, jclass clazz, jint fd) {
|
||||
int optval;
|
||||
int optlen = sizeof(optval);
|
||||
// We call getsockopt directly so we can handle ENOPROTOOPT by ourself.
|
||||
if (getsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &optval, &optlen) == -1) {
|
||||
// We call netty_unix_socket_getOption0 directly so we can handle ENOPROTOOPT by ourself.
|
||||
if (netty_unix_socket_getOption0(fd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &optval, sizeof(optval)) == -1) {
|
||||
if (errno == ENOPROTOOPT) {
|
||||
// Not supported by the system, so just return 0.
|
||||
return 0;
|
||||
|
@ -328,7 +328,7 @@ void netty_unix_socket_getOptionHandleError(JNIEnv* env, int err) {
|
||||
netty_unix_socket_optionHandleError(env, err, "getsockopt() failed: ");
|
||||
}
|
||||
|
||||
static int netty_unix_socket_getOption0(jint fd, int level, int optname, void* optval, socklen_t optlen) {
|
||||
int netty_unix_socket_getOption0(jint fd, int level, int optname, void* optval, socklen_t optlen) {
|
||||
return getsockopt(fd, level, optname, optval, &optlen);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ int netty_unix_socket_getOption(JNIEnv* env, jint fd, int level, int optname, vo
|
||||
int netty_unix_socket_setOption(JNIEnv* env, jint fd, int level, int optname, const void* optval, socklen_t len);
|
||||
|
||||
// These method is sometimes needed if you want to special handle some errno value before throwing an exception.
|
||||
int netty_unix_socket_getOption0(jint fd, int level, int optname, void* optval, socklen_t optlen);
|
||||
void netty_unix_socket_getOptionHandleError(JNIEnv* env, int err);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user