Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket HAL bugfix (virtual device) #1134

Merged
merged 2 commits into from
Oct 17, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions hal/src/gcc/socket_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ sock_result_t socket_receive(sock_handle_t sd, void* buffer, socklen_t len, syst
handle.io_control(command);
std::size_t available = command.get();
sock_result_t result = 0;
if (_timeout || available)
available = handle.read_some(boost::asio::buffer(buffer, len), ec);
result = ec.value() ? -abs(ec.value()) : available;
if (ec.value()) {
if (ec.value() == boost::system::errc::resource_deadlock_would_occur || // EDEADLK (35)
ec.value() == boost::system::errc::resource_unavailable_try_again) { // EAGAIN (11)
result = 0; // No data available
} else {
DEBUG("socket receive error: %d %s, read=%d", ec.value(), ec.message().c_str(), available);
if (_timeout || available) {
available = handle.read_some(boost::asio::buffer(buffer, len), ec);
result = ec.value() ? -abs(ec.value()) : available;
if (ec.value()) {
if (ec.value() == boost::system::errc::resource_deadlock_would_occur || // EDEADLK (35)
ec.value() == boost::system::errc::resource_unavailable_try_again) { // EAGAIN (11)
result = 0; // No data available
} else {
DEBUG("socket receive error: %d %s, read=%d", ec.value(), ec.message().c_str(), available);
}
}
}
return result;
Expand Down