aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xC.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/xC.c b/xC.c
index a589836..5a59a8f 100644
--- a/xC.c
+++ b/xC.c
@@ -15543,14 +15543,13 @@ static void
client_process_buffer_log
(struct client *c, uint32_t seq, struct buffer *buffer)
{
- struct relay_event_data_response *e = relay_prepare_response (c->ctx, seq);
- e->data.command = RELAY_COMMAND_BUFFER_LOG;
-
+ // XXX: We log failures to the global buffer,
+ // so the client just receives nothing if there is no log file.
+ struct str log = str_make ();
char *path = buffer_get_log_path (buffer);
FILE *fp = open_log_path (c->ctx, buffer, path);
if (fp)
{
- struct str log = str_make ();
char buf[BUFSIZ];
size_t len;
while ((len = fread (buf, 1, sizeof buf, fp)))
@@ -15558,17 +15557,15 @@ client_process_buffer_log
if (ferror (fp))
log_global_error (c->ctx, "Failed to read `#l': #l",
path, strerror (errno));
-
- // On overflow, it will later fail serialization.
- e->data.buffer_log.log_len = MIN (UINT32_MAX, log.len);
- e->data.buffer_log.log = (uint8_t *) str_steal (&log);
fclose (fp);
}
-
- // XXX: We log failures to the global buffer,
- // so the client just receives nothing if there is no log file.
-
free (path);
+
+ struct relay_event_data_response *e = relay_prepare_response (c->ctx, seq);
+ e->data.command = RELAY_COMMAND_BUFFER_LOG;
+ // On overflow, it will later fail serialization (frame will be too long).
+ e->data.buffer_log.log_len = MIN (UINT32_MAX, log.len);
+ e->data.buffer_log.log = (uint8_t *) str_steal (&log);
relay_send (c);
}