From 4651cf5d7a7d32accaeb54c8f57d4759d2d55af4 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 22 Sep 2020 11:39:27 +0200 Subject: [PATCH] client: request connections with prosumer epoch --- kernel/mars_client.c | 14 +++++++++++--- kernel/mars_client.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/mars_client.c b/kernel/mars_client.c index c06d3377..93783692 100644 --- a/kernel/mars_client.c +++ b/kernel/mars_client.c @@ -244,7 +244,10 @@ void _maintain_bundle(struct client_bundle *bundle, bool keep_idle_sockets) } static -int _request_connect(struct client_channel *ch, int code, const char *path) +int _request_connect(struct client_channel *ch, + int code, + const char *path, + struct lamport_time *cmd_stamp) { struct mars_cmd cmd = { .cmd_code = code, @@ -252,6 +255,8 @@ int _request_connect(struct client_channel *ch, int code, const char *path) }; int status; + if (cmd_stamp && cmd_stamp->tv_sec) + cmd.cmd_stamp = *cmd_stamp; status = mars_send_cmd(&ch->socket, &cmd, false); MARS_DBG("send CMD_CONNECT status = %d\n", status); return status; @@ -358,13 +363,16 @@ struct client_channel *_get_channel(struct client_bundle *bundle, */ if (unlikely(!res->is_connected)) { struct client_output *output = res->output; + struct lamport_time *cmd_stamp = NULL; int code = CMD_CONNECT; int status; - if (strstr(bundle->path, "/logger-")) + if (strstr(bundle->path, "/logger-")) { code = CMD_CONNECT_LOGGER; + cmd_stamp = output->prosumer_epoch; + } - status = _request_connect(res, code, bundle->path); + status = _request_connect(res, code, bundle->path, cmd_stamp); if (unlikely(status < 0)) { if (error_code) *error_code = status; diff --git a/kernel/mars_client.h b/kernel/mars_client.h index a63afa4e..9ca59ed9 100644 --- a/kernel/mars_client.h +++ b/kernel/mars_client.h @@ -116,6 +116,7 @@ struct client_output { struct client_bundle bundle; struct mars_info info; struct lamport_time stor_epoch; + struct lamport_time *prosumer_epoch; int last_id; bool fatal_error; bool get_info;