aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-05-21 12:04:02 +0200
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:06 -0400
commitadf5d4c2e4e7a2979a6ca6de806151fe04c23162 (patch)
tree00608baf1c5e60f0858685ba54421def4cb91341 /src
parentee44fa95761724a83a76dd862a36bd9af0fc021f (diff)
downloadbitcoin-adf5d4c2e4e7a2979a6ca6de806151fe04c23162.tar.xz
net: SocketSendData returns written size
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp5
-rw-r--r--src/net.h2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index a62ee2291c..aded8d05d3 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -791,9 +791,10 @@ int CNetMessage::readData(const char *pch, unsigned int nBytes)
// requires LOCK(cs_vSend)
-void SocketSendData(CNode *pnode)
+size_t SocketSendData(CNode *pnode)
{
std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin();
+ size_t nSentSize = 0;
while (it != pnode->vSendMsg.end()) {
const CSerializeData &data = *it;
@@ -804,6 +805,7 @@ void SocketSendData(CNode *pnode)
pnode->nSendBytes += nBytes;
pnode->nSendOffset += nBytes;
pnode->RecordBytesSent(nBytes);
+ nSentSize += nBytes;
if (pnode->nSendOffset == data.size()) {
pnode->nSendOffset = 0;
pnode->nSendSize -= data.size();
@@ -832,6 +834,7 @@ void SocketSendData(CNode *pnode)
assert(pnode->nSendSize == 0);
}
pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it);
+ return nSentSize;
}
static std::list<CNode*> vNodesDisconnected;
diff --git a/src/net.h b/src/net.h
index 0e83ff4a0c..503e009c49 100644
--- a/src/net.h
+++ b/src/net.h
@@ -236,7 +236,7 @@ unsigned short GetListenPort();
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 StopNode(CConnman& connman);
-void SocketSendData(CNode *pnode);
+size_t SocketSendData(CNode *pnode);
struct CombinerAll
{