Exemplo n.º 1
0
int remove_parent_from_host(host *hst, host *parent)
{
	if (hst->parent_hosts) {
		g_tree_remove(hst->parent_hosts, parent->name);
	}
	if (parent->child_hosts) {
		g_tree_remove(parent->child_hosts, hst->name);
	}
	return 0;
}
static int8_t scheduleTimeoutEventLockHeld(dispatcher_t* disp, 
		entity_context_t* ent_context) {

	if (disp->fd_flag[ent_context->fd] != 1)
		return -1;

	gboolean rc = g_tree_remove(disp->registered_timeouts, 
			&(ent_context->scheduled));
	ent_context->scheduled.tv_sec = 
		ent_context->to_be_scheduled.tv_sec;
	ent_context->scheduled.tv_usec = 
		ent_context->to_be_scheduled.tv_usec;
	struct timeval* key = newTimevalKey(&(ent_context->scheduled));
	if (key) {
		while (1) {
			entity_context_t* tmp_ent_ctx = g_tree_lookup(
					disp->registered_timeouts, key);
			if (!tmp_ent_ctx)
				break;
			key->tv_usec += 1;
		}
		g_tree_insert(disp->registered_timeouts, 
				key, ent_context);
		ent_context->to_be_scheduled.tv_sec = 0;
		ent_context->to_be_scheduled.tv_usec = 0;
		//recalculate the epoll_timeout
		GTraverseFunc update_epoll_timeout = updateEpollTimeout;
		g_tree_foreach(disp->registered_timeouts, 
				update_epoll_timeout, disp);
		//traverse only one element.require MIN(timeout)
		return 1;
	}
	return -1;
}
Exemplo n.º 3
0
/**
 * PRE:
 * - The base must be owned by the current thread
 * - it must be opened only once and locked only once
 * - the cache-wide lock must be owned by the current thread
 *
 * POST:
 * - The base is returned to the FREE list
 * - the base is not owned by any thread
 * - The cache-wide lock is still owned
 */
static void
_expire_base(sqlx_cache_t *cache, sqlx_base_t *b)
{
	hashstr_t *n = b->name;
	gpointer handle = b->handle;

	sqlx_base_debug("FREEING", b);
	EXTRA_ASSERT(b->owner != NULL);
	EXTRA_ASSERT(b->count_open == 0);
	EXTRA_ASSERT(b->status == SQLX_BASE_USED);

	sqlx_base_move_to_list(cache, b, SQLX_BASE_CLOSING);

	/* the base is for the given thread, it is time to REALLY close it.
	 * But this can take a lot of time. So we can release the pool,
	 * free the handle and unlock the cache */
	g_cond_signal(b->cond);
	g_mutex_unlock(&cache->lock);
	if (cache->close_hook)
		cache->close_hook(handle);
	g_mutex_lock(&cache->lock);

	b->handle = NULL;
	b->owner = NULL;
	b->name = NULL;
	b->count_open = 0;
	b->last_update.tv_sec = b->last_update.tv_usec = 0;
	sqlx_base_move_to_list(cache, b, SQLX_BASE_FREE);

	g_tree_remove(cache->bases_by_name, n);

	g_free(n);
}
Exemplo n.º 4
0
Arquivo: manage.c Projeto: artzub/mc
void
mc_event_group_del (const gchar * event_group_name)
{

    if (mc_event_grouplist != NULL && event_group_name != NULL)
        g_tree_remove (mc_event_grouplist, (gconstpointer) event_group_name);
}
Exemplo n.º 5
0
gboolean
ibus_hotkey_profile_remove_hotkey_by_event (IBusHotkeyProfile *profile,
                                            GQuark             event)
{
    IBusHotkeyProfilePrivate *priv;
    priv = IBUS_HOTKEY_PROFILE_GET_PRIVATE (profile);

    gint i;
    IBusHotkeyEvent *p = NULL;
    for ( i = 0; i < priv->events->len; i++) {
        p = &g_array_index (priv->events, IBusHotkeyEvent, i);
        if (p->event == event)
            break;
    }

    if (p == NULL || p->event != event)
        return FALSE;

    GList *list;
    for (list = p->hotkeys; list != NULL; list = list->next) {
        g_tree_remove (priv->hotkeys, (IBusHotkey *)list->data);
    }

    g_list_free (p->hotkeys);
    g_array_remove_index_fast (priv->events, i);

    return TRUE;
}
Exemplo n.º 6
0
/**
 * pka_subscription_remove_source:
 * @subscription: A #PkaSubscription.
 * @context: A #PkaContext.
 * @source: A #PkaSource.
 * @error: A location for #GError, or %NULL.
 *
 * Removes @source from @subscription.
 *
 * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
 * Side effects: None.
 */
