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
This commit is contained in:
Christian Helmuth 2015-09-18 12:51:19 +02:00
parent 8eec092851
commit 7e3bcb1e39
1 changed files with 5 additions and 1 deletions

View File

@ -159,7 +159,7 @@ class Open_socket : public Genode::List<Open_socket>::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<Open_socket>::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;
}