8000 Merge pull request #7679 from dhalbert/socket-fix · dhalbert/circuitpython@bd88992 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd88992

Browse files
authored
Merge pull request adafruit#7679 from dhalbert/socket-fix
be more careful when setting socket to non-blocking
2 parents bdb9816 + 08c9eb9 commit bd88992

File tree

1 file changed

+5
-6
lines changed
  • ports/espressif/common-hal/socketpool

1 file changed

+5
-6
lines changed

ports/espressif/common-hal/socketpool/Socket.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_
253253
uint64_t start_ticks = supervisor_ticks_ms64();
254254

255255
// Allow timeouts and interrupts
256-
while (newsoc == -1 &&
257-
!timed_out &&
258-
!mp_hal_is_interrupted()) {
256+
while (newsoc == -1 && !timed_out) {
259257
if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) {
260258
timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms;
261259
}
@@ -267,9 +265,6 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_
267265
}
268266
}
269267

270-
// New client socket will not be non-blocking by default, so make it non-blocking.
271-
lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK);
272-
273268
if (!timed_out) {
274269
// harmless on failure but avoiding memcpy is faster
275270
memcpy((void *)ip, (void *)&accept_addr.sin_addr.s_addr, sizeof(accept_addr.sin_addr.s_addr));
@@ -280,6 +275,10 @@ int socketpool_socket_accept(socketpool_socket_obj_ 6E7B t *self, uint8_t *ip, uint32_
280275
if (newsoc < 0) {
281276
return -MP_EBADF;
282277
}
278+
279+
// We got a socket. New client socket will not be non-blocking by default, so make it non-blocking.
280+
lwip_fcntl(newsoc, F_SETFL, O_NONBLOCK);
281+
283282
if (!register_open_socket(newsoc)) {
284283
lwip_close(newsoc);
285284
return -MP_EBADF;

0 commit comments

Comments
 (0)
0