Merge pull request #16 from normanmaurer/composite_fix

Correctly handle CompositeByteBuf when using IOURING
This commit is contained in:
Josef Grieb 2020-09-01 16:12:37 +02:00 committed by GitHub
commit bfc51bffd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 3 deletions

View File

@ -276,12 +276,18 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
if (writeScheduled) {
return;
}
int msgCount = in.size();
if (msgCount > 1 && in.current() instanceof ByteBuf) {
if (msgCount == 0) {
return;
}
ByteBuf msg = (ByteBuf) in.current();
if (msgCount > 1 ||
// We also need some special handling for CompositeByteBuf
msg.nioBufferCount() > 1) {
doWriteMultiple(in);
} else if (msgCount == 1) {
Object msg = in.current();
doWriteSingle((ByteBuf) msg);
doWriteSingle(msg);
}
}

View File

@ -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.CompositeBufferGatheringWriteTest;
import java.util.List;
public class IOUringCompositeBufferGatheringWriteTest extends CompositeBufferGatheringWriteTest {
@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return IOUringSocketTestPermutation.INSTANCE.socket();
}
}