Revision 7f8c73fa

b/host/lib/transport/libusb1_zero_copy.cpp
555 555
    libusb_managed_send_buffer_impl(libusb_transfer *lut,
556 556
                                    usb_endpoint *endpoint,
557 557
                                    size_t buff_size)
558
        : _buff(lut->buffer, buff_size)
558
        : _buff(lut->buffer, buff_size), _committed(false)
559 559
    {
560 560
        _lut = lut;
561 561
        _endpoint = endpoint;
......
563 563

  
564 564
    ~libusb_managed_send_buffer_impl()
565 565
    {
566
        /* NOP */
566
        if (!_committed) {
567
            _lut->length = 0;
568
            _lut->actual_length = 0;
569
            _endpoint->submit(_lut);
570
        }
567 571
    }
568 572

  
569 573
    ssize_t commit(size_t num_bytes)
570 574
    {
575
        if (_committed) {
576
            std::cerr << "UHD: send buffer already committed" << std::endl;
577
            return 0;
578
        }
579
        
580
        UHD_ASSERT_THROW(num_bytes <= boost::asio::buffer_size(_buff));
581

  
571 582
        _lut->length = num_bytes;
572 583
        _lut->actual_length = 0;
573 584

  
574
        if (_endpoint->submit(_lut))
585
        if (_endpoint->submit(_lut)) {
586
            _committed = true;
575 587
            return num_bytes;
576
        else
588
        }
589
        else {
577 590
            return 0;
591
        }
578 592
    }
579 593

  
580 594
private:
......
586 600
    libusb_transfer *_lut;
587 601
    usb_endpoint *_endpoint;
588 602
    const boost::asio::mutable_buffer _buff;
603
    bool _committed;
589 604
};
590 605

  
591 606

  

Also available in: Unified diff