Пример #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
/* 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() */