Change in simtrace2[master]: sniffer: only allocate USB message if queue is not too long

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 11 20:25:07 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9927 )

Change subject: sniffer: only allocate USB message if queue is not too long
......................................................................

sniffer: only allocate USB message if queue is not too long

When the host does not retrieved the USB messages, they keep getting
queue in the firmware, filling the RAM, and preventing further memory
to be allocated.

Change-Id: I0e447acdf757dcb5dc5c4d8b84a4235866914cad
---
M firmware/libcommon/source/sniffer.c
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 1c691af..0ca71a5 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -226,6 +226,14 @@
  */
 static struct msgb *usb_msg_alloc_hdr(uint8_t ep, uint8_t msg_class, uint8_t msg_type)
 {
+	/* Only allocate message if not too many are already in the queue */
+	struct llist_head *head = usb_get_queue(SIMTRACE_USB_EP_CARD_DATAIN);
+	if (!head) {
+		return NULL;
+	}
+	if (llist_count(head) > 5) {
+		return NULL;
+	}
 	struct msgb *usb_msg = usb_buf_alloc(SIMTRACE_USB_EP_CARD_DATAIN);
 	if (!usb_msg) {
 		return NULL;

-- 
To view, visit https://gerrit.osmocom.org/9927
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0e447acdf757dcb5dc5c4d8b84a4235866914cad
Gerrit-Change-Number: 9927
Gerrit-PatchSet: 6
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180711/1e791c68/attachment.htm>


More information about the gerrit-log mailing list