MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ReceiveAndProcess

Method ReceiveAndProcess

src/torcontrol.cpp:148–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148bool TorControlConnection::ReceiveAndProcess()
149{
150 if (!m_sock) return false;
151
152 std::byte buf[4096];
153 ssize_t nread = m_sock->Recv(buf, sizeof(buf), MSG_DONTWAIT);
154
155 if (nread < 0) {
156 int err = WSAGetLastError();
157 if (err == WSAEWOULDBLOCK || err == WSAEINTR || err == WSAEINPROGRESS) {
158 // No data available currently
159 return true;
160 }
161 LogWarning("tor: Error reading from socket: %s", NetworkErrorString(err));
162 return false;
163 }
164
165 if (nread == 0) {
166 LogDebug(BCLog::TOR, "End of stream");
167 return false;
168 }
169
170 m_recv_buffer.insert(m_recv_buffer.end(), buf, buf + nread);
171 try {
172 return ProcessBuffer();
173 } catch (const std::runtime_error& e) {
174 LogWarning("tor: Error processing receive buffer: %s", e.what());
175 return false;
176 }
177}
178
179bool TorControlConnection::ProcessBuffer()
180{

Callers 1

ThreadControlMethod · 0.80

Calls 5

NetworkErrorStringFunction · 0.85
RecvMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected