Free remaining pollers before exiting

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/socket-handler.c b/socket-handler.c
index 8e0cebc..d7ef00c 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -21,6 +21,7 @@
 struct socket_handler {
 	struct handler	handler;
 	struct console	*console;
+	struct poller	*poller;
 	int		sd;
 
 	struct client	*clients;
@@ -140,8 +141,8 @@
 		return -1;
 	}
 
-	console_register_poller(console, handler, socket_poll, sh->sd, POLLIN,
-			NULL);
+	sh->poller = console_register_poller(console, handler, socket_poll,
+			sh->sd, POLLIN, NULL);
 
 	return 0;
 }
@@ -161,6 +162,14 @@
 static void socket_fini(struct handler *handler)
 {
 	struct socket_handler *sh = to_socket_handler(handler);
+	int i;
+
+	for (i = 0; i < sh->n_clients; i++)
+		client_close(sh, &sh->clients[i]);
+
+	if (sh->poller)
+		console_unregister_poller(sh->console, sh->poller);
+
 	close(sh->sd);
 }