本文整理汇总了C++中CompileJob::environmentVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ CompileJob::environmentVersion方法的具体用法?C++ CompileJob::environmentVersion怎么用?C++ CompileJob::environmentVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompileJob
的用法示例。
在下文中一共展示了CompileJob::environmentVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_remote_int
static int build_remote_int(CompileJob &job, UseCSMsg *usecs, MsgChannel *local_daemon, const string &environment,
const string &version_file, const char *preproc_file, bool output )
{
string hostname = usecs->hostname;
unsigned int port = usecs->port;
int job_id = usecs->job_id;
bool got_env = usecs->got_env;
job.setJobID( job_id );
job.setEnvironmentVersion( environment ); // hoping on the scheduler's wisdom
trace() << "Have to use host " << hostname << ":" << port << " - Job ID: "
<< job.jobID() << " - env: " << usecs->host_platform
<< " - has env: " << (got_env ? "true" : "false")
<< " - match j: " << usecs->matched_job_id
<< "\n";
int status = 255;
MsgChannel *cserver = 0;
try {
cserver = Service::createChannel(hostname, port, 10);
if ( !cserver ) {
log_error() << "no server found behind given hostname " << hostname << ":" << port << endl;
throw ( 2 );
}
if ( !got_env ) {
log_block b("Transfer Environment");
// transfer env
struct stat buf;
if ( stat( version_file.c_str(), &buf ) ) {
log_perror( "error stat'ing version file" );
throw( 4 );
}
EnvTransferMsg msg( job.targetPlatform(), job.environmentVersion() );
if ( !cserver->send_msg( msg ) )
throw( 6 );
int env_fd = open( version_file.c_str(), O_RDONLY );
if (env_fd < 0)
throw ( 5 );
write_server_cpp( env_fd, cserver );
if ( !cserver->send_msg( EndMsg() ) ) {
log_error() << "write of environment failed" << endl;
throw( 8 );
}
if ( IS_PROTOCOL_31( cserver )) {
VerifyEnvMsg verifymsg( job.targetPlatform(), job.environmentVersion() );
if ( !cserver->send_msg( verifymsg ) )
throw( 22 );
Msg *msg = cserver->get_msg(60);
if ( msg && msg->type == M_VERIFY_ENV_RESULT ) {
if( !static_cast<VerifyEnvResultMsg*>( msg )->ok ) {
// The remote can't handle the environment at all (e.g. kernel too old),
// mark it as never to be used again for this environment.
log_info() << "Host " << hostname << " did not successfully verify environment." << endl;
BlacklistHostEnvMsg blacklist( job.targetPlatform(), job.environmentVersion(), hostname );
local_daemon->send_msg( blacklist );
throw( 24 );
} else
trace() << "Verified host " << hostname << " for environment " << job.environmentVersion()
<< " (" << job.targetPlatform() << ")" << endl;
} else
throw( 25 );
}
}
if( !IS_PROTOCOL_31( cserver ) && ignore_unverified()) {
log_warning() << "Host " << hostname << " cannot be verified." << endl;
throw( 26 );
}
CompileFileMsg compile_file( &job );
{
log_block b("send compile_file");
if ( !cserver->send_msg( compile_file ) ) {
log_info() << "write of job failed" << endl;
throw( 9 );
}
}
if ( !preproc_file ) {
int sockets[2];
if (pipe(sockets)) {
/* for all possible cases, this is something severe */
exit(errno);
}
/* This will fork, and return the pid of the child. It will not
return for the child itself. If it returns normally it will have
closed the write fd, i.e. sockets[1]. */
pid_t cpp_pid = call_cpp(job, sockets[1], sockets[0] );
if ( cpp_pid == -1 )
throw( 18 );
try {
//.........这里部分代码省略.........
示例2: build_remote_int
static int build_remote_int(CompileJob &job, UseCSMsg *usecs, MsgChannel *local_daemon,
const string &environment, const string &version_file,
const char *preproc_file, bool output)
{
string hostname = usecs->hostname;
unsigned int port = usecs->port;
int job_id = usecs->job_id;
bool got_env = usecs->got_env;
job.setJobID(job_id);
job.setEnvironmentVersion(environment); // hoping on the scheduler's wisdom
trace() << "Have to use host " << hostname << ":" << port << " - Job ID: "
<< job.jobID() << " - env: " << usecs->host_platform
<< " - has env: " << (got_env ? "true" : "false")
<< " - match j: " << usecs->matched_job_id
<< "\n";
int status = 255;
MsgChannel *cserver = 0;
try {
cserver = Service::createChannel(hostname, port, 10);
if (!cserver) {
log_error() << "no server found behind given hostname " << hostname << ":"
<< port << endl;
throw(2);
}
if (!got_env) {
log_block b("Transfer Environment");
// transfer env
struct stat buf;
if (stat(version_file.c_str(), &buf)) {
log_perror("error stat'ing version file");
throw(4);
}
EnvTransferMsg msg(job.targetPlatform(), job.environmentVersion());
if (!cserver->send_msg(msg)) {
throw(6);
}
int env_fd = open(version_file.c_str(), O_RDONLY);
if (env_fd < 0) {
throw(5);
}
write_server_cpp(env_fd, cserver);
if (!cserver->send_msg(EndMsg())) {
log_error() << "write of environment failed" << endl;
throw(8);
}
if (IS_PROTOCOL_31(cserver)) {
VerifyEnvMsg verifymsg(job.targetPlatform(), job.environmentVersion());
if (!cserver->send_msg(verifymsg)) {
throw(22);
}
Msg *verify_msg = cserver->get_msg(60);
if (verify_msg && verify_msg->type == M_VERIFY_ENV_RESULT) {
if (!static_cast<VerifyEnvResultMsg*>(verify_msg)->ok) {
// The remote can't handle the environment at all (e.g. kernel too old),
// mark it as never to be used again for this environment.
log_info() << "Host " << hostname
<< " did not successfully verify environment."
<< endl;
BlacklistHostEnvMsg blacklist(job.targetPlatform(),
job.environmentVersion(), hostname);
local_daemon->send_msg(blacklist);
throw(24);
} else
trace() << "Verified host " << hostname << " for environment "
<< job.environmentVersion() << " (" << job.targetPlatform() << ")"
<< endl;
} else {
throw(25);
}
}
}
if (!IS_PROTOCOL_31(cserver) && ignore_unverified()) {
log_warning() << "Host " << hostname << " cannot be verified." << endl;
throw(26);
}
CompileFileMsg compile_file(&job);
{
log_block b("send compile_file");
if (!cserver->send_msg(compile_file)) {
log_info() << "write of job failed" << endl;
throw(9);
//.........这里部分代码省略.........