gboolean
pka_subscription_remove_source (PkaSubscription  *subscription, /* IN */
                                PkaContext       *context,      /* IN */
                                PkaSource        *source,       /* IN */
                                GError          **error)        /* OUT */
{
	gboolean ret = FALSE;
	gint key;

	g_return_val_if_fail(subscription != NULL, FALSE);
	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_SOURCE(source), FALSE);

	ENTRY;
	if (!IS_AUTHORIZED(context, MODIFY_SUBSCRIPTION, subscription)) {
		g_set_error(error, PKA_CONTEXT_ERROR,
		            PKA_CONTEXT_ERROR_NOT_AUTHORIZED,
		            "Not authoraized to remove source %d from subscription %d.",
		            pka_source_get_id(source), subscription->id);
		GOTO(failed);
	}
	key = pka_source_get_id(source);
	pka_source_remove_subscription(source, subscription);
	g_static_rw_lock_writer_lock(&subscription->rw_lock);
	g_tree_remove(subscription->sources, &key);
	g_static_rw_lock_writer_unlock(&subscription->rw_lock);
	ret = TRUE;
  failed:
	RETURN(ret);
}
Exemplo n.º 7
0
/* removes AND DESTROYS the named link from catalog */
void links_catalog_remove(const link_id_t *key)
{
  g_assert(all_links);
  g_assert(key);

  g_tree_remove (all_links, key);
}
Exemplo n.º 8
0
static void __agent_schedule_abs(struct ice_agent *ag, const struct timeval *tv) {
	struct timeval nxt;
	long long diff;

	if (!ag) {
		ilog(LOG_ERR, "ice ag is NULL");
		return;
	}

	nxt = *tv;

	mutex_lock(&ice_agents_timers_lock);
	if (ag->last_run.tv_sec) {
		/* make sure we don't run more often than we should */
		diff = timeval_diff(&nxt, &ag->last_run);
		if (diff < TIMER_RUN_INTERVAL * 1000)
			timeval_add_usec(&nxt, TIMER_RUN_INTERVAL * 1000 - diff);
	}
	if (ag->next_check.tv_sec && timeval_cmp(&ag->next_check, &nxt) <= 0)
		goto nope; /* already scheduled sooner */
	if (!g_tree_remove(ice_agents_timers, ag))
		obj_hold(ag); /* if it wasn't removed, we make a new reference */
	ag->next_check = nxt;
	g_tree_insert(ice_agents_timers, ag, ag);
	cond_broadcast(&ice_agents_timers_cond);
nope:
	mutex_unlock(&ice_agents_timers_lock);
}
Exemplo n.º 9
0
void
wavegen_noteoff (Machine *mach, int notenum)
{
  WaveGen *wavegen = WAVEGEN (mach);

  /* TODO: BAD STUFF: doesn't free the WaveGenNote! */
  g_tree_remove (wavegen->notes, GINT_TO_POINTER (notenum));
}
Exemplo n.º 10
0
static void oscats_administrand_dispose (GObject *object)
{
    OscatsAdministrand *self = OSCATS_ADMINISTRAND(object);
    G_OBJECT_CLASS(oscats_administrand_parent_class)->dispose(object);
    if (self->characteristics) g_object_unref(self->characteristics);
    self->characteristics = NULL;
    g_tree_remove(administrands, self);
}
Exemplo n.º 11
0
static void
tree_remove_watch_directory(struct watch_directory *directory)
{
	G_GNUC_UNUSED
	bool found = g_tree_remove(inotify_directories,
				   GINT_TO_POINTER(directory->descriptor));
	assert(found);
}
Exemplo n.º 12
0
static void
keyfile_to_tree (GKeyfileSettingsBackend *kfsb,
                 GTree                   *tree,
                 GKeyFile                *keyfile,
                 gboolean                 dup_check)
{
  gchar **groups;
  gint i;

  groups = g_key_file_get_groups (keyfile, NULL);
  for (i = 0; groups[i]; i++)
    {
      gboolean is_root_group;
      gchar **keys;
      gint j;

      is_root_group = g_strcmp0 (kfsb->root_group, groups[i]) == 0;

      /* reject group names that will form invalid key names */
      if (!is_root_group &&
          (g_str_has_prefix (groups[i], "/") ||
           g_str_has_suffix (groups[i], "/") || strstr (groups[i], "//")))
        continue;

      keys = g_key_file_get_keys (keyfile, groups[i], NULL, NULL);
      g_assert (keys != NULL);

      for (j = 0; keys[j]; j++)
        {
          gchar *path, *value;

          /* reject key names with slashes in them */
          if (strchr (keys[j], '/'))
            continue;

          if (is_root_group)
            path = g_strdup_printf ("%s%s", kfsb->prefix, keys[j]);
          else
            path = g_strdup_printf ("%s%s/%s", kfsb->prefix, groups[i], keys[j]);

          value = g_key_file_get_value (keyfile, groups[i], keys[j], NULL);

          if (dup_check && g_strcmp0 (g_tree_lookup (tree, path), value) == 0)
            {
              g_tree_remove (tree, path);
              g_free (value);
              g_free (path);
            }
          else
            g_tree_insert (tree, path, value);
        }

      g_strfreev (keys);
    }
  g_strfreev (groups);
}
Exemplo n.º 13
0
static void msn_buddy_data_free( bee_user_t *bu )
{
	struct msn_data *md = bu->ic->proto_data;
	struct msn_buddy_data *bd = bu->data;
	
	g_free( bd->cid );
	g_free( bd );
	
	g_tree_remove( md->domaintree, bu->handle );
}
Exemplo n.º 14
0
static void on_remove(breakpoint *bp)
{
	/* remove marker */
	markers_remove_breakpoint(bp);
	/* remove from breakpoints tab */
	bptree_remove_breakpoint(bp);
	/* remove from internal storage */
	GTree *tree = g_hash_table_lookup(files, bp->file);
	g_tree_remove(tree, GINT_TO_POINTER(bp->line));
}
Exemplo n.º 15
0
static void deRegisterInterface(PINTERFACE pif)
{
    PPARSEINFO pParseInfo=(PPARSEINFO)gScanner->user_data;

    /* Remove the interface from our list */
    g_ptr_array_remove(pParseInfo->pInterfaceArray, (gpointer) pif);

    /* Any found interface was registered as a new type so it can be
     used in other classes. */
    g_tree_remove(pParseInfo->pSymbolTree, pif->pSymbolIFace);

    g_scanner_scope_remove_symbol(gScanner, ID_SCOPE, pif->pSymbolIFace->chrSymbolName);
    /* For legacy support and convenience we automatically registered a pointer type
     to the interface. */
    g_tree_remove(pParseInfo->pSymbolTree, pif->pSymbolIFacePtr);
    g_scanner_scope_remove_symbol(gScanner, ID_SCOPE, pif->pSymbolIFacePtr->chrSymbolName);
    /* We don't clean up. Looking at the whole mess with string dupes and stuff in side the
     structs I just decided to use a GC instead... */
}
Exemplo n.º 16
0
Arquivo: i2c.c Projeto: useche/btstats
static void C(struct blk_io_trace *t, void *data)
{
	DECL_ASSIGN_I2C(i2c,data);

	if(g_tree_lookup(i2c->is, &t->sector)!=NULL) {
		g_tree_remove(i2c->is, &t->sector);
		
		oio_change(i2c, t, FALSE);
	}
}
Exemplo n.º 17
0
Arquivo: manage.c Projeto: artzub/mc
void
mc_event_destroy (const gchar * event_group_name, const gchar * event_name)
{
    GTree *event_group;

    if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL)
        return;

    event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
    g_tree_remove (event_group, (gconstpointer) event_name);
}
Exemplo n.º 18
0
static gboolean mailbox_clear_recent(uint64_t *uid, MessageInfo *msginfo, T M)
{
	msginfo->flags[IMAP_FLAG_RECENT] = 0;
	gpointer value;
	gpointer orig_key;
	if (g_tree_lookup_extended(M->recent_queue, uid, &orig_key, &value)) {
		g_tree_remove(M->recent_queue, orig_key);
		mempool_push(M->pool, orig_key, sizeof(uint64_t));
	}
	return FALSE;
}
Exemplo n.º 19
0
void ice_thread_run(void *p) {
	struct ice_agent *ag;
	struct call *call;
	long long sleeptime;
	struct timeval tv;

	mutex_lock(&ice_agents_timers_lock);

	while (!g_shutdown) {
		gettimeofday(&g_now, NULL);

		/* lock our list and get the first element */
		ag = g_tree_find_first(ice_agents_timers, NULL, NULL);
		/* scheduled to run? if not, we just go to sleep, otherwise we remove it from the tree,
		 * steal the reference and run it */
		if (!ag)
			goto sleep;
		if (timeval_cmp(&g_now, &ag->next_check) < 0)
			goto sleep;

		g_tree_remove(ice_agents_timers, ag);
		ZERO(ag->next_check);
		ag->last_run = g_now;
		mutex_unlock(&ice_agents_timers_lock);

		/* this agent is scheduled to run right now */

		/* lock the call */
		call = ag->call;
		log_info_ice_agent(ag);
		rwlock_lock_r(&call->master_lock);

		/* and run our checks */
		__do_ice_checks(ag);

		/* finally, release our reference and start over */
		log_info_clear();
		rwlock_unlock_r(&call->master_lock);
		obj_put(ag);
		mutex_lock(&ice_agents_timers_lock);
		continue;

sleep:
		/* figure out how long we should sleep */
		sleeptime = ag ? timeval_diff(&ag->next_check, &g_now) : 100000;
		sleeptime = MIN(100000, sleeptime); /* 100 ms at the most */
		tv = g_now;
		timeval_add_usec(&tv, sleeptime);
		cond_timedwait(&ice_agents_timers_cond, &ice_agents_timers_lock, &tv);
		continue;
	}

	mutex_unlock(&ice_agents_timers_lock);
}
Exemplo n.º 20
0
/**
 * @brief Clears the contents of a GTree
 *
 * @param tree  the tree to remove all elements from
 */
