Fix EpollServerSocketConfig.isFreebind()

Motivation:

EpollServerSocketConfig.isFreebind() throws an exception when called.

Modifications:

Use the correct getsockopt arguments.

Result:

No more exception when call EpollServerSocketConfig.isFreebind()
This commit is contained in:
Norman Maurer 2016-03-08 14:05:29 +01:00
parent 0fd12502ca
commit c8b2633864
2 changed files with 9 additions and 1 deletions

View File

@ -507,7 +507,7 @@ static jint netty_epoll_native_getTcpUserTimeout(JNIEnv* env, jclass clazz, jint
static jint netty_epoll_Native_isIpFreeBind(JNIEnv* env, jclass clazz, jint fd) { static jint netty_epoll_Native_isIpFreeBind(JNIEnv* env, jclass clazz, jint fd) {
int optval; int optval;
if (netty_unix_socket_getOption(env, fd, IPPROTO_TCP, IP_FREEBIND, &optval, sizeof(optval)) == -1) { if (netty_unix_socket_getOption(env, fd, IPPROTO_IP, IP_FREEBIND, &optval, sizeof(optval)) == -1) {
return -1; return -1;
} }
return optval; return optval;

View File

@ -67,4 +67,12 @@ public class EpollServerSocketChannelConfigTest {
ch.config().setReusePort(true); ch.config().setReusePort(true);
assertTrue(ch.config().isReusePort()); assertTrue(ch.config().isReusePort());
} }
@Test
public void testFreeBind() {
ch.config().setFreeBind(false);
assertFalse(ch.config().isFreeBind());
ch.config().setFreeBind(true);
assertTrue(ch.config().isFreeBind());
}
} }