bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 1/2 hurd] acpi, libmachdev: Add _forever variant of trivfs server


From: Damien Zammit
Subject: [PATCH 1/2 hurd] acpi, libmachdev: Add _forever variant of trivfs server loop
Date: Sun, 10 Nov 2024 08:42:02 +0000

The acpi server needs to survive after the shutdown notification,
so it can serve S_acpi_sleep() RPC to actually shut down the machine.
Therefore we need to keep the server alive and not respond to the
trivfs goaway request.
---
 acpi/main.c                |  4 ++--
 libmachdev/machdev.h       |  1 +
 libmachdev/trivfs_server.c | 13 +++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/acpi/main.c b/acpi/main.c
index aa153bdb..18f0afc5 100644
--- a/acpi/main.c
+++ b/acpi/main.c
@@ -235,9 +235,9 @@ main (int argc, char **argv)
 
   if (next_task != MACH_PORT_NULL)
     {
-      err = pthread_create (&mt, NULL, machdev_trivfs_server_loop, NULL);
+      err = pthread_create (&mt, NULL, machdev_trivfs_server_loop_forever, 
NULL);
       if (err)
-        error(1, err, "creating machdev_trivfs_server_loop thread");
+        error(1, err, "creating machdev_trivfs_server_loop_forever thread");
       pthread_detach (mt);
     }
 
diff --git a/libmachdev/machdev.h b/libmachdev/machdev.h
index 50bfd41b..007d2750 100644
--- a/libmachdev/machdev.h
+++ b/libmachdev/machdev.h
@@ -39,6 +39,7 @@ int machdev_trivfs_init(int argc, char **argv, mach_port_t 
bootstrap_resume_task
 int machdev_demuxer(mach_msg_header_t *inp, mach_msg_header_t *outp);
 void machdev_trivfs_server_startup(mach_port_t bootstrap);
 void * machdev_trivfs_server_loop(void *);
+void * machdev_trivfs_server_loop_forever(void *);
 boolean_t machdev_is_master_device (mach_port_t port);
 
 #endif
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
index 54a682e7..d2031974 100644
--- a/libmachdev/trivfs_server.c
+++ b/libmachdev/trivfs_server.c
@@ -562,3 +562,16 @@ machdev_trivfs_server_loop(void *arg)
 
   return NULL;
 }
+
+void *
+machdev_trivfs_server_loop_forever(void *arg)
+{
+  /* Launch.  */
+  do
+    {
+      ports_manage_port_operations_one_thread (port_bucket, demuxer, 0);
+    } while (1);
+
+  /* Not reached, or machine powers off */
+  return NULL;
+}
-- 
2.45.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]