Home » U++ Library support » U++ Core » SIGPIPE problem
Re: SIGPIPE problem [message #57120 is a reply to message #57108] |
Thu, 27 May 2021 09:14 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
zsolt wrote on Wed, 26 May 2021 05:19I'm writing an HTTP App server currently and I'm using some libraries, such as libpq.
My problem is, that some of the libraries are switching SIGPIPE signal handler on and off, and I have no control over that.
So when a client disconnects while my server is sending the HTTP response, sometimes it gets a SIGPIPE and my app stops at that point in debugger.
I'm running tons of unit tests so this is not very convenient, as some tests are doing this.
I fixed this by changing the flags argument of send() from 0 to MSG_NOSIGNAL in TcpSocket::RawSend() method.
Do you have any better idea?
int TcpSocket::RawSend(const void *buf, int amount)
{
+#ifdef PLATFORM_POSIX
+ int res = send(socket, (const char *)buf, amount, MSG_NOSIGNAL);
+#else
int res = send(socket, (const char *)buf, amount, 0);
+#endif
if(res < 0 && WouldBlock())
res = 0;
else
if(res == 0 || res < 0)
SetSockError("send");
return res;
}
Sounds good, applied, thank you.
Mirek
|
|
|
|
|
SIGPIPE problem
By: zsolt on Wed, 26 May 2021 05:19
|
|
|
Re: SIGPIPE problem
By: mirek on Thu, 27 May 2021 09:14
|
|
|
Re: SIGPIPE problem
By: zsolt on Thu, 27 May 2021 16:41
|
|
|
Re: SIGPIPE problem
By: Novo on Fri, 28 May 2021 20:41
|
|
|
Re: SIGPIPE problem
By: mirek on Mon, 31 May 2021 09:44
|
|
|
Re: SIGPIPE problem
By: zsolt on Mon, 31 May 2021 11:01
|
|
|
Re: SIGPIPE problem
By: mirek on Mon, 31 May 2021 11:21
|
|
|
Re: SIGPIPE problem
|
|
|
Re: SIGPIPE problem
By: zsolt on Mon, 31 May 2021 17:05
|
|
|
Re: SIGPIPE problem
By: zsolt on Mon, 31 May 2021 17:06
|
|
|
Re: SIGPIPE problem
By: zsolt on Mon, 31 May 2021 17:10
|
|
|
Re: SIGPIPE problem
By: Novo on Mon, 31 May 2021 17:18
|
|
|
Re: SIGPIPE problem
|
|
|
Re: SIGPIPE problem
By: mirek on Tue, 01 June 2021 09:19
|
|
|
Re: SIGPIPE problem
|
Goto Forum:
Current Time: Thu May 09 10:14:20 CEST 2024
Total time taken to generate the page: 0.02617 seconds
|