Skip to content

Commit

Permalink
Merge pull request #1466 from pguyot/w02/fix-deadlock-in-sockets
Browse files Browse the repository at this point in the history
Fix deadlock in socket code

Fix a deadlock that was introduced in 555745c
and that happens on platforms without recursive locks (e.g. esp32) by removing
an unnessary lock in `socket_recv`.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Jan 11, 2025
2 parents 23b0781 + 263c831 commit 03dcfa5
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/libAtomVM/otp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1910,9 +1910,7 @@ static ssize_t do_socket_recv(struct SocketResource *rsrc_obj, uint8_t *buf, siz

ssize_t socket_recv(struct SocketResource *rsrc_obj, uint8_t *buf, size_t len, int flags, term *from, Heap *heap)
{
SMP_RWLOCK_RDLOCK(rsrc_obj->socket_lock);
ssize_t result = do_socket_recv(rsrc_obj, buf, len, flags, from, heap);
SMP_RWLOCK_UNLOCK(rsrc_obj->socket_lock);
return result;
}

Expand Down

0 comments on commit 03dcfa5

Please sign in to comment.