*** empty log message ***

svn path=/trunk/boinc/; revision=3271
This commit is contained in:
David Anderson 2004-04-18 18:40:13 +00:00
parent 83c6281a88
commit 1e13d8e1d9
12 changed files with 108 additions and 13 deletions

View File

@ -11650,3 +11650,27 @@ Rom April 15 2004
client/
cpu_benchmark.h
David April 18 2004
- Added cross-project identification (scheme developed by Janus Kristensen)
NOTE: this involves a database change (new field in user table).
You must update your database by adding the field and initializing it
(see html/ops/db_update.php) before using this code.
client/
client_types.C,h
cs_scheduler.C
db/
boinc_db.C,h
schema.sql
html/
user/
create_account_action.php
ops/
db_update.php (new)
py/Boinc/
database.py
sched/
db_dump.C
server_types.C

View File

@ -52,6 +52,8 @@ void PROJECT::init() {
strcpy(project_name, "");
strcpy(user_name, "");
strcpy(team_name, "");
strcpy(email_hash, "");
strcpy(cross_project_id, "");
user_total_credit = 0;
user_expavg_credit = 0;
user_create_time = 0;
@ -268,6 +270,8 @@ int PROJECT::parse_state(FILE* in) {
strcpy(project_name, "");
strcpy(user_name, "");
strcpy(team_name, "");
strcpy(email_hash, "");
strcpy(cross_project_id, "");
resource_share = 100;
exp_avg_cpu = 0;
exp_avg_mod_time = 0;
@ -287,6 +291,8 @@ int PROJECT::parse_state(FILE* in) {
else if (parse_str(buf, "<project_name>", project_name, sizeof(project_name))) continue;
else if (parse_str(buf, "<user_name>", user_name, sizeof(user_name))) continue;
else if (parse_str(buf, "<team_name>", team_name, sizeof(team_name))) continue;
else if (parse_str(buf, "<email_hash>", email_hash, sizeof(email_hash))) continue;
else if (parse_str(buf, "<cross_project_id>", cross_project_id, sizeof(cross_project_id))) continue;
else if (parse_double(buf, "<user_total_credit>", user_total_credit)) continue;
else if (parse_double(buf, "<user_expavg_credit>", user_expavg_credit)) continue;
else if (parse_int(buf, "<user_create_time>", (int &)user_create_time)) continue;
@ -339,6 +345,8 @@ int PROJECT::write_state(FILE* out) {
" <project_name>%s</project_name>\n"
" <user_name>%s</user_name>\n"
" <team_name>%s</team_name>\n"
" <email_hash>%s</email_hash>\n"
" <cross_project_id>%s</cross_project_id>\n"
" <user_total_credit>%f</user_total_credit>\n"
" <user_expavg_credit>%f</user_expavg_credit>\n"
" <user_create_time>%d</user_create_time>\n"
@ -357,6 +365,8 @@ int PROJECT::write_state(FILE* out) {
project_name,
u2.c_str(),
t2.c_str(),
email_hash,
cross_project_id,
user_total_credit,
user_expavg_credit,
user_create_time,
@ -391,6 +401,8 @@ void PROJECT::copy_state_fields(PROJECT& p) {
safe_strcpy(project_name, p.project_name);
safe_strcpy(user_name, p.user_name);
safe_strcpy(team_name, p.team_name);
safe_strcpy(email_hash, p.email_hash);
safe_strcpy(cross_project_id, p.cross_project_id);
user_total_credit = p.user_total_credit;
user_expavg_credit = p.user_expavg_credit;
user_create_time = p.user_create_time;

View File

@ -32,6 +32,7 @@
#include <sys/time.h>
#endif
#include "md5_file.h"
#include "hostinfo.h"
#include "result_state.h"
@ -137,6 +138,8 @@ public:
char project_name[256]; // descriptive. not unique
char user_name[256];
char team_name[256];
char email_hash[MD5_LEN];
char cross_project_id[MD5_LEN];
double user_total_credit; // as reported by server
double user_expavg_credit; // as reported by server
unsigned int user_create_time; // as reported by server

View File

@ -293,9 +293,8 @@ int CLIENT_STATE::remove_trickle_files(PROJECT* project) {
return 0;
}
// Prepare the scheduler request. This writes the request in XML to a
// file (SCHED_OP_REQUEST_FILE) which is later sent to the scheduling
// server
// Prepare the scheduler request. This writes the request to a
// file (SCHED_OP_REQUEST_FILE) which is later sent to the scheduling server
//
int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
FILE* f = boinc_fopen(SCHED_OP_REQUEST_FILE, "wb");
@ -303,6 +302,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
RESULT* rp;
int retval;
double size;
char cross_project_id[MD5_LEN];
if (!f) return ERR_FOPEN;
fprintf(f,
@ -351,6 +351,20 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
}
}
// send the maximum of cross_project_id over projects
// with the same email hash as this one
//
strcpy(cross_project_id, p->cross_project_id);
for (i=0; i<projects.size(); i++ ) {
PROJECT* project = projects[i];
if (project == p) continue;
if (strcmp(project->email_hash, p->email_hash)) continue;
if (strcmp(project->cross_project_id, cross_project_id) > 0) {
strcpy(cross_project_id, project->cross_project_id);
}
}
fprintf(f, "<cross_project_id>%s</cross_project_id>\n", cross_project_id);
fprintf(f, "<projects>\n");
for (i=0; i<projects.size(); i++ ) {
PROJECT* project = projects[i];

View File

@ -209,7 +209,8 @@ void DB_USER::db_print(char* buf){
"teamid=%d, venue='%s', url='%s', send_email=%d, show_hosts=%d, "
"posts=%d, "
"seti_id=%d, seti_nresults=%d, seti_last_result_time=%d, "
"seti_total_cpu=%.15e, signature='%s', has_profile=%d",
"seti_total_cpu=%.15e, signature='%s', has_profile=%d, "
"cross_project_id='%s'",
id, create_time, email_addr, name,
authenticator,
country, postal_code,
@ -218,7 +219,8 @@ void DB_USER::db_print(char* buf){
teamid, venue, url, send_email, show_hosts,
posts,
seti_id, seti_nresults, seti_last_result_time,
seti_total_cpu, signature, has_profile
seti_total_cpu, signature, has_profile,
cross_project_id
);
UNESCAPE(email_addr);
UNESCAPE(name);
@ -257,6 +259,7 @@ void DB_USER::db_parse(MYSQL_ROW &r) {
seti_total_cpu = safe_atof(r[i++]);
strcpy2(signature, r[i++]);
has_profile = atoi(r[i++]);
strcpy2(cross_project_id, r[i++]);
}
void DB_TEAM::db_print(char* buf){

View File

@ -173,6 +173,7 @@ struct USER {
double seti_total_cpu; // number of CPU seconds
char signature[256];
bool has_profile;
char cross_project_id[256];
void clear();
};

View File

@ -56,7 +56,7 @@ create table app_version (
platformid integer not null,
xml_doc blob,
min_core_version integer not null,
max_core_version integer not null,
max_core_version integer not null,
deprecated integer not null,
primary key (id)
);
@ -86,6 +86,7 @@ create table user (
seti_total_cpu double not null,
signature varchar(254),
has_profile smallint not null,
cross_project_id varchar(254) not null,
primary key (id)
);

20
html/ops/db_update.php Normal file
View File

@ -0,0 +1,20 @@
#! /usr/local/bin/php
<?php
// code for one-time database updates goes here.
// Don't run this unless you know what you're doing!
require_once("../inc/util.inc");
function update_4_18_2004() {
mysql_query("alter table user add cross_project_id varchar(254) not null");
$result = mysql_query("select * from user");
while ($user = mysql_fetch_object($result)) {
$x = random_string();
mysql_query("update user set cross_project_id='$x' where id=$user->id");
}
}
update_4_18_2004();
?>

View File

@ -64,9 +64,10 @@ function show_error($str) {
}
$authenticator = random_string();
$cross_project_id = random_string();
$munged_email_addr = munge_email_addr($new_email_addr, $authenticator);
$query = sprintf(
"insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1)",
"insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1, $cross_project_id)",
time(),
$munged_email_addr,
$new_name,

View File

@ -102,7 +102,8 @@ class User(DatabaseObject):
'seti_last_result_time',
'seti_total_cpu',
'signature',
'has_profile'
'has_profile',
'cross_project_id'
])
class Team(DatabaseObject):

View File

@ -61,6 +61,7 @@
#include "boinc_db.h"
#include "util.h"
#include "md5_file.h"
#include "parse.h"
#include "sched_config.h"
@ -272,12 +273,17 @@ void write_host(HOST& host, FILE* f, bool detail, bool show_user) {
void write_user(USER& user, FILE* f, bool detail, bool show_team) {
DB_HOST host;
char buf[256];
char buf[1024];
char cpid[MD5_LEN];
string name, url;
xml_escape(user.name, name);
xml_escape(user.url, url);
strcpy(buf, user.cross_project_id);
strcat(buf, user.email_addr);
md5_block((unsigned char*)buf, strlen(buf), cpid);
fprintf(f,
"<user>\n"
" <id>%d</id>\n"
@ -286,14 +292,16 @@ void write_user(USER& user, FILE* f, bool detail, bool show_team) {
" <country>%s</country>\n"
" <create_time>%d</create_time>\n"
" <total_credit>%f</total_credit>\n"
" <expavg_credit>%f</expavg_credit>\n",
" <expavg_credit>%f</expavg_credit>\n"
" <cpid>%s</cpid>\n",
user.id,
name.c_str(),
url.c_str(),
user.country,
user.create_time,
user.total_credit,
user.expavg_credit
user.expavg_credit,
cpid
);
if (show_team) {
fprintf(f,

View File

@ -26,6 +26,7 @@ using namespace std;
#include <assert.h>
#include "parse.h"
#include "md5_file.h"
#include "error_numbers.h"
#include "util.h"
#include "main.h"
@ -175,6 +176,7 @@ int SCHEDULER_REPLY::write(FILE* fout) {
unsigned int i, j;
string u1, u2, t1, t2;
int retval;
char email_hash[MD5_LEN];
fprintf(fout,
"<scheduler_reply>\n"
@ -199,6 +201,7 @@ int SCHEDULER_REPLY::write(FILE* fout) {
u1 = user.name;
xml_escape(u1, u2);
md5_block((unsigned char*)user.email_addr, strlen(user.email_addr), email_hash);
fprintf(fout,
"<user_name>%s</user_name>\n"
"<user_total_credit>%f</user_total_credit>\n"
@ -206,14 +209,18 @@ int SCHEDULER_REPLY::write(FILE* fout) {
"<user_create_time>%d</user_create_time>\n"
"<host_total_credit>%f</host_total_credit>\n"
"<host_expavg_credit>%f</host_expavg_credit>\n"
"<host_venue>%s</host_venue>\n",
"<host_venue>%s</host_venue>\n"
"<email_hash>%s</email_hash>\n"
"<cross_project_id>%s</cross_project_id>\n",
u2.c_str(),
user.total_credit,
user.expavg_credit,
user.create_time,
host.total_credit,
host.expavg_credit,
host.venue
host.venue,
email_hash,
user.cross_project_id
);
// might want to send team credit too.