[glib] Use MSG_NOSIGNAL in GSocket if it's available
- From: Dan Winship <danw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Use MSG_NOSIGNAL in GSocket if it's available
- Date: Wed, 19 Aug 2009 16:13:01 +0000 (UTC)
commit cd5bd15987b573a436e715e59b0c651e50534bc1
Author: Dan Winship <danw gnome org>
Date: Wed Aug 19 12:12:06 2009 -0400
Use MSG_NOSIGNAL in GSocket if it's available
Even though we ignore SIGPIPE, gdb will still stop when the process
receives one, which sometimes confuses people into thinking the app
has crashed (eg, bug 578984, bug 590420), and is annoying anyway. So
use MSG_NOSIGNAL if it's there.
http://bugzilla.gnome.org/show_bug.cgi?id=591378
gio/gsocket.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index e216bd0..dd60e03 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -1707,6 +1707,16 @@ g_socket_receive_from (GSocket *socket,
error);
}
+/* Although we ignore SIGPIPE, gdb will still stop if the app receives
+ * one, which can be confusing and annoying. So if possible, we want
+ * to suppress the signal entirely.
+ */
+#ifdef MSG_NOSIGNAL
+#define G_SOCKET_DEFAULT_SEND_FLAGS MSG_NOSIGNAL
+#else
+#define G_SOCKET_DEFAULT_SEND_FLAGS 0
+#endif
+
/**
* g_socket_send:
* @socket: a #GSocket
@@ -1759,7 +1769,7 @@ g_socket_send (GSocket *socket,
G_IO_OUT, cancellable, error))
return -1;
- if ((ret = send (socket->priv->fd, buffer, size, 0)) < 0)
+ if ((ret = send (socket->priv->fd, buffer, size, G_SOCKET_DEFAULT_SEND_FLAGS)) < 0)
{
int errsv = get_socket_errno ();
@@ -2681,7 +2691,7 @@ g_socket_send_message (GSocket *socket,
G_IO_OUT, cancellable, error))
return -1;
- result = sendmsg (socket->priv->fd, &msg, flags);
+ result = sendmsg (socket->priv->fd, &msg, flags | G_SOCKET_DEFAULT_SEND_FLAGS);
if (result < 0)
{
int errsv = get_socket_errno ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]