RPC Server never returns
In normal operation AVmPayload_runVsockRpcServer should never return -
the calling thread joins the server's thread pool, and we provide no
way to shut down the server. If the server does exit, that indicates a
failure somewhere.
If there is a failure of any sort (including unexepected server exit)
there is nothing the caller can do, so we panic rather than returning
a bool.
Update callers to not expect a return value.
I got slightly carried away and also:
- Modified compsvc to use AVmPayload_runVsockRpcServer rather than
rolling its own.
- Turned on unsafe_op_in_unsafe_fn in the API implementation. That
requires us to explicitly mark unsafe blocks in unsafe functions, so
I've gone through and done that. I checked that all the top-level
functions that should be marked unsafe are.
Bug: 243512108
Test: atest MicrodroidTests
Test: composd_cmd test-compile
Change-Id: I447ce0baa09d6a244ffe2ba7ab08092be3cd0f82
diff --git a/vm_payload/include/vm_payload.h b/vm_payload/include/vm_payload.h
index 0ad4c64..7c224f6 100644
--- a/vm_payload/include/vm_payload.h
+++ b/vm_payload/include/vm_payload.h
@@ -18,6 +18,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include <stdnoreturn.h>
#include <sys/cdefs.h>
#include "vm_main.h"
@@ -46,18 +47,17 @@
* called to allow appropriate action to be taken - e.g. to notify clients that they may now
* attempt to connect with `AVmPayload_notifyPayloadReady`.
*
- * The current thread is joined to the binder thread pool to handle incoming messages.
+ * Note that this function does not return. The calling thread joins the binder
+ * thread pool to handle incoming messages.
*
* \param service the service to bind to the given port.
* \param port vsock port.
* \param on_ready the callback to execute once the server is ready for connections. The callback
* will be called at most once.
* \param param param for the `on_ready` callback.
- *
- * \return true if the server has shutdown normally, false if it failed in some way.
*/
-bool AVmPayload_runVsockRpcServer(AIBinder *service, unsigned int port,
- void (*on_ready)(void *param), void *param);
+noreturn void AVmPayload_runVsockRpcServer(AIBinder *service, unsigned int port,
+ void (*on_ready)(void *param), void *param);
/**
* Get a secret that is uniquely bound to this VM instance. The secrets are