commands: only set ringbuffer datalen when needed

If we do it unconditionally a request to only clear the ringbuffer and not read or write anything will fail. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent d91adfa6
...@@ -1037,7 +1037,9 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req, ...@@ -1037,7 +1037,9 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
if (buffer_size <= 0) if (buffer_size <= 0)
goto out; goto out;
rsp.datalen = lxc_ringbuf_used(buf); if (log->read || log->write_logfile)
rsp.datalen = lxc_ringbuf_used(buf);
if (log->read) if (log->read)
rsp.data = lxc_ringbuf_get_read_addr(buf); rsp.data = lxc_ringbuf_get_read_addr(buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment