static gboolean afsocket_dd_reconnect_timer(gpointer s) { AFSocketDestDriver *self = (AFSocketDestDriver *) s; afsocket_dd_reconnect(self); return FALSE; }
static gboolean afsocket_dd_setup_connection(AFSocketDestDriver *self) { GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); self->time_reopen = cfg->time_reopen; if (!log_writer_opened(self->writer)) afsocket_dd_reconnect(self); self->connection_initialized = TRUE; return TRUE; }
gboolean afsocket_dd_init(LogPipe *s) { AFSocketDestDriver *self = (AFSocketDestDriver *) s; GlobalConfig *cfg = log_pipe_get_config(s); if (!log_dest_driver_init_method(s)) return FALSE; if (!afsocket_dd_apply_transport(self)) return FALSE; /* these fields must be set up by apply_transport, so let's check if it indeed did */ g_assert(self->transport); g_assert(self->bind_addr); g_assert(self->hostname); g_assert(self->dest_name); if (cfg) { self->time_reopen = cfg->time_reopen; } log_writer_options_init(&self->writer_options, cfg, 0); self->writer = cfg_persist_config_fetch(cfg, afsocket_dd_format_persist_name(self, FALSE)); if (!self->writer) { /* NOTE: we open our writer with no fd, so we can send messages down there * even while the connection is not established */ self->writer = log_writer_new(LW_FORMAT_PROTO | #if ENABLE_SSL (((self->flags & AFSOCKET_STREAM) && !self->tls_context) ? LW_DETECT_EOF : 0) | #else ((self->flags & AFSOCKET_STREAM) ? LW_DETECT_EOF : 0) | #endif (self->flags & AFSOCKET_SYSLOG_PROTOCOL ? LW_SYSLOG_PROTOCOL : 0)); } log_writer_set_options((LogWriter *) self->writer, &self->super.super.super, &self->writer_options, 0, afsocket_dd_stats_source(self), self->super.super.id, afsocket_dd_stats_instance(self)); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue(&self->super, afsocket_dd_format_persist_name(self, TRUE))); log_pipe_init(self->writer, NULL); log_pipe_append(&self->super.super.super, self->writer); if (!log_writer_opened((LogWriter *) self->writer)) afsocket_dd_reconnect(self); return TRUE; }
static gboolean afsocket_dd_setup_connection(AFSocketDestDriver *self) { GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); self->time_reopen = cfg->time_reopen; afsocket_dd_restore_connection(self); if (!afsocket_dd_setup_writer(self)) return FALSE; if (!log_writer_opened(self->writer)) afsocket_dd_reconnect(self); return TRUE; }
gboolean afsocket_dd_init(LogPipe *s) { AFSocketDestDriver *self = (AFSocketDestDriver *) s; GlobalConfig *cfg = log_pipe_get_config(s); #if ENABLE_SSL if (self->flags & AFSOCKET_REQUIRE_TLS && !self->tls_context) { msg_error("Transport TLS was specified, but TLS related parameters missing", NULL); return FALSE; } #endif self->error_logged = FALSE; if (cfg) { self->time_reopen = cfg->time_reopen; } if (!self->writer) { log_writer_options_init(&self->writer_options, cfg, 0); /* NOTE: we open our writer with no fd, so we can send messages down there * even while the connection is not established */ if ((self->flags & AFSOCKET_KEEP_ALIVE)) self->writer = cfg_persist_config_fetch(cfg, afsocket_dd_format_persist_name(self, self->dest_name, FALSE)); if (!self->writer) self->writer = log_writer_new(LW_FORMAT_PROTO | #if ENABLE_SSL (((self->flags & AFSOCKET_STREAM) && !self->tls_context) ? LW_DETECT_EOF : 0) | #else ((self->flags & AFSOCKET_STREAM) ? LW_DETECT_EOF : 0) | #endif (self->flags & AFSOCKET_SYSLOG_PROTOCOL ? LW_SYSLOG_PROTOCOL : 0)); log_writer_set_options((LogWriter *) self->writer, &self->super.super, &self->writer_options, 0, afsocket_dd_stats_source(self), self->super.id, afsocket_dd_stats_instance(self)); log_pipe_init(self->writer, NULL); log_pipe_append(&self->super.super, self->writer); } afsocket_dd_reconnect(self); return TRUE; }