Пример #1
0
/* currently this function can only be called for jobs in the alljobs array */
int swap_jobs(

  struct all_jobs *aj,
  job             *job1,
  job             *job2)

  {
  int rc = -1;
  int new1;
  int new2;

  if (job1 == NULL)
    {
    rc = PBSE_BAD_PARAMETER;
    log_err(rc,__func__,"null input pointer to job1");
    return(rc);
    }
  if (job2 == NULL)
    {
    rc = PBSE_BAD_PARAMETER;
    log_err(rc,__func__,"null input pointer to job2");
    return(rc);
    }

  if (aj == NULL)
    {
    aj = &alljobs;
    }

  pthread_mutex_lock(aj->alljobs_mutex);

  new2 = get_value_hash(aj->ht,job1->ji_qs.ji_jobid);
  new1 = get_value_hash(aj->ht,job2->ji_qs.ji_jobid);

  if ((new1 == -1) ||
      (new2 == -1))
    {
    rc = THING_NOT_FOUND;
    }
  else
    {
    rc = swap_things(aj->ra,job1,job2);
    
    change_value_hash(aj->ht,job1->ji_qs.ji_jobid,new1);
    change_value_hash(aj->ht,job2->ji_qs.ji_jobid,new2);
    }

  pthread_mutex_unlock(aj->alljobs_mutex);
  
  return(rc);
  } /* END swap_jobs() */
Пример #2
0
int remove_queue(

  all_queues *aq,
  pbs_queue  *pque)

  {
  int  rc = PBSE_NONE;
  int  index;
  char log_buf[1000];

  if (pthread_mutex_trylock(aq->allques_mutex))
    {
    unlock_queue(pque, __func__, NULL, LOGLEVEL);
    lock_allques_mutex(aq, __func__, "1", LOGLEVEL);
    lock_queue(pque, __func__, NULL, LOGLEVEL);
    }

  if ((index = get_value_hash(aq->ht,pque->qu_qs.qu_name)) < 0)
    rc = THING_NOT_FOUND;
  else
    {
    remove_thing_from_index(aq->ra,index);
    remove_hash(aq->ht,pque->qu_qs.qu_name);
    }

  snprintf(log_buf, sizeof(log_buf), "index = %d, name = %s", index, pque->qu_qs.qu_name);
  log_err(-1, __func__, log_buf);

  unlock_allques_mutex(aq, __func__, "2", LOGLEVEL);

  return(rc);
  } /* END remove_queue() */
Пример #3
0
int has_job(

  struct all_jobs *aj,
  job             *pjob)

  {
  int  rc;
  char jobid[PBS_MAXSVRJOBID + 1];

  strcpy(jobid, pjob->ji_qs.ji_jobid);

  if (pthread_mutex_trylock(aj->alljobs_mutex))
    {
    unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
    pthread_mutex_lock(aj->alljobs_mutex);
    lock_ji_mutex(pjob, __func__, NULL, LOGLEVEL);

    if (pjob->ji_being_recycled == TRUE)
      {
      pthread_mutex_unlock(aj->alljobs_mutex);
      unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);

      return(PBSE_JOB_RECYCLED);
      }
    }

  if (get_value_hash(aj->ht, pjob->ji_qs.ji_jobid) < 0)
    rc = FALSE;
  else
    rc = TRUE;

  pthread_mutex_unlock(aj->alljobs_mutex);

  return(rc);
  } /* END has_job() */
Пример #4
0
int get_jobs_index(

  struct all_jobs *aj,
  job             *pjob)

  {
  int  index;

  if (pthread_mutex_trylock(aj->alljobs_mutex))
    {
    unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
    pthread_mutex_lock(aj->alljobs_mutex);
    lock_ji_mutex(pjob, __func__, NULL, LOGLEVEL);

    if (pjob->ji_being_recycled == TRUE)
      {
      pthread_mutex_unlock(aj->alljobs_mutex);
      unlock_ji_mutex(pjob, __func__, "2", LOGLEVEL);
      return(-1);
      }
    }

  index = get_value_hash(aj->ht, pjob->ji_qs.ji_jobid);
  pthread_mutex_unlock(aj->alljobs_mutex);

  return(index);
  } /* END get_jobs_index() */
Пример #5
0
/*
 * insert a new job into the array after a previous one
 *
 * @param already_in - the job this job should follow 
 * @param pjob - the job to be inserted
 * @return PBSE_NONE if the job is inserted correctly
 */
