aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-11-02 12:27:10 +0100
committerTimo Weingärtner <timo@tiwe.de>2013-11-02 12:27:10 +0100
commita42c87e6a761a56ebc63cd7728fa2126b2e8805f (patch)
tree30952f004675bbe93d3fb5ffb928f8f21fb3cf55
parentb05034bc176b38b3b3f31c7a2e1e53b4c16f61e2 (diff)
downloadssh-agent-filter-a42c87e6a761a56ebc63cd7728fa2126b2e8805f.tar.gz
(re)unify client iostreams
boost::iostreams does not do lseek()s without being asked extend try-block around entire function
-rw-r--r--ssh-agent-filter.C23
1 files changed, 9 insertions, 14 deletions
diff --git a/ssh-agent-filter.C b/ssh-agent-filter.C
index b4234c3..8ee6aaf 100644
--- a/ssh-agent-filter.C
+++ b/ssh-agent-filter.C
@@ -427,22 +427,17 @@ rfc4251string handle_request (rfc4251string const & r) {
return rfc4251string{answer.str()};
}
-void handle_client (int const sock) {
- // we could use only one streambuf and iostream but when
- // switching from read to write an lseek call is made that
- // fails with ESPIPE and causes an exception
- io::stream_buffer<io::file_descriptor_source> client_filebuf_in{sock, io::close_handle};
- io::stream_buffer<io::file_descriptor_sink> client_filebuf_out{sock, io::never_close_handle};
- std::istream client_in{&client_filebuf_in};
- std::ostream client_out{&client_filebuf_out};
- client_out.exceptions(std::ios::badbit | std::ios::failbit);
+void handle_client (int const sock) try {
+ io::stream_buffer<io::file_descriptor> client_filebuf{sock, io::close_handle};
+ std::iostream client{&client_filebuf};
+ client.exceptions(std::ios::badbit | std::ios::failbit);
- rfc4251string request;
- while (client_in >> request) try {
- client_out << handle_request(request) << std::flush;
- } catch (...) {
- break;
+ for (;;) {
+ rfc4251string request;
+ client >> request;
+ client << handle_request(request) << std::flush;
}
+} catch (...) {
}
void sighandler (int sig) {