diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2018-04-20 05:31:57 +0100 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2018-07-03 11:12:24 +0100 |
commit | a34d1fd23449ee1518352aed896550da66a877a5 (patch) | |
tree | ac48d17a59dfb3d624b910c87cb20b5cc6803a99 | |
parent | 45287547cf2b530db6f7815b25dce9c0b6acfef8 (diff) |
function to output log informations on start
-rw-r--r-- | src/spice-streaming-agent.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp index 1bf07cd..7a49068 100644 --- a/src/spice-streaming-agent.cpp +++ b/src/spice-streaming-agent.cpp @@ -32,6 +32,9 @@ #include <poll.h> #include <syslog.h> #include <signal.h> +#include <err.h> +#include <sys/types.h> +#include <sys/wait.h> #include <exception> #include <stdexcept> #include <memory> @@ -373,6 +376,38 @@ static void cursor_changes(StreamPort *stream_port, Display *display, int event_ } } +static std::string stat_dir; + +static void +start_stats() +{ + char dirname[128]; + strcpy(dirname, "/tmp/streaming-stat-XXXXXX"); + if (!mkdtemp(dirname)) { + err(1, "mkdtemp"); + } + stat_dir = dirname; + + pid_t pid = fork(); + switch (pid) { + case -1: + err(1, "fork"); + default: // parent + int status; + while (waitpid(pid, &status, 0) == -1) + continue; + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + errx(1, "Child terminated with error"); + return; + case 0: // child + break; + } + + setenv("SPICE_STAT_DIR", dirname, 1); + execlp("/home/start_stat", "start_stat", NULL); + exit(1); +} + static void do_capture(StreamPort &stream_port, FrameLog &frame_log) { @@ -421,6 +456,8 @@ do_capture(StreamPort &stream_port, FrameLog &frame_log) height = frame.size.height; codec = capture->VideoCodecType(); + start_stats(); + syslog(LOG_DEBUG, "wXh %uX%u codec=%u", width, height, codec); frame_log.log_stat("Started new stream wXh %uX%u codec=%u", width, height, codec); |