int insert_job_after(

  struct all_jobs *aj,
  job             *already_in,
  job             *pjob)

  {
  int rc;
  int i;

  pthread_mutex_lock(aj->alljobs_mutex);

  i = get_value_hash(aj->ht,already_in->ji_qs.ji_jobid);
  
  if (i < 0)
    rc = THING_NOT_FOUND;
  else
    {
    if ((rc = insert_thing_after(aj->ra,pjob,i)) == -1)
      {
      rc = ENOMEM;
      log_err(rc, __func__, "No memory to resize the array...SYSTEM FAILURE");
      }
    else
      {
      add_hash(aj->ht,rc,pjob->ji_qs.ji_jobid);
      rc = PBSE_NONE;
      }
    }

  pthread_mutex_unlock(aj->alljobs_mutex);

  return(rc);
  } /* END insert_job_after() */
int is_orphaned(

  char *rsv_id)

  {
  int               index;
  int               orphaned = FALSE;
  job              *pjob;
  alps_reservation *ar = NULL;

  pthread_mutex_lock(alps_reservations.rh_mutex);
  index = get_value_hash(alps_reservations.rh_ht, rsv_id);
  if (index != -1)
    ar = (alps_reservation *)alps_reservations.rh_alps_rsvs->slots[index].item;
  pthread_mutex_unlock(alps_reservations.rh_mutex);

  if (ar != NULL)
    {
    if ((pjob = svr_find_job(ar->job_id, TRUE)) != NULL)
      {
      if (pjob->ji_qs.ji_state == JOB_STATE_COMPLETE)
        orphaned = TRUE;

      unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
      }
    else
      orphaned = TRUE;
    }
  else
    orphaned = TRUE;

  return(orphaned);
  } /* END is_orphaned() */
int remove_alps_reservation(
    
  char *rsv_id)

  {
  int               index;
  int               rc = PBSE_NONE;
  alps_reservation *ar = NULL;

  pthread_mutex_lock(alps_reservations.rh_mutex);
  if ((index = get_value_hash(alps_reservations.rh_ht, rsv_id)) < 0)
    rc = THING_NOT_FOUND;
  else
    {
    ar = (alps_reservation *)alps_reservations.rh_alps_rsvs->slots[index].item;
    remove_thing_from_index(alps_reservations.rh_alps_rsvs, index);
    remove_hash(alps_reservations.rh_ht, rsv_id);
    }
  pthread_mutex_unlock(alps_reservations.rh_mutex);

  if (ar != NULL)
    free_alps_reservation(ar);

  return(rc);
  } /* END remove_alps_reservation() */
Пример #8
0
int add_to_hash_map(
    
  hash_map *hm,
  void     *obj,
  char     *key)

  {
  int index;
  int rc = PBSE_NONE;

  pthread_mutex_lock(hm->hm_mutex);

  if (get_value_hash(hm->hm_ht, key) >= 0)
    {
    rc = ALREADY_IN_HASH_MAP;
    }
  else
    {
    if ((index = insert_thing(hm->hm_ra, obj)) == -1)
      {
      rc = ENOMEM;
      log_err(rc, __func__, "Memory failure");
      }
    else
      add_hash(hm->hm_ht, index, key);
    }

  pthread_mutex_unlock(hm->hm_mutex);

  return(rc);
  } /* END add_to_hash_map() */
Пример #9
0
struct sockaddr_in *get_cached_addrinfo(
    
  char               *hostname)
  
  {
  network_info       *ni;
  int                 index;
  struct sockaddr_in *sai = NULL;

  if (cache.nc_mutex == NULL)
    return(NULL);

  pthread_mutex_lock(cache.nc_mutex);

  if ((index = get_value_hash(cache.nc_namekey, hostname)) >= 0)
    {
    ni = (network_info *)cache.nc_ra->slots[index].item;

    if (ni != NULL)
      {
      sai = &ni->sai;
      }
    }

  pthread_mutex_unlock(cache.nc_mutex);

  return(sai);
  } /* END get_cached_addrinfo() */
Пример #10
0
char *get_cached_nameinfo(
    
  struct sockaddr_in  *sai)

  {
  network_info *ni;
  char         *hostname = NULL;
  int           index;
  char          s_addr_key[65];

  pthread_mutex_lock(cache.nc_mutex);

  sprintf (s_addr_key, "%d", sai->sin_addr.s_addr);

  if ((index = get_value_hash(cache.nc_saikey, s_addr_key)) >= 0)
    {
    ni = (network_info *)cache.nc_ra->slots[index].item;

    if (ni != NULL)
      hostname = ni->hostname;
    }


  pthread_mutex_unlock(cache.nc_mutex);

  return(hostname);
  } /* END get_cached_nameinfo() */
