Skip to content

Commit

Permalink
logproto: remove handshake_in_progress from LogProtoClient
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed Apr 21, 2024
1 parent eb44fc8 commit d8b5258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
18 changes: 4 additions & 14 deletions lib/logproto/logproto-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 7 additions & 5 deletions lib/logwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct _LogWriter
LogQueue *queue;
guint32 flags:31;
gint32 seq_num;
gboolean handshake_in_progress;
gboolean partial_write;

struct
Expand Down Expand Up @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d8b5258

Please sign in to comment.