commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/05: blocks: fix destruction and shutdown


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/05: blocks: fix destruction and shutdown for socket_pdu
Date: Wed, 14 Oct 2015 02:48:37 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit bde02e814e7f68e6ebf945d7f294014605fd3239
Author: Nathan West <address@hidden>
Date:   Mon Oct 5 18:15:20 2015 -0400

    blocks: fix destruction and shutdown for socket_pdu
    
    This removes the inheritance from stream_pdu_base and stop the
    io_service and internal service thread when stop() and dtor are
    called.
---
 gr-blocks/lib/socket_pdu_impl.cc | 17 +++++++++++++++++
 gr-blocks/lib/socket_pdu_impl.h  |  7 ++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
index 756e2df..7f7abd5 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 c0262ce..e45f6d4 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 */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]