Skip to content

Commit d38fc31

Browse files
committed
Fix TCPSocket timeout issues
1 parent c11eff4 commit d38fc31

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

include/ur_client_library/comm/pipeline.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ class Pipeline
342342
producer_.stopProducer();
343343
if (pThread_.joinable())
344344
{
345-
printf("Join Thread");
346345
pThread_.join();
347346
}
348347
if (cThread_.joinable())
@@ -397,15 +396,13 @@ class Pipeline
397396
std::vector<std::unique_ptr<T>> products;
398397
while (running_)
399398
{
400-
printf("runProducer() is running\n");
401399
if (!producer_.tryGet(products))
402400
{
403401
producer_.teardownProducer();
404402
running_ = false;
405403
break;
406404
}
407405

408-
printf("runProducer() for loop\n");
409406
for (auto& p : products)
410407
{
411408
if (!queue_.tryEnqueue(std::move(p)))
@@ -416,7 +413,6 @@ class Pipeline
416413

417414
products.clear();
418415
}
419-
printf("runProducer() ended\n");
420416
URCL_LOG_DEBUG("Pipeline producer ended! <%s>", name_.c_str());
421417
notifier_.stopped(name_);
422418
}

src/comm/tcp_socket.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void TCPSocket::setupOptions()
5959
if (recv_timeout_ != nullptr)
6060
{
6161
#ifdef _WIN32
62-
DWORD value = recv_timeout_->tv_usec * 1000;
63-
value += recv_timeout_->tv_sec / 1000;
62+
DWORD value = recv_timeout_->tv_sec * 1000;
63+
value += recv_timeout_->tv_usec / 1000;
6464
ur_setsockopt(socket_fd_, SOL_SOCKET, SO_RCVTIMEO, &value, sizeof(value));
6565
#else
6666
ur_setsockopt(socket_fd_, SOL_SOCKET, SO_RCVTIMEO, recv_timeout_.get(), sizeof(timeval));
@@ -202,7 +202,8 @@ bool TCPSocket::read(uint8_t* buf, const size_t buf_len, size_t& read)
202202
{
203203
res = 0;
204204
#ifdef _WIN32
205-
if (::WSAGetLastError() != WSAEWOULDBLOCK)
205+
int code = ::WSAGetLastError();
206+
if (code != WSAETIMEDOUT && code != WSAEWOULDBLOCK)
206207
{
207208
state_ = SocketState::Disconnected;
208209
}

0 commit comments

Comments
 (0)