fixeria has submitted this change. (
https://gerrit.osmocom.org/c/osmocom-bb/+/41694?usp=email )
Change subject: trx_toolkit: UDPLink: catch and ignore BlockingIOError
......................................................................
trx_toolkit: UDPLink: catch and ignore BlockingIOError
We should not crash when failing to send a datagram due to blocking.
Print an error, drop the data, and keep going.
Change-Id: If2248d4a670f893848c44e0fcbd2089371532207
Related: OS#6904
---
M src/target/trx_toolkit/udp_link.py
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
osmith: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/target/trx_toolkit/udp_link.py
b/src/target/trx_toolkit/udp_link.py
index 4db7283..f0a8224 100644
--- a/src/target/trx_toolkit/udp_link.py
+++ b/src/target/trx_toolkit/udp_link.py
@@ -17,6 +17,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
+import logging as log
import socket
class UDPLink:
@@ -45,5 +46,10 @@
def sendto(self, data, remote):
if type(data) not in [bytearray, bytes]:
data = data.encode()
-
- self.sock.sendto(data, remote)
+ try:
+ self.sock.sendto(data, remote)
+ except BlockingIOError:
+ # When the message does not fit into the send buffer of
the socket, send()
+ # normally blocks, unless the socket has been placed in
nonblocking I/O mode.
+ # In nonblocking mode it would fail with the
BlockingIOError in this case.
+ log.error('(%s) BlockingIOError: dropping Tx data',
self.desc_link())
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/41694?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: If2248d4a670f893848c44e0fcbd2089371532207
Gerrit-Change-Number: 41694
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>