/*
 * @return a node, or NULL. if NULL, this mom should talk to pbs_server
 */
node_comm_t *update_current_path(

    mom_hierarchy_t *nt)

{
    /* check to make sure we're initialized */
    if (nt->paths.size() == 0)
        return(NULL);

    /* if we haven't picked a path, update */
    if ((nt->current_level < 0) ||
            (nt->current_path  < 0) ||
            (nt->current_node  < 0))
        return(force_path_update(nt));

    mom_levels  &levels = nt->paths.at(nt->current_path);
    mom_nodes   &node_comm_entries = levels.at(nt->current_level);
    node_comm_t &nc = node_comm_entries.at(nt->current_node);

    if (nc.stream < 0)
        return(force_path_update(nt));
    else if ((nt->current_path  != 0) ||
             (nt->current_level != 0) ||
             (nt->current_node  != 0))
    {
        if ((time(NULL) - nc.mtime) > mom_hierarchy_retry_time)
        {
            close(nc.stream);
            return(force_path_update(nt));
        }
    }

    return(&nc);
} /* END update_current_path() */
示例#2
0
/* 
 * @return a node, or NULL. if NULL, this mom should talk to pbs_server
 */
node_comm_t *update_current_path(

  mom_hierarchy_t *nt)

  {
  resizable_array *levels;
  resizable_array *node_comm_entries;
  node_comm_t     *nc;

  /* check to make sure we're initialized */
  if (nt->paths->num == 0)
    return(NULL);

  /* if we haven't picked a path, update */
  if ((nt->current_level < 0) ||
      (nt->current_path  < 0) ||
      (nt->current_node  < 0))
    return(force_path_update(nt));

  levels = (resizable_array *)nt->paths->slots[nt->current_path+1].item;
  node_comm_entries = (resizable_array *)levels->slots[nt->current_level+1].item;
  nc = (node_comm_t *)node_comm_entries->slots[nt->current_node+1].item;

  if (nc->stream < 0)
    return(force_path_update(nt));
  else if ((nt->current_path  != 0) ||
           (nt->current_level != 0) ||
           (nt->current_node  != 0))
    {
    if ((time(NULL) - nc->mtime) > mom_hierarchy_retry_time)
      {
      close(nc->stream);
      return(force_path_update(nt));
      }
    }

  return(nc);
  } /* END update_current_path() */