-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Router::allocForSending: null-check packet pool allocation #10261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 3 commits
6a77c93
931f2ed
43bb584
ac1dddc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ class SinglePortModule : public MeshModule | |
| { | ||
| // Update our local node info with our position (even if we don't decide to update anyone else) | ||
| meshtastic_MeshPacket *p = router->allocForSending(); | ||
| if (!p) | ||
| return nullptr; | ||
| p->decoded.portnum = ourPortNum; | ||
|
|
||
| return p; | ||
|
Comment on lines
33
to
39
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,10 @@ inline void onReceiveJson(byte *payload, size_t length) | |
|
|
||
| // construct protobuf data packet using TEXT_MESSAGE, send it to the mesh | ||
| meshtastic_MeshPacket *p = router->allocForSending(); | ||
| if (!p) { | ||
| LOG_WARN("MQTT downlink sendtext dropped: packet pool exhausted"); | ||
| return; | ||
| } | ||
|
Comment on lines
191
to
+195
|
||
| p->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP; | ||
| if (json.find("channel") != json.end() && json["channel"]->IsNumber() && | ||
| (json["channel"]->AsNumber() < channels.getNumChannels())) | ||
|
|
@@ -220,6 +224,10 @@ inline void onReceiveJson(byte *payload, size_t length) | |
|
|
||
| // construct protobuf data packet using POSITION, send it to the mesh | ||
| meshtastic_MeshPacket *p = router->allocForSending(); | ||
| if (!p) { | ||
| LOG_WARN("MQTT downlink sendposition dropped: packet pool exhausted"); | ||
| return; | ||
| } | ||
| p->decoded.portnum = meshtastic_PortNum_POSITION_APP; | ||
| if (json.find("channel") != json.end() && json["channel"]->IsNumber() && | ||
| (json["channel"]->AsNumber() < channels.getNumChannels())) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packetPool.allocZeroed()already emits aLOG_WARNwhen the static pool has no free slots. Adding another unthrottledLOG_WARNhere can double-log the same event and potentially flood logs during ACK/NAK storms (which are also a scenario where pool exhaustion occurs). Consider lowering this toLOG_DEBUG, throttling it, or removing it in favor of the pool's existing warning.