From 246f5a2d1ef390ecd546ade87e1883660a57dc31 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 16 Jul 2014 20:18:06 -0700 Subject: [PATCH] client/scheduler: add support for "client brand" Currently the server doesn't know about different client "brands", e.g. HTC Power to Give, Charity Engine, GridRepublic, etc., so there's no way to collect statistics about them. Changes: - client: at startup, read a "client brand" string from client_brand.txt (i.e. branded clients will have to include this file in their installer) Report this string in scheduler requests. - scheduler: parse this request element, and store it in host.serialnum as [BOINC|7.4.2|brand] --- client/client_state.cpp | 7 +++++++ client/client_state.h | 9 ++++++--- client/cs_scheduler.cpp | 4 ++++ client/file_names.h | 1 + db/boinc_db_types.h | 2 ++ sched/handle_request.cpp | 7 ++++++- sched/sched_types.cpp | 1 + 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/client/client_state.cpp b/client/client_state.cpp index 58bc502b0f..c06aaf807d 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -405,6 +405,13 @@ int CLIENT_STATE::init() { msg_printf(NULL, MSG_INFO, "Running under account %s", pbuf); #endif + FILE* f = fopen(CLIENT_BRAND_FILENAME, "r"); + if (f) { + fgets(client_brand, sizeof(client_brand), f); + msg_printf(NULL, MSG_INFO, "Client brand: %s", client_brand); + fclose(f); + } + parse_account_files(); parse_statistics_files(); diff --git a/client/client_state.h b/client/client_state.h index 2bcb395eec..8d6d3adbbb 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -110,6 +110,9 @@ struct CLIENT_STATE { double device_status_time; char language[16]; // ISO language code reported by GUI + char client_brand[256]; + // contents of client_brand.txt, e.g. "HTP Power to Give" + // reported to scheduler VERSION_INFO core_client_version; string statefile_platform_name; int file_xfer_giveup_period; @@ -138,11 +141,11 @@ struct CLIENT_STATE { // Determine when it is safe to leave the quit_client() handler // and to finish cleaning up. char detach_project_url[256]; - // stores URL for -detach_project option + // stores URL for --detach_project option char reset_project_url[256]; - // stores URL for -reset_project option + // stores URL for --reset_project option char update_prefs_url[256]; - // stores URL for -update_prefs option + // stores URL for --update_prefs option char main_host_venue[256]; // venue from project or AMS that gave us general prefs char attach_project_url[256]; diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp index c2fe36e949..ead7e56a8b 100644 --- a/client/cs_scheduler.cpp +++ b/client/cs_scheduler.cpp @@ -395,6 +395,10 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) { fclose(cof); } + if (strlen(client_brand)) { + fprintf(f, " %s\n", client_brand); + } + fprintf(f, "\n"); fclose(f); diff --git a/client/file_names.h b/client/file_names.h index 0aba40f07b..bf729f2e53 100644 --- a/client/file_names.h +++ b/client/file_names.h @@ -62,6 +62,7 @@ extern void send_log_after(const char* filename, double t, MIOFILE& mf); #define CA_BUNDLE_FILENAME "ca-bundle.crt" #define CERTIFICATE_DIRECTORY "certificates" #define CLIENT_AUTH_FILENAME "client_auth.xml" +#define CLIENT_BRAND_FILENAME "client_brand.txt" #define CLIENT_OPAQUE_FILENAME "client_opaque.txt" #define CONFIG_FILE "cc_config.xml" #define COPROC_INFO_FILENAME "coproc_info.xml" diff --git a/db/boinc_db_types.h b/db/boinc_db_types.h index 1580ac3568..2f23ab98bc 100644 --- a/db/boinc_db_types.h +++ b/db/boinc_db_types.h @@ -347,6 +347,8 @@ struct HOST { // char p_features[1024]; char virtualbox_version[256]; + char client_brand[256]; + // as specific in client_brand.txt config file on client bool p_vm_extensions_disabled; int num_opencl_cpu_platforms; OPENCL_CPU_PROP opencl_cpu_prop[MAX_OPENCL_CPU_PLATFORMS]; diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp index 95e03de90d..dff726bdab 100644 --- a/sched/handle_request.cpp +++ b/sched/handle_request.cpp @@ -500,11 +500,16 @@ static int modify_host_struct(HOST& host) { host.timezone = g_request->host.timezone; strncpy(host.domain_name, g_request->host.domain_name, sizeof(host.domain_name)); char buf[1024], buf2[1024]; - sprintf(buf, "[BOINC|%d.%d.%d]", + sprintf(buf, "[BOINC|%d.%d.%d", g_request->core_client_major_version, g_request->core_client_minor_version, g_request->core_client_release ); + if (strlen(host.client_brand)) { + strcat(buf, "|"); + strcat(buf, host.client_brand); + } + strcat(buf, "]"); g_request->coprocs.summary_string(buf2, sizeof(buf2)); strlcpy(host.serialnum, buf, sizeof(host.serialnum)); strlcat(host.serialnum, buf2, sizeof(host.serialnum)); diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp index 207537d5cb..b2602f3662 100644 --- a/sched/sched_types.cpp +++ b/sched/sched_types.cpp @@ -1249,6 +1249,7 @@ int HOST::parse(XML_PARSER& xp) { if (xp.parse_double("n_bwdown", n_bwdown)) continue; if (xp.parse_str("p_features", p_features, sizeof(p_features))) continue; if (xp.parse_str("virtualbox_version", virtualbox_version, sizeof(virtualbox_version))) continue; + if (xp.parse_str("client_brand", client_brand, sizeof(client_brand))) continue; if (xp.parse_bool("p_vm_extensions_disabled", p_vm_extensions_disabled)) continue; if (xp.match_tag("opencl_cpu_prop")) { int retval = opencl_cpu_prop[num_opencl_cpu_platforms].parse(xp);