Skip to contentSkip to conversation

Fix reference handling in hfp_ag

PATCH In review Frédéric Dalleau 2 participants 4 messages Feb 17, 2011

lore
Share & tools
lore
#0 lore raw

cover Fix reference handling in hfp_ag

Hi, these patch fixes reference handling in hfp_ag.

First patch makes sure that GATServer properly disconnects client when modem is put offline.

Second patch fixes a Glib warning about a socket closed twice. dun_gw may need something similar.

Frédéric Dalleau (2):
emulator: unref GIOChannel after creation
hfp_ag: Do not close client fd on unref

 plugins/hfp_ag.c |    9 +--------
 src/emulator.c   |    2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
#1 lore raw

PATCH 1/2 emulator: unref GIOChannel after creation

---
 src/emulator.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
src/emulator.c +2 -0
index 567692d..5744903 100644
@@ -75,6 +75,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 	if (em->server == NULL)
 		return;
 
+	g_io_channel_unref(io);
+
 	g_at_server_set_debug(em->server, emulator_debug, "Server");
 	g_at_server_set_disconnect_function(em->server,
 						emulator_disconnect, em);
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 hfp_ag: Do not close client fd on unref

In reply to Frédéric Dalleau
---
 plugins/hfp_ag.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
plugins/hfp_ag.c +1 -9
index cbf3ccd..cb4a0be 100644
@@ -40,7 +40,6 @@
 static struct server *server;
 static guint modemwatch_id;
 static GList *modems;
-static guint channel_watch;
 
 static const gchar *hfp_ag_record =
 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
@@ -86,12 +85,6 @@ static const gchar *hfp_ag_record =
 "  </attribute>\n"
 "</record>\n";
 
-static gboolean hfp_ag_disconnect_cb(GIOChannel *io, GIOCondition cond,
-							gpointer user_data)
-{
-	return FALSE;
-}
-
 static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
 	struct ofono_modem *modem;
@@ -118,8 +111,7 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 	fd = g_io_channel_unix_get_fd(io);
 	ofono_emulator_register(em, fd);
 
-	channel_watch = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR,
-					hfp_ag_disconnect_cb, NULL);
+	g_io_channel_set_close_on_unref(io, FALSE);
 
 	return;
 
Signature · 1 line
1.7.1
#3 lore raw
In reply to Frédéric Dalleau

Hi Frédéric,

Quoted 8 lines · Frédéric Dalleau

Hi, these patch fixes reference handling in hfp_ag.

First patch makes sure that GATServer properly disconnects client when modem is put offline.

Second patch fixes a Glib warning about a socket closed twice. dun_gw may need something similar.

Quoted 8 lines

Frédéric Dalleau (2):
emulator: unref GIOChannel after creation
hfp_ag: Do not close client fd on unref

 plugins/hfp_ag.c |    9 +--------
 src/emulator.c   |    2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)

Both patches have been applied, thanks.

Regards,
-Denis