Azure / DotNetty

DotNetty project – a port of netty, event-driven asynchronous network application framework
Other
4.09k stars 977 forks source link

Does `SocketDatagramChannel.ScheduleMessageWrite` not really works? #425

Open yyjdelete opened 6 years ago

yyjdelete commented 6 years ago

Callback of it is AbstractSocketChannel.AbstractSocketUnsafe.FinishWrite, but it call input.RemoveBytes and which only handle the case of IByteBuffer instead of IAddressedEnvelope<IByteBuffer>

StormHub commented 6 years ago

What do you mean? datagram bytes are sent by io/array buffers https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/Sockets/SocketDatagramChannel.cs#L194 When FinishWrite gets called, the io buffers in the output gets cleared.

yyjdelete commented 6 years ago

https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/Sockets/SocketDatagramChannel.cs#L180 expected an IAddressedEnvelope<IByteBuffer> but FinishWrite call ChannelOutboundBuffer.RemoveBytes(int) which only work with IByteBuffer. https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/Sockets/AbstractSocketChannel.cs#L412

caozhiyuan commented 6 years ago

@yyjdelete look this https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/Sockets/SocketDatagramChannel.cs#L188

StormHub commented 6 years ago

@yyjdelete the point is that it does not need to do anything for IAddressedEnvelope because all data sent through byte arrays.

yyjdelete commented 6 years ago

@StormHub Maybe an assert failure here, and the IAddressedEnvelope will not be removed properly?(Unable to make an test to hit the path)

An missing link: https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/ChannelOutboundBuffer.cs#L289-L293