net: SocketSendData returns written size
This commit is contained in:
parent
ee44fa9576
commit
adf5d4c2e4
2 changed files with 5 additions and 2 deletions
|
@ -791,9 +791,10 @@ int CNetMessage::readData(const char *pch, unsigned int nBytes)
|
||||||
|
|
||||||
|
|
||||||
// requires LOCK(cs_vSend)
|
// requires LOCK(cs_vSend)
|
||||||
void SocketSendData(CNode *pnode)
|
size_t SocketSendData(CNode *pnode)
|
||||||
{
|
{
|
||||||
std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin();
|
std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin();
|
||||||
|
size_t nSentSize = 0;
|
||||||
|
|
||||||
while (it != pnode->vSendMsg.end()) {
|
while (it != pnode->vSendMsg.end()) {
|
||||||
const CSerializeData &data = *it;
|
const CSerializeData &data = *it;
|
||||||
|
@ -804,6 +805,7 @@ void SocketSendData(CNode *pnode)
|
||||||
pnode->nSendBytes += nBytes;
|
pnode->nSendBytes += nBytes;
|
||||||
pnode->nSendOffset += nBytes;
|
pnode->nSendOffset += nBytes;
|
||||||
pnode->RecordBytesSent(nBytes);
|
pnode->RecordBytesSent(nBytes);
|
||||||
|
nSentSize += nBytes;
|
||||||
if (pnode->nSendOffset == data.size()) {
|
if (pnode->nSendOffset == data.size()) {
|
||||||
pnode->nSendOffset = 0;
|
pnode->nSendOffset = 0;
|
||||||
pnode->nSendSize -= data.size();
|
pnode->nSendSize -= data.size();
|
||||||
|
@ -832,6 +834,7 @@ void SocketSendData(CNode *pnode)
|
||||||
assert(pnode->nSendSize == 0);
|
assert(pnode->nSendSize == 0);
|
||||||
}
|
}
|
||||||
pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it);
|
pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it);
|
||||||
|
return nSentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::list<CNode*> vNodesDisconnected;
|
static std::list<CNode*> vNodesDisconnected;
|
||||||
|
|
|
@ -236,7 +236,7 @@ unsigned short GetListenPort();
|
||||||
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
|
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
|
||||||
bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, std::string& strNodeError);
|
bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, std::string& strNodeError);
|
||||||
bool StopNode(CConnman& connman);
|
bool StopNode(CConnman& connman);
|
||||||
void SocketSendData(CNode *pnode);
|
size_t SocketSendData(CNode *pnode);
|
||||||
|
|
||||||
struct CombinerAll
|
struct CombinerAll
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue