From: Valmantas <walmis@gmail.com>
To: Bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] bluetoothd-service-network fails to execute ifup scripts from network.conf after repeated connection attempts (Patched)
Date: Tue, 29 Apr 2008 23:42:39 +0300 [thread overview]
Message-ID: <1209501760.14773.13.camel@ubuntu> (raw)
[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]
After connecting to a server once, the relevent scripts in network.conf
are executed, and pan* and bnep* interfaces come up, but when you
disconnect and
reconnect the second time, neither the script gets executed, nor the
interface comes up and this makes the connection unusable. (You would
have to manually bring it up with "ifconfig bnep0 up" )
Also PANU role script does not get executed, ever, on incoming
connections, fixed in patch.
Example:
i have /etc/bluetooth/network.conf
[General]
[PANU Role]
Script=/usr/bin/my-ifup
[GN Role]
Script=/usr/bin/my-ifup
[NAP Role]
Script=/usr/bin/my-ifup
Connection 1 ( server pan0 (GN) )
my-ifup gets executed with pan0 argument
Disconnect / Connect 2 ( server pan0 (GN) )
No execution
Correct behaviour:
Connection 1 ( server pan0 (GN) )
my-ifup gets executed with pan0 argument
my-ifup gets executed with bnep0 argument
Disconnect / Connect 2 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument
Disconnect / Connect 3 ( server pan0 (GN) )
my-ifup gets executed with bnep0 argument
[-- Attachment #2: 008_ifup_script_execution_fix.patch --]
[-- Type: text/x-patch, Size: 2578 bytes --]
--- network/server.c.orig 2008-02-10 21:38:30.000000000 +0200
+++ network/server.c 2008-04-29 22:39:37.000000000 +0300
@@ -344,7 +344,7 @@
goto failed;
}
- bnep_if_up(devname, 0);
+ bnep_if_up(devname, ns->id);
} else
bnep_if_up(devname, ns->id);
--- network/common.c.orig 2008-02-02 01:16:33.000000000 +0200
+++ network/common.c 2008-04-29 23:27:07.000000000 +0300
@@ -81,13 +81,34 @@
return strcmp(data->devname, devname);
}
-static void script_exited(GPid pid, gint status, gpointer data)
+static gint find_devname_by_pid(gconstpointer a, gconstpointer b)
{
+ struct bnep_data *data = (struct bnep_data *) a;
+ const GPid* pid= (GPid*)b;
+
+ if(data->pid == *pid) return 0;
+ if(data->pid > *pid) return 1;
+ if(data->pid < *pid) return -1;
+}
+
+static void script_exited(GPid pid, gint status, gpointer data)
+{
+ struct bnep_data *bnep;
+
if (WIFEXITED(status))
debug("%d exited with status %d", pid, WEXITSTATUS(status));
else
debug("%d was killed by signal %d", pid, WTERMSIG(status));
-
+
+
+ GSList* l = g_slist_find_custom(pids, &pid, find_devname_by_pid);
+
+ bnep = l->data;
+
+ info("Resetting PID - %s %d", bnep->devname, bnep->pid);
+
+ bnep->pid = 0;
+
g_spawn_close_pid(pid);
}
@@ -231,24 +252,27 @@
struct bnep_data *bnep;
GSpawnFlags flags;
GSList *l;
-
+
/* Check if a script is running */
- if ((l = g_slist_find_custom(pids, devname, find_devname))) {
+
+ l = g_slist_find_custom(pids, devname, find_devname);
+ if ( l != NULL ) {
bnep = l->data;
-
- if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
- argv[0] = bnep->script;
- argv[1] = devname;
- argv[2] = "--refresh";
- argv[3] = NULL;
-
- flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
- g_spawn_async(NULL, (char **) argv, NULL, flags,
- bnep_setup, (gpointer) devname, &pid,
- NULL);
+ if(bnep->pid != 0) {
+ if (bnep->script && !strcmp(bnep->script, "avahi-autoipd")) {
+ argv[0] = bnep->script;
+ argv[1] = devname;
+ argv[2] = "--refresh";
+ argv[3] = NULL;
+
+ flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
+ g_spawn_async(NULL, (char **) argv, NULL, flags,
+ bnep_setup, (gpointer) devname, &pid,
+ NULL);
+ }
+ info("%s script is running", devname);
+ return bnep->pid;
}
-
- return bnep->pid;
}
sd = socket(AF_INET6, SOCK_DGRAM, 0);
@@ -315,7 +339,7 @@
GSList *l;
GSpawnFlags flags;
const char *argv[4];
-
+ info("bringing down %s", devname);
l = g_slist_find_custom(pids, devname, find_devname);
if (!l)
return 0;
[-- Attachment #3: Type: text/plain, Size: 320 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
[-- 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
next reply other threads:[~2008-04-29 20:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-29 20:42 Valmantas [this message]
2008-04-30 2:06 ` [Bluez-devel] bluetoothd-service-network fails to execute ifup scripts from network.conf after repeated connection attempts (Patched) Luiz Augusto von Dentz
2008-04-30 6:33 ` walmis
2008-04-30 9:45 ` Valmantas
2008-04-30 18:37 ` Luiz Augusto von Dentz
2008-04-30 19:36 ` Valmantas
2008-04-30 19:38 ` Valmantas
2008-05-06 22:27 ` Luiz Augusto von Dentz
2008-05-08 5:56 ` walmis
2008-05-08 9:55 ` [Bluez-devel] BlueZ API Documentation Saurabh.Mukadam
2008-05-08 13:43 ` [Bluez-devel] bluetoothd-service-network fails to execute ifup scripts from network.conf after repeated connection attempts (Patched) Luiz Augusto von Dentz
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=1209501760.14773.13.camel@ubuntu \
--to=walmis@gmail.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;
as well as URLs for NNTP newsgroup(s).