scheduler: fix bug that could permanently disconnect clients

The scheduler sends <no_rsc_apps> flags for processor types for which
the project doesn't have app versions.
Problem: if the project doesn't have app versions for any processor types
(e.g. because everything was temporarily deprecated)
and it sends all the flags,
7.0.x clients may never contact the scheduler again.
Solution: check whether we have app versions for any of the client's processor types.
If not, don't send the no_rsc_apps flags.
This commit is contained in:
David Anderson 2013-05-17 11:38:24 -07:00
parent c6d79d1172
commit 24998d0a7d
1 changed files with 40 additions and 15 deletions

View File

@ -614,6 +614,17 @@ SCHEDULER_REPLY::SCHEDULER_REPLY() {
strcpy(email_hash, "");
}
static bool have_apps_for_client() {
for (int i=0; i<NPROC_TYPES; i++) {
if (ssp->have_apps_for_proc_type[i]) {
if (!i) return true;
COPROC* cp = g_request->coprocs.type_to_coproc(i);
if (cp->count) return true;
}
}
return false;
}
int SCHEDULER_REPLY::write(FILE* fout, SCHEDULER_REQUEST& sreq) {
unsigned int i;
char buf[BLOB_SIZE];
@ -899,26 +910,40 @@ int SCHEDULER_REPLY::write(FILE* fout, SCHEDULER_REQUEST& sreq) {
fprintf(fout, "%s", file_transfer_requests[i].c_str());
}
// write deprecated form for old clients
// before writing no_X_apps elements,
// make sure that we're not going tell it we have no apps
// for any of its resources.
// Otherwise (for 7.0.x clients) it will never contact us again
//
if (g_request->core_client_version < 70040) {
fprintf(fout,
"<no_cpu_apps>%d</no_cpu_apps>\n"
"<no_cuda_apps>%d</no_cuda_apps>\n"
"<no_ati_apps>%d</no_ati_apps>\n",
ssp->have_apps_for_proc_type[PROC_TYPE_CPU]?0:1,
ssp->have_apps_for_proc_type[PROC_TYPE_NVIDIA_GPU]?0:1,
ssp->have_apps_for_proc_type[PROC_TYPE_AMD_GPU]?0:1
);
}
for (i=0; i<NPROC_TYPES; i++) {
if (!ssp->have_apps_for_proc_type[i]) {
if (have_apps_for_client()) {
// write deprecated form for old clients
//
if (g_request->core_client_version < 70040) {
fprintf(fout,
"<no_rsc_apps>%s</no_rsc_apps>\n",
proc_type_name_xml(i)
"<no_cpu_apps>%d</no_cpu_apps>\n"
"<no_cuda_apps>%d</no_cuda_apps>\n"
"<no_ati_apps>%d</no_ati_apps>\n",
ssp->have_apps_for_proc_type[PROC_TYPE_CPU]?0:1,
ssp->have_apps_for_proc_type[PROC_TYPE_NVIDIA_GPU]?0:1,
ssp->have_apps_for_proc_type[PROC_TYPE_AMD_GPU]?0:1
);
}
for (i=0; i<NPROC_TYPES; i++) {
if (!ssp->have_apps_for_proc_type[i]) {
fprintf(fout,
"<no_rsc_apps>%s</no_rsc_apps>\n",
proc_type_name_xml(i)
);
}
}
} else {
if (config.debug_send) {
log_messages.printf(MSG_NORMAL,
"[send] no app versions for client resources; suppressing no_rsc_apps\n"
);
}
}
gui_urls.get_gui_urls(user, host, team, buf);
fputs(buf, fout);
if (project_files.text) {