From: Dan Winship Date: Wed, 19 Aug 2009 16:12:06 +0000 (-0400) Subject: Use MSG_NOSIGNAL in GSocket if it's available X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=cd5bd15987b573a436e715e59b0c651e50534bc1;p=dana%2Fcg-glib.git 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 --- diff --git a/gio/gsocket.c b/gio/gsocket.c index e216bd04..dd60e030 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 ();