All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] android/client: Fix annoying delay in command line
@ 2013-11-04 11:33 Jerzy Kasenberg
  2013-11-04 19:15 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Jerzy Kasenberg @ 2013-11-04 11:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jerzy Kasenberg

Move fflush(stdout) to after prints and user input.
This removes delay of showing prompt.
---
Same effect could be achieved by calling setbuf(stdout, NULL)
in terminal_setup() then all fflush calls could be removed.

If you think this should be better approach, I will change it.

 android/client/pollhandler.c |    5 -----
 android/client/terminal.c    |    6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/android/client/pollhandler.c b/android/client/pollhandler.c
index dd0d09f..6160921 100644
--- a/android/client/pollhandler.c
+++ b/android/client/pollhandler.c
@@ -68,11 +68,6 @@ void poll_dispatch_loop(void)
 			if (cur_fds_count != fds_count)
 				break;
 		}
-		/*
-		 * This seems to be needed for correct output handling
-		 * when all waiting is performed in poll
-		 */
-		fflush(stdout);
 	}
 }
 
diff --git a/android/client/terminal.c b/android/client/terminal.c
index e721160..22a1d8a 100644
--- a/android/client/terminal.c
+++ b/android/client/terminal.c
@@ -197,6 +197,8 @@ int terminal_vprint(const char *format, va_list args)
 
 	terminal_draw_command_line();
 
+	fflush(stdout);
+
 	return ret;
 }
 
@@ -570,6 +572,9 @@ void terminal_process_char(int c, void (*process_line)(char *line))
 		printf("%s \b", line_buf + refresh_from);
 		terminal_move_cursor(line_buf_ix - line_len);
 	}
+
+	/* Flush output after all user input */
+	fflush(stdout);
 }
 
 static struct termios origianl_tios;
@@ -596,4 +601,5 @@ void terminal_setup(void)
 	atexit(terminal_cleanup);
 
 	printf("%s", prompt);
+	fflush(stdout);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] android/client: Fix annoying delay in command line
  2013-11-04 11:33 [PATCH] android/client: Fix annoying delay in command line Jerzy Kasenberg
@ 2013-11-04 19:15 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2013-11-04 19:15 UTC (permalink / raw)
  To: Jerzy Kasenberg; +Cc: linux-bluetooth

Hi Jerzy,

On Mon, Nov 04, 2013, Jerzy Kasenberg wrote:
> Move fflush(stdout) to after prints and user input.
> This removes delay of showing prompt.
> ---
> Same effect could be achieved by calling setbuf(stdout, NULL)
> in terminal_setup() then all fflush calls could be removed.
> 
> If you think this should be better approach, I will change it.
> 
>  android/client/pollhandler.c |    5 -----
>  android/client/terminal.c    |    6 ++++++
>  2 files changed, 6 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-04 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-04 11:33 [PATCH] android/client: Fix annoying delay in command line Jerzy Kasenberg
2013-11-04 19:15 ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.