Skip to content

linux support: "Broken pipe" exception #5

@yalov

Description

@yalov

Hello,

on Linux (Ubuntu 20.04 arm64), if the server tries to send something to an already closed client, there is an exception in the libpthread send() function.
I tried to try{} catch(...){} the block in the Scs::Socket::Send , but it did not catch the exception for some reason.

on windows the same code, the same cmake project do not have this exception.

There is the call stack below.

 	libpthread.so.0!__libc_send(size_t len, const void * buf, int fd) Line 28	C
 	libpthread.so.0!__libc_send(int fd, const void * buf, size_t len, int flags) Line 23	C
>	Scs::Socket::Send(Scs::Socket * const this, void * data, size_t bytes, uint32_t flags, size_t * bytesSent) Line 210	C++
 	Scs::SendQueue::Send(Scs::SendQueue * const this, Scs::SocketPtr socket) Line 54	C++
 	Scs::Server::RunConnection(Scs::Server * const this, Scs::Server::ClientConnectionPtr connection) Line 214	C++
 	Scs::Server::<lambda()>::operator()(void) const(const Scs::Server::<lambda()> * const __closure) Line 161	C++
 	std::__invoke_impl<void, Scs::Server::RunListener()::<lambda()> >(std::__invoke_other, Scs::Server::<lambda()> &&)(Scs::Server::<lambda()> && __f) Line 60	C++
 	std::__invoke<Scs::Server::RunListener()::<lambda()> >(Scs::Server::<lambda()> &&)(Scs::Server::<lambda()> && __fn) Line 95	C++
 	std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>)(std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > > * const this) Line 244	C++
 	std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > >::operator()(void)(std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > > * const this) Line 251	C++
 	std::thread::_State_impl<std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > > >::_M_run(void)(std::thread::_State_impl<std::thread::_Invoker<std::tuple<Scs::Server::RunListener()::<lambda()> > > > * const this) Line 195	C++
 	libstdc++.so.6![Unknown/Just-In-Time compiled code]	
 	libpthread.so.0!start_thread(void * arg) Line 477	C
 	libc.so.6!thread_start() Line 78	C++

and cmake thread lib lines:

1> [CMake] -- Looking for pthread.h
1> [CMake] -- Looking for pthread.h - found
1> [CMake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
1> [CMake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
1> [CMake] -- Looking for pthread_create in pthreads
1> [CMake] -- Looking for pthread_create in pthreads - not found
1> [CMake] -- Looking for pthread_create in pthread
1> [CMake] -- Looking for pthread_create in pthread - found
1> [CMake] -- Found Threads: TRUE  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions