hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Sun Oct 8 15:49:25 PDT 2006


 hald/hald.c      |   27 ++++++++++++++++++++-------
 hald/run-hald.sh |   10 +++++++---
 2 files changed, 27 insertions(+), 10 deletions(-)

New commits:
diff-tree bd9e32febb881700d76fb3524c86ee469463a946 (from 0fe19dec4668a0d8288941d56a351d7dc1c895b7)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Oct 8 18:49:16 2006 -0400

    make it easier to measure startup time
    
    Add an option to exit the daemon after probing. The magical invocation is
    
     # time ./run-hald.sh --skip-fdi-install --exit-after-probing > /dev/null 2>&1
    
    running from the hald/ directory (need one normal run to install the
    fdi files). On my Macbook Pro I get these figures
    
     real    0m2.084s
     user    0m0.564s
     sys     0m0.576s

diff --git a/hald/hald.c b/hald/hald.c
index 02ae7a0..cb5c6c7 100644
--- a/hald/hald.c
+++ b/hald/hald.c
@@ -212,13 +212,15 @@ usage ()
 	fprintf (stderr, "\n" "usage : hald [--daemon=yes|no] [--verbose=yes|no] [--help]\n");
 	fprintf (stderr,
 		 "\n"
-		 "        --daemon=yes|no      Become a daemon\n"
-		 "        --verbose=yes|no     Print out debug (overrides HALD_VERBOSE)\n"
- 		 "        --use-syslog         Print out debug messages to syslog instead of stderr.\n"
-		 "                             Use this option to get debug messages if HAL runs as\n"
-		 "                             daemon.\n"
-		 "        --help               Show this information and exit\n"
-		 "        --version            Output version information and exit"
+		 "        --daemon=yes|no       Become a daemon\n"
+		 "        --verbose=yes|no      Print out debug (overrides HALD_VERBOSE)\n"
+ 		 "        --use-syslog          Print out debug messages to syslog instead of\n"
+		 "                              stderr. Use this option to get debug messages\n"
+		 "                              if hald runs as a daemon.\n"
+		 "        --help                Show this information and exit\n"
+		 "        --version             Output version information and exit\n"
+		 "        --exit-after-probing  Exit when probing is complete. Useful only\n"
+		 "                              when profiling hald.\n"
 		 "\n"
 		 "The HAL daemon detects devices present in the system and provides the\n"
 		 "org.freedesktop.Hal service through the system-wide message bus provided\n"
@@ -234,6 +236,7 @@ static dbus_bool_t opt_become_daemon = T
 /** If #TRUE, we will spew out debug */
 dbus_bool_t hald_is_verbose = FALSE;
 dbus_bool_t hald_use_syslog = FALSE;
+dbus_bool_t hald_debug_exit_after_probing = FALSE;
 
 static int sigterm_unix_signal_pipe_fds[2];
 static GIOChannel *sigterm_iochn;
@@ -399,6 +402,7 @@ main (int argc, char *argv[])
 		int option_index = 0;
 		const char *opt;
 		static struct option long_options[] = {
+			{"exit-after-probing", 0, NULL, 0},
 			{"daemon", 1, NULL, 0},
 			{"verbose", 1, NULL, 0},
 			{"use-syslog", 0, NULL, 0},
@@ -422,6 +426,8 @@ main (int argc, char *argv[])
 			} else if (strcmp (opt, "version") == 0) {
 				fprintf (stderr, "HAL package version: " PACKAGE_VERSION "\n");
 				return 0;
+			} else if (strcmp (opt, "exit-after-probing") == 0) {
+				hald_debug_exit_after_probing = TRUE;
 			} else if (strcmp (opt, "daemon") == 0) {
 				if (strcmp ("yes", optarg) == 0) {
 					opt_become_daemon = TRUE;
@@ -618,6 +624,13 @@ osspec_probe_done (void)
 
 	HAL_INFO (("Device probing completed"));
 
+	if (hald_debug_exit_after_probing) {
+		HAL_INFO (("Exiting on user request (--exit-after-probing)"));
+		hald_runner_kill_all();
+		exit (0);
+	}
+
+
 	if (!hald_dbus_init ()) {
 		hald_runner_kill_all();
 		exit (1);
diff --git a/hald/run-hald.sh b/hald/run-hald.sh
index d8e6cb3..0ae1f6b 100755
--- a/hald/run-hald.sh
+++ b/hald/run-hald.sh
@@ -3,13 +3,17 @@
 export HALD_RUNNER_PATH=`pwd`/linux:`pwd`/linux/probing:`pwd`/linux/addons:`pwd`/.:`pwd`/../tools:`pwd`/../tools/linux
 export PATH=`pwd`/../hald-runner:$PATH
 
-rm -rf .local-fdi
-make -C ../fdi install DESTDIR=`pwd`/.local-fdi prefix=/
+if [ "$1" = "--skip-fdi-install" ] ; then
+    shift
+else
+    rm -rf .local-fdi
+    make -C ../fdi install DESTDIR=`pwd`/.local-fdi prefix=/
+fi
 export HAL_FDI_SOURCE_PREPROBE=.local-fdi/share/hal/fdi/preprobe
 export HAL_FDI_SOURCE_INFORMATION=.local-fdi/share/hal/fdi/information
 export HAL_FDI_SOURCE_POLICY=.local-fdi/share/hal/fdi/policy
 
-./hald --daemon=no --verbose=yes
+./hald --daemon=no --verbose=yes $@
 #./hald --daemon=no
 
 


More information about the hal-commit mailing list