diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2017-11-21 17:33:07 +0000 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2017-11-23 11:39:01 +0000 |
commit | 922b17ccc6db2a4992841b1901afb3a0f7fbe6e8 (patch) | |
tree | 9b36e2b75afff072059781e9b9a6a90c01bc6a05 | |
parent | eb09773f7f9dfef42e0ac5ed1e647485b3929400 (diff) |
Move out command handling from SpiceStream
-rw-r--r-- | src/spice-streaming-agent.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp index 7c80003..461ccc0 100644 --- a/src/spice-streaming-agent.cpp +++ b/src/spice-streaming-agent.cpp @@ -68,7 +68,10 @@ public: } public: - bool have_something_to_read(int *pfd, int timeout); + /*! + * Return file descriptor to poll from + */ + int eventFd() const { return streamfd; } int read_command(); int send_format(unsigned w, unsigned h, unsigned c); int send_frame(const void *buf, const unsigned size); @@ -93,21 +96,21 @@ static bool quit; static bool stdin_ok; static int log_binary = 0; -bool SpiceStream::have_something_to_read(int *pfd, int timeout) +static bool have_something_to_read(SpiceStream& stream, int *pfd, int timeout) { int nfds; struct pollfd pollfds[2] = { - {streamfd, POLLIN, 0}, + {stream.eventFd(), POLLIN, 0}, {0, POLLIN, 0} }; *pfd = -1; nfds = (stdin_ok ? 2 : 1); if (poll(pollfds, nfds, timeout) < 0) { syslog(LOG_ERR, "poll FAILED\n"); - return -1; + return false; } if (pollfds[0].revents == POLLIN) { - *pfd = streamfd; + *pfd = 1; } if (pollfds[1].revents == POLLIN) { *pfd = 0; @@ -186,7 +189,7 @@ static int read_command(SpiceStream &stream, bool blocking) int fd, n=1; int timeout = blocking?-1:0; while (!quit) { - if (!stream.have_something_to_read(&fd, timeout)) { + if (!have_something_to_read(stream, &fd, timeout)) { if (!blocking) { return 0; } |