diff options
author | Brian Orr <brian.orr@gmail.com> | 2017-08-09 17:35:21 -0700 |
---|---|---|
committer | Brian Orr <brian.orr@gmail.com> | 2017-08-09 17:35:21 -0700 |
commit | ff794c230e8f5215f5347b2d6903779fe8a2a9b3 (patch) | |
tree | 25dbc389565c97f89a638813293916382e002b28 /gr-blocks/lib/tcp_connection.h | |
parent | 811bee8c54bdca5c53c2ccbc6ef6d1bbca55eaae (diff) |
Fix invalid Asio buffer usage in tcp_connection
Asio requires that the underlying buffer passed to `async_write()`
remain valid valid until the handler was called. The previous version
was allocating a vector on the stack which gets destroyed once the
`send()` method returns.
Added a unit test for TCP server.
Diffstat (limited to 'gr-blocks/lib/tcp_connection.h')
-rw-r--r-- | gr-blocks/lib/tcp_connection.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h index 6eeb64e54f..f45650577b 100644 --- a/gr-blocks/lib/tcp_connection.h +++ b/gr-blocks/lib/tcp_connection.h @@ -53,7 +53,9 @@ namespace gr { void start(gr::basic_block *block); void send(pmt::pmt_t vector); void handle_read(const boost::system::error_code& error, size_t bytes_transferred); - void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { } + void handle_write(char* txbuf, const boost::system::error_code& error, size_t bytes_transferred) { + delete[] txbuf; + } }; } /* namespace blocks */ |