From 24998d0a7d9d9a8aff84a2454bf4d16c15aef9cd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 17 May 2013 11:38:24 -0700 Subject: [PATCH] scheduler: fix bug that could permanently disconnect clients The scheduler sends 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. --- sched/sched_types.cpp | 55 +++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp index 3cef7b5163..04d4cf4fe7 100644 --- a/sched/sched_types.cpp +++ b/sched/sched_types.cpp @@ -614,6 +614,17 @@ SCHEDULER_REPLY::SCHEDULER_REPLY() { strcpy(email_hash, ""); } +static bool have_apps_for_client() { + for (int i=0; ihave_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, - "%d\n" - "%d\n" - "%d\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; ihave_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, - "%s\n", - proc_type_name_xml(i) + "%d\n" + "%d\n" + "%d\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; ihave_apps_for_proc_type[i]) { + fprintf(fout, + "%s\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) {