Skip to content

Fix would block causing disconnect #70

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

Merged
merged 2 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void ESP8266::_packet_handler()
struct packet *packet = (struct packet*)malloc(
sizeof(struct packet) + amount);
if (!packet) {
debug("Could not allocate memory for RX data");
debug("Could not allocate memory for RX data\n");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int ESP8266Interface::socket_recv(void *handle, void *data, unsigned size)
int32_t recv;
if (socket->proto == NSAPI_TCP) {
recv = _esp.recv_tcp(socket->id, data, size);
if (recv <= 0) {
if (recv <= 0 && recv != NSAPI_ERROR_WOULD_BLOCK) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question... Is there any situation where these conditions would be met and the socket wouldn't have been closed in ESP8266.cpp? If this flag ever gets set to false incorrectly socket_close() won't actually try to close the socket when called.

socket->connected = false;
}
} else {
Expand Down