Instead of trying all socket types (local + rpmsg), select the
correct one based on the net type. And use getsockname() at runtime
to decide when both net_local and net_rpmsg are enabled, if on
the same core as KVDB server, use local socket; otherwise use rpmsg socket.
Increase KVDB_BACKLOG_CONNS to 256
Signed-off-by: jingfei <jingfei@xiaomi.com>
Add KVERR error logs at all exit positions in server.c to help debug
unexpected server exits. This includes:
- kvdb_monitor_open: zalloc and epoll_ctl failures
- kvdb_recv: recv failures and connection close
- kvdb_client: malloc, recv failures, and exit command
- kvdb_loop: epoll_create, epoll_ctl, pthread_create failures and loop exit
- kvdb_bind: socket, bind, listen failures
- main: kvdb_bind, kvdb_init failures and exit
All logs include detailed context (function name, error codes, errno)
to help quickly identify the root cause of server crashes.
Signed-off-by: ligd <liguiding1@xiaomi.com>
Fixed a file descriptor leak issue reported by Coverity static analysis
tool. The problem occurs in property_connect_one() when connect() fails
but the file descriptor is not properly closed in certain error paths.
Root cause:
Previously, the code checked if errno equals ENOENT before closing the fd,
allowing it to retry connect() in a while loop in the caller. However,
with the refactored connect_one approach, this function is called once
per attempt, so ALL connect() failures must close the fd before returning
the error code. The ENOENT check was preventing proper cleanup, causing
fd leaks when connect() failed with ENOENT.
Changes:
- Remove errno != ENOENT condition check in error path
- Always close(fd) when connect() fails, regardless of errno value
- Simplify control flow: return fd on success, close and return error on failure
- Prevent file descriptor leak detected by Coverity scan
The connect retry logic (if needed) should be handled by the caller,
not within property_connect_one().
Tool: Coverity static analysis
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Get proxy properties after interface added, before reply, if
recieved interface removed message, it's safer to cancel
pending_call object of get_all_prop at proxy free process.
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
Even if a proxy has already been added, the properties
should still be retrieved when adding the interface.
because the proxy maybe not got prop before.
Signed-off-by: huangcaihua <huangcaihua@xiaomi.com>
kvdbd is single threaded.
If CP calls property_list, AP'S kvdbd will continue to send to cp,
then accept will not be executed.
If another thread at CP loops to call property_set,
the AP server-side's pending queue will be full and reject next connection.
Bluetooth now loops through 15 times to call 'property_set',
So to avoid rejecting the connection,
set a macro to separately manage the listening count of kvdb
Signed-off-by: yintao <yintao@xiaomi.com>
When server recv msg header, there maybe recv only one byte.
Then we should continue the full header use kvdb_recv()
Signed-off-by: ligd <liguiding1@xiaomi.com>
KVDB_NVS should depend on MTD_CONFIG_NAMED. If choose
select MTD_CONFIG_NAMED and CONFIG_MTD is not set, it
will lead to compile error like:
dev-system/nuttx/include/nuttx/mtd/configdata.h:79:20: error: 'CONFIG_MTD_CONFIG_NAME_LEN' undeclared here (not in a function); did you mean 'CONFIG_MTD_CONFIG_NAMED'?
79 | char name[CONFIG_MTD_CONFIG_NAME_LEN];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| CONFIG_MTD_CONFIG_NAMED
Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
clang-format the file include/cutils/trace.h
"/home/mi/workspace_vela/nuttx/../apps/frameworks/
system/utils/include/cutils/trace.h", line 154: warning #1731-D:
function must be declared at file scope
void atrace_begin_body(const char*);
^
"/home/mi/workspace_vela/nuttx/../apps/frameworks/
system/utils/include/cutils/trace.h", line 167: warning #1731-D:
function must be declared at file scope
void atrace_end_body(void);
^
"/home/mi/workspace_vela/nuttx/../apps/frameworks/
system/utils/include/cutils/trace.h", line 185: warning #1731-D:
function must be declared at file scope
void atrace_async_begin_body(const char*, int32_t);
^
"/home/mi/workspace_vela/nuttx/../apps/frameworks/
system/utils/include/cutils/trace.h", line 198: warning #1731-D:
function must be declared at file scope
void atrace_async_end_body(const char*, int32_t);
^
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>