gboolean afsocket_sd_deinit(LogPipe *s) { AFSocketSourceDriver *self = (AFSocketSourceDriver *) s; GlobalConfig *cfg = log_pipe_get_config(s); if ((self->flags & AFSOCKET_KEEP_ALIVE) == 0 || !cfg->persist) { afsocket_sd_kill_connection_list(self->connections); } else { GList *p; /* for AFSOCKET_STREAM source drivers this is a list, for * AFSOCKET_DGRAM this is a single connection */ for (p = self->connections; p; p = p->next) { log_pipe_deinit((LogPipe *) p->data); } cfg_persist_config_add(cfg, afsocket_sd_format_persist_name(self, FALSE), self->connections, (GDestroyNotify) afsocket_sd_kill_connection_list, FALSE); } self->connections = NULL; if (self->flags & AFSOCKET_STREAM) { afsocket_sd_stop_watches(self); if ((self->flags & AFSOCKET_KEEP_ALIVE) == 0) { msg_verbose("Closing listener fd", evt_tag_int("fd", self->fd), NULL); close(self->fd); } else { /* NOTE: the fd is incremented by one when added to persistent config * as persist config cannot store NULL */ cfg_persist_config_add(cfg, afsocket_sd_format_persist_name(self, TRUE), GUINT_TO_POINTER(self->fd + 1), afsocket_sd_close_fd, FALSE); } } else if (self->flags & AFSOCKET_DGRAM) { /* we don't need to close the listening fd here as we have a * single connection which will close it */ ; } if (!log_src_driver_deinit_method(s)) return FALSE; return TRUE; }
static void afsocket_sd_save_listener(AFSocketSourceDriver *self) { GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); if (self->transport_mapper->sock_type == SOCK_STREAM) { afsocket_sd_stop_watches(self); if (!self->connections_kept_alive_accross_reloads) { msg_verbose("Closing listener fd", evt_tag_int("fd", self->fd), NULL); close(self->fd); } else { /* NOTE: the fd is incremented by one when added to persistent config * as persist config cannot store NULL */ cfg_persist_config_add(cfg, afsocket_sd_format_persist_name(self, TRUE), GUINT_TO_POINTER(self->fd + 1), afsocket_sd_close_fd, FALSE); } } }