We may just free some TCP connections before monitor stopped, e.g.
sacrificie a TCP conn in `tcp_alloc` will just call `tcp_free` and reuse
the connection. But we noticed that the TCP monitor is not released in
`tcp_free` because it is mounted on `conn->connevents` instead of
`conn->sconn.list` while `tcp_free` only release the latter.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Fix the problem when vfork() calls execv() (or execl()) to start a new application:
When the parent thread calls vfork() it receives and gets the pid of the vforked task,
and not the pid of the desired execv'ed application.
issue #3334
Signed-off-by: yangyalei <yangyalei@xiaomi.com>
with nonblocking sockets, POLLOUT is returned when the application
calls poll even if the send buffer is full
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
When we are using newlib as libm, we can consider newlib-esp32 for esp32
hardware. An it contains some optimization for esp32 hardware.
Besides, two small issues has been fixed.
1. add the tar ball to .gitignore
2. Fix the some build warnings
These values are only provided by bream private message, should not include in
NMEA 0183 standard struct.
Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
We support search directory structure as follows:
Current directory
stm32/configs/common
stm32/common/configs
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Normally, `SO_ERROR` for disconn events will be set by `tcp_poll_eventhandler`, but when the socket is closed before poll, we should also set the `SO_ERROR`.
On Linux, `tcp_poll` returns `EPOLLERR` event when `sk->sk_err` has value but doesn't let `poll` fail (doesn't set `errno`). https://github.com/torvalds/linux/blob/v6.5/net/ipv4/tcp.c#L594-L596
Note: `sk->sk_err` can be get by socket option `SO_ERROR` on Linux, so `POLLERR` will always be together with `SO_ERROR`.
Common libs like curl may try to read `SO_ERROR` on `POLLERR`.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
A dead lock may happen before this patch:
rptun thread (usrsock_rpmsg_recvfrom_handler):
Gets all tx payload but waiting net_lock in psock_recvfrom
net driver thread (higher priority):
Receives a packet, holding net_lock, calling usrsock_rpmsg_send_event
But no tx buffer left, so rpmsg_send blocks, and won't release net_lock
In short:
Rptun: Hold all `tx_payload_buffer` -> want `net_lock`
Driver: Hold `net_lock` -> want `tx_payload_buffer`
This patch use net_lock to combine get_tx_payload and recvfrom together,
then:
- If it's waiting net_lock, tx payload will not be held, other threads
may get tx buffer and do their work.
- If net_lock is got, it won't be disturbed before finish receiving,
then tx payload won't have chance to be blocked before releasing.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
If the gulp size in the stdio buffer the remaining user buffer size it will:
- Corrupt memory in dest (user memory) and
- Keep corrupting KERNEL memory via the stdio character buffer until the
whole system crashes, as the 'remaining' count underflows
This patch fixes this behavior.