Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 14th, 2013  |  syntax: None  |  size: 1.55 KB  |  hits: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp
  2. index 9125be5..1661771 100644
  3. --- a/host/lib/transport/udp_zero_copy.cpp
  4. +++ b/host/lib/transport/udp_zero_copy.cpp
  5. @@ -1,5 +1,5 @@
  6.  //
  7. -// Copyright 2010-2012 Ettus Research LLC
  8. +// Copyright 2010-2013 Ettus Research LLC
  9.  //
  10.  // This program is free software: you can redistribute it and/or modify
  11.  // it under the terms of the GNU General Public License as published by
  12. @@ -24,6 +24,7 @@
  13.  #include <uhd/utils/atomic.hpp>
  14.  #include <boost/format.hpp>
  15.  #include <boost/make_shared.hpp>
  16. +#include <boost/thread/thread.hpp> //sleep
  17.  #include <vector>
  18.  
  19.  using namespace uhd;
  20. @@ -112,7 +113,20 @@ public:
  21.          _mem(mem), _sock_fd(sock_fd), _frame_size(frame_size) { /*NOP*/ }
  22.  
  23.      void release(void){
  24. -        UHD_ASSERT_THROW(::send(_sock_fd, (const char *)_mem, size(), 0) == ssize_t(size()));
  25. +        //Retry logic because send may fail with ENOBUFS.
  26. +        //This is known to occur at least on some OSX systems.
  27. +        //But it should be safe to always check for the error.
  28. +        while (true)
  29. +        {
  30. +            const ssize_t ret = ::send(_sock_fd, (const char *)_mem, size(), 0);
  31. +            if (ret == ssize_t(size())) break;
  32. +            if (ret == -1 and errno == ENOBUFS)
  33. +            {
  34. +                boost::this_thread::sleep(boost::posix_time::microseconds(1));
  35. +                continue; //try to send again
  36. +            }
  37. +            UHD_ASSERT_THROW(ret == ssize_t(size()));
  38. +        }
  39.          _claimer.release();
  40.      }