See bug #57445. Short version of the description there: lwip_select() failed
to decrement 'select_waiting' of a socket since that code part failed on
'free_pending' sockets. However, the code does not have to check that as it
has marked the socket to be in use itself earlier.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
sys_arch_mbox_tryfetch() shall return SYS_MBOX_EMPTY or 0 according
to the documentation. Wherever the function is used the return
value is incorrectly compared to SYS_ARCH_TIMEOUT. For now
SYS_MBOX_EMPTY is defined to SYS_ARCH_TIMEOUT so this is not an
issue as long as SYS_MBOX_EMPTY isn't re-defined.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
* Lwip declares msghdr->msg_iovlen as int, but when
using external socket headers, some systems declare
msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
expects users to typedef it to the type they need
for their system.
Lwip's struct sockaddr includes sa_len, but some systems
like Linux doesn't have this filed, which produces many
compilation problems when using external headers.
A set of macros has benn added to detect the absence of
sa_len and adapt sockets.c
This reuses the member 'int socket' by making it a union containing
both int and void pointer.
See bug #56593.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
Suggested-by: Wilfred <wilfrednilsen@hotmail.com>
The err field is removed from struct lwip_sock since commit e0a2472706ee
("netconn/sockets: remove fatal error handling, fix asynchronous error handling, ensure data before RST can be received")
sock_set_errno() simply calls set_errno() now, so use set_errno() instead.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Dirk Ziegelmeier <dziegelmeier@de.pepperl-fuchs.com>
Replace '\n' with '<br>', as this allows doxygen to understand reference
names followed by newline. For some cases just drop the newline if it's
not required.
Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.
bug #56004
lwip_getsockopt_internal/lwip_setsockopt_internal were renamed to
lwip_getsockopt_impl/lwip_setsockopt_impl. Update the comment accordingly.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This reverts commit 8b4a8159a898795ef0fc9226dae1ce66531ad487.
We do not want to do this shortly before a release. Reformatting (buggy reformatting) may introduce new bugs.
Threads blocked on the rx mbox are counted and on close,
one "netconn closed" message per thread is posted to the mbox
to ensure all threads are woken.
The netconn can then be safely deleted. In socket API, "fd_used"
and "fd_free_pending" help with auto-deleting the netconn.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This is necessary to implement fullduplex sockets that are closed asynchronously:
the netconn in the socket must not be freed before all threads have given up
using it.
We now call the first part of 'netconn_delete()' (moved to 'netconn_prepare_delete()')
from lwip_close() and only actually end up calling 'netconn_free()' from
'free_socket()', which might be called later if LWIP_NETCONN_FULLDUPLEX is enabled.
Signed-off-by: goldsimon <goldsimon@gmx.de>
Calling SYS_ARCH_PROTECT() could happen twice in 'free_socket()' if
that free was executed delayed (e.g. in 'done_socket_locked()').
Signed-off-by: goldsimon <goldsimon@gmx.de>
This simply wasn't the case until 6LoWPAN. However, since tcpip_input is like this, we
should stay with that pattern.
Adapted documentation in netif.h
Signed-off-by: goldsimon <goldsimon@gmx.de>
With the changes introduced in b1b62751105d608d57249462d6ac5acbb809dd54
it's no longer possible to get ERR_CLSD from netconn_recv_tcp_pbuf_flags
after we've received data because of the NETCONN_NOFIN flag, so remove
handling for this case. Further the NETCONN_EVT_RCVPLUS stays active in
netconn_recv_data_tcp when the NETCONN_NOFIN flag is used
FIN should only be reported once (as '0' for sockets, as 'ERR_CLSD' for
netconns). Before this change, ERR_CLSD was returned forever...
This is the 2nd try. First try (commit ebcae98ae65c26a0c210c802540bf027d07fe2f1)
was buggy in that it could drop the FIN if it was read together with data
(reverted in commit ebcae98ae65c26a0c210c802540bf027d07fe2f1).
This version fixes this by adding an apiflag and a netconn flag to keep
track of this.
LWIP_HOOK_SOCKETS_SETSOCKOPT() and LWIP_HOOK_SOCKETS_GETSOCKOPT()
are introduced to implement additional socket options. The hooks
are always called first and report back if they handled the option
or not.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This cleans up the code: sys_timeouts_mbox_fetch() was only used from
tcpip.c anyway, so let's move it there.
Signed-off-by: goldsimon <goldsimon@gmx.de>