Skip to contentSkip to conversation

killing a persisted pand session

Bluez-users wim delvaux 2 participants 13 messages Mar 6, 2004 – Mar 7, 2004 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi all,

If i run

pand --persist --connect XXXX

this means that pand will try to reestablish the connection to XXX whenever it needs to.

Now I want to terminate that application.

Should I run

pand -k XXX ?

or

pand -K ?

or

kill pidof pand ( or a bit more complicated)

I have tried

pand -k

which seems the most logical but this only closes the connection which then gets reestablished after the interval timeout (5 secs). I would expect a -k to really 'kill' the connection and terminate the corresponding pand

W

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#1 lore raw

Hi Wim,

Quoted 21 lines

If i run

pand --persist --connect XXXX

this means that pand will try to reestablish the connection to XXX whenever it needs to.

Now I want to terminate that application.

Should I run

pand -k XXX ?

or

pand -K ?

or

kill pidof pand ( or a bit more complicated)

Quoted 7 lines

I have tried

pand -k

which seems the most logical but this only closes the connection which then gets reestablished after the interval timeout (5 secs). I would expect a -k to really 'kill' the connection and terminate the corresponding pand

you have to kill the pand process first and then run 'pand -k' to kill the active connections.

Or you extend pand that it will kill the current connection by itself if it receives SIG_TERM. Patches are welcome ;)

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#2 lore raw
Quoted 6 lines

you have to kill the pand process first and then run 'pand -k' to kill the active connections.

Or you extend pand that it will kill the current connection by itself if it receives SIG_TERM. Patches are welcome ;)

Ah so it means that pand -k does not send anything to the pand that is
running . pand --connect just does something to create the connection.

If that is the case why doesn't pand without --persist return after the connection was established ?

W

maintainer
#3 lore raw

Hi Wim,

Quoted 5 lines

Ah so it means that pand -k does not send anything to the pand that is
running . pand --connect just does something to create the connection.

If that is the case why doesn't pand without --persist return after the connection was established ?

what are you talking about? After pand has established the connection it hands it over to the kernel BNEP module and exit.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#4 lore raw
Quoted 10 lines · Marcel Holtmann

Hi Wim,

Quoted 5 lines

Ah so it means that pand -k does not send anything to the pand that is
running . pand --connect just does something to create the connection.

If that is the case why doesn't pand without --persist return after the connection was established ?

what are you talking about? After pand has established the connection it hands it over to the kernel BNEP module and exit.

I was wondering WHY pand is kept running after the BNEP is set up. For the persist option I can understand since i presume pand monitors the connection it had to establish and if it 'downs' it restarts it. However if this feature is NOT requested (i.e. no --presist is given), then WHY is pand
still alive after the setup of the connection.

The reason for this question is that I was trying to determine a fail safe integration into hotplug/interfaces. Seems that if you pand -k the bnep module is deactivated and ifdown does no longer work properly (and hence the dhcp server is not stopped properly and does not RELEASE its lease)

I have noticed something else here. I am testing BT between my Ipaq and a usb BT dongle. When I suspend my Ipaq the pand on my desktop (the one that is listening) blocks on an ioctl after it receives the connection request. (I
checked with strace on that listening pand)

The iotcl that blocks is the one in bnep_connadd. Because of this blocking
(for I do not know what reason) the connection is not established (no IP is set up)

static int bnep_connadd(int sk, uint16_t role, char *dev)

{
        struct bnep_connadd_req req;

        strcpy(req.device, dev);
        req.sock = sk;
        req.role = role;
        /* THIS IS THE ONE THAT BLOCKS */
        if (ioctl(ctl, bnepconnadd, &req))
                return -1;
        strcpy(dev, req.device);
        return 0;
}

Do you know what that ioctl is supposed to do and why it blocks on something

Quoted 4 lines

Regards

Marcel

maintainer
#5 lore raw
In reply to wim delvaux

Hi Wim,

Quoted 5 lines

I was wondering WHY pand is kept running after the BNEP is set up. For the persist option I can understand since i presume pand monitors the connection it had to establish and if it 'downs' it restarts it. However if this feature is NOT requested (i.e. no --presist is given), then WHY is pand
still alive after the setup of the connection.

if you don't use --presist the "pand --connect" process exit after the full BNEP connection is established. Try "--nodetach" to see it.

Quoted 4 lines

The reason for this question is that I was trying to determine a fail safe integration into hotplug/interfaces. Seems that if you pand -k the bnep module is deactivated and ifdown does no longer work properly (and hence the dhcp server is not stopped properly and does not RELEASE its lease)

