public int ReadByte()
{
lock (_streamLock)
{
return Stream.ReadByte();
}
}
public virtual int ReadByte()
{
byte[] array = new byte[1];
if (Read(array, 0, 1) != 0)
{
return array[0];
}
return -1;
}
private string ReadLine()
{
if (!_io.Stream.CanRead)
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder();
bool flag = false;
while (true)
{
char c = (char)_io.ReadByte();
if (c == '\r')
{
flag = true;
continue;
}
if (c == '\n' && flag)
{
break;
}
stringBuilder.Append(c);
flag = false;
}
return stringBuilder.ToString();
}
This function does'nt judgment on returning -1.
It will reproduce the problem when i restart the reids,or in case of network anomaly with redis
I found these datas when i debugged with lldb

And then i suggest the following amendment
private string ReadLine()
{
if (!_io.Stream.CanRead)
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder();
bool flag = false;
int c = -1;
while ((c = _io.ReadByte()) != -1)
{
if ((char)c == '\r')
{
flag = true;
continue;
}
if (((char)c == '\n') || ((char)c == '\n' && flag))
{
break;
}
stringBuilder.Append((char)c);
flag = false;
}
return stringBuilder.ToString();
}
public int ReadByte()
{
lock (_streamLock)
{
return Stream.ReadByte();
}
}
public virtual int ReadByte()
{
byte[] array = new byte[1];
if (Read(array, 0, 1) != 0)
{
return array[0];
}
return -1;
}
private string ReadLine()
{
if (!_io.Stream.CanRead)
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder();
bool flag = false;
while (true)
{
char c = (char)_io.ReadByte();
if (c == '\r')
{
flag = true;
continue;
}
if (c == '\n' && flag)
{
break;
}
stringBuilder.Append(c);
flag = false;
}
return stringBuilder.ToString();
}
This function does'nt judgment on returning -1.
It will reproduce the problem when i restart the reids,or in case of network anomaly with redis
I found these datas when i debugged with lldb
And then i suggest the following amendment
private string ReadLine()
{
if (!_io.Stream.CanRead)
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder();
bool flag = false;
int c = -1;
while ((c = _io.ReadByte()) != -1)
{
if ((char)c == '\r')
{
flag = true;
continue;
}
if (((char)c == '\n') || ((char)c == '\n' && flag))
{
break;
}
stringBuilder.Append((char)c);
flag = false;
}
return stringBuilder.ToString();
}