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);
|
||||
}
|
||||
|
||||
// @Test(timeout = 30000)
|
||||
// public void testSimpleEchoNotAutoRead() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, false, false, false);
|
||||
// }
|
||||
//
|
||||
// @Test//(timeout = 30000)
|
||||
// public void testSimpleEchoWithAdditionalExecutor() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoWithAdditionalExecutor(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, true, false, true);
|
||||
// }
|
||||
//
|
||||
// @Test//(timeout = 30000)
|
||||
// public void testSimpleEchoWithAdditionalExecutorNotAutoRead() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoWithAdditionalExecutorNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, true, false, false);
|
||||
// }
|
||||
//
|
||||
// @Test//(timeout = 30000)
|
||||
// public void testSimpleEchoWithVoidPromise() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoWithVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, false, true, true);
|
||||
// }
|
||||
//
|
||||
// @Test//(timeout = 30000)
|
||||
// public void testSimpleEchoWithVoidPromiseNotAutoRead() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoWithVoidPromiseNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, false, true, false);
|
||||
// }
|
||||
//
|
||||
// @Test(timeout = 30000)
|
||||
// public void testSimpleEchoWithAdditionalExecutorAndVoidPromise() throws Throwable {
|
||||
// run();
|
||||
// }
|
||||
//
|
||||
// public void testSimpleEchoWithAdditionalExecutorAndVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
// testSimpleEcho0(sb, cb, true, true, true);
|
||||
// }
|
||||
@Test(timeout = 30000)
|
||||
public void testSimpleEchoNotAutoRead() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, false, false, false);
|
||||
}
|
||||
|
||||
@Test//(timeout = 30000)
|
||||
public void testSimpleEchoWithAdditionalExecutor() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithAdditionalExecutor(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, true, false, true);
|
||||
}
|
||||
|
||||
@Test//(timeout = 30000)
|
||||
public void testSimpleEchoWithAdditionalExecutorNotAutoRead() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithAdditionalExecutorNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, true, false, false);
|
||||
}
|
||||
|
||||
@Test//(timeout = 30000)
|
||||
public void testSimpleEchoWithVoidPromise() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, false, true, true);
|
||||
}
|
||||
|
||||
@Test//(timeout = 30000)
|
||||
public void testSimpleEchoWithVoidPromiseNotAutoRead() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithVoidPromiseNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, false, true, false);
|
||||
}
|
||||
|
||||
@Test(timeout = 30000)
|
||||
public void testSimpleEchoWithAdditionalExecutorAndVoidPromise() throws Throwable {
|
||||
run();
|
||||
}
|
||||
|
||||
public void testSimpleEchoWithAdditionalExecutorAndVoidPromise(ServerBootstrap sb, Bootstrap cb) throws Throwable {
|
||||
testSimpleEcho0(sb, cb, true, true, true);
|
||||
}
|
||||
|
||||
private static void testSimpleEcho0(
|
||||
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;
|
||||
|
||||
//to release it
|
||||
private long iovecMemoryAddress;
|
||||
private long iovecMemoryAddress = -1;
|
||||
|
||||
AbstractIOUringChannel(final Channel parent, LinuxSocket socket) {
|
||||
super(parent);
|
||||
@ -274,8 +274,6 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
|
||||
int msgCount = in.size();
|
||||
if (msgCount > 1 && in.current() instanceof ByteBuf) {
|
||||
doWriteMultiple(in);
|
||||
//Object msg = in.current();
|
||||
//doWriteSingle((ByteBuf) msg);
|
||||
} else if (msgCount == 1) {
|
||||
Object msg = in.current();
|
||||
doWriteSingle((ByteBuf) msg);
|
||||
|
@ -25,12 +25,6 @@ final class IOUringRecvByteAllocatorHandle extends RecvByteBufAllocator.Delegati
|
||||
implements RecvByteBufAllocator.ExtendedHandle {
|
||||
private final PreferredDirectByteBufAllocator preferredDirectByteBufAllocator =
|
||||
new PreferredDirectByteBufAllocator();
|
||||
private final UncheckedBooleanSupplier defaultMaybeMoreDataSupplier = new UncheckedBooleanSupplier() {
|
||||
@Override
|
||||
public boolean get() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
IOUringRecvByteAllocatorHandle(RecvByteBufAllocator.ExtendedHandle handle) {
|
||||
super(handle);
|
||||
|
@ -19,7 +19,7 @@ final class IovecArrayPool implements MessageProcessor {
|
||||
private static int poolSize = 40;
|
||||
|
||||
//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 CAPACITY = IOVEC_ARRAY_SIZE * poolSize;
|
||||
@ -60,6 +60,7 @@ final class IovecArrayPool implements MessageProcessor {
|
||||
long index = remainingIovec.pop();
|
||||
|
||||
currentIovecMemoryAddress = index * IOVEC_ARRAY_SIZE + iovecArrayMemoryAddress;
|
||||
|
||||
return currentIovecMemoryAddress;
|
||||
}
|
||||
|
||||
@ -124,12 +125,6 @@ final class IovecArrayPool implements MessageProcessor {
|
||||
PlatformDependent.putLong(baseOffset + currentIovecMemoryAddress, addr);
|
||||
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;
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user