[gnio] Add property notification



commit 34d6c24626f7b98d6d3b964a18876174000835d2
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Apr 28 10:54:44 2009 +0200

    Add property notification
    
    Add proper notification for property setters, also short-circuit if
    we're setting to the same value as the current value.
---
 gio/gsocket.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gio/gsocket.c b/gio/gsocket.c
index 85e00f7..5f531f2 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -507,6 +507,11 @@ g_socket_set_blocking (GSocket  *socket,
 
   g_return_if_fail (G_IS_SOCKET (socket));
 
+  blocking = !!blocking;
+
+  if (socket->priv->blocking == blocking)
+    return;
+
 #ifndef G_OS_WIN32
   if ((arg = fcntl (socket->priv->fd, F_GETFL, NULL)) < 0)
     g_warning ("Error getting socket status flags: %s", g_strerror (errno));
@@ -522,6 +527,7 @@ g_socket_set_blocking (GSocket  *socket,
 #endif
 
   socket->priv->blocking = blocking;
+  g_object_notify (G_OBJECT (socket), "blocking");
 }
 
 gboolean
@@ -540,10 +546,16 @@ g_socket_set_reuse_address (GSocket  *socket,
 
   g_return_if_fail (G_IS_SOCKET (socket));
 
-  if (setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR, (gpointer) &value, sizeof (value)) < 0)
+  reuse = !!reuse;
+  if (socket->priv->reuse_address == reuse)
+    return;
+
+  if (setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
+		  (gpointer) &value, sizeof (value)) < 0)
     g_warning ("error setting reuse address: %s", g_strerror (errno));
 
   socket->priv->reuse_address = reuse;
+  g_object_notify (G_OBJECT (socket), "reuse_address");
 }
 
 gboolean
@@ -568,7 +580,11 @@ g_socket_set_listen_backlog (GSocket *socket,
 {
   g_return_if_fail (G_IS_SOCKET (socket));
 
-  socket->priv->listen_backlog = backlog;
+  if (backlog != socket->priv->listen_backlog)
+    {
+      socket->priv->listen_backlog = backlog;
+      g_object_notify (G_OBJECT (socket), "reuse_address");
+    }
 }
 
 GSocketAddress *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]