aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/include/uhd/transport/zero_copy.hpp13
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp10
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp4
-rw-r--r--host/lib/transport/zero_copy.cpp10
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp2
5 files changed, 22 insertions, 17 deletions
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index da10bfbe2..513291b63 100644
--- a/host/include/uhd/transport/zero_copy.hpp
+++ b/host/include/uhd/transport/zero_copy.hpp
@@ -82,8 +82,9 @@ namespace uhd{ namespace transport{
* This should be called to commit the write to the transport object.
* After calling, the referenced memory should be considered invalid.
* \param num_bytes the number of bytes written into the buffer
+ * \return the number of bytes written, 0 for timeout, negative for error
*/
- virtual void commit(size_t num_bytes) = 0;
+ virtual ssize_t commit(size_t num_bytes) = 0;
/*!
* Get the size of the underlying buffer.
@@ -121,6 +122,7 @@ namespace uhd{ namespace transport{
/*!
* Get a new receive buffer from this transport object.
+ * \return a managed buffer, or null sptr on timeout/error
*/
virtual managed_recv_buffer::sptr get_recv_buff(void) = 0;
@@ -135,6 +137,7 @@ namespace uhd{ namespace transport{
/*!
* Get a new send buffer from this transport object.
+ * \return a managed buffer, or null sptr on timeout/error
*/
virtual managed_send_buffer::sptr get_send_buff(void) = 0;
@@ -175,9 +178,9 @@ namespace uhd{ namespace transport{
/*!
* Perform a private copying recv.
* \param buff the buffer to write data into
- * \return the number of bytes written to buff
+ * \return the number of bytes written to buff, 0 for timeout, negative for error
*/
- virtual size_t recv(const boost::asio::mutable_buffer &buff) = 0;
+ virtual ssize_t recv(const boost::asio::mutable_buffer &buff) = 0;
UHD_PIMPL_DECL(impl) _impl;
};
@@ -208,9 +211,9 @@ namespace uhd{ namespace transport{
/*!
* Perform a private copying send.
* \param buff the buffer to read data from
- * \return the number of bytes read from buff
+ * \return the number of bytes read from buff, 0 for timeout, negative for error
*/
- virtual size_t send(const boost::asio::const_buffer &buff) = 0;
+ virtual ssize_t send(const boost::asio::const_buffer &buff) = 0;
UHD_PIMPL_DECL(impl) _impl;
};
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index e3f3ef5bf..98451f188 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -105,7 +105,7 @@ private:
boost::asio::io_service _io_service;
int _sock_fd;
- size_t recv(const boost::asio::mutable_buffer &buff){
+ ssize_t recv(const boost::asio::mutable_buffer &buff){
//setup timeval for timeout
timeval tv;
tv.tv_sec = 0;
@@ -122,17 +122,15 @@ private:
return ::recv(
_sock_fd,
boost::asio::buffer_cast<char *>(buff),
- boost::asio::buffer_size(buff),
- 0
+ boost::asio::buffer_size(buff), 0
);
}
- size_t send(const boost::asio::const_buffer &buff){
+ ssize_t send(const boost::asio::const_buffer &buff){
return ::send(
_sock_fd,
boost::asio::buffer_cast<const char *>(buff),
- boost::asio::buffer_size(buff),
- 0
+ boost::asio::buffer_size(buff), 0
);
}
};
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index c0d6bbe12..221e2bfa6 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -329,7 +329,9 @@ namespace vrt_packet_handler{
);
//commit the samples to the zero-copy interface
- send_buffs[i]->commit(if_packet_info.num_packet_words32*sizeof(boost::uint32_t));
+ if (send_buffs[i]->commit(if_packet_info.num_packet_words32*sizeof(boost::uint32_t)) < num_samps){
+ std::cerr << "commit to send buffer returned less than commit size" << std::endl;
+ }
}
}
diff --git a/host/lib/transport/zero_copy.cpp b/host/lib/transport/zero_copy.cpp
index 27f41329b..42f69d77b 100644
--- a/host/lib/transport/zero_copy.cpp
+++ b/host/lib/transport/zero_copy.cpp
@@ -71,7 +71,9 @@ managed_recv_buffer::sptr phony_zero_copy_recv_if::get_recv_buff(void){
boost::uint8_t *recv_mem = new boost::uint8_t[_impl->max_buff_size];
//call recv() with timeout option
- size_t num_bytes = this->recv(boost::asio::buffer(recv_mem, _impl->max_buff_size));
+ ssize_t num_bytes = this->recv(boost::asio::buffer(recv_mem, _impl->max_buff_size));
+
+ if (num_bytes <= 0) return managed_recv_buffer::sptr(); //NULL sptr
//create a new managed buffer to house the data
return managed_recv_buffer::sptr(
@@ -86,7 +88,7 @@ managed_recv_buffer::sptr phony_zero_copy_recv_if::get_recv_buff(void){
//! phony zero-copy send buffer implementation
class managed_send_buffer_impl : public managed_send_buffer{
public:
- typedef boost::function<size_t(const boost::asio::const_buffer &)> send_fcn_t;
+ typedef boost::function<ssize_t(const boost::asio::const_buffer &)> send_fcn_t;
managed_send_buffer_impl(
const boost::asio::mutable_buffer &buff,
@@ -102,8 +104,8 @@ public:
/* NOP */
}
- void commit(size_t num_bytes){
- _send_fcn(boost::asio::buffer(_buff, num_bytes));
+ ssize_t commit(size_t num_bytes){
+ return _send_fcn(boost::asio::buffer(_buff, num_bytes));
}
private:
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 0853f48be..7e231095f 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -85,7 +85,7 @@ void usrp2_impl::io_impl::recv_pirate_loop(
recv_pirate_crew_raiding = true;
while(recv_pirate_crew_raiding){
managed_recv_buffer::sptr buff = zc_if->get_recv_buff();
- if (buff->size() == 0) continue; //ignore timeout buffers
+ if (not buff.get()) continue; //ignore timeout/error buffers
try{
//extract the vrt header packet info