diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2013-01-15 14:45:18 -0800 |
---|---|---|
committer | Nicholas Corgan <nick.corgan@ettus.com> | 2013-01-15 14:45:18 -0800 |
commit | 9b4804c17a97401ed77f4b98b34159de8de62292 (patch) | |
tree | a1041ffde92206f7185c831c307e10cdba1c4da8 /host/lib | |
parent | a3b7a3f8498d5e32f5aaa1051401e8a57c92cb3d (diff) | |
parent | 58a123c907b38ebf87ae1993e1e8572c21d32f91 (diff) | |
download | uhd-9b4804c17a97401ed77f4b98b34159de8de62292.tar.gz uhd-9b4804c17a97401ed77f4b98b34159de8de62292.tar.bz2 uhd-9b4804c17a97401ed77f4b98b34159de8de62292.zip |
Merge branch 'maint'
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/transport/udp_zero_copy.cpp | 18 |
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(); } |