avoid dup hosts

svn path=/trunk/boinc/; revision=9629
This commit is contained in:
David Anderson 2006-03-11 00:17:46 +00:00
parent 293e33345f
commit ad91e8475b
7 changed files with 74 additions and 65 deletions

View File

@ -2734,3 +2734,24 @@ David 9 Mar 2006
client/
cs_scheduler.C
David 9 Mar 2006
- user web: minor fixes
html/user/
debug.php (removed)
profile_search_action.php
user_search_action.php
David 9 Mar 2006
- Scheduler: avoid creating redundant host records.
If a scheduler request has zero host ID but non-blank host CPID,
see if there's a host record in the DB with that CPID;
if so, pick the most recent (i.e. largest ID)
and use it (rather than creating a new host record).
This change means that when you detach/reattach to a project,
you won't get a new host record. Woo hoo!
sched/
handle_request.C

View File

@ -1190,13 +1190,13 @@ void CLIENT_STATE::scale_duration_correction_factors(double factor) {
}
// Choose a new host CPID.
// If using account manager,
// do scheduler RPCs to all projects to propagate the CPID
// If using account manager, do scheduler RPCs
// to all acct-mgr-attached projects to propagate the CPID
//
void CLIENT_STATE::generate_new_host_cpid() {
host_info.generate_host_cpid();
if (strlen(acct_mgr_info.acct_mgr_url)) {
for (unsigned int i=0; i<projects.size(); i++) {
if (projects[i]->attached_via_acct_mgr) {
projects[i]->sched_rpc_pending = true;
projects[i]->min_rpc_time = now + 15;
}

View File

@ -11,9 +11,9 @@ array("March 5, 2006",
array("March 3, 2006",
"<a href=http://qah.uni-muenster.de/>Quantum Monte Carlo at Home</a>
announces the public release of the first chemistry BOINC project.
This project studies the structure and reactivity of molecules
using Quantum Chemistry, whose vastly complex equations
require huge amounts of computing power.
This project, based at the University of M&uuml;nster in Germany,
studies the structure and reactivity of molecules using Quantum Chemistry,
whose vastly complex equations require huge amounts of computing power.
"
),
array("February 24, 2006",

View File

@ -1,44 +0,0 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/util.inc");
init_session();
page_head("Download debugging files");
echo "
<h2>Download debugging files</h2>
<p>
<b>Windows users</b>:
<p>
If the BOINC application crashes, it is very helpful if you mail us the stack trace
(which shows exactly where the crash occurred).
To do this, you will need to have the symbol file on your computer.
<p>
<b>BOINC core client</b>
<p>
The zipped symbol file(s) are for the BOINC core client 2.25
(both GUI and CLI versions) are here:
<a href=http://setiboinc.ssl.berkeley.edu/ap/download/boinc_225_pdb.zip>boinc_225_pdb.zip</a>
<p>
Place the extracted file(s) in the same directory as the executable(s)
(usually <code>C:/Program Files/BOINC</code>).
<p>
<p>
<h2>Sending Debug Results</h2>
<p>
The files we are interested in are user.dmp and drwtsn32.log, they can be found in the Dr. Watson folder
(usually <code>C:/Documents and Settings/All Users/Application Data/Dr Watson</code>).
<p>
We would perfer the files to be zipped up with a compression program like winzip or gzip.
<p>
Be sure to include which version of BOINC and the project applications you are using in the email.
<p>
Thanks for helping make BOINC a better product.
<p>
<p>
";
page_tail();
?>

View File

@ -10,8 +10,8 @@ function show_profile_link($profile, $n) {
db_init();
$search_string = $_GET['search_string'];
$offset = $_GET['offset'];
$search_string = get_str('search_string');
$offset = get_int('offset', true);
if (!$offset) $offset=0;
$count = 10;

View File

@ -60,9 +60,7 @@ $default_sort = 'id';
$allowed_order = array('id', 'name', 'create_time','country', 'total_credit', 'expavg_credit');
$nice_names = array('', 'sorted by name', 'sorted by date joined', 'sorted by country', 'sorted by total credit', 'sorted by recent average credit');
/* Sanity check on order */
if (!isset ($_GET['order']) ||
!in_array ($_GET['order'], $allowed_order)) {
if (!isset ($_GET['order']) || !in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
$nice_name='';
} else {
@ -70,7 +68,7 @@ if (!isset ($_GET['order']) ||
$nice_name = $nice_names[array_search($order, $allowed_order)];
}
if (isset($_GET['search_string'])) $search_string = $_GET['search_string'];
$search_string = get_str('search_string');
if (isset($_GET['offset'])) $offset = $_GET['offset'];
if (!is_numeric($offset) || $offset<0) $offset=0;
@ -91,8 +89,7 @@ page_head("Search results");
if (strlen($search_string)>=3) {
$urls = urlencode($search_string);
$s = str_replace('_', '\\\\_', $search_string);
$s = str_replace('%', '\\\\%', $s);
$s = escape_pattern($search_string);
$q = "select * from user where name like '$s%' order by $order $upordown limit $offset,$count";
$result = mysql_query($q);

View File

@ -108,6 +108,23 @@ void unlock_sched(SCHEDULER_REPLY& reply) {
close(reply.lockfile_fd);
}
// find the user's most recent host with given host CPID
//
bool find_host_by_cpid(DB_USER& user, char* host_cpid, DB_HOST& host) {
char buf[256], buf2[256];
sprintf(buf, "%s%s", host_cpid, user.email_addr);
md5_block((const unsigned char*)buf, strlen(buf), buf2);
sprintf(buf,
"where userid=%d and host_cpid='%s' order by id desc", user.id, buf2
);
if (!host.enumerate(buf)) {
host.end_enumerate();
return true;
}
return false;
}
// Based on the info in the request message,
// look up the host and its user, and make sure the authenticator matches.
// Some special cases:
@ -118,7 +135,7 @@ void unlock_sched(SCHEDULER_REPLY& reply) {
// then follow links to find the proper host
//
// POSTCONDITION:
// If this returns zero, then:
// If this function returns zero, then:
// - reply.host contains a valid host record (possibly new)
// - reply.user contains a valid user record
// - if user belongs to a team, reply.team contains team record
@ -165,8 +182,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
);
strlcpy(
user.authenticator, sreq.authenticator,
sizeof(user.authenticator)
user.authenticator, sreq.authenticator, sizeof(user.authenticator)
);
sprintf(buf, "where authenticator='%s'", user.authenticator);
retval = user.lookup(buf);
@ -215,8 +231,8 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
goto make_new_host;
}
} else {
// here no hostid was given; we'll have to create a new host record
// Here no hostid was given, or the ID was bad.
// Look up the user, then create a new host record
//
lookup_user_and_make_new_host:
strlcpy(
@ -241,7 +257,25 @@ lookup_user_and_make_new_host:
return ERR_AUTHENTICATOR;
}
reply.user = user;
// If host CPID is present,
// scan backwards through this user's hosts,
// looking for one with the same host CPID.
// If we find one, it means the user detached and reattached.
// Use the existing host record.
//
if (strlen(sreq.host.host_cpid)) {
if (find_host_by_cpid(user, sreq.host.host_cpid, host)) {
goto got_host;
}
}
make_new_host:
// either of the above cases,
// or host ID didn't match user ID,
// or RPC seqno was too low.
//
// Create a new host.
// reply.user is filled in and valid at this point
//
host = sreq.host;
@ -262,6 +296,7 @@ make_new_host:
}
host.id = boinc_db.insert_id();
got_host:
reply.host = host;
reply.hostid = reply.host.id;
// this tells client to updates its host ID
@ -287,7 +322,7 @@ make_new_host:
reply.email_hash
);
// see if new cross-project ID
// if new user CPID, update user record
//
if (strlen(sreq.cross_project_id)) {
if (strcmp(sreq.cross_project_id, reply.user.cross_project_id)) {