public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Shiraishi <tetsu@s-direct.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] rfcomm bind : Address already in use
Date: Tue, 13 Jul 2004 02:16:34 +0900	[thread overview]
Message-ID: <4.3.2-J.20040713015123.0463e378@emi.s-direct.com> (raw)
In-Reply-To: <1089481271.13519.71.camel@pegasus>

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

Hi Marcel,

At 04/07/10 19:41 +0200, Marcel Holtmann wrote:
>
>you should have mentioned that, because dund creates a /dev/rfcommX
>device node for starting PPP. Maybe there is a leftover, which leaves
>the DLC open and so the session can't be terminated. Maybe a running
>pppd holds the socket descriptor open.
>
>But I won't have time to look into that in detail. If you provide me a
>patch for dund or for the kernel RFCOMM part, I will review it.
>

I tried to make patch for this.

Thanks,

Tetsuo

[-- Attachment #2: bluez_sock_garbage.patch --]
[-- Type: application/octet-stream, Size: 2102 bytes --]

diff -urN linux-2.4.24-org/include/net/bluetooth/rfcomm.h linux-2.4.24-test1/include/net/bluetooth/rfcomm.h
--- linux-2.4.24-org/include/net/bluetooth/rfcomm.h	Sat Nov 29 03:26:21 2003
+++ linux-2.4.24-test1/include/net/bluetooth/rfcomm.h	Tue Jul 13 00:10:29 2004
@@ -317,6 +317,7 @@
 void rfcomm_cleanup_sockets(void);
 
 int  rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc **d);
+void rfcomm_sock_cleanup_garbage (struct rfcomm_dlc *d);
 
 /* ---- RFCOMM TTY ---- */
 #define RFCOMM_MAX_DEV  256
diff -urN linux-2.4.24-org/net/bluetooth/rfcomm/core.c linux-2.4.24-test1/net/bluetooth/rfcomm/core.c
--- linux-2.4.24-org/net/bluetooth/rfcomm/core.c	Mon May 24 23:24:12 2004
+++ linux-2.4.24-test1/net/bluetooth/rfcomm/core.c	Tue Jul 13 00:14:23 2004
@@ -365,6 +365,7 @@
 		rfcomm_dlc_unlock(d);
 
 		skb_queue_purge(&d->tx_queue);
+		rfcomm_sock_cleanup_garbage (d);
 		rfcomm_dlc_unlink(d);
 	}
 
diff -urN linux-2.4.24-org/net/bluetooth/rfcomm/sock.c linux-2.4.24-test1/net/bluetooth/rfcomm/sock.c
--- linux-2.4.24-org/net/bluetooth/rfcomm/sock.c	Mon Aug 25 20:44:44 2003
+++ linux-2.4.24-test1/net/bluetooth/rfcomm/sock.c	Tue Jul 13 00:17:44 2004
@@ -110,6 +110,18 @@
 }
 
 /* ---- Socket functions ---- */
+struct sock *__rfcomm_get_sock_by_dlc(struct rfcomm_dlc *d, bdaddr_t *src)
+{
+	struct sock *sk;
+
+	for (sk = rfcomm_sk_list.head; sk; sk = sk->next) {
+		if (rfcomm_pi(sk)->dlc == d && 
+				!bacmp(&bluez_pi(sk)->src, src))
+			break;
+	}
+
+	return sk;
+}
 static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
 {
 	struct sock *sk;
@@ -244,6 +256,23 @@
 	lock_sock(sk);
 	__rfcomm_sock_close(sk);
 	release_sock(sk);
+}
+
+void rfcomm_sock_cleanup_garbage (struct rfcomm_dlc *d)
+{
+	struct rfcomm_session *s = d->session;
+	struct sock *sk;
+	bdaddr_t src, dst;
+
+	if (!s)
+		return;
+
+	rfcomm_session_getaddr(s, &src, &dst);
+	sk = __rfcomm_get_sock_by_dlc (d, &src);
+	if (sk && sk->state == BT_CLOSED) {
+		rfcomm_sock_close (sk);
+		rfcomm_sock_kill (sk);
+	}
 }
 
 static void rfcomm_sock_init(struct sock *sk, struct sock *parent)

[-- Attachment #3: Type: text/plain, Size: 93 bytes --]


//
//   Tetsuo Shiraishi tetsu@s-direct.com
//                    tshiro@arion.ocn.ne.jp
//

  reply	other threads:[~2004-07-12 17:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-09 17:21 [Bluez-devel] rfcomm bind : Address already in use Tetsuo Shiraishi
2004-07-09 18:13 ` Marcel Holtmann
2004-07-10 14:11   ` Tetsuo Shiraishi
2004-07-10 17:41     ` Marcel Holtmann
2004-07-12 17:16       ` Tetsuo Shiraishi [this message]
2004-07-12 18:26         ` Marcel Holtmann
2004-07-14  9:12           ` Tetsuo Shiraishi

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=4.3.2-J.20040713015123.0463e378@emi.s-direct.com \
    --to=tetsu@s-direct.com \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=marcel@holtmann.org \
    /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