Skip to content

Bug in WiFiSocket.cpp causing infinite loop #278

@S2Doc

Description

@S2Doc

WiFiSocket::write() contains the following loop:

while ((err = send(sock, (void *)buf, size, 0)) < 0) {
  // Exit on fatal error, retry if buffer not ready.
  if (err != SOCK_ERR_BUFFER_FULL)  {
    size = 0;
    break;
  } else if (hif_receive_blocked) {
    size = 0;
    break;
  }
  m2m_wifi_handle_events(NULL);
}

Note that if the call to send() returns with err = SOCK_ERR_BUFFER_FULL, the while loop never exits unless hif_receive_blocked becomes true. I frequently (several times per day) experience this situation. There is no way to exit this loop other than by watchdog timer forcing a reset.

As a possibly relevant side-note, the call to send() (in socket.c) can return only the SOCK_ERR_BUFFER_FULL error. No matter what error actually occurred, send() will always misleadingly return the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions