All of lore.kernel.org
 help / color / mirror / Atom feed
* Profile1 close question
@ 2017-12-14  0:13 John Klug
  2017-12-14 15:21 ` John Klug
  0 siblings, 1 reply; 4+ messages in thread
From: John Klug @ 2017-12-14  0:13 UTC (permalink / raw)
  To: linux-bluetooth

The file descriptor that is placed as a parameter to the NewConnection
callback does not close the connection when it is called with the OS's
close.  This is using Bluez 5.47 on Linux.

Bluetoothctl still shows the connection as being up, as does the remote.

What method should one use to close the connection?

I am using Python and GObject Introspection.

Before connection:
rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]

After Connection:
NewConnection(/org/bluez/hci0/dev_BC_44_86_56_6B_95, 8)

rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
rw.py   3983 root    8u     sock        0,7      0t0 23050 protocol: RFCOMM

After Close:
rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]


Device BC:44:86:56:6B:95
...
Connected: yes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Profile1 close question
  2017-12-14  0:13 Profile1 close question John Klug
@ 2017-12-14 15:21 ` John Klug
  2017-12-14 15:35   ` Szymon Janc
  0 siblings, 1 reply; 4+ messages in thread
From: John Klug @ 2017-12-14 15:21 UTC (permalink / raw)
  To: linux-bluetooth

What is holding the connection open is bluetoothd.

After closing the file descriptor for RFCOMM, there are two file
descriptors in the Bluetooth daemon that are left:

bluetooth 1406 root   18u     sock        0,7      0t0 26587 protocol: RFCOMM
bluetooth 1406 root   19u     sock        0,7      0t0 26602 protocol: RFCOMM

By terminating the application these go away, but what if I wish to
keep the daemon running?  How do I tell the Bluetooth daemon to close
the RFCOMM sockets?

On Wed, Dec 13, 2017 at 6:13 PM, John Klug <ski.brimson@gmail.com> wrote:
> The file descriptor that is placed as a parameter to the NewConnection
> callback does not close the connection when it is called with the OS's
> close.  This is using Bluez 5.47 on Linux.
>
> Bluetoothctl still shows the connection as being up, as does the remote.
>
> What method should one use to close the connection?
>
> I am using Python and GObject Introspection.
>
> Before connection:
> rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
>
> After Connection:
> NewConnection(/org/bluez/hci0/dev_BC_44_86_56_6B_95, 8)
>
> rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
> rw.py   3983 root    8u     sock        0,7      0t0 23050 protocol: RFCOMM
>
> After Close:
> rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
>
>
> Device BC:44:86:56:6B:95
> ...
> Connected: yes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Profile1 close question
  2017-12-14 15:21 ` John Klug
@ 2017-12-14 15:35   ` Szymon Janc
  2017-12-14 16:08     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Szymon Janc @ 2017-12-14 15:35 UTC (permalink / raw)
  To: John Klug; +Cc: linux-bluetooth

Hi John,

On Thursday, 14 December 2017 16:21:32 CET John Klug wrote:
> What is holding the connection open is bluetoothd.
> 
> After closing the file descriptor for RFCOMM, there are two file
> descriptors in the Bluetooth daemon that are left:
> 
> bluetooth 1406 root   18u     sock        0,7      0t0 26587 protocol:
> RFCOMM bluetooth 1406 root   19u     sock        0,7      0t0 26602
> protocol: RFCOMM
> 
> By terminating the application these go away, but what if I wish to
> keep the daemon running?  How do I tell the Bluetooth daemon to close
> the RFCOMM sockets?

I think you need to shutdown() socket.

> 
> On Wed, Dec 13, 2017 at 6:13 PM, John Klug <ski.brimson@gmail.com> wrote:
> > The file descriptor that is placed as a parameter to the NewConnection
> > callback does not close the connection when it is called with the OS's
> > close.  This is using Bluez 5.47 on Linux.
> > 
> > Bluetoothctl still shows the connection as being up, as does the remote.
> > 
> > What method should one use to close the connection?
> > 
> > I am using Python and GObject Introspection.
> > 
> > Before connection:
> > rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> > rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> > rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
> > 
> > After Connection:
> > NewConnection(/org/bluez/hci0/dev_BC_44_86_56_6B_95, 8)
> > 
> > rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> > rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> > rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
> > rw.py   3983 root    8u     sock        0,7      0t0 23050 protocol:
> > RFCOMM
> > 
> > After Close:
> > rw.py   3983 root    0u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    1u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    2u      CHR      136,3      0t0     6 /dev/pts/3
> > rw.py   3983 root    3u     unix 0xceaf54a0      0t0 22976 type=STREAM
> > rw.py   3983 root    4u  a_inode        0,9        0     7 [eventfd]
> > rw.py   3983 root    5u  a_inode        0,9        0     7 [eventfd]
> > 
> > 
> > Device BC:44:86:56:6B:95
> > ...
> > Connected: yes
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Profile1 close question
  2017-12-14 15:35   ` Szymon Janc
@ 2017-12-14 16:08     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2017-12-14 16:08 UTC (permalink / raw)
  To: Szymon Janc; +Cc: John Klug, linux-bluetooth

Hi John,

On Thu, Dec 14, 2017 at 1:35 PM, Szymon Janc <szymon.janc@codecoup.pl> wrote:
> Hi John,
>
> On Thursday, 14 December 2017 16:21:32 CET John Klug wrote:
>> What is holding the connection open is bluetoothd.
>>
>> After closing the file descriptor for RFCOMM, there are two file
>> descriptors in the Bluetooth daemon that are left:
>>
>> bluetooth 1406 root   18u     sock        0,7      0t0 26587 protocol:
>> RFCOMM bluetooth 1406 root   19u     sock        0,7      0t0 26602
>> protocol: RFCOMM
>>
>> By terminating the application these go away, but what if I wish to
>> keep the daemon running?  How do I tell the Bluetooth daemon to close
>> the RFCOMM sockets?
>
> I think you need to shutdown() socket.

Yep, shutdown must be used since bluetoothd keeps a reference in case
it has to disconnect and to keep track of the service state. We should
perhaps document that we expect the user application to shutdown the
fd in case it want it to be disconnected.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-14 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14  0:13 Profile1 close question John Klug
2017-12-14 15:21 ` John Klug
2017-12-14 15:35   ` Szymon Janc
2017-12-14 16:08     ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.