#1004449 rfcomm busyloops taking 35% CPU due to needlessly low busy loop timeout

Package:
bluez
Source:
bluez
Description:
Bluetooth tools and daemons
Submitter:
Thomas Habets
Date:
2022-01-27 20:45:04 UTC
Severity:
normal
#1004449#5
Date:
2022-01-27 20:40:27 UTC
From:
To:
tools/rfcomm.c has a ppoll() with 200ns timeout. It just appears to be
there to detect when the program should end, and takes about 35% CPU
on a raspberry pi 4.

If I change it to 10'000'000 (10ms) it seems to not have any
functional impact aside from making the CPU problems go away.

E.g. running:
 sudo tools/rfcomm watch hci0 1 getty rfcomm0 115200 vt100
doesn't take any CPU initially, but if one connects to the port it
busyloops. It works, but it busyloops.

The fix is simple. Change line 260 of tools/rfcomm.c to read:
                            ts.tv_nsec = 10000000;