sort workers use the first idle thread to build packages
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 10 Sep 2012 22:44:35 +0000 (06:44 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 10 Sep 2012 22:44:35 +0000 (06:44 +0800)
sort workers using keys to use the build worker with smallest
id. Without this patch build worker use order is 1,3,0,2,...
but it should be 0,1,2,3,...

This is necessary to make gbs back compatible while building single
package.

Change-Id: Ief248542194d697535387753a13200b426b8fcb6

depanneur

index e177861..88301c8 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -609,7 +609,7 @@ sub createrepo
 
 sub find_idle {
     my $idle = -1;
-    foreach my $w (keys %workers) {
+    foreach my $w (sort keys %workers) {
         my $tid = $workers{$w}->{tid};
         my $state = $workers{$w}->{state};
         if (! defined(threads->object($tid))) {
@@ -618,7 +618,7 @@ sub find_idle {
             last;
         }
     }
-    foreach my $w (keys %workers) {
+    foreach my $w (sort keys %workers) {
         if ( $workers{$w}->{state} eq 'idle' ) {
             $idle = $w;
             last;