diff options
| author | Jared Hancock <jared.hancock@centeredsolutions.com> | 2022-11-07 11:21:27 -0600 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-11-09 10:48:53 +1100 |
| commit | a2fd382c34ad9ccca3bf9f0b6ca8c42db7ea6282 (patch) | |
| tree | c7304db461c05b15f720eda1008810854017a731 /extmod/modlwip.c | |
| parent | ecd4d54391b908a55f7ac53fd0196972c96a04c9 (diff) | |
extmod/modlwip: Use actual errno in exception for error in listen.
The actual underlying error number raised from the lwIP subsystem when
attempting to listen on a socket is swallowed and replaced with an
out-of-memory error which is confusing.
This commit passes the underlying error message from the lwIP subsystem to
the appropriate OSError exception.
Diffstat (limited to 'extmod/modlwip.c')
| -rw-r--r-- | extmod/modlwip.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/extmod/modlwip.c b/extmod/modlwip.c index f64a5a625..734722f83 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -931,9 +931,20 @@ STATIC mp_obj_t lwip_socket_listen(size_t n_args, const mp_obj_t *args) { mp_raise_OSError(MP_EOPNOTSUPP); } - struct tcp_pcb *new_pcb = tcp_listen_with_backlog(socket->pcb.tcp, (u8_t)backlog); + struct tcp_pcb *new_pcb; + #if LWIP_VERSION_MACRO < 0x02000100 + new_pcb = tcp_listen_with_backlog(socket->pcb.tcp, (u8_t)backlog); + #else + err_t error; + new_pcb = tcp_listen_with_backlog_and_err(socket->pcb.tcp, (u8_t)backlog, &error); + #endif + if (new_pcb == NULL) { + #if LWIP_VERSION_MACRO < 0x02000100 mp_raise_OSError(MP_ENOMEM); + #else + mp_raise_OSError(error_lookup_table[-error]); + #endif } socket->pcb.tcp = new_pcb; |
