Eldad Zack wrote:
Hi,

While using the sample mgmtcmd.py as a client to mgmtd, I discovered that although mgmt_disconnect() is called on the client side, I still have connections registered (I noticed that when I was looking at the connections and saw about 250 connection at the CLOSE_WAIT state)

almost all connections has Recv-Q of 1 (some has 0) and all has a Send-Q of 0.

seeing that the mgmtd uses glib for connection and it calls g_io_channel_unref I was wondering who was holding the connection. This could lead to an unintended DoS if you would use (like I plan to) mgmtd for monitoring...

ok, found a solution.

the problem is that g_io_channel_shutdown () is not called after an unref of the channel. from the glib doc for g_io_channel_set_close_on_unref (): "Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is TRUE for channels created by g_io_channel_new_file(), and FALSE for all other channels."
so since we are using g_io_channel_unix_new, the default is not to close.
what I did is add g_io_channel_set_close_on_unref(client->ch,TRUE) after the creation of the channel.

I've attached this trivial patch here.


--- heartbeat-2.0.7/mgmt/daemon/mgmtd.c.orig    2006-09-12 18:46:13.000000000 
+0300
+++ heartbeat-2.0.7/mgmt/daemon/mgmtd.c 2006-09-12 18:48:52.000000000 +0300
@@ -510,6 +510,7 @@
        }
        client->id = id;
        client->ch = g_io_channel_unix_new(sock);
+       g_io_channel_set_close_on_unref(client->ch,TRUE);
        g_io_add_watch(client->ch, G_IO_IN|G_IO_ERR|G_IO_HUP
        ,               on_msg_arrived, GINT_TO_POINTER(client->id));
        client->session = session;
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to