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() */
Example #2
0
void remove_user_by_socket(int fd)
{
	struct sock_map_entry *pos;
	struct sock_map_entry *entry = socket_to_sock_map_entry(fd);

	if (!entry)
		return;

	rwlock_wr_lock(&sock_map_lock);

	pos = remove_hash(entry->fd, entry, entry->next, &sock_mapper);
	while (pos && pos->next && pos->next != entry)
		pos = pos->next;
	if (pos && pos->next && pos->next == entry)
		pos->next = entry->next;

	memset(entry->proto->enonce, 0, sizeof(entry->proto->enonce));
	memset(entry->proto->dnonce, 0, sizeof(entry->proto->dnonce));

	entry->proto = NULL;
	entry->next = NULL;

	xfree(entry);

	rwlock_unlock(&sock_map_lock);
}
Example #3
0
void remove_user_by_sockaddr(struct sockaddr_storage *sa, size_t sa_len)
{
	struct sockaddr_map_entry *pos;
	struct sockaddr_map_entry *entry;
	unsigned int hash = hash_name((char *) sa, sa_len);

	entry = sockaddr_to_sockaddr_map_entry(sa, sa_len);
	if (!entry)
		return;

	rwlock_wr_lock(&sockaddr_map_lock);

	pos = remove_hash(hash, entry, entry->next, &sockaddr_mapper);
	while (pos && pos->next && pos->next != entry)
		pos = pos->next;
	if (pos && pos->next && pos->next == entry)
		pos->next = entry->next;

	memset(entry->proto->enonce, 0, sizeof(entry->proto->enonce));
	memset(entry->proto->dnonce, 0, sizeof(entry->proto->dnonce));

	entry->proto = NULL;
	entry->next = NULL;

	xfree(entry->sa);
	xfree(entry);

	rwlock_unlock(&sockaddr_map_lock);
}
buf *remove_hash_head(int i){
  buf *ret = h_head[i].hash_fp;
  remove_hash(ret);
  //h_head[i].hash_fp = h_head[i].hash_fp -> hash_fp;
  //h_head[i].hash_fp -> hash_bp = &h_head[i];
  return ret;
}
Example #5
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() */
Example #6
0
/*
 * Move a successfully used entry to level2. If already at level2,
 * move it to the end of the LRU queue..
 */
static inline void move_to_level2(struct dir_cache_entry * old_de, struct hash_list * hash)
{
	struct dir_cache_entry * de;

	if (old_de->lru_head == &level2_head) {
		update_lru(old_de);
		return;
	}	
	de = level2_head;
	level2_head = de->next_lru;
	remove_hash(de);
	COPYDATA(old_de, de);
	add_hash(de, hash);
}
Example #7
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() */
buf *remove_free_head(){
  if(IsEmptyFree()){
    return NULL;
  }
  buf *ret = f_head.free_fp;
  while(CheckStatus(ret, STAT_DWR)){
    if(ret == &f_head){
      printf("Oops somethig wrong happening heer\n");
      return NULL;
    }
    ret = ret -> free_fp;
  }
 
  remove_hash(ret);
  f_head.free_fp = f_head.free_fp -> free_fp;
  f_head.free_fp -> free_bp = &f_head;
  return ret;
}
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() */
Example #10
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() */
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() */
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() */
Example #13
0
void unregister_socket(int fd)
{
	struct map_entry *pos;
	struct map_entry *entry = socket_to_map_entry(fd);

	if (!entry == 0 && errno == ENOENT)
		return;

	rwlock_wr_lock(&map_lock);

	cpu_assigned[entry->cpu]--;

	pos = remove_hash(entry->fd, entry, entry->next, &mapper);
	while (pos && pos->next && pos->next != entry)
		pos = pos->next;
	if (pos && pos->next && pos->next == entry)
		pos->next = entry->next;

	entry->next = NULL;
	xfree(entry);

	rwlock_unlock(&map_lock);
}
Example #14
0
void dcache_add(struct inode * dir, const char * name, int len, unsigned long ino)
{
	struct hash_list * hash;
	struct dir_cache_entry *de;

	if (len > DCACHE_NAME_LEN)
		return;
	hash = hash_table + hash_fn(dir->i_dev, dir->i_ino, namehash(name,len));
	if ((de = find_entry(dir, name, len, hash)) != NULL) {
		de->ino = ino;
		update_lru(de);
		return;
	}
	de = level1_head;
	level1_head = de->next_lru;
	remove_hash(de);
	de->dev = dir->i_dev;
	de->dir = dir->i_ino;
	de->version = dir->i_version;
	de->ino = ino;
	de->name_len = len;
	memcpy(de->name, name, len);
	add_hash(de, hash);
}