Пример #11
0
job *find_job_by_array(

  struct all_jobs *aj,
  char            *job_id,
  int              get_subjob)

  {
  job *pj = NULL;
  int  i;

  if (aj == NULL)
    {
    log_err(PBSE_BAD_PARAMETER, __func__, "null struct all_jobs pointer fail");
    return(NULL);
    }
  if (job_id == NULL)
    {
    log_err(PBSE_BAD_PARAMETER, __func__, "null job_id pointer fail");
    return(NULL);
    }

  pthread_mutex_lock(aj->alljobs_mutex);

  i = get_value_hash(aj->ht, job_id);

  if (i >= 0)
    pj = (job *)aj->ra->slots[i].item;
  if (pj != NULL)
    lock_ji_mutex(pj, __func__, NULL, LOGLEVEL);

  pthread_mutex_unlock(aj->alljobs_mutex);

  if (pj != NULL)
    {
    if (get_subjob == TRUE)
      {
      if (pj->ji_cray_clone != NULL)
        {
        pj = pj->ji_cray_clone;
        unlock_ji_mutex(pj->ji_parent_job, __func__, NULL, LOGLEVEL);
        lock_ji_mutex(pj, __func__, NULL, LOGLEVEL);
        }
      }

    if (pj->ji_being_recycled == TRUE)
      {
      unlock_ji_mutex(pj, __func__, "1", LOGLEVEL);
      pj = NULL;
      }
    }

  return(pj);
  } /* END find_job_by_array() */
Пример #12
0
pbs_queue *find_queuebyname(

  char *quename) /* I */

  {
  char      *pc;
  pbs_queue *pque = NULL;
  char       qname[PBS_MAXDEST + 1];
  char       log_buf[LOCAL_LOG_BUF_SIZE+1];
  int        i;

  snprintf(qname, sizeof(qname), "%s", quename);

  if (LOGLEVEL >= 7)
    {
    sprintf(log_buf, "%s", quename);
    LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf);
    }

  pc = strchr(qname, (int)'@'); /* strip off server (fragment) */

  if (pc != NULL)
    *pc = '\0';

  lock_allques_mutex(&svr_queues, __func__, NULL, LOGLEVEL);

  i = get_value_hash(svr_queues.ht,qname);

  if (i >= 0)
    {
    pque = svr_queues.ra->slots[i].item;
    }
  
  if (pque != NULL)
    lock_queue(pque, __func__, NULL, LOGLEVEL);

  unlock_allques_mutex(&svr_queues, __func__, NULL, LOGLEVEL);
  
  if (pque != NULL)
    {
    if (pque->q_being_recycled != FALSE)
      {
      unlock_queue(pque, __func__, "recycled queue", LOGLEVEL);
      pque = NULL;
      }
    }

  if (pc != NULL)
    *pc = '@'; /* restore '@' server portion */

  return(pque);
  }  /* END find_queuebyname() */
Пример #13
0
/* currently this function can only be called for jobs in the alljobs array */
int swap_jobs(

  struct all_jobs *aj,
  job             *job1,
  job             *job2)

  {
  int rc;
  int new1;
  int new2;

  if (aj == NULL)
    {
    aj = &alljobs;
    }

  pthread_mutex_lock(aj->alljobs_mutex);

  new2 = get_value_hash(aj->ht,job1->ji_qs.ji_jobid);
  new1 = get_value_hash(aj->ht,job2->ji_qs.ji_jobid);

  if ((new1 == -1) ||
      (new2 == -1))
    {
    rc = THING_NOT_FOUND;
    }
  else
    {
    rc = swap_things(aj->ra,job1,job2);
    
    change_value_hash(aj->ht,job1->ji_qs.ji_jobid,new1);
    change_value_hash(aj->ht,job2->ji_qs.ji_jobid,new2);
    }

  pthread_mutex_unlock(aj->alljobs_mutex);
  
  return(rc);
  } /* END swap_jobs() */
