示例#1
0
文件: zre_node.c 项目: Aluminus/zyre
static void
agent_destroy (agent_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        agent_t *self = *self_p;

        fmq_dir_t *inbox = fmq_dir_new (self->fmq_inbox, NULL);
        fmq_dir_remove (inbox, true);
        fmq_dir_destroy (&inbox);

        fmq_dir_t *outbox = fmq_dir_new (self->fmq_outbox, NULL);
        fmq_dir_remove (outbox, true);
        fmq_dir_destroy (&outbox);

        zhash_destroy (&self->peers);
        zhash_destroy (&self->peer_groups);
        zhash_destroy (&self->own_groups);
        zhash_destroy (&self->headers);
        zre_udp_destroy (&self->udp);
        zre_log_destroy (&self->log);
        
        fmq_server_destroy (&self->fmq_server);
        fmq_client_destroy (&self->fmq_client);
        free (self->identity);
        free (self);
        *self_p = NULL;
    }
}
示例#2
0
static bool
mount_refresh (mount_t *self, server_t *server)
{
    bool activity = false;

    //  Get latest snapshot and build a patches list for any changes
    fmq_dir_t *latest = fmq_dir_new (self->location, NULL);
    zlist_t *patches = fmq_dir_diff (self->dir, latest, self->alias);

    //  Drop old directory and replace with latest version
    fmq_dir_destroy (&self->dir);
    self->dir = latest;

    //  Copy new patches to clients' patches list
    sub_t *sub = (sub_t *) zlist_first (self->subs);
    while (sub) {
        fmq_patch_t *patch = (fmq_patch_t *) zlist_first (patches);
        while (patch) {
            sub_patch_add (sub, patch);
            patch = (fmq_patch_t *) zlist_next (patches);
            activity = true;
        }
        sub = (sub_t *) zlist_next (self->subs);
    }
    
    //  Destroy patches, they've all been copied
    while (zlist_size (patches)) {
        fmq_patch_t *patch = (fmq_patch_t *) zlist_pop (patches);
        fmq_patch_destroy (&patch);
    }
    zlist_destroy (&patches);
    return activity;
}
示例#3
0
static zhash_t *
sub_cache (sub_t *self)
{
    //  Get directory cache for this path
    fmq_dir_t *dir = fmq_dir_new (self->path + 1, self->inbox);
    zhash_t *cache = dir? fmq_dir_cache (dir): NULL;
    fmq_dir_destroy (&dir);
    return cache;
}
示例#4
0
static void
mount_destroy (mount_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        mount_t *self = *self_p;
        free (self->location);
        free (self->alias);
        //  Destroy subscriptions
        while (zlist_size (self->subs)) {
            sub_t *sub = (sub_t *) zlist_pop (self->subs);
            sub_destroy (&sub);
        }
        zlist_destroy (&self->subs);
        fmq_dir_destroy (&self->dir);
        free (self);
        *self_p = NULL;
    }
}