summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-01-14 13:58:42 -0800
committerNicholas Corgan <nick.corgan@ettus.com>2013-01-15 14:45:08 -0800
commit58a123c907b38ebf87ae1993e1e8572c21d32f91 (patch)
treede41a67e443e312b675116a64ff6767ea924b73a /host/lib/transport
parent85883530b160de19dba9c3cd3cf21488e61d0806 (diff)
downloaduhd-58a123c907b38ebf87ae1993e1e8572c21d32f91.tar.gz
uhd-58a123c907b38ebf87ae1993e1e8572c21d32f91.tar.bz2
uhd-58a123c907b38ebf87ae1993e1e8572c21d32f91.zip
udp: fix ENOBUFS with send/retry for udp socket
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/udp_zero_copy.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp
index 9125be53a..166177177 100644
--- a/host/lib/transport/udp_zero_copy.cpp
+++ b/host/lib/transport/udp_zero_copy.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2012 Ettus Research LLC
+// Copyright 2010-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
#include <uhd/utils/atomic.hpp>
#include <boost/format.hpp>
#include <boost/make_shared.hpp>
+#include <boost/thread/thread.hpp> //sleep
#include <vector>
using namespace uhd;
@@ -112,7 +113,20 @@ public:
_mem(mem), _sock_fd(sock_fd), _frame_size(frame_size) { /*NOP*/ }
void release(void){
- UHD_ASSERT_THROW(::send(_sock_fd, (const char *)_mem, size(), 0) == ssize_t(size()));
+ //Retry logic because send may fail with ENOBUFS.
+ //This is known to occur at least on some OSX systems.
+ //But it should be safe to always check for the error.
+ while (true)
+ {
+ const ssize_t ret = ::send(_sock_fd, (const char *)_mem, size(), 0);
+ if (ret == ssize_t(size())) break;
+ if (ret == -1 and errno == ENOBUFS)
+ {
+ boost::this_thread::sleep(boost::posix_time::microseconds(1));
+ continue; //try to send again
+ }
+ UHD_ASSERT_THROW(ret == ssize_t(size()));
+ }
_claimer.release();
}