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
19
gsock.cpp
19
gsock.cpp
|
@ -456,6 +456,11 @@ struct NBSendResult::_impl
|
||||||
int total;
|
int total;
|
||||||
int done;
|
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.
|
// 0: Not started.
|
||||||
// 1: Data is being sent
|
// 1: Data is being sent
|
||||||
// 2: Data sent without error.
|
// 2: Data sent without error.
|
||||||
|
@ -496,7 +501,14 @@ void NBSendResult::_impl::update()
|
||||||
|
|
||||||
if (err == gerrno::WouldBlock)
|
if (err == gerrno::WouldBlock)
|
||||||
{
|
{
|
||||||
status = 1;
|
if (stopAtEdge)
|
||||||
|
{
|
||||||
|
status = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -512,6 +524,11 @@ NBSendResult::NBSendResult() : _p(new _impl)
|
||||||
_p->status = 0;
|
_p->status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NBSendResult::setStopAtEdge(bool flag)
|
||||||
|
{
|
||||||
|
_p->stopAtEdge = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool NBSendResult::isFinished()
|
bool NBSendResult::isFinished()
|
||||||
{
|
{
|
||||||
_p->update();
|
_p->update();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user