2011-07-13 10:51:53

by Sérgio Capela

[permalink] [raw]
Subject: A couple of questions related to a rfcomm server


Hello,

since this is the only contact available at bluez.com I'm sending these
questions to this list. If this is not the contact to be used please
direct me to the one which is.

I'm trying to make a sort of content server using bluetooth. As such I
coded a non blocking rfcomm server which accepts remote connections and
according to the received connections sends data back. The machine doing
this uses two bluetooth adapters and one is binded to the accepting
socket, however the same machine, in this case the same application is
supposed to scan visible remote bluetooth adapters for rssi values and so
my first question arises.

Is it possible to accept connections at the same time a inquiry is running
or is the inquiry a blocking operation at the stack level? With two
adapters my server accepts remote connections and receives and sends data
but when an inquiry is running it stops accepting connections. The inquiry
is done in a separate thread.

Another question is related to a rfcomm client getting into D state and
thus not killable. Due to my setup (two adapters in the same computer) I
can use the computer as both the server and the client. For test purposes
only I made a simple rfcomm client and I put it in a shell cycle thus
stressing the system regarding bluetooth connections. In this situation
the rfcomm client application becomes unresponsive after some time due to
a non exiting disk sleep. I then end up with multiple instances of the
same application and I can't kill them. By launching the application after
this I can see that the code blocks at a socket connection command
entering in a disk sleep state from which it doesn't exit. When this
happens I have to unplug the bluetooth adapter to get it working again
since it starts to give timeouts with hciconfig commands like "hciconfig
reset".

Any ideas about this? The problem itself is not serious since it shouldn't
arise in normal conditions but it does require a reboot because of the
state D processes and makes the adapter unusable unless it is unplugged.

Best regards,
--
S?rgio Pedro dos Santos Capela - Tziranda

Polo Tecnol?gico de Lisboa
Edif?cio Empresarial 3
1600-546 Lisboa

Telf: 21 314 09 83
Telml: 96 491 94 37
Email: [email protected]


2011-07-25 22:05:17

by Peter Hurley

[permalink] [raw]
Subject: Re: A couple of questions related to a rfcomm server

SGkgU8OpcmdpbywNCg0KT24gU3VuLCAyMDExLTA3LTI0IGF0IDE4OjA4IC0wNDAwLCBTw6lyZ2lv
IENhcGVsYSB3cm90ZToNCj4gSGkgUGV0ZXIsDQo+IA0KLi4uLg0KPiA+IElmIHlvdSBoYXZlIHRv
IGhhdmUgc2VydmVyLXNpZGUgZGlzY292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29tZSBwcm9ibGVtIEkgd2lsbCByZXBseSBpbiB0aGlzIHRvcGljLg0K
DQpXZWxsLCByaWdodCBub3csIHRob3NlIHBhdGNoZXMgYXJlIG9uIHRoZSBtYWlsaW5nIGxpc3Qu
IEkgd2FzIHJlYWxseQ0KbG9va2luZyB0byBnZXQgc29tZSBtb3JlIHRlc3Rpbmcgb24gdGhlbSBf
cHJpb3JfIHRvIHRoZW0gbWFraW5nIHRoZWlyDQp3YXkgaW50byB0aGUga2VybmVsLiBUaGV5J3Jl
IG1vc3RseSBhc3NvY2lhdGVkIHdpdGggbWlzc2luZyB3YWtldXBzIC0tDQphbHRob3VnaCBpdCdz
IHBvc3NpYmxlIHRoZXkgY291bGQgZml4IHRoZSBEIHN0YXRlIGNsaWVudCwgSSBjb3VsZG4ndA0K
aHlwb3RoZXNpemUgaG93IHRoZSByZmNvbW0gc29ja2V0IGNvdWxkIGJlY29tZSB1bmludGVycnVw
dGlibGUgZnJvbSB3aGF0DQpJIGZpeGVkLiBUaGV5IG1heSBiZSB1bnJlbGF0ZWQuDQoNClJlZ2Fy
ZHMsDQpQZXRlcg0KDQo=

2011-07-24 22:08:00

by Sérgio Capela

[permalink] [raw]
Subject: Re: A couple of questions related to a rfcomm server

Hi Peter,

On Sun, 24 Jul 2011 17:26:24 +0100, Peter Hurley
<[email protected]> wrote:

> Hi S?rgio,
>
> On Wed, 2011-07-13 at 06:51 -0400, S?rgio Capela wrote:
>> Hello,
>>
> ...
>> Is it possible to accept connections at the same time a inquiry is
>> running
>> or is the inquiry a blocking operation at the stack level? With two
>> adapters my server accepts remote connections and receives and sends
>> data
>> but when an inquiry is running it stops accepting connections. The
>> inquiry
>> is done in a separate thread.
>
> That's handled in the controller at the baseband level. I don't know of
> any controllers that will accept connections while in the Inquiry
> substate - I'm not even sure if it's possible.
>
> Why are you initiating discovery from the server-side?
>

