diff mbox series

[RFC,1/5] dbus: remove dependency on agent

Message ID 20230630191812.2884637-2-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series Initial refactor for hwsim frame processing | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Make FAIL: make[2]: *** No rule to make target 'ell/sysctl.h', needed by 'distdir-am'. Stop. make[1]: *** [Makefile:4592: distdir] Error 2 make: *** [Makefile:4672: dist] Error 2
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1778: all] Error 2
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-alpine-ci-incremental_build fail Make FAIL (patch 0): make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1710: all] Error 2
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1777: all] Error 2
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1777: all] Error 2
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-incremental_build fail Make FAIL (patch 0): make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1709: all] Error 2
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: make[2]: *** No rule to make target 'ell/sysctl.h', needed by 'distdir-am'. Stop. make[1]: *** [Makefile:4591: distdir] Error 2 make: *** [Makefile:4671: dist] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP

Commit Message

James Prestwood June 30, 2023, 7:18 p.m. UTC
The dbus module is general purpose enough that it can be reworked
to allow apps such as hwsim to use it. First, remove the agent
dependency and instead use a setter API to register the shutdown
callback.
---
 src/agent.c | 12 +++++++-----
 src/agent.h |  2 --
 src/dbus.c  | 10 ++++++++--
 src/dbus.h  |  4 ++++
 4 files changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/src/agent.c b/src/agent.c
index 0f718b87..eff0df3f 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -678,6 +678,11 @@  static bool release_agent(void *data, void *user_data)
 	return true;
 }
 
+static void agent_shutdown(void)
+{
+	l_queue_foreach_remove(agents, release_agent, NULL);
+}
+
 static int agent_init(void)
 {
 	struct l_dbus *dbus = dbus_get_bus();
@@ -701,6 +706,8 @@  static int agent_init(void)
 		return -EIO;
 	}
 
+	__dbus_set_agent_shutdown_func(agent_shutdown);
+
 	return 0;
 }
 
@@ -714,9 +721,4 @@  static void agent_exit(void)
 	agents = NULL;
 }
 
-void agent_shutdown(void)
-{
-	l_queue_foreach_remove(agents, release_agent, NULL);
-}
-
 IWD_MODULE(agent, agent_init, agent_exit);
diff --git a/src/agent.h b/src/agent.h
index eb08c6b6..cd9f75d7 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -37,8 +37,6 @@  typedef void (*agent_request_user_name_passwd_func_t) (enum agent_result result,
 					void *user_data);
 typedef void (*agent_request_destroy_func_t)(void *user_data);
 
-void agent_shutdown(void);
-
 unsigned int agent_request_passphrase(const char *path,
 				agent_request_passphrase_func_t callback,
 				struct l_dbus_message *message,
diff --git a/src/dbus.c b/src/dbus.c
index 32de1e1a..1e0021f2 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -30,11 +30,11 @@ 
 
 #include <ell/ell.h>
 
-#include "src/agent.h"
 #include "src/iwd.h"
 #include "src/dbus.h"
 
 static struct l_dbus *g_dbus = NULL;
+static dbus_agent_shutdown_func_t agent_shutdown;
 
 struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg)
 {
@@ -220,8 +220,14 @@  void dbus_exit(void)
 	g_dbus = NULL;
 }
 
+void __dbus_set_agent_shutdown_func(dbus_agent_shutdown_func_t agent_shutdown)
+{
+	agent_shutdown = agent_shutdown;
+}
+
 void dbus_shutdown(void)
 {
 	/* Allow AgentManager to send a Release call before disconnecting */
-	agent_shutdown();
+	if (agent_shutdown)
+		agent_shutdown();
 }
diff --git a/src/dbus.h b/src/dbus.h
index 00c2df57..a5b667a7 100644
--- a/src/dbus.h
+++ b/src/dbus.h
@@ -51,10 +51,14 @@ 
 #define IWD_AGENT_MANAGER_PATH IWD_BASE_PATH
 #define IWD_P2P_SERVICE_MANAGER_PATH IWD_BASE_PATH
 
+typedef void (*dbus_agent_shutdown_func_t)(void);
+
 struct l_dbus;
 
 struct l_dbus *dbus_get_bus(void);
 
+void __dbus_set_agent_shutdown_func(dbus_agent_shutdown_func_t agent_shutdown);
+
 void dbus_pending_reply(struct l_dbus_message **msg,
 				struct l_dbus_message *reply);
 bool dbus_append_dict_basic(struct l_dbus_message_builder *builder,