Пример #14
0
int  remove_job(
   
  struct all_jobs *aj, 
  job             *pjob)

  {
  int rc = PBSE_NONE;
  int index;

  if (pjob == NULL)
    {
    rc = PBSE_BAD_PARAMETER;
    log_err(rc,__func__,"null input job pointer fail");
    return(rc);
    }
  if (aj == NULL)
    {
    rc = PBSE_BAD_PARAMETER;
    log_err(rc,__func__,"null input array pointer fail");
    return(rc);
    }

  if (LOGLEVEL >= 10)
    LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, pjob->ji_qs.ji_jobid);
  if (pthread_mutex_trylock(aj->alljobs_mutex))
    {
    unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
    pthread_mutex_lock(aj->alljobs_mutex);
    lock_ji_mutex(pjob, __func__, NULL, LOGLEVEL);

    if (pjob->ji_being_recycled == TRUE)
      {
      pthread_mutex_unlock(aj->alljobs_mutex);
      unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
      return(PBSE_JOB_RECYCLED);
      }
    }

  if ((index = get_value_hash(aj->ht,pjob->ji_qs.ji_jobid)) < 0)
    rc = THING_NOT_FOUND;
  else
    {
    remove_thing_from_index(aj->ra,index);
    remove_hash(aj->ht,pjob->ji_qs.ji_jobid);
    }

  pthread_mutex_unlock(aj->alljobs_mutex);

  return(rc);
  } /* END remove_job() */
Пример #15
0
char *get_cached_fullhostname(

  char               *hostname,
  struct sockaddr_in *sai)

  {
  network_info *ni;
  int           index = -1;
  char         *fullname = NULL;
  char          s_addr_key[65];

  if (cache.nc_mutex == NULL)
    return(NULL);

  pthread_mutex_lock(cache.nc_mutex);

  if (hostname != NULL)
    index = get_value_hash(cache.nc_namekey, hostname);

  if ((index == -1) &&
      (sai != NULL))
    {
    sprintf (s_addr_key, "%d", sai->sin_addr.s_addr);
    index = get_value_hash(cache.nc_saikey, s_addr_key);
    }

  if (index >= 0)
    {
    ni = (network_info *)cache.nc_ra->slots[index].item;
    fullname = ni->full_hostname;
    }

  pthread_mutex_unlock(cache.nc_mutex);

  return(fullname);
  } /* END get_cached_fullhostname() */
Пример #16
0
pbs_queue *find_queuebyname(

  char *quename) /* I */

  {
  char  *pc;
  pbs_queue *pque = NULL;
  char   qname[PBS_MAXDEST + 1];
  int    i;

  snprintf(qname, sizeof(qname), "%s", quename);

  pc = strchr(qname, (int)'@'); /* strip off server (fragment) */

  if (pc != NULL)
    *pc = '\0';

  pthread_mutex_lock(svr_queues.allques_mutex);

  i = get_value_hash(svr_queues.ht,qname);

  if (i >= 0)
    {
    pque = svr_queues.ra->slots[i].item;
    }
  
  if (pque != NULL)
    lock_queue(pque, __func__, NULL, LOGLEVEL);

  pthread_mutex_unlock(svr_queues.allques_mutex);
  
  if (pque != NULL)
    {
    if (pque->q_being_recycled != FALSE)
      {
      unlock_queue(pque, __func__, "recycled queue", LOGLEVEL);
      pque = NULL;
      }
    }

  if (pc != NULL)
    *pc = '@'; /* restore '@' server portion */

  return(pque);
  }  /* END find_queuebyname() */
Пример #17
0
void *get_from_hash_map(

  hash_map *hm,
  char     *key)

  {
  int   index;
  void *obj = NULL;

  pthread_mutex_lock(hm->hm_mutex);

  if ((index = get_value_hash(hm->hm_ht, key)) >= 0)
    obj = hm->hm_ra->slots[index].item;

  pthread_mutex_unlock(hm->hm_mutex);

  return(obj);
  } /* END get_from_hash_map() */
int already_recorded(

  char *rsv_id)

  {
  int               index;
  int               recorded = FALSE;

  pthread_mutex_lock(alps_reservations.rh_mutex);
  if ((index = get_value_hash(alps_reservations.rh_ht, rsv_id)) >= 0)
    {
    if (alps_reservations.rh_alps_rsvs->slots[index].item != NULL)
      recorded = TRUE;
    }
  pthread_mutex_unlock(alps_reservations.rh_mutex);

  return(recorded);
  } /* already_recorded() */
Пример #19
0
batch_request *get_batch_request(

  char *br_id)

  {
  batch_request *preq = NULL;
  int            i;

  pthread_mutex_lock(brh.brh_mutex);
  
  i = get_value_hash(brh.brh_ht, br_id);
  
  if (i >= 0)
    preq = (batch_request *)brh.brh_ra->slots[i].item;
  
  pthread_mutex_unlock(brh.brh_mutex);
  
  return(preq);
  } /* END get_batch_request() */
