Index: agent/seahorse-agent-io.c
===================================================================
RCS file: /cvs/gnome/seahorse/agent/seahorse-agent-io.c,v
retrieving revision 1.6.2.2
diff -U3 -r1.6.2.2 seahorse-agent-io.c
--- agent/seahorse-agent-io.c	14 Aug 2005 06:48:25 -0000	1.6.2.2
+++ agent/seahorse-agent-io.c	28 Aug 2005 19:09:45 -0000
@@ -165,21 +165,29 @@
     return 0;
 }
 
+/* Disconnect the connection */
+static void
+disconnect (SeahorseAgentConn *cn)
+{
+    /* The watch tag */
+    if (cn->stag) {
+        g_source_remove (cn->stag);
+        cn->stag = 0;
+
+        if (cn->iochannel)
+            g_io_channel_shutdown (cn->iochannel, TRUE, NULL);
+    }
+}        
+
 /* Free the given connection structure */
 static void
 free_conn (SeahorseAgentConn *cn)
 {
-    GError *err = NULL;
-
     if (cn->iochannel) {
-        if (cn->stag)
-            g_source_remove (cn->stag);
+        disconnect (cn);
 
-        g_io_channel_shutdown (cn->iochannel, TRUE, &err);
-        g_clear_error (&err);
-
-        cn->iochannel = 0;
-        cn->stag = 0;
+        g_io_channel_unref (cn->iochannel);
+        cn->iochannel = NULL;
     }
 
     g_connections = g_list_remove (g_connections, cn);
@@ -377,7 +385,7 @@
 
     else if (strcasecmp (string, ASS_BYE) == 0) {
         /* seahorse_agent_io_reply (cn, TRUE, "closing connection"); */
-        free_conn (cn);
+        disconnect (cn);
     }
 
     else if (strcasecmp (string, ASS_RESET) == 0) {
@@ -413,6 +421,7 @@
             g_critical ("couldn't read from socket: %s", err->message);
             g_clear_error (&err);
             free_conn (cn);
+            cn = NULL;
             ret = FALSE;
         }
 
@@ -425,7 +434,7 @@
             g_free (string);
     }
 
-    if (condition & G_IO_HUP) {
+    if (cn && condition & G_IO_HUP) {
         free_conn (cn);
         ret = FALSE;            /* removes watch */
     }
