Skip to content

Commit

Permalink
Merge pull request #4095 from hierophect/socket-timeout
Browse files Browse the repository at this point in the history
Fix default socket timeout
  • Loading branch information
tannewt authored Feb 1, 2021
2 parents 9bceb32 + ddd516a commit a52395a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ports/esp32s2/common-hal/socketpool/Socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_o
while (newsoc == -1 &&
!timed_out &&
!mp_hal_is_interrupted()) {
if (self->timeout_ms != (uint)-1) {
if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) {
timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms;
}
RUN_BACKGROUND_TASKS;
Expand Down Expand Up @@ -251,7 +251,7 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self,
while (received == -1 &&
!timed_out &&
!mp_hal_is_interrupted()) {
if (self->timeout_ms != (uint)-1) {
if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) {
timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms;
}
RUN_BACKGROUND_TASKS;
Expand Down Expand Up @@ -362,7 +362,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se
while (received == -1 &&
!timed_out &&
!mp_hal_is_interrupted()) {
if (self->timeout_ms != (uint)-1) {
if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) {
timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms;
}
RUN_BACKGROUND_TASKS;
Expand Down
1 change: 1 addition & 0 deletions ports/esp32s2/common-hal/socketpool/SocketPool.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ socketpool_socket_obj_t* common_hal_socketpool_socket(socketpool_socketpool_obj_
sock->type = socket_type;
sock->family = addr_family;
sock->ipproto = ipproto;
sock->timeout_ms = (uint)-1;

sock->tls = NULL;
sock->ssl_context = NULL;
Expand Down

0 comments on commit a52395a

Please sign in to comment.