improved handling of package_count - working with pointer now
authorFrank Schreiner <schreiner@suse.de>
Wed, 16 Mar 2016 20:15:28 +0000 (20:15 +0000)
committerFrank Schreiner <schreiner@suse.de>
Wed, 16 Mar 2016 20:15:28 +0000 (20:15 +0000)
src/createrepo_c.c

index 6388a67653d2fd6d7e4d09a8e8a1e3903d64d5d6..f964d8291b9f86cb9aee54129e637f5640f63c8a 100644 (file)
@@ -124,7 +124,7 @@ fill_pool(GThreadPool *pool,
           struct CmdOptions *cmd_options,
           GSList **current_pkglist,
           FILE *output_pkg_list,
-          long package_count,
+          long *package_count,
           int  media_id)
 {
     GQueue queue = G_QUEUE_INIT;
@@ -259,10 +259,10 @@ fill_pool(GThreadPool *pool,
 
     // Push sorted tasks into the thread pool
     while ((task = g_queue_pop_head(&queue)) != NULL) {
-        task->id = package_count;
+        task->id = *package_count;
         task->media_id = media_id;
         g_thread_pool_push(pool, task, NULL);
-        ++package_count;
+        ++*package_count;
     }
 
     return package_count;
@@ -475,19 +475,16 @@ main(int argc, char **argv)
     /* ^^^ List with basenames of files which will be processed */
 
     for (int media_id = 1; media_id < argc; media_id++ ) {
-    gchar *tmp_in_dir = cr_normalize_dir_path(argv[media_id]);
-    // Thread pool - Fill with tasks
-// TODO M0ses: looks ugly for me to get package_count back again
-// discuss better solutions
-        package_count = fill_pool(pool,
-                                  tmp_in_dir,
-                                  cmd_options,
-                                  &current_pkglist,
-                                  output_pkg_list,
-                                  package_count,
-                                  media_id);
+        gchar *tmp_in_dir = cr_normalize_dir_path(argv[media_id]);
+        // Thread pool - Fill with tasks
+        fill_pool(pool,
+                  tmp_in_dir,
+                  cmd_options,
+                  &current_pkglist,
+                  output_pkg_list,
+                  &package_count,
+                  media_id);
         g_free(tmp_in_dir);
-
     }
 
     g_debug("Package count: %ld", package_count);