From: "Daryl Van Vorst" <daryl@wideray.com>
To: "'BlueZ Mailing List'" <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] Rfcomm Use Count
Date: Thu, 16 Sep 2004 17:10:50 -0700 [thread overview]
Message-ID: <000c01c49c4a$ca42b9a0$1a01010a@baked> (raw)
Marcel,
I have a simple way to reproduce at least part of this bug. I don't have =
an
up-to-date x86 machine to try this on, but I suspect you'll see the same
behaviour:
1. Compile and run the attached code on one machine
2. Connect to it from another machine using: rctest -n -P1 <bd_addr>
3. Hit ctrl-c on rctest
4. Hit ctrl-c on bzt (or whatever you called the compiled code)
5. lsmod and look at the rfcomm use count.
I think the problem stems from rfcomm_cleanup_listen() and
bluez_accept_dequeue(). Bluez_accept_dequeue() won't return the socket =
if it
is in the closed state, and so rfcomm_cleanup_listen() can't fully =
cleanup.
And if accept is called before rfcomm_cleanup_listen(), then (I think) =
the
socket will be unlinked from the accept queue (by accept) but not =
killed,
and so also will not get cleaned up.
Things appear to work if you reverse the order of steps 3 and 4.
I'd send you a patch if I had a simple one, but I don't know what the =
best
approach is. On solution may be to make bluez_accept_dequeue() always =
return
the socket regardless of state and then fix anything that calls
bluez_accept_dequeue() to handle the possibility of a closed socket =
being
returned.
-Daryl.
--- test code below ---
// bzt.c
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
int main(int argc, char *argv[])
{
struct sockaddr_rc loc_addr;
int s;
=09
if((s =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {
printf("Can't create server socket:
%s(%d)\n",strerror(errno), errno);
return -1;
}
=09
loc_addr.rc_family =3D AF_BLUETOOTH;
bacpy(&loc_addr.rc_bdaddr, BDADDR_ANY);
loc_addr.rc_channel =3D 1;
if(bind(s,(struct sockaddr *) &loc_addr, sizeof(loc_addr)) < 0) {
printf("Can't bind %s(%d)\n",strerror(errno), errno);
return -1;
}
=09
if(listen(s,10)) {
printf("Can't listen %s(%d)\n",strerror(errno),errno);
return -1;
}
=09
printf("Listening...\n");
while(1) sleep(999);
=09
return 0;
}
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
next reply other threads:[~2004-09-17 0:10 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-17 0:10 Daryl Van Vorst [this message]
2004-09-17 8:58 ` [Bluez-devel] Rfcomm Use Count Marcel Holtmann
2004-09-20 17:58 ` Daryl Van Vorst
2004-09-20 18:32 ` Marcel Holtmann
2004-09-20 18:52 ` Daryl Van Vorst
2004-09-20 19:48 ` Marcel Holtmann
2004-09-20 20:52 ` Daryl Van Vorst
2004-09-20 18:37 ` Daryl Van Vorst
2004-09-20 19:50 ` Marcel Holtmann
2004-09-20 20:11 ` Daryl Van Vorst
2004-09-20 20:34 ` Marcel Holtmann
2004-09-20 21:03 ` Daryl Van Vorst
2004-09-20 21:28 ` Marcel Holtmann
2004-09-20 22:38 ` Daryl Van Vorst
2004-09-20 23:33 ` Marcel Holtmann
2004-09-21 20:14 ` Daryl Van Vorst
2004-09-21 20:32 ` Marcel Holtmann
2004-09-21 20:39 ` Daryl Van Vorst
2004-09-21 21:26 ` Daryl Van Vorst
2004-09-21 22:07 ` Marcel Holtmann
2004-09-21 22:26 ` Marcel Holtmann
2004-09-21 22:44 ` Daryl Van Vorst
2004-09-22 11:08 ` Marcel Holtmann
2004-09-22 13:53 ` Marcel Holtmann
2004-09-22 17:57 ` Daryl Van Vorst
2004-09-22 18:12 ` Marcel Holtmann
2004-09-22 19:05 ` Daryl Van Vorst
2004-09-22 19:33 ` Marcel Holtmann
2004-09-22 19:52 ` Daryl Van Vorst
2004-09-22 19:57 ` Marcel Holtmann
2004-09-22 20:05 ` Daryl Van Vorst
[not found] ` <1096471423.20392.444.camel@igno>
2004-10-02 9:26 ` Marcel Holtmann
-- strict thread matches above, loose matches on Subject: below --
2004-09-13 19:06 [Bluez-devel] Rfcomm use count Daryl Van Vorst
2004-09-13 20:48 ` Daryl Van Vorst
2004-09-13 23:54 ` Daryl Van Vorst
2004-09-14 9:18 ` Marcel Holtmann
2004-09-14 21:58 ` Daryl Van Vorst
2004-08-31 22:09 Daryl Van Vorst
2004-09-08 22:48 ` Daryl Van Vorst
2004-09-08 23:10 ` Daryl Van Vorst
2004-09-12 14:15 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000c01c49c4a$ca42b9a0$1a01010a@baked' \
--to=daryl@wideray.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox