Esempio n. 1
0
void
fen_remove (const gchar *filename, gpointer sub, gboolean is_mondir)
{
    node_t* f;
    
    g_assert (filename);
    g_assert (sub);

    G_LOCK (fen_lock);
	f = node_find(NULL, filename, FALSE);
    FH_W ("%s 0x%p sub[0x%p] %s\n", __func__, f, sub, filename);

    if (f) {
        if (is_mondir) {
            f->dir_subs = g_list_remove(f->dir_subs, sub);
        } else {
            f->subs = g_list_remove(f->subs, sub);
        }

        if (!NODE_IS_ACTIVE(f)) {
            node_try_delete (f);
        }
    }
    G_UNLOCK (fen_lock);
}
Esempio n. 2
0
/**
 * fen_add
 * 
 * Won't hold a ref, we have a timout callback to clean unused node_t.
 * If there is no value for a key, add it and return it; else return the old
 * one.
 */
void
fen_add (const gchar *filename, gpointer sub, gboolean is_mondir)
{
	node_t* f;

    g_assert (filename);
    g_assert (sub);

    G_LOCK (fen_lock);
	f = node_find(NULL, filename, TRUE);
    FH_W ("%s 0x%p sub[0x%p] %s\n", __func__, f, sub, filename);
    g_assert (f);

    /* Update timestamp, the events in global queue will compare itself to this
     * timestamp to decide if be emitted. TODO, timestamp should be per sub.
     */
    if (!NODE_IS_ACTIVE(f)) {
        g_get_current_time(&f->atv);
    }

    if (is_mondir) {
        f->dir_subs = g_list_prepend(f->dir_subs, sub);
    } else {
        f->subs = g_list_prepend(f->subs, sub);
    }
    
    if (NODE_HAS_STATE(f, NODE_STATE_ASSOCIATED) ||
      (node_lstat(f) == 0 && port_add(f) == 0)) {
#ifndef GIO_COMPILATION
        gam_server_emit_one_event (NODE_NAME(f),
          gam_subscription_is_dir (sub), GAMIN_EVENT_EXISTS, sub, 1);
#endif
        if (is_mondir) {
            scan_children_init (f, sub);
        }
    } else {
#ifndef GIO_COMPILATION
        gam_server_emit_one_event (NODE_NAME(f),
          gam_subscription_is_dir (sub), GAMIN_EVENT_DELETED, sub, 1);
#endif
        node_adjust_deleted (f);
    }
#ifndef GIO_COMPILATION
    gam_server_emit_one_event (NODE_NAME(f),
      gam_subscription_is_dir (sub), GAMIN_EVENT_ENDEXISTS, sub, 1);
#endif
    G_UNLOCK (fen_lock);
}
Esempio n. 3
0
static void
node_delete (node_t *f)
{
    FN_W ("%s 0x%p %s\n", __func__, f, NODE_NAME(f));
    g_assert(f->state == 0);
    g_assert(!NODE_IS_ACTIVE(f));
    g_assert(g_hash_table_size (f->children) == 0);
    g_assert(NODE_PARENT(f) == NULL);
    g_hash_table_unref(f->children);
#ifdef GIO_COMPILATION
    g_object_unref (f->gfile);
#endif
    g_free(f->basename);
    g_free(NODE_NAME(f));
    g_free (f);
}