From kde-commits Wed Jul 12 16:27:08 2006 From: Michael Matz Date: Wed, 12 Jul 2006 16:27:08 +0000 To: kde-commits Subject: icecream/services Message-Id: <1152721628.065335.4484.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=115272175109230 SVN commit 561593 by matz: Fix an ugly problem with x86-64 (e.g.) machines which have only the i686 native env but not the x86-64 native env with the same name anymore. The scheduler was giving them out nevertheless as if they got the x86-64 env already. M +36 -9 scheduler.cpp --- trunk/icecream/services/scheduler.cpp #561592:561593 @@ -587,26 +587,45 @@ return false; } -static bool +/* Given a candidate CS and a JOB, check all installed environments + on the CS for a match. Return an empty string if none of the required + environments for this job is installed. Otherwise return the + host platform of the first found installed environment which is among + the requested. That can be send to the client, which then completely + specifies which environment to use (name, host platform and target + platform). */ +static string envs_match( CS* cs, const Job *job ) { if ( job->submitter == cs) - return true; // it will compile itself + return cs->host_platform; // it will compile itself + /* Check all installed envs on the candidate CS ... */ for ( Environments::const_iterator it = cs->compiler_versions.begin(); it != cs->compiler_versions.end(); ++it ) { - if ( platforms_compatible( it->first, job->target_platform ) ) + if ( it->first == job->target_platform ) { + /* ... IT now is an installed environment which produces code for + the requested target platform. Now look at each env which + could be installed from the client (i.e. those coming with the + job) if it matches in name and additionally could be run + by the candidate CS. */ for ( Environments::const_iterator it2 = job->environments.begin(); it2 != job->environments.end(); ++it2 ) { if ( it->second == it2->second && platforms_compatible( it2->first, cs->host_platform ) ) - return true; + return it2->first; } } } - return false; + return string(); } +/* Given a candidate CS and a JOB, check if any of the requested + environments could be installed on the CS. This is the case if that + env can be run there, i.e. if the host platforms of the CS and of the + environment are compatible. Return an empty string if none can be + installed, otherwise return the platform of the first found + environments which can be installed. */ static string can_install( CS* cs, const Job *job ) { @@ -758,7 +777,7 @@ { /* Make all servers compile a job at least once, so we'll get an idea about their speed. */ - if (envs_match (cs, job)) + if (!envs_match (cs, job).empty()) { best = cs; matches++; @@ -772,7 +791,7 @@ break; } - if ( envs_match( cs, job ) ) + if (!envs_match (cs, job).empty()) { if ( !best ) best = cs; @@ -981,8 +1000,16 @@ job->state = Job::WAITINGFORCS; job->server = cs; - bool gotit = envs_match( cs, job ); - UseCSMsg m2(can_install( cs, job ), cs->name, cs->remote_port, job->id, gotit, job->local_client_id ); + string host_platform = envs_match (cs, job); + bool gotit = true; + if (host_platform.empty ()) + { + gotit = false; + host_platform = can_install (cs, job); + } + + UseCSMsg m2(host_platform, cs->name, cs->remote_port, job->id, + gotit, job->local_client_id ); if (!job->submitter->send_msg (m2)) {