Fixed segmentation fault error in IovecArrayPool
Motivation: segmentation is caused in IovecArrayPool.release because the default of iovecMemoryAddress is 0 Modification: -set default to -1 -some cleanups -added new testsuite tests Result: fixed segmentation error
This commit is contained in:
parent
05289a3f5e
commit
242890899e
@ -67,59 +67,59 @@ public class SocketEchoTest extends AbstractSocketTest {
|
|||||||
testSimpleEcho0(sb, cb, false, false, true);
|
testSimpleEcho0(sb, cb, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
// public void testSimpleEchoNotAutoRead() throws Throwable {
|
public void testSimpleEchoNotAutoRead() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, false, false, false);
|
testSimpleEcho0(sb, cb, false, false, false);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test//(timeout = 30000)
|
@Test//(timeout = 30000)
|
||||||
// public void testSimpleEchoWithAdditionalExecutor() throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutor() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoWithAdditionalExecutor(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutor(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, true, false, true);
|
testSimpleEcho0(sb, cb, true, false, true);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test//(timeout = 30000)
|
@Test//(timeout = 30000)
|
||||||
// public void testSimpleEchoWithAdditionalExecutorNotAutoRead() throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutorNotAutoRead() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoWithAdditionalExecutorNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutorNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, true, false, false);
|
testSimpleEcho0(sb, cb, true, false, false);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test//(timeout = 30000)
|
@Test//(timeout = 30000)
|
||||||
// public void testSimpleEchoWithVoidPromise() throws Throwable {
|
public void testSimpleEchoWithVoidPromise() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoWithVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoWithVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, false, true, true);
|
testSimpleEcho0(sb, cb, false, true, true);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test//(timeout = 30000)
|
@Test//(timeout = 30000)
|
||||||
// public void testSimpleEchoWithVoidPromiseNotAutoRead() throws Throwable {
|
public void testSimpleEchoWithVoidPromiseNotAutoRead() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoWithVoidPromiseNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoWithVoidPromiseNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, false, true, false);
|
testSimpleEcho0(sb, cb, false, true, false);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
// public void testSimpleEchoWithAdditionalExecutorAndVoidPromise() throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutorAndVoidPromise() throws Throwable {
|
||||||
// run();
|
run();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void testSimpleEchoWithAdditionalExecutorAndVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
public void testSimpleEchoWithAdditionalExecutorAndVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||||
// testSimpleEcho0(sb, cb, true, true, true);
|
testSimpleEcho0(sb, cb, true, true, true);
|
||||||
// }
|
}
|
||||||
|
|
||||||
private static void testSimpleEcho0(
|
private static void testSimpleEcho0(
|
||||||
ServerBootstrap sb, Bootstrap cb, boolean additionalExecutor, boolean voidPromise, boolean autoRead)
|
ServerBootstrap sb, Bootstrap cb, boolean additionalExecutor, boolean voidPromise, boolean autoRead)
|
||||||
|
@ -82,7 +82,7 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
|
|||||||
private volatile SocketAddress remote;
|
private volatile SocketAddress remote;
|
||||||
|
|
||||||
//to release it
|
//to release it
|
||||||
private long iovecMemoryAddress;
|
private long iovecMemoryAddress = -1;
|
||||||
|
|
||||||
AbstractIOUringChannel(final Channel parent, LinuxSocket socket) {
|
AbstractIOUringChannel(final Channel parent, LinuxSocket socket) {
|
||||||
super(parent);
|
super(parent);
|
||||||
@ -274,8 +274,6 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
|
|||||||
int msgCount = in.size();
|
int msgCount = in.size();
|
||||||
if (msgCount > 1 && in.current() instanceof ByteBuf) {
|
if (msgCount > 1 && in.current() instanceof ByteBuf) {
|
||||||
doWriteMultiple(in);
|
doWriteMultiple(in);
|
||||||
//Object msg = in.current();
|
|
||||||
//doWriteSingle((ByteBuf) msg);
|
|
||||||
} else if (msgCount == 1) {
|
} else if (msgCount == 1) {
|
||||||
Object msg = in.current();
|
Object msg = in.current();
|
||||||
doWriteSingle((ByteBuf) msg);
|
doWriteSingle((ByteBuf) msg);
|
||||||
|
@ -25,12 +25,6 @@ final class IOUringRecvByteAllocatorHandle extends RecvByteBufAllocator.Delegati
|
|||||||
implements RecvByteBufAllocator.ExtendedHandle {
|
implements RecvByteBufAllocator.ExtendedHandle {
|
||||||
private final PreferredDirectByteBufAllocator preferredDirectByteBufAllocator =
|
private final PreferredDirectByteBufAllocator preferredDirectByteBufAllocator =
|
||||||
new PreferredDirectByteBufAllocator();
|
new PreferredDirectByteBufAllocator();
|
||||||
private final UncheckedBooleanSupplier defaultMaybeMoreDataSupplier = new UncheckedBooleanSupplier() {
|
|
||||||
@Override
|
|
||||||
public boolean get() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IOUringRecvByteAllocatorHandle(RecvByteBufAllocator.ExtendedHandle handle) {
|
IOUringRecvByteAllocatorHandle(RecvByteBufAllocator.ExtendedHandle handle) {
|
||||||
super(handle);
|
super(handle);
|
||||||
|
@ -19,7 +19,7 @@ final class IovecArrayPool implements MessageProcessor {
|
|||||||
private static int poolSize = 40;
|
private static int poolSize = 40;
|
||||||
|
|
||||||
//Todo IOVEC entries shoule be lower IOVEMAX
|
//Todo IOVEC entries shoule be lower IOVEMAX
|
||||||
private static final int IOV_ENTRIES = 500;
|
private static final int IOV_ENTRIES = 1024;
|
||||||
|
|
||||||
private static final int IOVEC_ARRAY_SIZE = IOV_SIZE * IOV_ENTRIES;
|
private static final int IOVEC_ARRAY_SIZE = IOV_SIZE * IOV_ENTRIES;
|
||||||
private static final int CAPACITY = IOVEC_ARRAY_SIZE * poolSize;
|
private static final int CAPACITY = IOVEC_ARRAY_SIZE * poolSize;
|
||||||
@ -60,6 +60,7 @@ final class IovecArrayPool implements MessageProcessor {
|
|||||||
long index = remainingIovec.pop();
|
long index = remainingIovec.pop();
|
||||||
|
|
||||||
currentIovecMemoryAddress = index * IOVEC_ARRAY_SIZE + iovecArrayMemoryAddress;
|
currentIovecMemoryAddress = index * IOVEC_ARRAY_SIZE + iovecArrayMemoryAddress;
|
||||||
|
|
||||||
return currentIovecMemoryAddress;
|
return currentIovecMemoryAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +125,6 @@ final class IovecArrayPool implements MessageProcessor {
|
|||||||
PlatformDependent.putLong(baseOffset + currentIovecMemoryAddress, addr);
|
PlatformDependent.putLong(baseOffset + currentIovecMemoryAddress, addr);
|
||||||
PlatformDependent.putLong(lengthOffset + currentIovecMemoryAddress, len);
|
PlatformDependent.putLong(lengthOffset + currentIovecMemoryAddress, len);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
assert ADDRESS_SIZE == 4;
|
|
||||||
if (PlatformDependent.hasUnsafe()) {
|
|
||||||
PlatformDependent.putInt(baseOffset + currentIovecMemoryAddress, (int) addr);
|
|
||||||
PlatformDependent.putInt(lengthOffset + currentIovecMemoryAddress, len);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 The Netty Project
|
||||||
|
*
|
||||||
|
* The Netty Project licenses this file to you 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.
|
||||||
|
*/
|
||||||
|
package io.netty.channel.uring;
|
||||||
|
|
||||||
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
|
import io.netty.testsuite.transport.TestsuitePermutation;
|
||||||
|
import io.netty.testsuite.transport.socket.SocketObjectEchoTest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class IOUringSocketObjectEchoTest extends SocketObjectEchoTest {
|
||||||
|
@Override
|
||||||
|
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
|
||||||
|
return IOUringSocketTestPermutation.INSTANCE.socket();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 The Netty Project
|
||||||
|
*
|
||||||
|
* The Netty Project licenses this file to you 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.
|
||||||
|
*/
|
||||||
|
package io.netty.channel.uring;
|
||||||
|
|
||||||
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
|
import io.netty.testsuite.transport.TestsuitePermutation;
|
||||||
|
import io.netty.testsuite.transport.socket.SocketStringEchoTest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class IOUringSocketStringEchoTest extends SocketStringEchoTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
|
||||||
|
return IOUringSocketTestPermutation.INSTANCE.socket();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user