summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-04-17 14:07:58 -0700
committerJosh Blum <josh@joshknows.com>2012-04-17 14:07:58 -0700
commit4a1ec80d496e7754cf5a8c0f96322b2871094a31 (patch)
tree32e505c00525bb274aa474a0150ff5bda026fc0f /host/lib/transport
parenta345c19cc2d4e9556b46b48d75b8ccc35b95ba45 (diff)
downloaduhd-4a1ec80d496e7754cf5a8c0f96322b2871094a31.tar.gz
uhd-4a1ec80d496e7754cf5a8c0f96322b2871094a31.tar.bz2
uhd-4a1ec80d496e7754cf5a8c0f96322b2871094a31.zip
usb: do not release recv buffer in wrapper
The actual recv buffer will be automatically released when dereferenced. By releasing this buffer early we allowed for a race condition: Subsequent wrapper buffers that shared the same actual buffer could get their memory filled by new recvd packets from the USB layer.
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/usb_zero_copy_wrapper.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/host/lib/transport/usb_zero_copy_wrapper.cpp b/host/lib/transport/usb_zero_copy_wrapper.cpp
index 690e5aaa2..3571ed856 100644
--- a/host/lib/transport/usb_zero_copy_wrapper.cpp
+++ b/host/lib/transport/usb_zero_copy_wrapper.cpp
@@ -35,10 +35,9 @@ public:
_queue(queue){/*NOP*/}
void release(void){
- if (_mrb.get() == NULL) return;
- _mrb->release();
+ if (not _mrb) return;
+ _mrb.reset(); //decrement ref count, other MRB's may hold a ref
_queue.push_with_haste(this);
- _mrb.reset();
}
UHD_INLINE sptr get_new(managed_recv_buffer::sptr mrb, const void *mem, size_t len){