You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/09/22 00:27:29 UTC
[5/8] guacamole-server git commit: GUACAMOLE-622: Require
guac_terminal_start() to be invoked before the terminal will render frames or
accept user input.
GUACAMOLE-622: Require guac_terminal_start() to be invoked before the terminal will render frames or accept user input.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/61a51df1
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/61a51df1
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/61a51df1
Branch: refs/heads/master
Commit: 61a51df1b29695f6464193b18dd4f24809ef07df
Parents: 332e187
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Aug 30 10:01:41 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun Sep 2 23:04:14 2018 -0700
----------------------------------------------------------------------
src/terminal/terminal.c | 29 ++++++++++++++++++++++++++---
src/terminal/terminal/terminal.h | 29 ++++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/61a51df1/src/terminal/terminal.c
----------------------------------------------------------------------
diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c
index 760e128..0427ae4 100644
--- a/src/terminal/terminal.c
+++ b/src/terminal/terminal.c
@@ -596,6 +596,7 @@ guac_terminal* guac_terminal_create(guac_client* client,
available_width = 0;
guac_terminal* term = malloc(sizeof(guac_terminal));
+ term->started = false;
term->client = client;
term->upload_path_handler = NULL;
term->file_download_handler = NULL;
@@ -723,6 +724,11 @@ guac_terminal* guac_terminal_create(guac_client* client,
}
+void guac_terminal_start(guac_terminal* term) {
+ term->started = true;
+ guac_terminal_notify(term);
+}
+
void guac_terminal_stop(guac_terminal* term) {
/* Close input pipe and set fds to invalid */
@@ -851,11 +857,13 @@ wait_complete:
int guac_terminal_render_frame(guac_terminal* terminal) {
+ guac_client* client = terminal->client;
+
int wait_result;
/* Wait for data to be available */
wait_result = guac_terminal_wait(terminal, 1000);
- if (wait_result) {
+ if (wait_result || !terminal->started) {
guac_timestamp frame_start = guac_timestamp_current();
@@ -867,13 +875,14 @@ int guac_terminal_render_frame(guac_terminal* terminal) {
- frame_end;
/* Wait again if frame remaining */
- if (frame_remaining > 0)
+ if (frame_remaining > 0 || !terminal->started)
wait_result = guac_terminal_wait(terminal,
GUAC_TERMINAL_FRAME_TIMEOUT);
else
break;
- } while (wait_result > 0);
+ } while (client->state == GUAC_CLIENT_RUNNING
+ && (wait_result > 0 || !terminal->started));
/* Flush terminal */
guac_terminal_lock(terminal);
@@ -1672,6 +1681,13 @@ int guac_terminal_send_string(guac_terminal* term, const char* data) {
static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed) {
+ /* Ignore user input if terminal is not started */
+ if (!term->started) {
+ guac_client_log(term->client, GUAC_LOG_DEBUG, "Ignoring user input "
+ "while terminal has not yet started.");
+ return 0;
+ }
+
/* Hide mouse cursor if not already hidden */
if (term->current_cursor != GUAC_TERMINAL_CURSOR_BLANK) {
term->current_cursor = GUAC_TERMINAL_CURSOR_BLANK;
@@ -1845,6 +1861,13 @@ int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed) {
static int __guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
int x, int y, int mask) {
+ /* Ignore user input if terminal is not started */
+ if (!term->started) {
+ guac_client_log(term->client, GUAC_LOG_DEBUG, "Ignoring user input "
+ "while terminal has not yet started.");
+ return 0;
+ }
+
/* Determine which buttons were just released and pressed */
int released_mask = term->mouse_mask & ~mask;
int pressed_mask = ~term->mouse_mask & mask;
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/61a51df1/src/terminal/terminal/terminal.h
----------------------------------------------------------------------
diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h
index bddf8e5..9a0145f 100644
--- a/src/terminal/terminal/terminal.h
+++ b/src/terminal/terminal/terminal.h
@@ -172,6 +172,16 @@ struct guac_terminal {
guac_client* client;
/**
+ * Whether user input should be handled and this terminal should render
+ * frames. Initially, this will be false, user input will be ignored, and
+ * rendering of frames will be withheld until guac_terminal_start() has
+ * been invoked. The data within frames will still be rendered, and text
+ * data received will still be handled, however actual frame boundaries
+ * will not be sent.
+ */
+ bool started;
+
+ /**
* The terminal render thread.
*/
pthread_t thread;
@@ -526,7 +536,13 @@ struct guac_terminal {
/**
* Creates a new guac_terminal, having the given width and height, and
- * rendering to the given client.
+ * rendering to the given client. As failover mechanisms and the Guacamole
+ * client implementation typically use the receipt of a "sync" message to
+ * denote successful connection, rendering of frames (sending of "sync") will
+ * be withheld until guac_terminal_start() is called, and user input will be
+ * ignored. The guac_terminal_start() function should be invoked only after
+ * either the underlying connection has truly succeeded, or until visible
+ * terminal output or user input is required.
*
* @param client
* The client to which the terminal will be rendered.
@@ -605,6 +621,17 @@ int guac_terminal_render_frame(guac_terminal* terminal);
int guac_terminal_read_stdin(guac_terminal* terminal, char* c, int size);
/**
+ * Notifies the terminal that rendering should begin and that user input should
+ * now be accepted. This function must be invoked following terminal creation
+ * for the end of frames to be signalled with "sync" messages. Until this
+ * function is invoked, "sync" messages will be withheld.
+ *
+ * @param term
+ * The terminal to start.
+ */
+void guac_terminal_start(guac_terminal* term);
+
+/**
* Manually stop the terminal to forcibly unblock any pending reads/writes,
* e.g. forcing guac_terminal_read_stdin() to return and cease all terminal I/O.
*