Skip to content

don't set tcp_err callback for listen sockets (fixes #7790) #7813

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 1 commit into from
Mar 29, 2023
Merged
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
8 changes: 4 additions & 4 deletions ports/raspberrypi/common-hal/socketpool/Socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,6 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self,
case MOD_NETWORK_SOCK_STREAM: {
// Register the socket object as our callback argument.
tcp_arg(socket->pcb.tcp, (void *)socket);
// Register our error callback.
tcp_err(socket->pcb.tcp, _lwip_tcp_error);
break;
}
case MOD_NETWORK_SOCK_DGRAM: {
Expand Down Expand Up @@ -916,10 +914,11 @@ void socketpool_socket_close(socketpool_socket_obj_t *socket) {
case SOCKETPOOL_SOCK_STREAM: {
// Deregister callback (pcb.tcp is set to NULL below so must deregister now)
tcp_arg(socket->pcb.tcp, NULL);
tcp_err(socket->pcb.tcp, NULL);
tcp_recv(socket->pcb.tcp, NULL);

if (socket->pcb.tcp->state != LISTEN) {
tcp_err(socket->pcb.tcp, NULL);
tcp_recv(socket->pcb.tcp, NULL);

// Schedule a callback to abort the connection if it's not cleanly closed after
// the given timeout. The callback must be set before calling tcp_close since
// the latter may free the pcb; if it doesn't then the callback will be active.
Expand Down Expand Up @@ -977,6 +976,7 @@ void common_hal_socketpool_socket_connect(socketpool_socket_obj_t *socket,
// Register our receive callback.
MICROPY_PY_LWIP_ENTER
tcp_recv(socket->pcb.tcp, _lwip_tcp_recv);
tcp_err(socket->pcb.tcp, _lwip_tcp_error);
socket->state = STATE_CONNECTING;
err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected);
if (err != ERR_OK) {
Expand Down