* [Bluez-devel] Fix for disconnection in new serial service
@ 2007-05-16 16:52 Frederic Danis
2007-05-20 13:11 ` Marcel Holtmann
0 siblings, 1 reply; 12+ messages in thread
From: Frederic Danis @ 2007-05-16 16:52 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 418 bytes --]
Hello,
I find a little bug preventing disconnection in new serial service.
Fred
--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic Access Company
Software engineer
Mail : mailto:frederic.danis@access-company.com
-----------------------------------------------
[-- Attachment #2: disconnection_serial.patch --]
[-- Type: text/x-patch, Size: 539 bytes --]
Index: serial/manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/serial/manager.c,v
retrieving revision 1.36
diff -a -u -r1.36 manager.c
--- serial/manager.c 15 May 2007 17:07:22 -0000 1.36
+++ serial/manager.c 16 May 2007 16:46:38 -0000
@@ -254,6 +254,7 @@
node->io_id = g_io_add_watch(io, G_IO_ERR | G_IO_NVAL | G_IO_HUP,
(GIOFunc) rfcomm_disconnect_cb, node);
+ g_io_channel_set_close_on_unref(io, TRUE);
connected_nodes = g_slist_append(connected_nodes, node);
[-- Attachment #3: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-16 16:52 [Bluez-devel] Fix for disconnection in new serial service Frederic Danis
@ 2007-05-20 13:11 ` Marcel Holtmann
2007-05-21 15:12 ` Claudio Takahasi
0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2007-05-20 13:11 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> I find a little bug preventing disconnection in new serial service.
can you check against latest CVS. I am not sure if Claudio fixed this or
not. Thanks.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-20 13:11 ` Marcel Holtmann
@ 2007-05-21 15:12 ` Claudio Takahasi
2007-05-22 16:59 ` Frederic Danis
0 siblings, 1 reply; 12+ messages in thread
From: Claudio Takahasi @ 2007-05-21 15:12 UTC (permalink / raw)
To: BlueZ development
On 5/20/07, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Frederic,
>
> > I find a little bug preventing disconnection in new serial service.
>
> can you check against latest CVS. I am not sure if Claudio fixed this or
> not. Thanks.
>
> Regards
>
> Marcel
Hi Frederic,
using g_io_channel_set_close_on_unref(io, TRUE) will trigger the
following warning for G_IO_NVAL condition:
(process:8085): GLib-WARNING **: Invalid file descriptor.
BR,
Claudio.
--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-21 15:12 ` Claudio Takahasi
@ 2007-05-22 16:59 ` Frederic Danis
2007-05-22 17:24 ` Marcel Holtmann
0 siblings, 1 reply; 12+ messages in thread
From: Frederic Danis @ 2007-05-22 16:59 UTC (permalink / raw)
To: BlueZ development
Claudio Takahasi wrote:
> On 5/20/07, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Frederic,
>>
>>> I find a little bug preventing disconnection in new serial service.
>> can you check against latest CVS. I am not sure if Claudio fixed this or
>> not. Thanks.
>>
>> Regards
>>
>> Marcel
>
> Hi Frederic,
>
> using g_io_channel_set_close_on_unref(io, TRUE) will trigger the
> following warning for G_IO_NVAL condition:
>
> (process:8085): GLib-WARNING **: Invalid file descriptor.
>
> BR,
> Claudio.
Hello Claudio,
I understand your comment.
But, I am trying to use the serial service and I do not understand one point :
after a ConnectService, the only way to disconnect it (disconnect rfcomm and acl), is by closing connection from remote side.
~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:05:06
string:spp
serial[1048]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
serial[1048]: Connect in progress
serial[1048]: rfcomm_connect_cb: connected
serial[1048]: name_listener_add(:1.28)
method return sender=:1.19 -> dest=:1.28
string "/dev/rfcomm0"
serial[1048]: Connect requestor :1.28 exited. Releasing /dev/rfcomm0 node
~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.DisconnectService string:/dev/rfcomm0
serial[1048]: /org/bluez/serial: org.bluez.serial.Manager.DisconnectService()
Error org.bluez.serial.Error.DoesNotExist: Invalid node
// Here, the RFComm connection is still up until remote side disconnect
How can I disconnect rfcomm (and acl) connection from local side (currently, the serial service has opened a file descriptor on /dev/rfcommX, that is close only
on remote disconnection, keeping up the /dev/rfcommX device) ?
What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
disconnect the bluetooth connection.
Hope I am clear
Regards
Fred
--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic Access Company
Software engineer
Mail : mailto:frederic.danis@access-company.com
-----------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 16:59 ` Frederic Danis
@ 2007-05-22 17:24 ` Marcel Holtmann
2007-05-22 19:06 ` Frédéric Danis
2007-05-23 18:15 ` Frederic Danis
0 siblings, 2 replies; 12+ messages in thread
From: Marcel Holtmann @ 2007-05-22 17:24 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> disconnect the bluetooth connection.
that is not the the use case for ConnectService and DisconnectService.
It is as simple as that. What you want is more like the CreatePort
methods that create persistent RFCOMM bindings.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 17:24 ` Marcel Holtmann
@ 2007-05-22 19:06 ` Frédéric Danis
2007-05-22 21:08 ` Marcel Holtmann
2007-05-23 18:15 ` Frederic Danis
1 sibling, 1 reply; 12+ messages in thread
From: Frédéric Danis @ 2007-05-22 19:06 UTC (permalink / raw)
To: BlueZ development
Hello Marcel,
>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>> disconnect the bluetooth connection.
>
> that is not the the use case for ConnectService and DisconnectService.
> It is as simple as that. What you want is more like the CreatePort
> methods that create persistent RFCOMM bindings.
Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
(that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
What I want to do is a non persistent rfcomm connection, only use "one-shot", but closable on local side.
Regards
Fred
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 19:06 ` Frédéric Danis
@ 2007-05-22 21:08 ` Marcel Holtmann
2007-05-22 22:11 ` Frederic Danis
0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2007-05-22 21:08 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> >> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >> disconnect the bluetooth connection.
> >
> > that is not the the use case for ConnectService and DisconnectService.
> > It is as simple as that. What you want is more like the CreatePort
> > methods that create persistent RFCOMM bindings.
>
> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
that is the use case this is designed for. If this doesn't seem to work
than it actually looks like a bug. Can you provide further information
for Claudio so he can debug it.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 21:08 ` Marcel Holtmann
@ 2007-05-22 22:11 ` Frederic Danis
2007-05-22 22:21 ` Marcel Holtmann
0 siblings, 1 reply; 12+ messages in thread
From: Frederic Danis @ 2007-05-22 22:11 UTC (permalink / raw)
To: BlueZ development
Hello Marcel, Claudio,
>>>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>>>> disconnect the bluetooth connection.
>>> that is not the the use case for ConnectService and DisconnectService.
>>> It is as simple as that. What you want is more like the CreatePort
>>> methods that create persistent RFCOMM bindings.
>> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
>> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
>> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
>
> that is the use case this is designed for. If this doesn't seem to work
> than it actually looks like a bug. Can you provide further information
> for Claudio so he can debug it.
To simply check this, I do :
- on remote, I create a SPP server :
frederic.danis@remote:~$ sdptool add --channel=5 sp
Serial Port service registered
frederic.danis@remote:~$ rfcomm listen 0 5
Waiting for connection on channel 5
- on local, I connect to remote using serial service :
~ # dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:serial
method return sender=:1.0 -> dest=:1.22
string ":1.19"
~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:04:05
string:spp
serial[1040]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
serial[1040]: Connect in progress
serial[1040]: rfcomm_connect_cb: connected
serial[1040]: name_listener_add(:1.23)
method return sender=:1.19 -> dest=:1.23
string "/dev/rfcomm0"
serial[1040]: Connect requestor :1.23 exited. Releasing /dev/rfcomm0 node
~ # ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 May 22 21:37 /dev/rfcomm0
- on remote I get :
Connection from 00:01:02:03:04:05 to /dev/rfcomm0
Press CTRL-C for hangup
As there is no program using /dev/rfcomm0, and it has been released at end of "ConnectService call by dbus-send", it should no more exist and rfcomm (and acl)
connection should be closed. It does not occur until pressing ctrl-c on remote. (I do not see any way to close the rfcomm connection from local)
- on local I have :
~ # hcitool con
Connections:
< ACL 00:01:02:03:04:05 handle 42 state 1 lm MASTER
~ # ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 May 22 21:37 /dev/rfcomm0
- I press ctrl-c on remote :
Disconnected
- on local I have :
~ # hcitool con
Connections:
~ # ls -l /dev/rfcomm0
ls: /dev/rfcomm0: No such file or directory
To me it seems that this bug is due to the file descriptor on /dev/rfcomm0 opened during connection and set in a g_io_channel. This file descriptor is not
closed before the g_io_channel is unreferenced (so reference to this file descriptor is lost, but still opened) preventing rfcomm stack to really release
connection.
Hope this helps,
Regards
Fred
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 22:11 ` Frederic Danis
@ 2007-05-22 22:21 ` Marcel Holtmann
2007-05-23 18:10 ` Frederic Danis
0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2007-05-22 22:21 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> >>>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >>>> disconnect the bluetooth connection.
> >>> that is not the the use case for ConnectService and DisconnectService.
> >>> It is as simple as that. What you want is more like the CreatePort
> >>> methods that create persistent RFCOMM bindings.
> >> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
> >> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
> >> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
> >
> > that is the use case this is designed for. If this doesn't seem to work
> > than it actually looks like a bug. Can you provide further information
> > for Claudio so he can debug it.
>
> To simply check this, I do :
>
> - on remote, I create a SPP server :
> frederic.danis@remote:~$ sdptool add --channel=5 sp
> Serial Port service registered
> frederic.danis@remote:~$ rfcomm listen 0 5
> Waiting for connection on channel 5
>
> - on local, I connect to remote using serial service :
> ~ # dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:serial
> method return sender=:1.0 -> dest=:1.22
> string ":1.19"
if the process goes away that called ConnectService() which is the care
here since dbus-send will exit from the system bus, the connection
should be automatically terminated. This is a meant to be cleanup of the
serial service.
> ~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:04:05
> string:spp
> serial[1040]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
> serial[1040]: Connect in progress
> serial[1040]: rfcomm_connect_cb: connected
> serial[1040]: name_listener_add(:1.23)
Claudio, this is way to late to call name_listener_add(). You need to
call it during the method call actually.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-22 17:24 ` Marcel Holtmann
2007-05-22 19:06 ` Frédéric Danis
@ 2007-05-23 18:15 ` Frederic Danis
2007-05-23 20:32 ` Marcel Holtmann
1 sibling, 1 reply; 12+ messages in thread
From: Frederic Danis @ 2007-05-23 18:15 UTC (permalink / raw)
To: BlueZ development
Hello Marcel,
>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>> disconnect the bluetooth connection.
>
> that is not the the use case for ConnectService and DisconnectService.
> It is as simple as that. What you want is more like the CreatePort
> methods that create persistent RFCOMM bindings.
>
Regarding the Serial service API, I am not sure to understand difference between ConnectService and CreatePort.
Is it possible to use port like this : CreatePort, open rfcomm, RemovePort, use file descriptor on rfcomm, than close it (that should disconnect bluetooth) ?
Regards
Fred
-----------------------------------------------
Danis Frederic Access Company
Software engineer
Mail : mailto:frederic.danis@access-company.com
-----------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Bluez-devel] Fix for disconnection in new serial service
2007-05-23 18:15 ` Frederic Danis
@ 2007-05-23 20:32 ` Marcel Holtmann
0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2007-05-23 20:32 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> >> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >> disconnect the bluetooth connection.
> >
> > that is not the the use case for ConnectService and DisconnectService.
> > It is as simple as that. What you want is more like the CreatePort
> > methods that create persistent RFCOMM bindings.
> >
>
> Regarding the Serial service API, I am not sure to understand difference between ConnectService and CreatePort.
> Is it possible to use port like this : CreatePort, open rfcomm, RemovePort, use file descriptor on rfcomm, than close it (that should disconnect bluetooth) ?
the CreatePort is a permanent binding that will be even restored after
reboot. The ConnectService is one-time use when you can't use the RFCOMM
socket directly or need a TTY. The advantage of ConnectService is that
the daemons cleans up after your process exits.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-05-23 20:32 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-16 16:52 [Bluez-devel] Fix for disconnection in new serial service Frederic Danis
2007-05-20 13:11 ` Marcel Holtmann
2007-05-21 15:12 ` Claudio Takahasi
2007-05-22 16:59 ` Frederic Danis
2007-05-22 17:24 ` Marcel Holtmann
2007-05-22 19:06 ` Frédéric Danis
2007-05-22 21:08 ` Marcel Holtmann
2007-05-22 22:11 ` Frederic Danis
2007-05-22 22:21 ` Marcel Holtmann
2007-05-23 18:10 ` Frederic Danis
2007-05-23 18:15 ` Frederic Danis
2007-05-23 20:32 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox