Commit 27854299 authored by neverlord's avatar neverlord

better diagnostic

parent f2e3753e
......@@ -120,17 +120,11 @@ void mailman_loop()
DEBUG("--> " << to_string(sjob.msg));
// write size of serialized message
auto sent = ::send(peer, &size32, sizeof(std::uint32_t), 0);
if (sent > 0)
if ( sent != static_cast<int>(sizeof(std::uint32_t))
|| static_cast<int>(bs.size()) != ::send(peer, bs.data(), bs.size(), 0))
{
// write message
sent = ::send(peer, bs.data(), bs.size(), 0);
}
// disconnect peer if send() failed
disconnect_peer = (sent <= 0);
// make sure all bytes are written
if (static_cast<std::uint32_t>(sent) != size32)
{
throw std::logic_error("send() not a synchronous socket");
disconnect_peer = true;
DEBUG("too few bytes written");
}
}
// something went wrong; close connection to this peer
......@@ -166,7 +160,7 @@ void mailman_loop()
}
else
{
// TODO: some kind of error handling?
DEBUG("add_peer_job failed: peer already known");
}
}
else if (job->is_kill_job())
......
......@@ -747,7 +747,7 @@ void post_office_loop(int pipe_read_handle, int pipe_write_handle)
for (po_peer& pd : peers)
{
auto fd = pd.get_socket();
if (fd > maxfd) maxfd = fd;
maxfd = std::max(maxfd, fd);
FD_SET(fd, &readset);
}
// iterate over key-value (actor id / doormen) pairs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment