Commit b00eb1c9 authored by Peter Simonsson's avatar Peter Simonsson

Simplify the code reading from socket

parent 77b66ee5
......@@ -1358,33 +1358,24 @@ void Server::incoming()
// split buffer to lines
QList<QByteArray> bufferLines;
static QByteArray lineBuffer;
while (m_socket->bytesAvailable())
{
QByteArray line(m_socket->readLine());
m_lineBuffer += m_socket->readLine();
if(!lineBuffer.isEmpty())
{
line.prepend(lineBuffer);
lineBuffer.clear();
}
if(line.endsWith('\n') || line.endsWith('\r'))
if(m_lineBuffer.endsWith('\n') || m_lineBuffer.endsWith('\r'))
{
//remove \n blowfish doesn't like it
int i = line.size()-1;
while (i >= 0 && (line[i]=='\n' || line[i]=='\r')) // since euIRC gets away with sending just \r, bet someone sends \n\r?
int i = m_lineBuffer.size()-1;
while (i >= 0 && (m_lineBuffer[i]=='\n' || m_lineBuffer[i]=='\r')) // since euIRC gets away with sending just \r, bet someone sends \n\r?
{
i--;
}
line.truncate(i+1);
m_lineBuffer.truncate(i+1);
if (line.size() > 0)
bufferLines.append(line);
}
else
{
lineBuffer = line;
if (m_lineBuffer.size() > 0)
bufferLines.append(m_lineBuffer);
m_lineBuffer.clear();
}
}
......
......@@ -748,6 +748,7 @@ class Server : public QObject
int m_currentLag;
QStringList m_inputBuffer;
QByteArray m_lineBuffer;
QList<IRCQueue *> m_queues;
// Stats used in QueueTuner
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment