mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
net/can: Add SO_RCVBUF option for can socket
If the CAN stack receiving packets fast, but the application layer reading packets slow. Then `conn->readahead` will continue to grow, leading to memory leaks. Finally CAN stack potentially starve out all IOB buffers. To prevent memory leaks, users can restrict can socket buffer length. Signed-off-by: gaohedong <gaohedong@xiaomi.com>
This commit is contained in:
@@ -44,7 +44,7 @@ if(CONFIG_MM_IOB)
|
||||
iob_navail.c
|
||||
iob_free_queue_qentry.c
|
||||
iob_tailroom.c
|
||||
iob_get_queue_size.c
|
||||
iob_get_queue_info.c
|
||||
iob_reserve.c
|
||||
iob_update_pktlen.c
|
||||
iob_count.c)
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ CSRCS += iob_free_chain.c iob_free_qentry.c iob_free_queue.c
|
||||
CSRCS += iob_initialize.c iob_pack.c iob_peek_queue.c iob_remove_queue.c
|
||||
CSRCS += iob_statistics.c iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c
|
||||
CSRCS += iob_navail.c iob_free_queue_qentry.c iob_tailroom.c
|
||||
CSRCS += iob_get_queue_size.c iob_reserve.c iob_update_pktlen.c
|
||||
CSRCS += iob_get_queue_info.c iob_reserve.c iob_update_pktlen.c
|
||||
CSRCS += iob_count.c
|
||||
|
||||
ifeq ($(CONFIG_IOB_NOTIFIER),y)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* mm/iob/iob_get_queue_size.c
|
||||
* mm/iob/iob_get_queue_info.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@@ -55,4 +55,23 @@ unsigned int iob_get_queue_size(FAR struct iob_queue_s *queue)
|
||||
return total;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: iob_get_queue_entry_count
|
||||
*
|
||||
* Description:
|
||||
* Queue helper for get the iob queue entry count.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int iob_get_queue_entry_count(FAR struct iob_queue_s *queue)
|
||||
{
|
||||
FAR struct iob_qentry_s *iobq;
|
||||
unsigned int count;
|
||||
|
||||
for (iobq = queue->qh_head, count = 0; iobq != NULL;
|
||||
iobq = iobq->qe_flink, count++);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IOB_NCHAINS > 0 */
|
||||
Reference in New Issue
Block a user