NBSendResult has setStopAtEdge() now

This commit is contained in:
Kirigaya Kazuto 2018-09-12 00:59:03 +08:00
parent 3bad71c8c9
commit 9d4767f741
2 changed files with 20 additions and 1 deletions

View File

@ -456,6 +456,11 @@ struct NBSendResult::_impl
int total;
int done;
// When work together with epoll at ET mode,
// setting this flag can avoid infinite EAGAIN send loop.
// (caused by buffer full or something else)
bool stopAtEdge;
// 0: Not started.
// 1: Data is being sent
// 2: Data sent without error.
@ -495,9 +500,16 @@ void NBSendResult::_impl::update()
errcode = err;
if (err == gerrno::WouldBlock)
{
if (stopAtEdge)
{
status = 2;
}
else
{
status = 1;
}
}
else
{
status = 3;
@ -512,6 +524,11 @@ NBSendResult::NBSendResult() : _p(new _impl)
_p->status = 0;
}
void NBSendResult::setStopAtEdge(bool flag)
{
_p->stopAtEdge = true;
}
bool NBSendResult::isFinished()
{
_p->update();

View File

@ -94,6 +94,8 @@ class NBSendResult
public:
NBSendResult();
void setStopAtEdge(bool flag);
// Is the operation finished.
bool isFinished();