diff --git a/checkin_notes b/checkin_notes
index 2c31d9527b..88477097f6 100755
--- a/checkin_notes
+++ b/checkin_notes
@@ -26784,3 +26784,31 @@ David 6 April 2005
clientgui/
*.cpp
+
+David 6 April 2005
+ - Attempt to fix the situation where:
+ 1) user merges hosts; hosts with lower IDs are folded
+ into host with maximal ID, then deleted
+ 2) If host's client_state.xml file still has one of the
+ lower IDs, then the next time it contacts the scheduler,
+ the host lookup fails and a new host record is created,
+ which defeats the purpose of the merge.
+
+ Solution:
+ - When merge hosts, don't delete lower-ID records.
+ Instead, change them to "zombie" state, in which:
+ - userid is zero
+ - rpc_seqno is ID of new host record
+ - scheduler: if host is zombie, follow link to new host,
+ send back its ID to client
+
+ db/
+ boinc_db.h
+ html/
+ inc/
+ util.inc
+ user/
+ host_edit_action.php
+ host_edit_form.php
+ sched/
+ handle_request.C
diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp
index 5111fb5dd4..3aa2e10e4d 100644
--- a/clientgui/MainDocument.cpp
+++ b/clientgui/MainDocument.cpp
@@ -1749,8 +1749,9 @@ wxInt32 CMainDocument::GetResourceProjectName(wxInt32 iIndex, wxString& strBuffe
PROJECT* pStateProject = NULL;
try {
- if (!resource_status.projects.empty())
+ if (!resource_status.projects.empty()) {
pProject = resource_status.projects.at(iIndex);
+ }
}
catch (std::out_of_range e) {
pProject = NULL;
@@ -1760,17 +1761,17 @@ wxInt32 CMainDocument::GetResourceProjectName(wxInt32 iIndex, wxString& strBuffe
pStateProject = state.lookup_project(pProject->master_url);
if (NULL != pStateProject) {
strBuffer = pStateProject->project_name.c_str();
- }
- else
+ } else {
ForceCacheUpdate();
+ }
}
return 0;
}
-wxInt32 CMainDocument::GetResourceDiskspace(wxInt32 iIndex, float& fBuffer)
-{ PROJECT* pProject = NULL;
+wxInt32 CMainDocument::GetResourceDiskspace(wxInt32 iIndex, float& fBuffer) {
+ PROJECT* pProject = NULL;
try {
if (!resource_status.projects.empty())
diff --git a/db/boinc_db.h b/db/boinc_db.h
index 06019d2612..9c1d8f242a 100755
--- a/db/boinc_db.h
+++ b/db/boinc_db.h
@@ -204,6 +204,9 @@ struct HOST {
int id;
int create_time;
int userid; // ID of user running this host
+ // If the host is "zombied" during merging of duplicate hosts,
+ // this field is set to zero and rpc_seqno is used to
+ // store the ID of the new host (kludge, but what the heck)
int rpc_seqno; // last seqno received from client
int rpc_time; // time of last scheduler RPC
double total_credit;
diff --git a/html/inc/util.inc b/html/inc/util.inc
index 51099a3c18..b44e65f6ac 100644
--- a/html/inc/util.inc
+++ b/html/inc/util.inc
@@ -220,13 +220,30 @@ function row3($x, $y, $z) {
function row4($xx, $xy, $yx, $yy) {
echo "
$xx | $xy | "
- . "$yx | $yy |
\n";
+ . "$yx | $yy |
+ ";
}
function rowify($string) {
echo "$string |
";
}
+function row($x) {
+ echo "";
+ foreach ($x as $h) {
+ echo "$h";
+ }
+ echo " |
\n";
+}
+
+function row_heading($x) {
+ echo "";
+ foreach ($x as $h) {
+ echo "$h | ";
+ }
+ echo "
\n";
+}
+
function random_string() {
return md5(uniqid(rand(), true));
}
diff --git a/html/user/host_edit_action.php b/html/user/host_edit_action.php
index 5a87f19bf3..e820efc887 100644
--- a/html/user/host_edit_action.php
+++ b/html/user/host_edit_action.php
@@ -18,34 +18,35 @@ function get_host($hostid, $user) {
}
function merge_hosts($old_host, $new_host) {
- if ($old_host->id == $new_host->id) {
- fail("same host");
- }
- if (!hosts_compatible($old_host, $new_host)) {
- fail("Can't merge hosts - they're incompatible");
- }
+ if ($old_host->id == $new_host->id) {
+ fail("same host");
+ }
+ if (!hosts_compatible($old_host, $new_host)) {
+ fail("Can't merge hosts - they're incompatible");
+ }
- echo "
Merging $old_host->id into $new_host->id\n";
+ echo "
Merging host $old_host->id into host $new_host->id\n";
- // update the database:
- // - add credit from old to new host
- // - change results to refer to new host
- // - delete old host
- //
- $total_credit = $old_host->total_credit + $new_host->total_credit;
- $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
- $result = mysql_query("update host set total_credit=$total_credit, expavg_credit=$recent_credit where id=$new_host->id");
- if (!$result) {
- fail("Couldn't update credit of new host");
- }
- $result = mysql_query("update result set hostid=$new_host->id where hostid=$old_host->id");
- if (!$result) {
- fail("Couldn't update results");
- }
- $result = mysql_query("delete from host where id=$old_host->id");
- if (!$result) {
- fail("Couldn't delete record of computer");
- }
+ // update the database:
+ // - add credit from old to new host
+ // - change results to refer to new host
+ // - put old host in "zombie" state
+ //
+ $total_credit = $old_host->total_credit + $new_host->total_credit;
+ $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
+ $result = mysql_query("update host set total_credit=$total_credit, expavg_credit=$recent_credit where id=$new_host->id");
+ if (!$result) {
+ fail("Couldn't update credit of new computer");
+ }
+ $result = mysql_query("update result set hostid=$new_host->id where hostid=$old_host->id");
+ if (!$result) {
+ fail("Couldn't update results");
+ }
+ $result = mysql_query("update host set total_credit=0, expavg_credit=0, userid=0, rpc_seqno=$new_host->id where id=$old_host->id");
+ if (!$result) {
+ fail("Couldn't update old computer");
+ }
+ echo "
Retired old computer $old_host->id\n";
}
db_init();
diff --git a/html/user/host_edit_form.php b/html/user/host_edit_form.php
index 651eae08f4..245038cf1f 100644
--- a/html/user/host_edit_form.php
+++ b/html/user/host_edit_form.php
@@ -22,12 +22,15 @@ echo "