void ExportFormatJSON::close() {
    if (m_fd > 0) {
        rollback_uncomitted();

        add_to_stream(m_stream, "\n");
        if (!m_text_sequence_format) {
            add_to_stream(m_stream, "]}\n");
        }

        flush_to_output();
        if (m_fsync == osmium::io::fsync::yes) {
            osmium::io::detail::reliable_fsync(m_fd);
        }
        ::close(m_fd);
        m_fd = -1;
    }
}
Beispiel #2
0
void *ices_runner (void *arg)
{
    struct runner *run = arg;
    struct instance *current;

#ifdef HAVE_SCHED_GET_PRIORITY_MAX
    int policy;
    struct sched_param param;

    pthread_getschedparam (pthread_self(), &policy, &param);
    param . sched_priority = sched_get_priority_min (SCHED_OTHER);

    if (pthread_setschedparam (pthread_self(), SCHED_OTHER, &param))
    {
        LOG_ERROR1 ("failed to set priority: %s", strerror (errno));
    }
    else
        LOG_INFO0 ("set priority on runner");
#endif
    LOG_INFO1 ("Runner %d ready", run->id);

    while (1)
    {
        input_buffer *buffer;
        
        buffer = runner_wait_for_data (run);

        if (buffer == NULL)
            break;

        current = run->instances;

        while (current != NULL)
        {
            add_to_stream (current, buffer);
            current = current->next;
        }

        send_to_runner (run->next, buffer);
    }

    runner_close (run->next);
    LOG_DEBUG1 ("Runner thread %d cleaning up streams", run->id);
    current = run->instances;
    while (current)
    {
        struct instance *next;
        next = current->next;
        stream_cleanup (current);
        current = next;
    }
    close (run->fd[0]);
    run->fd[0] = -1;
    run->not_running = 1;
    LOG_DEBUG1 ("Runner thread %d finshed", run->id);
    
    return NULL;
}
Beispiel #3
0
Datei: buffer.c Projekt: dmt4/ne
int delete_one_line(buffer * const b, line_desc * const ld, const int64_t line) {
	assert_line_desc(ld, b->encoding);
	assert_buffer(b);

	block_signals();

	if (ld->line_len && (b->last_deleted = reset_stream(b->last_deleted))) add_to_stream(b->last_deleted, ld->line, ld->line_len);

	/* We delete a line by delete_stream()ing its length plus one. However, if
		we are on the last line of text, there is no terminating line feed. */

	const int error = delete_stream(b, ld, line, 0, ld->line_len + (ld->ld_node.next->next ? 1 : 0));
	release_signals();

	return error;
}
ExportFormatJSON::ExportFormatJSON(const std::string& output_format,
                                   const std::string& output_filename,
                                   osmium::io::overwrite overwrite,
                                   osmium::io::fsync fsync,
                                   const options_type& options) :
    ExportFormat(options),
    m_fd(osmium::io::detail::open_for_writing(output_filename, overwrite)),
    m_fsync(fsync),
    m_text_sequence_format(output_format == "geojsonseq"),
    m_with_record_separator(m_text_sequence_format && options.print_record_separator),
    m_writer(m_stream),
    m_factory(m_writer) {
    m_stream.Reserve(initial_buffer_size);
    if (!m_text_sequence_format) {
        add_to_stream(m_stream, "{\"type\":\"FeatureCollection\",\"features\":[\n");
    }
    m_committed_size = m_stream.GetSize();
}