2009-06-17 13:28:31

by Dominic Sacré

[permalink] [raw]
Subject: Polling in rfcomm listen


I'm trying to use "rfcomm listen" (or "rfcomm watch") to run a command as
soon as a client connects. The problem is that after starting the command,
rfcomm enters a loop which continually calls ppoll() with a timeout of 200
nanoseconds. This causes a very high CPU load, and also a chirping noise on
my laptop, presumably from ther CPU entering a power save mode, and
immediately being woken up again.

Is there any reason to use such an extremely short timeout? I tried
replacing the timeout with 2 milliseconds (that's 10000 times the original
value...), and rfcomm works much better now. Probably even higher values
would work.

Another issue is that occasionally, the command started by rfcomm fails to
open /dev/rfcomm0. Apparently rfcomm starts the command before the device is
properly created and its permissions set?