Exemplo n.º 1
0
/**
 * \brief Close Intermediate Process
 *
 * \param[in] config configuration structure
 * \return 0 on success
 */
int ip_destroy(void *config)
{
	struct ip_config *conf;
	void *retval;
	int ret;

	conf = (struct ip_config *) config;

	if (!conf) {
		return -1;
	}

	/* free XML configuration */
	if (conf->xmldata) {
		free(conf->xmldata);
	}

	/* free input queue (output queue will be freed by next intermediate process) */
	rbuffer_free(conf->in_queue);

	/* Close plugin */
	conf->intermediate_close(conf->plugin_config);

	free(conf);

	return 0;
}
Exemplo n.º 2
0
/// Frees all memory allocated for a RStream instance
///
/// @param rstream The `RStream` instance
void rstream_free(RStream *rstream)
{
  if (rstream->free_handle) {
    if (rstream->fread_idle != NULL) {
      uv_close((uv_handle_t *)rstream->fread_idle, close_cb);
    } else {
      uv_close((uv_handle_t *)rstream->stream, close_cb);
    }
  }

  rbuffer_free(rstream->buffer);
  free(rstream);
}
Exemplo n.º 3
0
/**
 * \brief Close Ouput Manager and all Data Managers
 */
void output_manager_close(void *config)
{
	struct output_manager_config *manager = (struct output_manager_config *) config;
	struct data_manager_config *aux_config = NULL, *tmp = NULL;
	struct stat_thread *aux_thread = NULL, *tmp_thread = NULL;

	/* Stop Output Manager thread and free input buffer */
	if (manager->running) {
		rbuffer_write(manager->in_queue, NULL, 1);
		pthread_join(manager->thread_id, NULL);
		rbuffer_free(manager->in_queue);

		/* Close statistics thread */
		if (manager->stat_interval > 0) {
			manager->stats.done = 1;
			pthread_kill(manager->stat_thread, SIGUSR1);
			pthread_join(manager->stat_thread, NULL);
		}

		aux_config = manager->data_managers;

		/* Close all data managers */
		while (aux_config) {
			tmp = aux_config;
			aux_config = aux_config->next;
			data_manager_close(&tmp);
		}

		/* Free input_info_list */
		if (input_info_list) {
			struct input_info_node *aux_node = input_info_list;
			while (aux_node) {
				struct input_info_node *aux_node_rm = aux_node;
				aux_node = aux_node->next;
				free(aux_node_rm);
			}
		}

		/* Free all thread structures for statistics */
		aux_thread = manager->stats.threads;
		while (aux_thread) {
			tmp_thread = aux_thread;
			aux_thread = aux_thread->next;
			free(tmp_thread);
		}
	}

	free(manager);
}
Exemplo n.º 4
0
void stream_close(Stream *stream, stream_close_cb on_stream_close)
{
  assert(!stream->closed);

  if (stream->buffer) {
    rbuffer_free(stream->buffer);
  }

  stream->closed = true;
  stream->close_cb = on_stream_close;

  if (!stream->pending_reqs) {
    stream_close_handle(stream);
  }
}
Exemplo n.º 5
0
/**
 * \brief Close Intermediate Process
 */
int ip_destroy(struct intermediate *conf)
{
	if (!conf) {
		return -1;
	}

	/* free input queue (output queue will be freed by next intermediate process) */
	rbuffer_free(conf->in_queue);

	/* Close plugin */
	conf->intermediate_close(conf->plugin_config);

	free(conf);

	return 0;
}