Skip to content

Commit ada14b4

Browse files
committed
[DistCode][dmucs] Fix acquisition of the best available CPU - dmucs was erasing all the entries, rather than just one. Also update the DistCode version.
1 parent d53b0c8 commit ada14b4

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

DistCode/DistCode-Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.0.2</string>
18+
<string>3.0.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>3.0.2</string>
22+
<string>3.0.3</string>
2323
<key>LSMinimumSystemVersion</key>
2424
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
2525
<key>LSUIElement</key>

dmucs/dmucs/dmucs_db.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,19 @@ unsigned int
126126
DmucsDpropDb::getBestAvailCpu()
127127
{
128128
unsigned int result = 0UL;
129-
for (dmucs_avail_cpus_riter_t itr = availCpus_.rbegin();
130-
itr != availCpus_.rend(); ++itr) {
131-
if (itr->second.empty()) {
132-
continue;
133-
}
134-
srandom((unsigned int) time(NULL));
135-
unsigned long n = random() % itr->second.size();
136-
dmucs_cpus_iter_t itr2 = itr->second.begin();
137-
for (int i = 0; i < n; ++itr2, i++) ;
138-
result = *itr2; // get the IP address of the nth element in the list
139-
/* Remove the nth element from the list. */
140-
itr->second.erase(itr2);
129+
for (dmucs_avail_cpus_riter_t itr = availCpus_.rbegin(); result == 0UL && itr != availCpus_.rend(); ++itr)
130+
{
131+
if (itr->second.empty())
132+
{
133+
continue;
134+
}
135+
srandom((unsigned int) time(NULL));
136+
unsigned long n = random() % itr->second.size();
137+
dmucs_cpus_iter_t itr2 = itr->second.begin();
138+
for (int i = 0; i < n; ++itr2, i++) ;
139+
result = *itr2; // get the IP address of the nth element in the list
140+
/* Remove the nth element from the list. */
141+
itr->second.erase(itr2);
141142
}
142143
return result;
143144
}

0 commit comments

Comments
 (0)