From f15925cb50a768fa8da6eb3db69e9f627f9b867b Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Tue, 9 Jan 2018 15:24:59 -0500
Subject: [PATCH] datatransfer: fix io error during write op

io error in endpoint write operation was not handled.
Add this by this patch and fixes write issues (ex, when peer disconnect).

Change-Id: I24dada649f4d9f9627d2d2ff8efcea2b2d44b4ad
Reviewed-by: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
---
 src/peer_connection.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp
index ecd6a826e8..4b0fa7b818 100644
--- a/src/peer_connection.cpp
+++ b/src/peer_connection.cpp
@@ -529,8 +529,12 @@ PeerConnection::PeerConnectionImpl::eventLoop()
         handle_stream_list(inputs_, [&](auto& stream){
                 if (!stream->read(buf))
                     return false;
-                endpoint_->write(buf, ec);
-                return true;
+                auto size = endpoint_->write(buf, ec);
+                if (!ec)
+                    return true;
+                if (!size)
+                    return false;
+                throw std::system_error(ec);
             });
         handle_stream_list(outputs_, [&](auto& stream){
                 endpoint_->read(buf, ec);
-- 
GitLab