correct buffering
This commit is contained in:
parent
0c41298fe0
commit
b227bf6ff1
@ -47,7 +47,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
size_t conns;
|
size_t conns;
|
||||||
int epollfd;
|
int epollfd;
|
||||||
char readbuf[2048];
|
char readbuf[128];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,23 +151,30 @@ void Mainloop::Run()
|
|||||||
}
|
}
|
||||||
if(ev->events & EPOLLIN && handler->readable())
|
if(ev->events & EPOLLIN && handler->readable())
|
||||||
{
|
{
|
||||||
int readed = handler->read(readbuf, sizeof(readbuf));
|
bool errored = false;
|
||||||
if(readed == -1)
|
while(true)
|
||||||
{
|
{
|
||||||
if(errno != EAGAIN)
|
int readed = handler->read(readbuf, sizeof(readbuf));
|
||||||
|
if(readed == -1)
|
||||||
|
{
|
||||||
|
if(errno != EAGAIN)
|
||||||
|
{
|
||||||
|
perror("read()");
|
||||||
|
handler->close();
|
||||||
|
delete handler;
|
||||||
|
errored = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (readed == 0)
|
||||||
{
|
{
|
||||||
perror("read()");
|
|
||||||
handler->close();
|
handler->close();
|
||||||
delete handler;
|
delete handler;
|
||||||
continue;
|
errored = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (readed == 0)
|
if(errored) continue;
|
||||||
{
|
|
||||||
handler->close();
|
|
||||||
delete handler;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(ev->events & EPOLLOUT && handler->writeable())
|
if(ev->events & EPOLLOUT && handler->writeable())
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,8 @@ void NNTPServerHandler::OnData(const char *data, ssize_t l)
|
|||||||
}
|
}
|
||||||
ArticleObtained();
|
ArticleObtained();
|
||||||
diff += 5;
|
diff += 5;
|
||||||
Data(end + 5, l - diff);
|
if(l - diff)
|
||||||
|
Data(end + 5, l - diff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_article)
|
if (m_article)
|
||||||
|
Reference in New Issue
Block a user