wok-next rev 3327

Patch X-server (Xvesa) with hal in parallel (improve boot time)
author Rohit Joshi <jozee@slitaz.org>
date Tue Jun 09 17:27:19 2009 +0000 (2009-06-09)
parents a022b44347a2
children 776b87db3148
files xorg-server-tinyX/receipt xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-boottimestamp.u xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-hal_parallel.u
line diff
     1.1 --- a/xorg-server-tinyX/receipt	Tue Jun 09 17:23:06 2009 +0000
     1.2 +++ b/xorg-server-tinyX/receipt	Tue Jun 09 17:27:19 2009 +0000
     1.3 @@ -36,6 +36,15 @@
     1.4  compile_rules()
     1.5  {
     1.6  	cd $src
     1.7 +	while read file; do
     1.8 +    	[ -f done.$file ] && continue
     1.9 +    	echo "Apply $file..."
    1.10 +    	patch -p1 < ../stuff/$PACKAGE-$VERSION-$file || return 1
    1.11 +	touch done.$file
    1.12 +    done <<EOT
    1.13 +hal_parallel.u
    1.14 +boottimestamp.u
    1.15 +EOT
    1.16  	./configure \
    1.17  		--prefix=/usr \
    1.18  		--sysconfdir=/etc \
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-boottimestamp.u	Tue Jun 09 17:27:19 2009 +0000
     2.3 @@ -0,0 +1,38 @@
     2.4 +diff --git xorg-server-1.5.3/os/log.c xorg-server-1.5.3/os/log.c
     2.5 +index 0860847..2c46f1a 100644
     2.6 +--- xorg-server-1.5.3/os/log.c
     2.7 ++++ xorg-server-1.5.3/os/log.c
     2.8 +@@ -255,6 +255,33 @@ LogVWrite(int verb, const char *f, va_list args)
     2.9 +     static char tmpBuffer[1024];
    2.10 +     int len = 0;
    2.11 + 
    2.12 ++    struct timeval time;
    2.13 ++    time_t tv_sec;
    2.14 ++    suseconds_t tv_usec;
    2.15 ++    static Bool first = TRUE;
    2.16 ++    static time_t start_tv_sec;
    2.17 ++    static suseconds_t start_usec;
    2.18 ++    int diff_sec, diff_usec;
    2.19 ++
    2.20 ++    gettimeofday(&time, NULL);
    2.21 ++    tv_sec = time.tv_sec;
    2.22 ++    tv_usec = time.tv_usec;
    2.23 ++    if (first == TRUE) {
    2.24 ++        start_tv_sec = tv_sec;
    2.25 ++        start_usec = tv_usec;
    2.26 ++        first = FALSE;
    2.27 ++    }
    2.28 ++    diff_sec = (int)difftime(tv_sec, start_tv_sec);
    2.29 ++    diff_usec = (tv_usec - start_usec);
    2.30 ++    if (diff_usec < 0) {
    2.31 ++        diff_sec--;
    2.32 ++        diff_usec += 1000000;
    2.33 ++    }
    2.34 ++    sprintf(tmpBuffer, "[%d sec: %06d usec]", diff_sec , diff_usec);
    2.35 ++    len = strlen(tmpBuffer);
    2.36 ++    if (logFile)
    2.37 ++          fwrite(tmpBuffer, len, 1, logFile);
    2.38 ++
    2.39 +     /*
    2.40 +      * Since a va_list can only be processed once, write the string to a
    2.41 +      * buffer, and then write the buffer out to the appropriate output
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-hal_parallel.u	Tue Jun 09 17:27:19 2009 +0000
     3.3 @@ -0,0 +1,136 @@
     3.4 +diff --git xorg-server-1.5.3/config/hal.c xorg-server-1.5.3/config/hal.c
     3.5 +index 8dfbb07..36fa839 100644
     3.6 +--- xorg-server-1.5.3/config/hal.c
     3.7 ++++ xorg-server-1.5.3/config/hal.c
     3.8 +@@ -467,11 +467,10 @@ disconnect_hook(void *data)
     3.9 +info->system_bus = NULL;
    3.10 +}
    3.11 +-static void
    3.12 +-connect_hook(DBusConnection *connection, void *data)
    3.13 ++static BOOL
    3.14 ++connect_and_register(DBusConnection *connection, struct config_hal_info *info)
    3.15 +{
    3.16 +DBusError error;
    3.17 +- struct config_hal_info *info = data;
    3.18 +char **devices;
    3.19 +int num_devices, i;
    3.20 +@@ -479,8 +478,10 @@ connect_hook(DBusConnection *connection, void *data)
    3.21 +dbus_error_init(&error);
    3.22 +- if (!info->hal_ctx)
    3.23 +- info->hal_ctx = libhal_ctx_new();
    3.24 ++ if (info->hal_ctx)
    3.25 ++ return TRUE; /* already registered, pretend we did something */
    3.26 ++
    3.27 ++ info->hal_ctx = libhal_ctx_new();
    3.28 +if (!info->hal_ctx) {
    3.29 +LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n");
    3.30 +goto out_err;
    3.31 +@@ -512,7 +513,7 @@ connect_hook(DBusConnection *connection, void *data)
    3.32 +dbus_error_free(&error);
    3.33 +- return;
    3.34 ++ return TRUE;
    3.35 +out_ctx2:
    3.36 +if (!libhal_ctx_shutdown(info->hal_ctx, &error))
    3.37 +@@ -525,6 +526,104 @@ out_err:
    3.38 +info->hal_ctx = NULL;
    3.39 +info->system_bus = NULL;
    3.40 ++ return FALSE;
    3.41 ++}
    3.42 ++
    3.43 ++
    3.44 ++/**
    3.45 ++ * Handle NewOwnerChanged signals to deal with HAL startup at X server runtime.
    3.46 ++ *
    3.47 ++ * NewOwnerChanged is send once when HAL shuts down, and once again when it
    3.48 ++ * comes back up. Message has three arguments, first is the name
    3.49 ++ * (org.freedesktop.Hal), the second one is the old owner, third one is new
    3.50 ++ * owner.
    3.51 ++ */
    3.52 ++static DBusHandlerResult
    3.53 ++ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *data)
    3.54 ++{
    3.55 ++ int ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    3.56 ++
    3.57 ++ if (dbus_message_is_signal(message,
    3.58 ++ "org.freedesktop.DBus",
    3.59 ++ "NameOwnerChanged")) {
    3.60 ++ DBusError error;
    3.61 ++ char *name, *old_owner, *new_owner;
    3.62 ++
    3.63 ++ dbus_error_init(&error);
    3.64 ++ dbus_message_get_args(message, &error,
    3.65 ++ DBUS_TYPE_STRING, &name,
    3.66 ++ DBUS_TYPE_STRING, &old_owner,
    3.67 ++ DBUS_TYPE_STRING, &new_owner,
    3.68 ++ DBUS_TYPE_INVALID);
    3.69 ++
    3.70 ++ if (dbus_error_is_set(&error)) {
    3.71 ++ ErrorF("[config/hal] failed to get NameOwnerChanged args: %s (%s)\n",
    3.72 ++ error.name, error.message);
    3.73 ++ } else if (name && strcmp(name, "org.freedesktop.Hal") == 0) {
    3.74 ++
    3.75 ++ if (!old_owner || !strlen(old_owner)) {
    3.76 ++ DebugF("[config/hal] HAL startup detected.\n");
    3.77 ++ if (connect_and_register(connection, (struct config_hal_info*)data))
    3.78 ++ dbus_connection_unregister_object_path(connection,
    3.79 ++ "/org/freedesktop/DBus");
    3.80 ++ else
    3.81 ++ ErrorF("[config/hal] Failed to connect to HAL bus.\n");
    3.82 ++ }
    3.83 ++
    3.84 ++ ret = DBUS_HANDLER_RESULT_HANDLED;
    3.85 ++ }
    3.86 ++ dbus_error_free(&error);
    3.87 ++ }
    3.88 ++
    3.89 ++ return ret;
    3.90 ++}
    3.91 ++
    3.92 ++/**
    3.93 ++ * Register a handler for the NameOwnerChanged signal.
    3.94 ++ */
    3.95 ++static BOOL
    3.96 ++listen_for_startup(DBusConnection *connection, void *data)
    3.97 ++{
    3.98 ++ DBusObjectPathVTable vtable = { .message_function = ownerchanged_handler, };
    3.99 ++ DBusError error;
   3.100 ++ const char MATCH_RULE[] = "sender='org.freedesktop.DBus',"
   3.101 ++ "interface='org.freedesktop.DBus',"
   3.102 ++ "type='signal',"
   3.103 ++ "path='/org/freedesktop/DBus',"
   3.104 ++ "member='NameOwnerChanged'";
   3.105 ++ int rc = FALSE;
   3.106 ++
   3.107 ++ dbus_error_init(&error);
   3.108 ++ dbus_bus_add_match(connection, MATCH_RULE, &error);
   3.109 ++ if (!dbus_error_is_set(&error)) {
   3.110 ++ if (dbus_connection_register_object_path(connection,
   3.111 ++ "/org/freedesktop/DBus",
   3.112 ++ &vtable,
   3.113 ++ data))
   3.114 ++ rc = TRUE;
   3.115 ++ else
   3.116 ++ ErrorF("[config/hal] cannot register object path.\n");
   3.117 ++ } else {
   3.118 ++ ErrorF("[config/hal] couldn't add match rule: %s (%s)\n", error.name,
   3.119 ++ error.message);
   3.120 ++ ErrorF("[config/hal] cannot detect a HAL startup.\n");
   3.121 ++ }
   3.122 ++
   3.123 ++ dbus_error_free(&error);
   3.124 ++
   3.125 ++ return rc;
   3.126 ++}
   3.127 ++
   3.128 ++static void
   3.129 ++connect_hook(DBusConnection *connection, void *data)
   3.130 ++{
   3.131 ++ struct config_hal_info *info = data;
   3.132 ++
   3.133 ++ if (listen_for_startup(connection, data) &&
   3.134 ++ connect_and_register(connection, info))
   3.135 ++ dbus_connection_unregister_object_path(connection,
   3.136 ++ "/org/freedesktop/DBus");
   3.137 ++
   3.138 +return;
   3.139 +}