void g_tree_clear(GTree* tree)
{
  GList* keys = NULL;
  GList* iter = NULL;

  g_tree_foreach(tree, g_tree_collect, &keys);

  for(iter = keys; iter != NULL; iter = iter->next)
    g_tree_remove(tree, iter->data);

  g_list_free(keys);
}
Exemplo n.º 21
0
void b_free(void *p)
{
  heap_entry *he = g_tree_lookup(heap_info, p);

  if (he != NULL) {
    bitmap_set_bits(bm, 0, he->bm_nbits, he->start_bm_idx);

    g_tree_remove(heap_info, p);

    free(he);
  }
}
Exemplo n.º 22
0
static void
assert_compare_sample_and_delete_form_tree(GTree *tree,
                                           history_gluon_data_t *data_array,
                                           uint64_t num)
{
	uint64_t i;
	for (i = 0; i < num; i++) {
		history_gluon_data_t *data = &data_array[i];
		gboolean ret = g_tree_remove(g_gtree, make_sample_key(data));
		cut_assert_equal_int(TRUE, ret);
	}
}
Exemplo n.º 23
0
static void __agent_deschedule(struct ice_agent *ag) {
	int ret;
	mutex_lock(&ice_agents_timers_lock);
	if (!ag->next_check.tv_sec)
		goto nope; /* already descheduled */
	ret = g_tree_remove(ice_agents_timers, ag);
	ZERO(ag->next_check);
	if (ret)
		obj_put(ag);
nope:
	mutex_unlock(&ice_agents_timers_lock);
}
Exemplo n.º 24
0
/****************************************************************************************************
* remove a single point
****************************************************************************************************/
void poi_set_remove_point(PoiSet * poi_set, int node_id, double lon, double lat)
{
		struct Rect * rect = malloc(sizeof(struct Rect));
		rect -> boundary[0] = lon;
		rect -> boundary[1] = lat;
		rect -> boundary[2] = lon;
		rect -> boundary[3] = lat;
		int del = r_r_tree_delete_rect(poi_set -> rtree, rect, node_id);
		free(rect);
		/* remove from binary tree */
		g_tree_remove(poi_set -> points, &node_id);
}
Exemplo n.º 25
0
void prev_process_info__garbage_collector(cdtime_t tm) { /* {{{ */
    prev_process_info__userdata_t userdata;
    GSList *cur;

    userdata.gl = NULL;
    userdata.tm = tm;

    g_tree_foreach(prev_process_info, prev_process_info__check_unused, &userdata);
    for(cur=userdata.gl; cur; cur = cur->next) {
        g_tree_remove(prev_process_info, cur->data);
    }
    g_slist_free(userdata.gl);
} /* }}} */
Exemplo n.º 26
0
int main(void) {
  GTree *t = g_tree_new((GCompareFunc)g_ascii_strcasecmp);
  g_tree_insert(t, "c", "Chicago");
  printf("The tree height is %d\n", g_tree_height(t));
  g_tree_insert(t, "b", "Boston");
  g_tree_insert(t, "d", "Detroit");
  printf("Height is now %d for %d nodes in the tree\n", g_tree_height(t),
         g_tree_nnodes(t));
  g_tree_remove(t, "d");
  printf("Height is now %d for %d nodes in the tree\n", g_tree_height(t),
         g_tree_nnodes(t));
  g_tree_destroy(t);
}
Exemplo n.º 27
0
static void gslist_foreach_func (gpointer data, gpointer user_data)
{
    RequestData **request_data_pointer = data;
    RequestData *request_data = *request_data_pointer;
    HTTPServer *http_server = user_data;
    GError *err = NULL;

    g_tree_remove (http_server->idle_queue, &(request_data->wakeup_time));
    g_thread_pool_push (http_server->thread_pool, request_data_pointer, &err);
    if (err != NULL) {
        GST_FIXME ("Thread pool push error %s", err->message);
        g_error_free (err);
    }
}
Exemplo n.º 28
0
int main() {
    printf("Create a new GTree using g_tree_new_full().\n");
    GTree *tree = g_tree_new_full((GCompareDataFunc)g_ascii_strcasecmp, NULL,
            (GDestroyNotify)destroy_key, (GDestroyNotify)destroy_val);
    printf("Add items to the tree.\n");
    g_tree_insert(tree, "c", "Captain America");
    g_tree_insert(tree, "i", "Iron Man");
    g_tree_insert(tree, "h", "Hawk Eye");
    g_tree_insert(tree, "s", "Spider Man");
    printf("Tree height from g_tree_height(): %d\n", g_tree_height(tree));
    printf("Number of nodes from g_tree_nnodes(): %d\n", g_tree_nnodes(tree));
    printf("List the tree using g_tree_foreach() and a GTraverseFunc.\n");
    printf("Tree Contents:\n");
    g_tree_foreach(tree, (GTraverseFunc)print_iterator, NULL);
    printf("\n");

    printf("Find items using g_tree_lookup().\n");
    printf("The data at 'i' is '%s'\n", g_tree_lookup(tree, "i"));
    printf("%s\n\n", g_tree_lookup(tree, "d") ?
            "Unexpected value!!" : "No data found for 'd'");

    printf("Find items using g_tree_search() and a GCompareFunc.\n");
    gpointer val = g_tree_search(tree, (GCompareFunc)finder, NULL);
    printf("The value is %s\n\n", val);

    printf("Remove an item using g_tree_remove().\n");
    g_tree_remove(tree, "h");
    printf("Number of nodes is now: %d\n", g_tree_nnodes(tree));
    printf("Tree Contents:\n");
    g_tree_foreach(tree, (GTraverseFunc)print_iterator, NULL);
    printf("\n");

    printf("Replacing 's', destroy functions will be called.\n");
    g_tree_replace(tree, "s", "Storm");
    printf("Number of nodes is now: %d\n", g_tree_nnodes(tree));
    printf("Tree Contents:\n");
    g_tree_foreach(tree, (GTraverseFunc)print_iterator, NULL);
    printf("\n");

    printf("Stealing 'c' with g_tree_steal(), no drstroy functions now.\n");
    g_tree_steal(tree, "c");
    printf("Number of nodes is now: %d\n", g_tree_nnodes(tree));
    printf("Tree Contents:\n");
    g_tree_foreach(tree, (GTraverseFunc)print_iterator, NULL);
    printf("\n");

    printf("Destroying the tree using g_tree_destroy().\n");
    g_tree_destroy(tree);
}
Exemplo n.º 29
0
void timerthread_obj_deschedule(struct timerthread_obj *tt_obj) {
	if (!tt_obj)
		return;

	struct timerthread *tt = tt_obj->tt;
	mutex_lock(&tt->lock);
	if (!tt_obj->next_check.tv_sec)
		goto nope; /* already descheduled */
	int ret = g_tree_remove(tt->tree, tt_obj);
	ZERO(tt_obj->next_check);
	if (ret)
		obj_put(tt_obj);
nope:
	mutex_unlock(&tt->lock);
}
Exemplo n.º 30
0
/**
 * pka_subscription_remove_channel:
 * @subscription: A #PkaSubscription.
 * @context: A #PkaContext.
 * @channel: A #PkaChannel.
 * @error: A location #GError, or %NULL.
 *
 * Removes a channel and all of its sources from being monitored by the
 * subscription.
 *
 * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
 * Side effects: None.
 */
