bluetoothd-service-network fails to execute ifup scripts from network.conf after repeated connection attempts (Patched)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--- 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;
-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bluez-devel

[Index of Archives]     [Linux Bluetooth Devel]     [Linux USB Devel]     [Network Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux