diff options
author | Krzysztof Blazewicz <krzysztof.blazewicz@uxeon.com> | 2016-08-26 10:50:37 +0200 |
---|---|---|
committer | Krzysztof Blazewicz <krzysztof.blazewicz@uxeon.com> | 2016-08-26 10:57:32 +0200 |
commit | fc73c9b4b28e903641888a81a76169a929407383 (patch) | |
tree | 0e36816378dac296351dc942bfa50b12516c57fa | |
parent | 5ffe1d8dc07930818bbac6a88bec2aa5bd973402 (diff) |
stmhal/modusocket: set self->nic to MP_OBJ_NULL after socket close
This patch makes second and next calls to <socket>.close() a no-op.
It prevents GC from closing the underlying resource after user
already used <socket>.close() explicitly.
fixes #2355
-rw-r--r-- | stmhal/modusocket.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/stmhal/modusocket.c b/stmhal/modusocket.c index fbd119644..c0e30ce05 100644 --- a/stmhal/modusocket.c +++ b/stmhal/modusocket.c @@ -83,6 +83,7 @@ STATIC mp_obj_t socket_close(mp_obj_t self_in) { mod_network_socket_obj_t *self = self_in; if (self->nic != MP_OBJ_NULL) { self->nic_type->close(self); + self->nic = MP_OBJ_NULL; } return mp_const_none; } |