gboolean
pka_subscription_remove_channel (PkaSubscription  *subscription, /* IN */
                                 PkaContext       *context,      /* IN */
                                 PkaChannel       *channel,      /* IN */
                                 GError          **error)        /* OUT */
{
	gboolean ret = FALSE;
	GList *sources = NULL;
	GList *iter;
	gint key;

	g_return_val_if_fail(subscription != NULL, FALSE);
	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_CHANNEL(channel), FALSE);

	ENTRY;
	if (!IS_AUTHORIZED(context, MODIFY_SUBSCRIPTION, subscription)) {
		g_set_error(error, PKA_CONTEXT_ERROR,
		            PKA_CONTEXT_ERROR_NOT_AUTHORIZED,
		            "Not authorized to remove channel %d from subscription %d.",
		            pka_channel_get_id(channel), subscription->id);
		GOTO(failed);
	}
	g_signal_handlers_disconnect_by_func(channel,
	                                     pka_subscription_channel_source_added,
	                                     subscription);
	g_signal_handlers_disconnect_by_func(channel,
	                                     pka_subscription_channel_source_removed,
	                                     subscription);
	sources = pka_channel_get_sources(channel);
	for (iter = sources; iter; iter = iter->next) {
		if (!pka_subscription_remove_source(subscription, context,
		                                    iter->data, NULL)) {
		    WARNING(Subscription,
		            "Could not remove source %d from subscription %d",
		            pka_source_get_id(iter->data), subscription->id);
		}
	}
	g_list_foreach(sources, (GFunc)g_object_unref, NULL);
	g_list_free(sources);
	key = pka_channel_get_id(channel);
	g_static_rw_lock_writer_lock(&subscription->rw_lock);
	g_tree_remove(subscription->channels, &key);
	g_static_rw_lock_writer_unlock(&subscription->rw_lock);
	ret = TRUE;
  failed:
	RETURN(ret);
}