Add test in which close is delayed
Add test in which close is delayed

With this commit, we have the following use after free errors:

$ valgrind ./src/callbacks
==15367== Memcheck, a memory error detector
==15367== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15367== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==15367== Command: ./src/callbacks
==15367==
==15367== Invalid write of size 8
==15367==    at 0x40461A: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f060 is 32 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x404644: std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404550: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f090 is 80 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x404672: std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404550: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f090 is 80 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid write of size 8
==15367==    at 0x40469A: std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404550: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f090 is 80 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x4045C4: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40456E: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0c0 is 128 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x4045F2: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40456E: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0c0 is 128 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid write of size 8
==15367==    at 0x40461A: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40456E: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0c0 is 128 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x4046C4: std::__1::function<void (int)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40458C: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0f0 is 176 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid read of size 8
==15367==    at 0x4046F2: std::__1::function<void (int)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40458C: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0f0 is 176 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid write of size 8
==15367==    at 0x40471A: std::__1::function<void (int)>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40458C: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f0f0 is 176 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367== Invalid write of size 4
==15367==    at 0x404591: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40272B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::operator()() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4041F2: std::__1::function<void ()>::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404154: cxx_experiments::Transport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40295D: MyTransport::emit_connect() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401816: main (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==  Address 0x5e3f100 is 192 bytes inside a block of size 208 free'd
==15367==    at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15367==    by 0x405473: std::__1::__shared_ptr_pointer<MyTransport*, std::__1::default_delete<MyTransport>, std::__1::allocator<MyTransport> >::__on_zero_shared() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4EFE8A2: std::__1::__shared_weak_count::__release_shared() (in /usr/lib/x86_64-linux-gnu/libc++.so.1.0)
==15367==    by 0x4044FE: std::__1::shared_ptr<MyTransport>::~shared_ptr() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4044C4: cxx_experiments::Pointer<MyTransport>::~Pointer() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x401BA4: create_transport()::$_0::~$_0() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402844: std::__1::__libcpp_compressed_pair_imp<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, 2u>::~__libcpp_compressed_pair_imp() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x402824: std::__1::__compressed_pair<create_transport()::$_0, std::__1::allocator<create_transport()::$_0> >::~__compressed_pair() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x40265B: std::__1::__function::__func<create_transport()::$_0, std::__1::allocator<create_transport()::$_0>, void ()>::destroy() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4045E8: std::__1::function<void ()>::operator=(decltype(nullptr)) (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x404532: cxx_experiments::Transport::close() (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==    by 0x4027FC: create_transport()::$_0::operator()() const (in /home/sbasso/src/cxx-experiments/src/callbacks)
==15367==
==15367==
==15367== HEAP SUMMARY:
==15367==     in use at exit: 0 bytes in 0 blocks
==15367==   total heap usage: 2 allocs, 2 frees, 240 bytes allocated
==15367==
==15367== All heap blocks were freed -- no leaks are possible
==15367==
==15367== For counts of detected and suppressed errors, rerun with: -v
==15367== ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 0 from 0)

bassosimone/cxx-experiments