mirror of
https://github.com/Kiritow/GSock.git
synced 2024-03-22 13:10:51 +08:00
NBSendResult has setStopAtEdge() now
This commit is contained in:
parent
3bad71c8c9
commit
9d4767f741
17
gsock.cpp
17
gsock.cpp
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user