Index: rbmaster.pl
===================================================================
--- rbmaster.pl (revision 21770)
+++ rbmaster.pl (working copy)
@@ -14,7 +14,7 @@

# the minimum protocol version supported. The protocol version is provided
# by the client
-my $minimumversion = 21;
+my $minimumversion = 22;

# if the client is found too old, this is a svn rev we tell the client to
# use to pick an update
@@ -73,6 +73,7 @@
# {'bits'} 32 / 64
# {'os'}
# {'bogomips'}
+# {'clientclass'} - for requesting special treatment
#

my $started = time();
@@ -285,7 +286,7 @@
my ($rh, $args) = @_;

my ($version, $archlist, $auth, $cli, $cpu, $bits,
- $os, $bogomips) = split(" ", $args);
+ $os, $bogomips, $clientclass) = split(" ", $args);

my $fno = $rh->fileno;

@@ -334,6 +335,7 @@
$client{$fno}{'bits'} = $bits;
$client{$fno}{'os'} = $os;
$client{$fno}{'bogomips'} = $bogomips;
+ $client{$fno}{'clientclass'} = $clientclass;
$client{$fno}{'socket'} = $rh;
$client{$fno}{'expect'} = ""; # no response expected yet
$client{$fno}{'builds'} = ""; # none so far
@@ -343,7 +345,7 @@
$rh->write("_HELLO ok\n");

print "Joined: $args\n";
- slog "Joined: client $cli user $user arch $archlist bogomips $bogomips\n";
+ slog "Joined: client $cli user $user arch $archlist bogomips $bogomips class $clientclass\n";

if($version < $minimumversion) {
updateclient($fno, $updaterev);
@@ -476,6 +478,24 @@
}

# $a and $b are buildids
+sub sortbuilds_slow {
+ # done builds are, naturally, last
+ my $s = $builds{$b}{'done'} <=> $builds{$a}{'done'};
+
+ if (!$s) {
+ # 'handcount' is the number of times the build has been handed out
+ # to a client. Get the lowest one first.
+ $s = $builds{$b}{'handcount'} <=> $builds{$a}{'handcount'};
+ }
+
+ if(!$s) {
+ # if the same handcount, take score into account
+ $s = -($builds{$a}{'score'} <=> $builds{$b}{'score'});
+ }
+ return $s;
+}
+
+# $a and $b are buildids
sub sortbuilds {
# done builds are, naturally, last
my $s = $builds{$b}{'done'} <=> $builds{$a}{'done'};
@@ -639,7 +659,6 @@
}

my @scl = sort sortclients @_;
- my @blist = sort sortbuilds @buildids;

my $done=0;

@@ -650,7 +669,14 @@
$done =0;
my $found=0;

+ my @blist;
# time to go through the builds and give to clients
+ if ($client{$cl}{'clientclass'} eq 'slow') {
+ @blist = sort sortbuilds_slow @buildids;
+ }
+ else {
+ @blist = sort sortbuilds @buildids;
+ }
while (scalar @blist) {
my $id = pop @blist;

@@ -745,7 +771,6 @@
print "Server starts\n";

slog "Server starts\n";
-
# Mail loop active until ^C pressed
my $alldone = 0;
$SIG{INT} = sub { warn "received interrupt\n"; $alldone = 1; };
Index: rbclient.pl
===================================================================
--- rbclient.pl (revision 21770)
+++ rbclient.pl (working copy)
@@ -14,7 +14,7 @@
use POSIX ":sys_wait_h";

my $perlfile = "rbclient.pl";
-my $revision = 21;
+my $revision = 22;
my $cwd = `pwd`;
chomp $cwd;

@@ -27,6 +27,7 @@
my $password = $password;
my $clientname = $clientname;
my $archlist = $archlist;
+my $clientclass = $clientclass || 'default';
my $buildmaster = $buildmaster || 'buildmaster.rockbox.org';
my $port = $port || 19999;

@@ -85,6 +86,9 @@
-buildmaster=[host]
Connect to this given server instead of the default.

+-clientclass=[class]
+ Request special build order treatment from the server
+
You can also specify -config=file where parameters are stored as 'label: value'

MOO
@@ -118,8 +122,8 @@

my $auth = "$username:$password";

-tprint "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed\n";
-print $sock "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed\n";
+tprint "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed $clientclass\n";
+print $sock "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed $clientclass\n";

my $busy = 0;
my %builds = ();