Well, this is a test where I'm trying to see if content delivery is viable
through bluetooth and in this case the content depends on context. Imagine
a number of rooms which should serve differentiated content accordingly.
The server side discovery would try to automatically infer which content
should be delivered to a given possible client. For this purpose I perform
inquiries with rssi and thus the servers would act like tracking devices
which would transmit inquiry data to a central database. These are only
trials for now and I know that inquiries with rssi values are not that
good for this type of decision so in the future this operation can be
dropped in favor of other solution even if it end up as a choice at the
user side.


> If you have to have server-side discovery, you could only perform
> inquiry with one controller at a time. That way, the other controller's
> available for new rfcomm connections (assuming your client load-balances
> like that...).
>

Yep, that is what I'm doing. I bind one adapter to the rfcomm server and
use the other one for discovery and content delivery. The main process
thread is the accept server and both the inquiry and the content delivery
are done in threads launched for the purpose. I also made more tests
recently and what is happening is that as soon as the inquiry starts the
server stops accepting connections and starts processing inquiry result
events, however, after a couple of minutes I can see the server both
accepting and processing new connections and new inquiry result events.
The end result is that launching an inquiry leads me to loose possible
connections during a few minutes which is excessive for this case where
inquiries would be launched regularly.

>> Another question is related to a rfcomm client getting into D state and
>> thus not killable. Due to my setup (two adapters in the same computer) I
>> can use the computer as both the server and the client. For test
>> purposes
>> only I made a simple rfcomm client and I put it in a shell cycle thus
>> stressing the system regarding bluetooth connections. In this situation
>> the rfcomm client application becomes unresponsive after some time due
>> to
>> a non exiting disk sleep. I then end up with multiple instances of the
>> same application and I can't kill them. By launching the application
>> after
>> this I can see that the code blocks at a socket connection command
>> entering in a disk sleep state from which it doesn't exit. When this
>> happens I have to unplug the bluetooth adapter to get it working again
>> since it starts to give timeouts with hciconfig commands like "hciconfig
>> reset".
>>
>> Any ideas about this? The problem itself is not serious since it
>> shouldn't
>> arise in normal conditions but it does require a reboot because of the
>> state D processes and makes the adapter unusable unless it is unplugged.
>
> Although I'm not certain that they would fix the problem you're having,
> I just posted a patch series that resolves some issues with lost wakeups
> in rfcomm and l2cap. They need testing. You'd need patches 1~4 of 7.
>
> Please feel free to reply direct regarding whether you can test these
> and what that outcome was.

I suppose those patches would be available in the git sources right? At
the moment I can't test it but in a week or two I will try to compile the
sources and unless I encounter some problem I will reply in this topic.


Regards,
S?rgio

>
> Regards,
> Peter


--
S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5lZWQgcGF0Y2hlcyAxfjQgb2YgNy4NCg0KUGxlYXNlIGZlZWwgZnJlZSB0byByZXBseSBk
aXJlY3QgcmVnYXJkaW5nIHdoZXRoZXIgeW91IGNhbiB0ZXN0IHRoZXNlDQphbmQgd2hhdCB0aGF0
IG91dGNvbWUgd2FzLg0KDQpSZWdhcmRzLA0KUGV0ZXINCg==

2011-08-01 15:09:45

by Sérgio Capela

[permalink] [raw]
Subject: Re: A couple of questions related to a rfcomm server

Hi Peter,

Em Mon, 25 Jul 2011 23:05:17 +0100, Peter Hurley
<[email protected]> escreveu:

> Hi S?rgio,
>
> On Sun, 2011-07-24 at 18:08 -0400, S?rgio Capela wrote:
>> Hi Peter,
>>
> ....
>> > If you have to have server-side discovery, you could only perform
>> > inquiry with one controller at a time. That way, the other
>> controller's
>> > available for new rfcomm connections (assuming your client
>> load-balances
>> > like that...).
>> >
>>
>> Yep, that is what I'm doing. I bind one adapter to the rfcomm server and
>> use the other one for discovery and content delivery. The main process
>> thread is the accept server and both the inquiry and the content
>> delivery
>> are done in threads launched for the purpose. I also made more tests
>> recently and what is happening is that as soon as the inquiry starts the
>> server stops accepting connections and starts processing inquiry result
>> events, however, after a couple of minutes I can see the server both
>> accepting and processing new connections and new inquiry result events.
>> The end result is that launching an inquiry leads me to loose possible
>> connections during a few minutes which is excessive for this case where
>> inquiries would be launched regularly.
>
> Inquiry in the host stack does serialize wrt. several other ioctl
> functions; however, this is per device. Running a simple test here
> produces expected results, ie. concurrent discovery and connections:
> 1. Start inquiry on device hci1. eg.,
> hcitool -i hci1 inq --length=30
> 2. Initiate connection on device hci0. In my case, turning on a
> bluetooth headset initiates a connection. Of course, the headset
> was previously paired.
>
> You may need to confirm where/what your threads are blocked on (well, at
> least your main process thread that should be blocked on the accept
> syscall). Stack backtrace in gdb would clear that up.
>