Пример #20
0
job *find_job_by_array(

    struct all_jobs *aj,
    char            *job_id,
    int              get_subjob)

{
    job *pj = NULL;
    int  i;

    pthread_mutex_lock(aj->alljobs_mutex);

    i = get_value_hash(aj->ht, job_id);

    if (i >= 0)
        pj = (job *)aj->ra->slots[i].item;
    if (pj != NULL)
        lock_ji_mutex(pj, __func__, (char *)NULL, LOGLEVEL);

    pthread_mutex_unlock(aj->alljobs_mutex);

    if (pj != NULL)
    {
        if (get_subjob == TRUE)
        {
            if (pj->ji_cray_clone != NULL)
            {
                pj = pj->ji_cray_clone;
                unlock_ji_mutex(pj->ji_parent_job, __func__, (char *)NULL, LOGLEVEL);
                lock_ji_mutex(pj, __func__, (char *)NULL, LOGLEVEL);
            }
        }

        if (pj->ji_being_recycled == TRUE)
        {
            unlock_ji_mutex(pj, __func__, (char *)"1", LOGLEVEL);
            pj = NULL;
        }
    }

    return(pj);
} /* END find_job_by_array() */
Пример #21
0
int  increment_queued_jobs(
   
  user_info_holder *uih,
  char             *user_name,
  job              *pjob)

  {
  int           rc = PBSE_NONE;
  user_info    *ui;
  int           index;
  unsigned int  num_submitted = count_jobs_submitted(pjob);

  pthread_mutex_lock(uih->ui_mutex);

  /* get the user if there is one */
  if ((index = get_value_hash(uih->ui_ht, user_name)) > 0)
    {
    ui = uih->ui_ra->slots[index].item;
    ui->num_jobs_queued += num_submitted;
    }
  else
    {
    /* user doesn't exist, create a new one and insert */
    ui = calloc(1, sizeof(user_info));
    ui->user_name = strdup(user_name);
    ui->num_jobs_queued = num_submitted;

    if ((index = insert_thing(uih->ui_ra, ui)) == -1)
      {
      rc = ENOMEM;
      log_err(rc, __func__, (char *)"Can't resize the user info array");
      }
    else
      {
      add_hash(uih->ui_ht, index, ui->user_name);
      }
    }

  pthread_mutex_unlock(uih->ui_mutex);

  return(rc);
  } /* END increment_queued_jobs() */
Пример #22
0
unsigned int get_num_queued(
    
  char *user_name)

  {
  unsigned int  num_queued = 0;
  int           index;
  user_info    *ui = NULL;

  pthread_mutex_lock(users.ui_mutex);

  if ((index = get_value_hash(users.ui_ht, user_name)) > 0)
    {
    ui = users.ui_ra->slots[index].item;
    num_queued = ui->num_jobs_queued;
    }

  pthread_mutex_unlock(users.ui_mutex);

  return(num_queued);
  } /* END get_num_queued() */
Пример #23
0
void *get_remove_from_hash_map(

  hash_map *hm,
  char     *key)

  {
  void *obj = NULL;
  int   index;

  pthread_mutex_lock(hm->hm_mutex);

  if ((index = get_value_hash(hm->hm_ht, key)) >= 0)
    {
    obj = hm->hm_ra->slots[index].item;
    remove_thing_from_index(hm->hm_ra, index);
    remove_hash(hm->hm_ht, key);
    }

  pthread_mutex_unlock(hm->hm_mutex);

  return(obj);
  } /* END get_remove_from_hash_map() */
Пример #24
0
int  decrement_queued_jobs(
    
  char *user_name)

  {
  user_info *ui;
  int        index;
  int        rc = THING_NOT_FOUND;

  pthread_mutex_lock(users.ui_mutex);

  if ((index = get_value_hash(users.ui_ht, user_name)) > 0)
    {
    ui = users.ui_ra->slots[index].item;
    ui->num_jobs_queued -= 1;
    rc = PBSE_NONE;
    }

  pthread_mutex_unlock(users.ui_mutex);

  return(rc);
  } /* END decrement_queued_jobs() */
