void uninit_stream_sub_decoders(struct demuxer *demuxer) { for (int i = 0; i < demuxer->num_streams; i++) { struct sh_stream *sh = demuxer->streams[i]; if (sh->sub) { sub_destroy(sh->sub->dec_sub); sh->sub->dec_sub = NULL; } } }
static void mount_sub_purge (mount_t *self, client_t *client) { sub_t *sub = (sub_t *) zlist_first (self->subs); while (sub) { if (sub->client == client) { sub_t *next = (sub_t *) zlist_next (self->subs); zlist_remove (self->subs, sub); sub_destroy (&sub); sub = next; } else sub = (sub_t *) zlist_next (self->subs); } }
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; } }
static void mount_sub_store (mount_t *self, client_t *client, fmq_msg_t *request) { assert (self); assert (self->subs); // Store subscription along with any previous ones // Coalesce subscriptions that are on same path char *path = fmq_msg_path (request); sub_t *sub = (sub_t *) zlist_first (self->subs); while (sub) { if (client == sub->client) { // If old subscription is superset/same as new, ignore new if (strncmp (path, sub->path, strlen (sub->path)) == 0) return; else // If new subscription is superset of old one, remove old if (strncmp (sub->path, path, strlen (path)) == 0) { zlist_remove (self->subs, sub); sub_destroy (&sub); sub = (sub_t *) zlist_first (self->subs); } else sub = (sub_t *) zlist_next (self->subs); } else sub = (sub_t *) zlist_next (self->subs); } // New subscription for this client, append to our list sub = sub_new (client, path, fmq_msg_cache (request)); zlist_append (self->subs, sub); // If client requested resync, send full mount contents now if (fmq_msg_options_number (client->request, "RESYNC", 0) == 1) { zlist_t *patches = zdir_resync (self->dir, self->alias); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); sub_patch_add (sub, patch); zdir_patch_destroy (&patch); } zlist_destroy (&patches); } }
static void client_destroy (client_t **self_p) { assert (self_p); if (*self_p) { client_t *self = *self_p; fmq_config_destroy (&self->config); fmq_msg_destroy (&self->request); fmq_msg_destroy (&self->reply); // Destroy subscriptions while (zlist_size (self->subs)) { sub_t *sub = (sub_t *) zlist_pop (self->subs); sub_destroy (&sub); } zlist_destroy (&self->subs); free (self); *self_p = NULL; } }
static void client_destroy (client_t **self_p) { assert (self_p); if (*self_p) { client_t *self = *self_p; fmq_config_destroy (&self->config); int server_nbr; for (server_nbr = 0; server_nbr < self->nbr_servers; server_nbr++) { server_t *server = self->servers [server_nbr]; server_destroy (&server); } // Destroy subscriptions while (zlist_size (self->subs)) { sub_t *sub = (sub_t *) zlist_pop (self->subs); sub_destroy (&sub); } zlist_destroy (&self->subs); free (self); *self_p = NULL; } }