Guest User

Untitled

a guest
Jun 23rd, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. Index: rbmaster.pl
  2. ===================================================================
  3. --- rbmaster.pl (revision 21770)
  4. +++ rbmaster.pl (working copy)
  5. @@ -14,7 +14,7 @@
  6.  
  7. # the minimum protocol version supported. The protocol version is provided
  8. # by the client
  9. -my $minimumversion = 21;
  10. +my $minimumversion = 22;
  11.  
  12. # if the client is found too old, this is a svn rev we tell the client to
  13. # use to pick an update
  14. @@ -73,6 +73,7 @@
  15. # {'bits'} 32 / 64
  16. # {'os'}
  17. # {'bogomips'}
  18. +# {'clientclass'} - for requesting special treatment
  19. #
  20.  
  21. my $started = time();
  22. @@ -285,7 +286,7 @@
  23. my ($rh, $args) = @_;
  24.  
  25. my ($version, $archlist, $auth, $cli, $cpu, $bits,
  26. - $os, $bogomips) = split(" ", $args);
  27. + $os, $bogomips, $clientclass) = split(" ", $args);
  28.  
  29. my $fno = $rh->fileno;
  30.  
  31. @@ -334,6 +335,7 @@
  32. $client{$fno}{'bits'} = $bits;
  33. $client{$fno}{'os'} = $os;
  34. $client{$fno}{'bogomips'} = $bogomips;
  35. + $client{$fno}{'clientclass'} = $clientclass;
  36. $client{$fno}{'socket'} = $rh;
  37. $client{$fno}{'expect'} = ""; # no response expected yet
  38. $client{$fno}{'builds'} = ""; # none so far
  39. @@ -343,7 +345,7 @@
  40. $rh->write("_HELLO ok\n");
  41.  
  42. print "Joined: $args\n";
  43. - slog "Joined: client $cli user $user arch $archlist bogomips $bogomips\n";
  44. + slog "Joined: client $cli user $user arch $archlist bogomips $bogomips class $clientclass\n";
  45.  
  46. if($version < $minimumversion) {
  47. updateclient($fno, $updaterev);
  48. @@ -476,6 +478,24 @@
  49. }
  50.  
  51. # $a and $b are buildids
  52. +sub sortbuilds_slow {
  53. + # done builds are, naturally, last
  54. + my $s = $builds{$b}{'done'} <=> $builds{$a}{'done'};
  55. +
  56. + if (!$s) {
  57. + # 'handcount' is the number of times the build has been handed out
  58. + # to a client. Get the lowest one first.
  59. + $s = $builds{$b}{'handcount'} <=> $builds{$a}{'handcount'};
  60. + }
  61. +
  62. + if(!$s) {
  63. + # if the same handcount, take score into account
  64. + $s = -($builds{$a}{'score'} <=> $builds{$b}{'score'});
  65. + }
  66. + return $s;
  67. +}
  68. +
  69. +# $a and $b are buildids
  70. sub sortbuilds {
  71. # done builds are, naturally, last
  72. my $s = $builds{$b}{'done'} <=> $builds{$a}{'done'};
  73. @@ -639,7 +659,6 @@
  74. }
  75.  
  76. my @scl = sort sortclients @_;
  77. - my @blist = sort sortbuilds @buildids;
  78.  
  79. my $done=0;
  80.  
  81. @@ -650,7 +669,14 @@
  82. $done =0;
  83. my $found=0;
  84.  
  85. + my @blist;
  86. # time to go through the builds and give to clients
  87. + if ($client{$cl}{'clientclass'} eq 'slow') {
  88. + @blist = sort sortbuilds_slow @buildids;
  89. + }
  90. + else {
  91. + @blist = sort sortbuilds @buildids;
  92. + }
  93. while (scalar @blist) {
  94. my $id = pop @blist;
  95.  
  96. @@ -745,7 +771,6 @@
  97. print "Server starts\n";
  98.  
  99. slog "Server starts\n";
  100. -
  101. # Mail loop active until ^C pressed
  102. my $alldone = 0;
  103. $SIG{INT} = sub { warn "received interrupt\n"; $alldone = 1; };
  104. Index: rbclient.pl
  105. ===================================================================
  106. --- rbclient.pl (revision 21770)
  107. +++ rbclient.pl (working copy)
  108. @@ -14,7 +14,7 @@
  109. use POSIX ":sys_wait_h";
  110.  
  111. my $perlfile = "rbclient.pl";
  112. -my $revision = 21;
  113. +my $revision = 22;
  114. my $cwd = `pwd`;
  115. chomp $cwd;
  116.  
  117. @@ -27,6 +27,7 @@
  118. my $password = $password;
  119. my $clientname = $clientname;
  120. my $archlist = $archlist;
  121. +my $clientclass = $clientclass || 'default';
  122. my $buildmaster = $buildmaster || 'buildmaster.rockbox.org';
  123. my $port = $port || 19999;
  124.  
  125. @@ -85,6 +86,9 @@
  126. -buildmaster=[host]
  127. Connect to this given server instead of the default.
  128.  
  129. +-clientclass=[class]
  130. + Request special build order treatment from the server
  131. +
  132. You can also specify -config=file where parameters are stored as 'label: value'
  133.  
  134. MOO
  135. @@ -118,8 +122,8 @@
  136.  
  137. my $auth = "$username:$password";
  138.  
  139. -tprint "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed\n";
  140. -print $sock "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed\n";
  141. +tprint "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed $clientclass\n";
  142. +print $sock "HELLO $revision $archlist $auth $clientname $cpu $bits $os $speed $clientclass\n";
  143.  
  144. my $busy = 0;
  145. my %builds = ();
Add Comment
Please, Sign In to add comment