Modem: Close pico socket when native one returns an error.

Linux build fix.
This commit is contained in:
Flyinghead 2018-09-25 12:39:37 +02:00
parent be8bae0547
commit 1320ce5949
2 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ typedef int sock_t;
#define L_EWOULDBLOCK EWOULDBLOCK
#define L_EAGAIN EAGAIN
#define get_last_error() (errno)
#define INVALID_SOCKET (-1)
#else
typedef SOCKET sock_t;
#define VALID(s) ((s) != INVALID_SOCKET)

View File

@ -183,7 +183,13 @@ static void tcp_callback(uint16_t ev, struct pico_socket *s)
r = pico_socket_read(it->first, buf, sizeof(buf));
if (r > 0) {
if (send(it->second, buf, r, 0) < r)
{
perror("tcp_callback send");
closesocket(it->second);
pico_socket_close(it->first);
tcp_sockets.erase(it);
return;
}
}
}
}