Browse Source

thread-safety fix

cl-refactor
subtly 10 years ago
parent
commit
345416e7d7
  1. 22
      libwhisper/WhisperPeer.cpp

22
libwhisper/WhisperPeer.cpp

@ -82,21 +82,21 @@ bool WhisperPeer::interpret(unsigned _id, RLP const& _r)
void WhisperPeer::sendMessages() void WhisperPeer::sendMessages()
{ {
if (m_unseen.size()) RLPStream amalg;
unsigned msgCount = 0;
{ {
RLPStream amalg; Guard l(x_unseen);
unsigned msgCount; msgCount = m_unseen.size();
while (m_unseen.size())
{ {
Guard l(x_unseen); auto p = *m_unseen.begin();
msgCount = m_unseen.size(); m_unseen.erase(m_unseen.begin());
while (m_unseen.size()) host()->streamMessage(p.second, amalg);
{
auto p = *m_unseen.begin();
m_unseen.erase(m_unseen.begin());
host()->streamMessage(p.second, amalg);
}
} }
}
if (msgCount)
{
RLPStream s; RLPStream s;
prep(s, MessagesPacket, msgCount).appendRaw(amalg.out(), msgCount); prep(s, MessagesPacket, msgCount).appendRaw(amalg.out(), msgCount);
sealAndSend(s); sealAndSend(s);

Loading…
Cancel
Save