If the BNEP connection is deleted you get a remove event from net.agent hotplug script. If you have problems with DHCP put a bridge interface above your bnep0 interface.

Quoted 22 lines

I have noticed something else here. I am testing BT between my Ipaq and a usb BT dongle. When I suspend my Ipaq the pand on my desktop (the one that is listening) blocks on an ioctl after it receives the connection request. (I
checked with strace on that listening pand)

The iotcl that blocks is the one in bnep_connadd. Because of this blocking
(for I do not know what reason) the connection is not established (no IP is set up)

static int bnep_connadd(int sk, uint16_t role, char *dev)

{
        struct bnep_connadd_req req;

        strcpy(req.device, dev);
        req.sock = sk;
        req.role = role;
        /* THIS IS THE ONE THAT BLOCKS */
        if (ioctl(ctl, bnepconnadd, &req))
                return -1;
        strcpy(dev, req.device);
        return 0;
}
Quoted 1 line

Do you know what that ioctl is supposed to do and why it blocks on something

This ioctl gives the control of your incoming connection to the kernel BNEP module, but I don't know why it can block.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#7 lore raw
In reply to wim delvaux

Hi Wim,

Quoted 3 lines

When the ioctl locks I get the following dmesg

unregister_netdevice: waiting for bnep0 to become free. Usage count = 2

then your suspend don't clean up everything. What kernel are you using? Maybe it is impossible to do a suspend while you have a BNEP connection opened.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#10 lore raw
In reply to wim delvaux

Hi Wim,

Quoted 2 lines

I also have a lot of 'dead' pand --listens haning around in the process table (perhaps a pointer error caused the module to become dangling ???)

when do you start your "pand --listen"? Don't start it from bluetooth.agent script.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#8 lore raw
In reply to Marcel Holtmann
Quoted 9 lines · Marcel Holtmann

Hi Wim,

Quoted 3 lines

When the ioctl locks I get the following dmesg

unregister_netdevice: waiting for bnep0 to become free. Usage count = 2

then your suspend don't clean up everything. What kernel are you using? Maybe it is impossible to do a suspend while you have a BNEP connection opened.

it is the Ipaq that suspends and the desktop that hangs ! Ipaq 2.4.19 Desktop 2.6.4.rc2 (bleeding edge !)

I do not do a real suspend. I bring the network down using a script in the suspend_scripts dir and bring it back up in the resume

W

#11 lore raw
In reply to Marcel Holtmann
Quoted 7 lines · Marcel Holtmann

Hi Wim,

Quoted 2 lines

I also have a lot of 'dead' pand --listens haning around in the process table (perhaps a pointer error caused the module to become dangling ???)

when do you start your "pand --listen"? Don't start it from bluetooth.agent script.

Ah that might be the problem. Indeed it is started from there.

Why ? As said I have a dongle that gets inserted and removed frequently. Therefore I wanted the hcid/sdpd/pand thing to start when the dongle is inserted. so I added the start / stop of these apps to the bluetooth.agent script.

case $ACTION in
add|register)
# start bluetooth daemons
sh -x /etc/init.d/bluez-utils start
sleep 1
sh -x /etc/init.d/bluez-sdp start
sleep 1
sh -x /etc/init.d/bluez-pan start

# install remover
#echo "set -x" > $REMOVER
#echo 'exec 2> /tmp/HCI_REMOVE' >> $REMOVER #echo "/etc/init.d/bluez-pan stop" >> $REMOVER #echo "/etc/init.d/bluez-sdp stop" >> $REMOVER #echo "/etc/init.d/bluez-utils stop" >> $REMOVER #chmod 700 $REMOVER
;;
unregister)
/etc/init.d/bluez-pan stop /etc/init.d/bluez-sdp stop /etc/init.d/bluez-utils stop
;;
esac

Quoted 4 lines

Regards

Marcel

maintainer
#12 lore raw

Hi Wim,

Quoted 9 lines
Quoted 2 lines

when do you start your "pand --listen"? Don't start it from bluetooth.agent script.

Ah that might be the problem. Indeed it is started from there.

Why ? As said I have a dongle that gets inserted and removed frequently. Therefore I wanted the hcid/sdpd/pand thing to start when the dongle is inserted. so I added the start / stop of these apps to the bluetooth.agent script.

all these daemons can run all the time, even when no dongle is inserted. Start them from /etc/init.d/... and not from bluetooth.agent, because the hotplug stuff is not for starting daemons. It is for device configuration.

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users