I was able to test this today to make sure that a block was not the cause
of the problem. The thread isn't blocked since it remains printing to
stdout on the accept thread.

I'm calling the client from a separate machine using the following shell
command:

while [ 1 ]; do ./rfcomm-client; sleep 5; done

where rfcomm-client is the simple example found in the web from the
bluetooth introduction book.

The response from my server is:

waiting for connection
waiting for connection
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
waiting for connection
waiting for connection
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
waiting for connection
waiting for connection
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
waiting for connection
waiting for connection
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
thread end
waiting for connection
waiting for connection
waiting for connection

where "waiting for connection" is written to stdout before the accept
call. The timeout for the accept is of 1.5 seconds.

In attachment I send two logs with my results when I turn on the rssi
inquiry. For testing purposes I initiate the inquiry when receiving a
client connection if one isn't already running.

- ssh-output.txt is the log for the client where the error message I get
is presented in one line followed by the time in seconds in another;

- shell-output.txt is the log for the server where both the accept server
messages and the inquiry messages are present. The content of the file is
similar to the one already presented except for the following:
-- inquiry start logged with two lines: "Inquiry" and "Starting inquiry
with RSSI..." which appears whenever I start a inquiry;
-- inquiry results: "<TZ_OK> RSSI 188 Time 1312194878" which shows the
result of a curl call from within the program followed by a "RSSI" value
and time in seconds.

From the server log it can be seen that I initiate a inquiry in response
to a connection and start receiving inquiry responses at time 1312194729
and at the same time I stop receiving connections despite the "waiting for
connection" logged output. Inspecting the client log I see six failed
connection attempts from Time 1312194740 to time 1312194791. Going to the
sever log again I can see that I then receive 3 connection from the client
with the inquiry still running as seen below.

<TZ_OK> RSSI 200 Time 1312194794
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
waiting for connection
waiting for connection
<TZ_OK> RSSI 190 Time 1312194799

<TZ_OK> RSSI 182 Time 1312194801
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
<TZ_OK> RSSI 181 Time 1312194801

<TZ_OK> RSSI 186 Time 1312194804
waiting for connection
accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
waiting for connection
thread end
waiting for connection
<TZ_OK> RSSI 189 Time 1312194809

I then start another inquiry:

<TZ_OK> RSSI 190 Time 1312194811
<TZ_OK>accepted connection from 00:15:83:15:A3:10
received [{"sala":"Sala
tziranda","conteudos":[{"i":"qualquercoisa","t":"qualquercoisa2","d":"a"}]}]
thread created and detached
Inquiry
waiting for connection
Starting inquiry with RSSI...
thread end
RSSI 189 Time 1312194812

And start loosing connections again:

uh oh: Invalid argument
Time 1312194823

>> >> Another question is related to a rfcomm client getting into D state
>> and
>> >> thus not killable.
> ...
>> >
>> > Although I'm not certain that they would fix the problem you're
>> having,
>> > I just posted a patch series that resolves some issues with lost
>> wakeups
>> > in rfcomm and l2cap. They need testing. You'd need patches 1~4 of 7.
>> >
>> > Please feel free to reply direct regarding whether you can test these
>> > and what that outcome was.
>>
>> I suppose those patches would be available in the git sources right? At
>> the moment I can't test it but in a week or two I will try to compile
>> the
>> sources and unless I encounter some problem I will reply in this topic.
>
> Well, right now, those patches are on the mailing list. I was really
> looking to get some more testing on them _prior_ to them making their
> way into the kernel. They're mostly associated with missing wakeups --
> although it's possible they could fix the D state client, I couldn't
> hypothesize how the rfcomm socket could become uninterruptible from what
> I fixed. They may be unrelated.
>

I thought the patches were on the user side of things and not on the
kernel side. I can't really test this since I can't even afford the disk
space needed for the kernel compilation because I'm making these tests in
a resource limited machine. Also I can't make the machine unstable.

Regards,
S?rgio Capela

> Regards,
> Peter
>


--
S?rgio Pedro dos Santos Capela - Tziranda

Polo Tecnol?gico de Lisboa
Edif?cio Empresarial 3
1600-546 Lisboa

Telf: 21 314 09 83
Telml: 96 491 94 37
Email: [email protected]


Attachments:
ssh-output.txt (724.00 B)
shell-output.txt (70.74 kB)
Download all attachments