2008-03-06 16:50:25

by José Miguel Gonçalves

[permalink] [raw]
Subject: [Bluez-devel] Bug in compat_ppoll

Hi,

When I was cross-compiling Bluez for a system without the ppoll() system
call, I've found a bug on you ppoll() stub, compat_ppoll(), that causes
rfcomm to eat all CPU power when called in this way:

$ rfcomm listen 0 1 <cmd>

After the RFCOMM connection is established and the command is executed
the CPU load reaches 100%.

This patch solved my problem:

diff -Naur bluez-utils-3.27.orig/common/ppoll.h
bluez-utils-3.27/common/ppoll.h
--- bluez-utils-3.27.orig/common/ppoll.h 2007-05-20
09:28:28.000000000 +0100
+++ bluez-utils-3.27/common/ppoll.h 2008-03-06 15:56:02.000000000 +0000
@@ -7,5 +7,10 @@
static inline int compat_ppoll(struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout, const sigset_t *sigmask)
{
- return poll(fds, nfds, timeout ? timeout->tv_sec * 1000 : 500);
+ if (timeout =3D=3D NULL)
+ return poll(fds, nfds, -1);
+ else if (timeout->tv_sec =3D=3D 0)
+ return poll(fds, nfds, 500);
+ else
+ return poll(fds, nfds, timeout->tv_sec * 1000);
}

Regards,
Jos=E9 Miguel Gon=E7alves


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2008-03-07 14:43:16

by José Miguel Gonçalves

[permalink] [raw]
Subject: Re: [Bluez-devel] Bug in compat_ppoll

Marcel Holtmann wrote:
> Hi Jose,
>
> =

>> When I was cross-compiling Bluez for a system without the ppoll() system
>> call, I've found a bug on you ppoll() stub, compat_ppoll(), that causes
>> rfcomm to eat all CPU power when called in this way:
>>
>> $ rfcomm listen 0 1 <cmd>
>>
>> After the RFCOMM connection is established and the command is executed
>> the CPU load reaches 100%.
>>
>> This patch solved my problem:
>> =

>
> your patch has been applied. Thanks.
>
> I was actually considering to simply fail compilation on systems that
> don't support ppoll().
>
> =


I don't think that is such a good idea because there are still several
embedded systems that use an old Linux kernel or an old Glibc (that's my
case, I'm using Glibc 2.3.6 on my board).

Regards,
Jos=E9 Miguel Gon=E7alves


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-03-07 14:19:33

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Bug in compat_ppoll

Hi Jose,

> When I was cross-compiling Bluez for a system without the ppoll() system
> call, I've found a bug on you ppoll() stub, compat_ppoll(), that causes
> rfcomm to eat all CPU power when called in this way:
>
> $ rfcomm listen 0 1 <cmd>
>
> After the RFCOMM connection is established and the command is executed
> the CPU load reaches 100%.
>
> This patch solved my problem:

your patch has been applied. Thanks.

I was actually considering to simply fail compilation on systems that
don't support ppoll().

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel