From 7e3bcb1e39507f91d897fbd375e9fd41f4602db9 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 18 Sep 2015 12:51:19 +0200 Subject: [PATCH] tcp_terminal: signal available bytes on partial read If a client provides a read buffer of insufficient size for all available data, we have two options 1) Leave it to the client to do partial reads until not further data is available, or 2) Signal the client that there still some bytes on a partial read. As the second option seems more robust it's implemented in this commit. Fixes #1705 --- repos/gems/src/server/tcp_terminal/main.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repos/gems/src/server/tcp_terminal/main.cc b/repos/gems/src/server/tcp_terminal/main.cc index e4ef90b14c..c6700a01ba 100644 --- a/repos/gems/src/server/tcp_terminal/main.cc +++ b/repos/gems/src/server/tcp_terminal/main.cc @@ -159,7 +159,7 @@ class Open_socket : public Genode::List::Element socklen_t len = sizeof(addr); _sd = accept(_listen_sd, &addr, &len); - if (_sd > 0) + if (_sd != -1) Genode::printf("connection established\n"); /* @@ -209,6 +209,10 @@ class Open_socket : public Genode::List::Element if (_read_buf_bytes_read >= _read_buf_bytes_used) _read_buf_bytes_used = _read_buf_bytes_read = 0; + /* notify client if there are still bytes available for reading */ + if (_read_avail_sigh.valid() && !read_buffer_empty()) + Genode::Signal_transmitter(_read_avail_sigh).submit(); + return num_bytes; }