[4/5] services: Sort autostart services by dwTagId config value.

Sebastian Lackner sebastian at fds-team.de
Thu Aug 18 02:31:35 CDT 2016


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

Sorting by load order group is not required here because service_start() will later
pay attention to that and choose a suitable target process.

@Aric: You recently submitted a similar patch, but I noticed that the compare function
was implemented wrong (no double pointers) and parameters of qsort() were swapped.
I guess you had a bit luck when everything still worked as expected. ;)

 programs/services/services.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/programs/services/services.c b/programs/services/services.c
index 9156dbc..1092a25 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -318,6 +318,13 @@ static void scmdatabase_remove_service(struct scmdatabase *db, struct service_en
     service->entry.next = service->entry.prev = NULL;
 }
 
+static int compare_tags(const void *a, const void *b)
+{
+    struct service_entry *service_a = *(struct service_entry **)a;
+    struct service_entry *service_b = *(struct service_entry **)b;
+    return service_a->config.dwTagId - service_b->config.dwTagId;
+}
+
 static void scmdatabase_autostart_services(struct scmdatabase *db)
 {
     struct service_entry **services_list;
@@ -352,6 +359,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
     size = i;
 
     scmdatabase_unlock(db);
+    qsort(services_list, size, sizeof(services_list[0]), compare_tags);
     while (!scmdatabase_lock_startup(db)) Sleep(10);
 
     for (i = 0; i < size; i++)
-- 
2.9.0



More information about the wine-patches mailing list