diff --git a/lib/logproto/logproto-client.h b/lib/logproto/logproto-client.h index a0ed02a71e..ca2607793a 100644 --- a/lib/logproto/logproto-client.h +++ b/lib/logproto/logproto-client.h @@ -73,8 +73,7 @@ struct _LogProtoClient LogProtoStatus (*process_in)(LogProtoClient *s); LogProtoStatus (*flush)(LogProtoClient *s); gboolean (*validate_options)(LogProtoClient *s); - gboolean (*handshake_in_progess)(LogProtoClient *s); - LogProtoStatus (*handshake)(LogProtoClient *s); + LogProtoStatus (*handshake)(LogProtoClient *s, gboolean *handshake_finished); gboolean (*restart_with_state)(LogProtoClient *s, PersistState *state, const gchar *persist_name); void (*free_fn)(LogProtoClient *s); LogProtoClientFlowControlFuncs flow_control_funcs; @@ -113,23 +112,14 @@ log_proto_client_validate_options(LogProtoClient *self) return self->validate_options(self); } -static inline gboolean -log_proto_client_handshake_in_progress(LogProtoClient *s) -{ - if (s->handshake_in_progess) - { - return s->handshake_in_progess(s); - } - return FALSE; -} - static inline LogProtoStatus -log_proto_client_handshake(LogProtoClient *s) +log_proto_client_handshake(LogProtoClient *s, gboolean *handshake_finished) { if (s->handshake) { - return s->handshake(s); + return s->handshake(s, handshake_finished); } + *handshake_finished = TRUE; return LPS_SUCCESS; } diff --git a/lib/logwriter.c b/lib/logwriter.c index d79348c47c..bb76b2e954 100644 --- a/lib/logwriter.c +++ b/lib/logwriter.c @@ -68,6 +68,7 @@ struct _LogWriter LogQueue *queue; guint32 flags:31; gint32 seq_num; + gboolean handshake_in_progress; gboolean partial_write; struct @@ -1304,11 +1305,13 @@ log_writer_queue_pop_message(LogWriter *self, LogPathOptions *path_options, gboo static inline gboolean log_writer_process_handshake(LogWriter *self) { - LogProtoStatus status = log_proto_client_handshake(self->proto); + gboolean handshake_finished; + LogProtoStatus status = log_proto_client_handshake(self->proto, &handshake_finished); if (status != LPS_SUCCESS) return FALSE; + self->handshake_in_progress = FALSE; return TRUE; } @@ -1329,10 +1332,8 @@ log_writer_flush(LogWriter *self, LogWriterFlushMode flush_mode) if (!self->proto) return FALSE; - if (log_proto_client_handshake_in_progress(self->proto)) - { - return log_writer_process_handshake(self); - } + if (self->handshake_in_progress) + return log_writer_process_handshake(self); /* NOTE: in case we're reloading or exiting we flush all queued items as * long as the destination can consume it. This is not going to be an @@ -1921,6 +1922,7 @@ log_writer_new(guint32 flags, GlobalConfig *cfg) self->flags = flags; self->line_buffer = g_string_sized_new(128); self->pollable_state = -1; + self->handshake_in_progress = TRUE; init_sequence_number(&self->seq_num); log_writer_init_watches(self);