Пример #25
0
int get_jobs_index(

  struct all_jobs *aj,
  job             *pjob)

  {
  int index = -1;

  if (aj == NULL)
    {
    log_err(PBSE_BAD_PARAMETER, __func__, "null job array input");
    return(PBSE_BAD_PARAMETER);
    }
  if (pjob == NULL)
    {
    log_err(PBSE_BAD_PARAMETER, __func__, "null job input");
    return(PBSE_BAD_PARAMETER);
    }

  if (pthread_mutex_trylock(aj->alljobs_mutex))
    {
    unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL);
    pthread_mutex_lock(aj->alljobs_mutex);
    lock_ji_mutex(pjob, __func__, NULL, LOGLEVEL);

    if (pjob->ji_being_recycled == TRUE)
      {
      pthread_mutex_unlock(aj->alljobs_mutex);
      unlock_ji_mutex(pjob, __func__, "2", LOGLEVEL);
      return(-1);
      }
    }

  index = get_value_hash(aj->ht, pjob->ji_qs.ji_jobid);
  pthread_mutex_unlock(aj->alljobs_mutex);

  return(index);
  } /* END get_jobs_index() */
Пример #26
0
int remove_from_hash_map(

  hash_map *hm,
  char     *key)

  {
  int index;
  int rc = PBSE_NONE;

  pthread_mutex_lock(hm->hm_mutex);

  if ((index = get_value_hash(hm->hm_ht, key)) < 0)
    rc = KEY_NOT_FOUND;
  else
    {
    remove_thing_from_index(hm->hm_ra, index);
    remove_hash(hm->hm_ht, key);
    }

  pthread_mutex_unlock(hm->hm_mutex);

  return(rc);
  } /* END remove_from_hash_map() */
Пример #27
0
int remove_batch_request(

  char *br_id)

  {
  int i;

  pthread_mutex_lock(brh.brh_mutex);

  i = get_value_hash(brh.brh_ht, br_id);

  if (i >= 0)
    {
    remove_thing_from_index(brh.brh_ra, i);
    remove_hash(brh.brh_ht, br_id);
    }
  pthread_mutex_unlock(brh.brh_mutex);

  if (i < 0)
    return(THING_NOT_FOUND);
  else
    return(PBSE_NONE);
  } /* END remove_batch_request() */
Пример #28
0
batch_request *get_remove_batch_request(

  char *br_id)

  {
  batch_request *preq = NULL;
  int            i;

  pthread_mutex_lock(brh.brh_mutex);
  
  i = get_value_hash(brh.brh_ht, br_id);
  
  if (i >= 0)
    {
    preq = (batch_request *)brh.brh_ra->slots[i].item;
    remove_thing_from_index(brh.brh_ra, i);
    remove_hash(brh.brh_ht, br_id);
    }
  
  pthread_mutex_unlock(brh.brh_mutex);
  
  return(preq);
  } /* END get_remove_batch_request() */
Пример #29
0
struct pbsnode *find_alpsnode_by_name(

  struct pbsnode *parent,
  char           *node_id)

  {
  struct pbsnode *node = NULL;
  int             index;

  pthread_mutex_lock(parent->alps_subnodes.allnodes_mutex);

  index = get_value_hash(parent->alps_subnodes.ht, node_id);

  if (index >= 0)
    node = (struct pbsnode *)parent->alps_subnodes.ra->slots[index].item;

  pthread_mutex_unlock(parent->alps_subnodes.allnodes_mutex);

  if (node != NULL)
    lock_node(node, __func__, NULL, 0);

  return(node);
  } /* END find_alpsnode_by_name() */
Пример #30
0
int insert_addr_name_info(
    
  char               *hostname,
  char               *full_hostname,
  struct sockaddr_in *sai)

  {
  int           rc = PBSE_NONE;
  int           index;
  network_info *ni;
  char          s_addr_key[65];

  if (cache.nc_mutex == NULL)
    return(-1);

  pthread_mutex_lock(cache.nc_mutex);

  /* only insert if it isn't already there */
  if (get_value_hash(cache.nc_namekey, hostname) < 0)
    {
    ni = get_network_info_holder(hostname, full_hostname, sai);

    if ((index = insert_thing(cache.nc_ra, ni)) < 0)
      rc = ENOMEM;
    else
      {
      /* store the key in both hash tables so we can look things up either way */
      add_hash(cache.nc_namekey, index, ni->hostname);
      sprintf (s_addr_key, "%d", sai->sin_addr.s_addr);
      add_hash(cache.nc_saikey, index, strdup(s_addr_key));
      }
    }

  pthread_mutex_unlock(cache.nc_mutex);

  return(rc);
  } /* END insert_addr_name_info() */