cmd SHUTDOWN
authorChristian Thaeter <ct@pipapo.org>
Sun, 7 Oct 2007 08:36:35 +0000 (10:36 +0200)
committerChristian Thaeter <ct@pipapo.org>
Sun, 7 Oct 2007 08:36:35 +0000 (10:36 +0200)
rxpd.c

diff --git a/rxpd.c b/rxpd.c
index cf980d7..c3e506f 100644 (file)
--- a/rxpd.c
+++ b/rxpd.c
@@ -697,5 +697,18 @@ void
 rxpd_connection_cmd_SHUTDOWN (int fd, short event, void* ptr)
 {
   struct rxpd_connection* self = (struct rxpd_connection*) ptr;
-  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
+  // destroy all sockets
+  LLIST_WHILE_HEAD (&self->base->sockets_pending, n)
+    {
+      struct rxpd_socket* socket = (struct rxpd_socket*)n;
+      rxpd_socket_delete (socket);
+    }
+  LLIST_WHILE_HEAD (&self->base->sockets_active, n)
+    {
+      struct rxpd_socket* socket = (struct rxpd_socket*)n;
+      rxpd_socket_delete (socket);
+    }
+
+  rxpd_buffer_printf (&self->out, "#OK:\n");
+  close (fd);
 }