mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 01:50:46 +02:00
Adds multiple retries to accept reverse connection
We observed that the accept failed nondeterministically in rare cases.
This commit is contained in:
@@ -60,10 +60,14 @@ bool URServer::accept()
|
|||||||
|
|
||||||
struct sockaddr addr;
|
struct sockaddr addr;
|
||||||
socklen_t addr_len;
|
socklen_t addr_len;
|
||||||
int client_fd = ::accept(getSocketFD(), &addr, &addr_len);
|
int client_fd = -1;
|
||||||
|
|
||||||
if (client_fd <= 0)
|
int retry = 0;
|
||||||
return false;
|
while((client_fd = ::accept(getSocketFD(), &addr, &addr_len)) == -1){
|
||||||
|
ROS_ERROR_STREAM("Accepting socket connection failed. (errno: " << errno << ")");
|
||||||
|
if(retry++ >= 5)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setOptions(client_fd);
|
setOptions(client_fd);
|
||||||
|
|
||||||
@@ -81,4 +85,4 @@ void URServer::disconnectClient()
|
|||||||
bool URServer::write(const uint8_t* buf, size_t buf_len, size_t& written)
|
bool URServer::write(const uint8_t* buf, size_t buf_len, size_t& written)
|
||||||
{
|
{
|
||||||
return client_.write(buf, buf_len, written);
|
return client_.write(buf, buf_len, written);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user