summaryrefslogtreecommitdiff
path: root/gr-blocks/lib
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2015-10-13 19:03:40 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2015-10-13 19:03:40 -0700
commitce73fbf0986c1e66c83f37b92c3b61d1c9813d60 (patch)
tree3c7547261ec8145af71121a62138afebe1e144e3 /gr-blocks/lib
parentb1883cb00cdb7c9d9d24cd48bf3127ff4aa547ae (diff)
parent5ac4940c2ed1400de10edf35efd47b7b905bd803 (diff)
Merge branch 'maint'
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r--gr-blocks/lib/socket_pdu_impl.cc17
-rw-r--r--gr-blocks/lib/socket_pdu_impl.h7
2 files changed, 23 insertions, 1 deletions
diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
index 756e2dfd0f..7f7abd50be 100644
--- a/gr-blocks/lib/socket_pdu_impl.cc
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -128,6 +128,23 @@ namespace gr {
d_started = true;
}
+ socket_pdu_impl::~socket_pdu_impl()
+ {
+ stop();
+ }
+
+ bool
+ socket_pdu_impl::stop()
+ {
+ if (d_started) {
+ d_io_service.stop();
+ d_thread.interrupt();
+ d_thread.join();
+ }
+ d_started = false;
+ return true;
+ }
+
void
socket_pdu_impl::handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred)
{
diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h
index c0262ce59a..e45f6d4463 100644
--- a/gr-blocks/lib/socket_pdu_impl.h
+++ b/gr-blocks/lib/socket_pdu_impl.h
@@ -30,12 +30,15 @@
namespace gr {
namespace blocks {
- class socket_pdu_impl : public socket_pdu, public stream_pdu_base
+ class socket_pdu_impl : public socket_pdu
{
private:
boost::asio::io_service d_io_service;
std::vector<char> d_rxbuf;
void run_io_service() { d_io_service.run(); }
+ gr::thread::thread d_thread;
+ bool d_started;
+ bool d_finished;
// TCP specific
boost::asio::ip::tcp::endpoint d_tcp_endpoint;
@@ -62,6 +65,8 @@ namespace gr {
public:
socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU = 10000, bool tcp_no_delay = false);
+ ~socket_pdu_impl();
+ bool stop();
};
} /* namespace blocks */