Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:
1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
functions
Calling send() or write() on a connected UDP socket raises a
kernel panic in posix_sockets.c, line 215, because _sockaddr_to_ep()
is called from socket_sendto() with address set to NULL.
This change modifies socket_sendto() to
* Check if the UDP socket is connected when the address argument
is NULL.
* If connected, use the stored remote endpoint for sock_udp_send().
AwaLWM2M needs to be polled regularly to check for incoming data.
Since RIOT only supports timeout at the GNRC sock layer while
the network abstraction for RIOT in AwaLWM2M uses the posix layer,
this causes RIOT to be blocked waiting for data that never arrive.
This commit implements only the SO_RCVTIMEO option in setsockopt to
allow users to set a receive timeout for a socket at the posix layer.
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
Commit de41971aab sets the default
timeout to 0. This change should not have been part of the commit.
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
The address is an optional parameter of recvfrom. If it is
not null, recvfrom must store the address of the sender.
However this was only allowed if res was equal to 0, which
is wrong since res contains the number of bytes received
or -1.
This commit ensures that the address is set only if no
previous errors happened before.
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
The return value of these functions was not always correct
in case of errors: they were not returning -1 and setting
errno.
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
A client should not require to explicitly call bind() to receive packets, but is expected to receive replies sent to the ephemeral port that was selected as a source port by the UDP implementation.