Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » SIGPIPE problem
SIGPIPE problem [message #57108] Wed, 26 May 2021 05:19 Go to previous message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
I'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;
 }
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Small optimization
Next Topic: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg
Goto Forum:
  


Current Time: Sat Apr 27 10:22:13 CEST 2024

Total time taken to generate the page: 0.02624 seconds