Skip to content
Snippets Groups Projects
Commit 8de25ef9 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

peer_connection: shutdown socket on io error

If a write operation fails on a ICE Transport, the transport
just fail but do not shutdown as other components can be created
or used. So, the error must be catched on another level.
IceSocketEndpoint is the socket we use to send data. If a write
fails at this point this means the ICE must be closed

Change-Id: I6e67cb003df2a9855e8293f4753d1bc4fe75e340
parent bc04bcd6
Branches
No related tags found
No related merge requests found
......@@ -129,7 +129,9 @@ IceSocketEndpoint::read(ValueType* buf, std::size_t len, std::error_code& ec)
return 0;
try {
auto res = ice_->recvfrom(compId_, reinterpret_cast<char*>(buf), len, ec);
return (res >= 0) ? res : 0;
if (res < 0)
shutdown();
return res;
} catch (const std::exception& e) {
JAMI_ERR("IceSocketEndpoint::read exception: %s", e.what());
}
......@@ -148,10 +150,11 @@ IceSocketEndpoint::write(const ValueType* buf, std::size_t len, std::error_code&
res = ice_->send(compId_, reinterpret_cast<const unsigned char*>(buf), len);
if (res < 0) {
ec.assign(errno, std::generic_category());
shutdown();
} else {
ec.clear();
}
return (res >= 0) ? res : 0;
return res;
}
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment