You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ valgrind -q --leak-check=full ./tcp-client
Connected to the server successfully.
Message from the Server: OK!
123
Message from the Server: OK!
123
Message from the Server: OK!
123
Message from the Server: OK!
123
Message from the Server: OK!
123
Message from the Server: OK!
123
Message from the Server: OK!
^C==9540== 288 bytes in 1 blocks are possibly lost in loss record 2 of 2
==9540== at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9540== by 0x40149CA: allocate_dtv (dl-tls.c:286)
==9540== by 0x40149CA: _dl_allocate_tls (dl-tls.c:532)
==9540== by 0x4860322: allocate_stack (allocatestack.c:622)
==9540== by 0x4860322: pthread_create@@GLIBC_2.2.5 (pthread_create.c:660)
==9540== by 0x49510A8: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==9540== by 0x10CE6E: std::thread::thread<void (&)(TCPSocket*), TCPSocket*, void>(void (&)(TCPSocket*), TCPSocket*&&) (in /home/ardxwe/github/async-sockets-cpp/examples/tcp-client)
==9540== by 0x10C788: TCPSocket::Listen() (in /home/ardxwe/github/async-sockets-cpp/examples/tcp-client)
==9540== by 0x10C6F9: TCPSocket::Connect(unsigned int, unsigned short, std::function<void ()>, std::function<void (int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)>) (in /home/ardxwe/github/async-sockets-cpp/examples/tcp-client)
==9540== by 0x10C525: TCPSocket::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned short, std::function<void ()>, std::function<void (int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)>) (in /home/ardxwe/github/async-sockets-cpp/examples/tcp-client)
==9540== by 0x10A9AF: main (in /home/ardxwe/github/async-sockets-cpp/examples/tcp-client)
==9540==
I think we shouldn't use std::thread.detach.
The text was updated successfully, but these errors were encountered:
The detached threads end when function finish. So the return of recv() not bigger than 0 makes thread function finish and clear itself. Yes valgrind shows a leak because of the detached thread but I see no problem here.
I think we shouldn't use std::thread.detach.
The text was updated successfully, but these errors were encountered: