Exemple #1
0
static void channel_redirection_listener(Channel * host, Channel * target) {
    if (target->state == ChannelStateStarted) {
#if SERVICE_LineNumbers
        ini_line_numbers_service(target->protocol);
#endif
#if SERVICE_Symbols
        ini_symbols_service(target->protocol);
#endif
#if ENABLE_DebugContext && ENABLE_ContextProxy
        ini_context_proxy_service(target->protocol);
#endif
    }
    if (target->state == ChannelStateConnected) {
        int i;
#if SERVICE_LineNumbers
        int service_ln = 0;
#endif
#if SERVICE_PathMap
#  if ENABLE_DebugContext && ENABLE_ContextProxy
        int service_pm = 0;
#  endif
#endif
#if SERVICE_Symbols
        int service_sm = 0;
#endif
#if SERVICE_Disassembly
        int service_da = 0;
#endif
#if ENABLE_DebugContext && ENABLE_ContextProxy
        int forward_pm = 0;
#endif
        for (i = 0; i < target->peer_service_cnt; i++) {
            char * nm = target->peer_service_list[i];
            /* Added this line to avoid build warnings if none of the
             * services below are defined (note that nm may be used
             * in TARGET_SERVICE_CHECK_HOOK() macro). */
            if (nm);
#if SERVICE_LineNumbers
            if (strcmp(nm, "LineNumbers") == 0) service_ln = 1;
#endif
#if SERVICE_Symbols
            if (strcmp(nm, "Symbols") == 0) service_sm = 1;
#endif
#if SERVICE_PathMap
#  if ENABLE_DebugContext && ENABLE_ContextProxy
            if (strcmp(nm, "PathMap") == 0) service_pm = 1;
#  endif
#endif
#if SERVICE_Disassembly
            if (strcmp(nm, "Disassembly") == 0) service_da = 1;
#endif
            TARGET_SERVICE_CHECK_HOOK;
        }
#if SERVICE_PathMap
        ini_path_map_service(host->protocol, bcg);
#  if ENABLE_DebugContext && ENABLE_ContextProxy
        if (service_pm) forward_pm = 1;
#  endif
#endif
#if SERVICE_LineNumbers
        if (!service_ln) ini_line_numbers_service(host->protocol);
#endif
#if SERVICE_Symbols
        if (!service_sm) ini_symbols_service(host->protocol);
#endif
#if SERVICE_Disassembly
        if (!service_da) ini_disassembly_service(host->protocol);
#endif
#if SERVICE_Expressions
        ini_expressions_service(host->protocol);
#endif
#if ENABLE_DebugContext && ENABLE_ContextProxy
        create_context_proxy(host, target, forward_pm);
#endif
    }
}
Exemple #2
0
bool 
Purger::operator()(jobid::JobId const& id)
{
  ContextPtr log_ctx;

  try {
    log_ctx = create_context(id, get_host_x509_proxy(), f_sequence_code);
  }
  catch (CannotCreateLBContext& e) {
    Error(
      id.toString()
      << ": CannotCreateLBContext from host proxy, error code #"
      << e.error_code()
    );
    return false;
  }

  ContextPtr log_proxy_ctx;
  if (m_have_lb_proxy) {
    try {
      log_proxy_ctx = create_context_proxy(id, get_host_x509_proxy(), f_sequence_code);
    } catch (CannotCreateLBContext& e) {
      Error(
        id.toString()
        << ": CannotCreateLBProxyContext from host proxy, error code #"
        << e.error_code()
      );
      log_proxy_ctx = log_ctx;
    }
  }

  edg_wll_JobStat job_status;
  edg_wll_InitStatus(&job_status);

  utilities::scope_guard free_job_status(
    boost::bind(edg_wll_FreeStatus, &job_status)
  );
  switch( query_job_status(job_status, id, log_ctx) ) {
    case 0: break; // query succeeded
    case EIDRM: // identifier removed(matching job already purged) 
    case ENOENT: // no matching jobs found

      Info(id.toString() << ": forced removal, unknown/removed L&B job");
      
      if (m_have_lb_proxy) {
        return remove_path(
          jobid_to_absolute_path(id),  
          log_proxy_ctx
        );
      } else {
        return remove_path(
          jobid_to_absolute_path(id),  
          log_ctx
        );
      }
   default: 
    return false;
  }

  // Reads the TYPE of the JOB...
  bool is_dag = 
    (job_status.jobtype == EDG_WLL_STAT_DAG ) || 
    (job_status.jobtype == EDG_WLL_STAT_COLLECTION);
  
  if (is_dag && 
      (m_skip_status_checking || is_status_removable(job_status)) &&
      ( !m_threshold || is_threshold_overcome(job_status, m_threshold))
  ) { // removing dag and children
    
    std::vector<std::string> children;
    if (job_status.children) {
      char** i = &job_status.children[0];
      while(*i) {
        children.push_back(std::string(*i));
        ++i;
      }
    }

    ContextPtr this_context = (m_have_lb_proxy) ? log_proxy_ctx : log_ctx;

    std::vector<std::string>::const_iterator i = children.begin();
    std::vector<std::string>::const_iterator const e = children.end();
    size_t n = 0;
    for( ; i != e; ++i ) {
    
      jobid::JobId const job_id(*i);
      change_logging_job(this_context, job_id, m_have_lb_proxy);
    
        if (!remove_path(strid_to_absolute_path(*i), log_proxy_ctx)) {
          ++n;
        }
    }
    Info(
      id.toString() << ": " 
      << children.size() - n << '/' << children.size() << " nodes removed"
    );

    change_logging_job(this_context, jobid::JobId(id), m_have_lb_proxy);

    bool path_removed = remove_path(
        jobid_to_absolute_path(id), 
        this_context
    );

    if (path_removed) {
      Info(
        id.toString()<< ": removed " << StatToString(job_status) << " dag "
      );
    }
    return path_removed;
  }
  
  bool const is_dag_node = job_status.parent_job != 0;
  
  // if the job is a dag node we should skip its removal
  // unless it is an orphan node or so requested
  if (is_dag_node && m_force_dag_node_removal ) {
    bool path_removed = false;
    if (m_have_lb_proxy) {
      path_removed = remove_path(
        jobid_to_absolute_path(id), 
        log_proxy_ctx
      );
    } else {
      path_removed = remove_path(
        jobid_to_absolute_path(id), 
        log_ctx
      );
    }
    if (path_removed) {
      Info(
	id.toString() << ": removed "
        << StatToString(job_status) << " node"
      );
    }
    return path_removed;
  }
  
  if (is_dag_node && m_force_orphan_node_removal) try {

    jobid::JobId const p_id(job_status.parent_job);
    fs::path pp(jobid_to_absolute_path(p_id));
    if (!fs::exists(pp)) {
      bool path_removed = false;
      if (m_have_lb_proxy) {
        path_removed = remove_path(
          jobid_to_absolute_path(id), 
          log_proxy_ctx
        );
      } else {
        path_removed = remove_path(
          jobid_to_absolute_path(id), 
          log_ctx
        );
      }
      if (path_removed) {
        Info(
          id.toString() << ": removed "
          << StatToString(job_status) << " orphan node"
        );
      }
      return path_removed;
    }
  } catch(...) {                // TODO: refine catch
    return false;
  }

  if ((m_skip_status_checking || is_status_removable(job_status))
      && (!m_threshold
          || is_threshold_overcome(job_status, m_threshold)
         )
     )
  { // removing normal job
    bool path_removed = false;
    if (m_have_lb_proxy) {
      path_removed = remove_path(
        jobid_to_absolute_path(id), 
        log_proxy_ctx
      );
    } else {
      path_removed = remove_path(
        jobid_to_absolute_path(id), 
        log_ctx
      );
    }
    if (path_removed) {
      Info(
        id.toString() << ": removed " << StatToString(job_status) << " job"
      );
      return path_removed;
    }
  }
  return false;
}