Skip to content

Commit

Permalink
roscpp/transport_tcp: enable poll event POLLRDHUP to detect dead (#1704)
Browse files Browse the repository at this point in the history
connections properly
  • Loading branch information
cwecht authored and dirk-thomas committed Aug 7, 2019
1 parent 18fbb59 commit 185f8c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clients/roscpp/src/libros/transport/transport_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ bool TransportTCP::initializeSocket()
{
ROS_DEBUG("Adding tcp socket [%d] to pollset", sock_);
poll_set_->addSocket(sock_, boost::bind(&TransportTCP::socketUpdate, this, _1), shared_from_this());
#if defined(POLLRDHUP) // POLLRDHUP is not part of POSIX!
// This is needed to detect dead connections. #1704
poll_set_->addEvents(sock_, POLLRDHUP);
#endif
}

if (!(flags_ & SYNCHRONOUS))
Expand Down Expand Up @@ -696,6 +700,9 @@ void TransportTCP::socketUpdate(int events)

if((events & POLLERR) ||
(events & POLLHUP) ||
#if defined(POLLRDHUP) // POLLRDHUP is not part of POSIX!
(events & POLLRDHUP) ||
#endif
(events & POLLNVAL))
{
uint32_t error = -1;
Expand Down

0 comments on commit 185f8c5

Please sign in to comment.