[
https://issues.apache.org/jira/browse/AVRO-1675?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
John Cai updated AVRO-1675:
---------------------------
Description:
SocketTransceiver.ReaderBuffer goes into infinite loop when a bad request is
received from client. It seems the timeout logic is flawed
Test Case - Sending a bad request
{noformat}
int port = server.Port;
const string msg = "1";
var clientSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect("localhost", port);
clientSocket.Send(Encoding.ASCII.GetBytes(msg));
clientSocket.Close();
{noformat}
My fix below
{noformat}
private void ReadBuffer(byte[] buffer, int length)
{
if (length == 0)
return;
int totalReceived = 0;
int numReceived = 0;
do
{
numReceived = channel.Receive(buffer, totalReceived, length -
totalReceived, SocketFlags.None);
totalReceived += numReceived;
Timeout(numReceived);
} while (totalReceived < length);
}
{noformat}
Thanks
John
was:
SocketTransceiver.ReaderBuffer goes into infinite loop when a bad request is
received from client. It seems the timeout doesn't flawed
Test Case - Sending a bad request
{noformat}
int port = server.Port;
const string msg = "1";
var clientSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect("localhost", port);
clientSocket.Send(Encoding.ASCII.GetBytes(msg));
clientSocket.Close();
{noformat}
My fix below
{noformat}
private void ReadBuffer(byte[] buffer, int length)
{
if (length == 0)
return;
int totalReceived = 0;
int numReceived = 0;
do
{
numReceived = channel.Receive(buffer, totalReceived, length -
totalReceived, SocketFlags.None);
totalReceived += numReceived;
Timeout(numReceived);
} while (totalReceived < length);
}
{noformat}
Thanks
John
> CSharp SocketTransceiver.ReadBuffer goes into infinite loop
> -----------------------------------------------------------
>
> Key: AVRO-1675
> URL: https://issues.apache.org/jira/browse/AVRO-1675
> Project: Avro
> Issue Type: Bug
> Components: csharp
> Affects Versions: 1.7.7
> Reporter: John Cai
>
> SocketTransceiver.ReaderBuffer goes into infinite loop when a bad request is
> received from client. It seems the timeout logic is flawed
> Test Case - Sending a bad request
> {noformat}
> int port = server.Port;
> const string msg = "1";
> var clientSocket = new Socket(AddressFamily.InterNetwork,
> SocketType.Stream, ProtocolType.Tcp);
> clientSocket.Connect("localhost", port);
> clientSocket.Send(Encoding.ASCII.GetBytes(msg));
> clientSocket.Close();
> {noformat}
> My fix below
> {noformat}
> private void ReadBuffer(byte[] buffer, int length)
> {
> if (length == 0)
> return;
> int totalReceived = 0;
> int numReceived = 0;
> do
> {
> numReceived = channel.Receive(buffer, totalReceived, length -
> totalReceived, SocketFlags.None);
> totalReceived += numReceived;
> Timeout(numReceived);
> } while (totalReceived < length);
> }
> {noformat}
> Thanks
> John
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)