Skip to content

Commit 370c32a

Browse files
authored
Merge pull request #5830 from BOINC/dpa_init_data
client and API: add plan class to APP_INIT_DATA
2 parents 711d4f1 + d18d4c5 commit 370c32a

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

client/app_start.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ void ACTIVE_TASK::init_app_init_data(APP_INIT_DATA& aid) {
188188
aid.release = BOINC_RELEASE;
189189
aid.app_version = app_version->version_num;
190190
safe_strcpy(aid.app_name, wup->app->name);
191+
safe_strcpy(aid.plan_class, app_version->plan_class);
191192
safe_strcpy(aid.symstore, project->symstore);
192193
safe_strcpy(aid.acct_mgr_url, gstate.acct_mgr_info.master_url);
193194
if (project->project_specific_prefs.length()) {

client/client_types.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -785,27 +785,27 @@ int FILE_INFO::gunzip(char* md5_buf) {
785785
void APP_VERSION::init() {
786786
safe_strcpy(app_name, "");
787787
version_num = 0;
788-
safe_strcpy(platform, "");
789-
safe_strcpy(plan_class, "");
790-
safe_strcpy(api_version, "");
788+
platform[0] = 0;
789+
plan_class[0] = 0;
790+
api_version[0] = 0;
791791
avg_ncpus = 1;
792792
gpu_usage.rsc_type = 0;
793793
gpu_usage.usage = 0;
794794
gpu_ram = 0;
795795
flops = gstate.host_info.p_fpops;
796-
safe_strcpy(cmdline, "");
797-
safe_strcpy(file_prefix, "");
796+
cmdline[0] = 0;
797+
file_prefix[0] = 0;
798798
needs_network = false;
799799
app = NULL;
800800
project = NULL;
801801
ref_cnt = 0;
802802
graphics_exec_fip = NULL;
803-
safe_strcpy(graphics_exec_path,"");
804-
safe_strcpy(graphics_exec_file, "");
803+
graphics_exec_path[0] = 0;
804+
graphics_exec_file[0] = 0;
805805
max_working_set_size = 0;
806806
missing_coproc = false;
807807
missing_coproc_usage = 0.0;
808-
safe_strcpy(missing_coproc_name, "");
808+
missing_coproc_name[0] = 0;
809809
dont_throttle = false;
810810
is_vm_app = false;
811811
is_wrapper = false;

lib/app_ipc.cpp

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ APP_INIT_DATA::APP_INIT_DATA(const APP_INIT_DATA& a) {
5353

5454
APP_INIT_DATA &APP_INIT_DATA::operator=(const APP_INIT_DATA& a) {
5555
if (this != &a) {
56-
copy(a);
56+
copy(a);
5757
}
5858
return *this;
5959
}
6060

6161
void APP_INIT_DATA::copy(const APP_INIT_DATA& a) {
6262
safe_strcpy(app_name, a.app_name);
63+
safe_strcpy(plan_class, a.plan_class);
6364
safe_strcpy(symstore, a.symstore);
6465
safe_strcpy(acct_mgr_url, a.acct_mgr_url);
6566
safe_strcpy(user_name, a.user_name);
@@ -138,8 +139,12 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
138139
ai.teamid,
139140
ai.hostid
140141
);
141-
if (strlen(ai.app_name)) {
142-
fprintf(f, "<app_name>%s</app_name>\n", ai.app_name);
142+
// some strings are always present;
143+
// for others, print only if present
144+
145+
fprintf(f, "<app_name>%s</app_name>\n", ai.app_name);
146+
if (strlen(ai.plan_class)) {
147+
fprintf(f, "<plan_class>%s</plan_class>\n", ai.plan_class);
143148
}
144149
if (strlen(ai.symstore)) {
145150
fprintf(f, "<symstore>%s</symstore>\n", ai.symstore);
@@ -158,21 +163,11 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
158163
xml_escape(ai.user_name, buf, sizeof(buf));
159164
fprintf(f, "<user_name>%s</user_name>\n", buf);
160165
}
161-
if (strlen(ai.project_dir)) {
162-
fprintf(f, "<project_dir>%s</project_dir>\n", ai.project_dir);
163-
}
164-
if (strlen(ai.boinc_dir)) {
165-
fprintf(f, "<boinc_dir>%s</boinc_dir>\n", ai.boinc_dir);
166-
}
167-
if (strlen(ai.authenticator)) {
168-
fprintf(f, "<authenticator>%s</authenticator>\n", ai.authenticator);
169-
}
170-
if (strlen(ai.wu_name)) {
171-
fprintf(f, "<wu_name>%s</wu_name>\n", ai.wu_name);
172-
}
173-
if (strlen(ai.result_name)) {
174-
fprintf(f, "<result_name>%s</result_name>\n", ai.result_name);
175-
}
166+
fprintf(f, "<project_dir>%s</project_dir>\n", ai.project_dir);
167+
fprintf(f, "<boinc_dir>%s</boinc_dir>\n", ai.boinc_dir);
168+
fprintf(f, "<authenticator>%s</authenticator>\n", ai.authenticator);
169+
fprintf(f, "<wu_name>%s</wu_name>\n", ai.wu_name);
170+
fprintf(f, "<result_name>%s</result_name>\n", ai.result_name);
176171
#ifdef _WIN32
177172
if (strlen(ai.shmem_seg_name)) {
178173
fprintf(f, "<comm_obj_name>%s</comm_obj_name>\n", ai.shmem_seg_name);
@@ -241,7 +236,9 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
241236
MIOFILE mf;
242237
mf.init_file(f);
243238
ai.host_info.write(mf, true, true);
244-
ai.proxy_info.write(mf);
239+
if (ai.proxy_info.using_proxy()) {
240+
ai.proxy_info.write(mf);
241+
}
245242
ai.global_prefs.write(mf);
246243
for (unsigned int i=0; i<ai.app_files.size(); i++) {
247244
fprintf(f, "<app_file>%s</app_file>\n", ai.app_files[i].c_str());
@@ -255,20 +252,21 @@ void APP_INIT_DATA::clear() {
255252
minor_version = 0;
256253
release = 0;
257254
app_version = 0;
258-
safe_strcpy(app_name, "");
259-
safe_strcpy(symstore, "");
260-
safe_strcpy(acct_mgr_url, "");
255+
app_name[0] = 0;
256+
plan_class[0] = 0;
257+
symstore[0] = 0;
258+
acct_mgr_url[0] = 0;
261259
project_preferences = NULL;
262260
userid = 0;
263261
teamid = 0;
264262
hostid = 0;
265-
safe_strcpy(user_name, "");
266-
safe_strcpy(team_name, "");
267-
safe_strcpy(project_dir, "");
268-
safe_strcpy(boinc_dir, "");
269-
safe_strcpy(wu_name, "");
270-
safe_strcpy(result_name, "");
271-
safe_strcpy(authenticator, "");
263+
user_name[0] = 0;
264+
team_name[0] = 0;
265+
project_dir[0] = 0;
266+
boinc_dir[0] = 0;
267+
wu_name[0] = 0;
268+
result_name[0] = 0;
269+
authenticator[0] = 0;
272270
slot = 0;
273271
client_pid = 0;
274272
user_total_credit = 0;
@@ -292,7 +290,7 @@ void APP_INIT_DATA::clear() {
292290
checkpoint_period = 0;
293291
// gpu_type is an empty string for client versions before 6.13.3 without this
294292
// field or (on newer clients) if BOINC did not assign an OpenCL GPU to task.
295-
safe_strcpy(gpu_type, "");
293+
gpu_type[0] = 0;
296294
// gpu_device_num < 0 for client versions before 6.13.3 without this field
297295
// or (on newer clients) if BOINC did not assign an OpenCL GPU to task.
298296
gpu_device_num = -1;
@@ -365,6 +363,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
365363
if (xp.parse_int("release", ai.release)) continue;
366364
if (xp.parse_int("app_version", ai.app_version)) continue;
367365
if (xp.parse_str("app_name", ai.app_name, sizeof(ai.app_name))) continue;
366+
if (xp.parse_str("plan_class", ai.plan_class, sizeof(ai.plan_class))) continue;
368367
if (xp.parse_str("symstore", ai.symstore, sizeof(ai.symstore))) continue;
369368
if (xp.parse_str("acct_mgr_url", ai.acct_mgr_url, sizeof(ai.acct_mgr_url))) continue;
370369
if (xp.parse_int("userid", ai.userid)) continue;

lib/app_ipc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,18 @@ class APP_CLIENT_SHM {
127127
#endif
128128

129129
// parsed version of main init file
130-
// If you add anything here, update copy()
130+
// If you add anything here, update
131+
// APP_INIT_DATA::clear(), copy(),
132+
// write_init_data_file(), parse_init_data_file()
133+
// ACTIVE_TASK::init_app_init_data()
131134
//
132135
struct APP_INIT_DATA {
133136
int major_version; // BOINC client version info
134137
int minor_version;
135138
int release;
136139
int app_version;
137140
char app_name[256];
141+
char plan_class[256];
138142
char symstore[256]; // symstore URL (Windows)
139143
char acct_mgr_url[256];
140144
// if client is using account manager, its URL

lib/proxy_info.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ struct PROXY_INFO {
7474
// whether above fields are defined
7575

7676
PROXY_INFO() {
77-
clear();
77+
clear();
7878
}
7979
int parse(XML_PARSER&);
8080
int parse_config(XML_PARSER&);
8181
int write(MIOFILE&);
8282
void clear();
83+
// are we using a proxy?
84+
bool using_proxy() {
85+
return socks_server_name[0] || http_server_name[0];
86+
}
8387
};
8488

8589
#endif

0 commit comments

Comments
 (0)