aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorPaul David <paul.david@ettus.com>2017-02-02 14:54:43 -0500
committerAshish Chaudhari <ashish.chaudhari@ettus.com>2017-02-13 13:18:18 -0800
commit4987ea710b2b95f1e1a8756b53997690f17e8fda (patch)
treec52d2b9ece2cc6a57e949206d626d918a44d39d1 /host/lib
parentee59dc309d2b3a57eea3160e4fd9ec8a1089101c (diff)
downloaduhd-4987ea710b2b95f1e1a8756b53997690f17e8fda.tar.gz
uhd-4987ea710b2b95f1e1a8756b53997690f17e8fda.tar.bz2
uhd-4987ea710b2b95f1e1a8756b53997690f17e8fda.zip
UDP transport: Utilize poll instead of select
- Avoids the descriptor limit of 1024 on FD_SETSIZE - Fixes a buffer overflow due to that limit - Keeps select around for Windows compatibility
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/transport/udp_common.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/host/lib/transport/udp_common.hpp b/host/lib/transport/udp_common.hpp
index bf4712613..82eee237b 100644
--- a/host/lib/transport/udp_common.hpp
+++ b/host/lib/transport/udp_common.hpp
@@ -32,6 +32,7 @@ namespace uhd{ namespace transport{
* \return true when the socket is ready for receive
*/
UHD_INLINE bool wait_for_recv_ready(int sock_fd, double timeout){
+#ifdef UHD_PLATFORM_WIN32 // select is more portable than poll unfortunately
//setup timeval for timeout
timeval tv;
//If the tv_usec > 1 second on some platforms, select will
@@ -53,6 +54,17 @@ namespace uhd{ namespace transport{
//call select with timeout on receive socket
return TEMP_FAILURE_RETRY(::select(sock_fd+1, &rset, NULL, NULL, &tv)) > 0;
+#else
+ //calculate the total timeout in milliseconds (from seconds)
+ int total_timeout = int(timeout*1000);
+
+ pollfd pfd_read;
+ pfd_read.fd = sock_fd;
+ pfd_read.events = POLLIN;
+
+ //call poll with timeout on receive socket
+ return ::poll(&pfd_read, 1, total_timeout) > 0;
+#endif
}
}} //namespace uhd::transport