fixeria has uploaded this change for review.
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(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/94/41694/1
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 change 41694. To unsubscribe, or for help writing mail filters, visit settings.