summaryrefslogtreecommitdiffstats
path: root/gatchat/gatppp.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-04-09 12:15:37 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-04-13 12:03:32 -0500
commit36d15b4366823f59276c6d45ab4ad581a19c3bc4 (patch)
tree9226508ff203eb576dc8fd19ce1e34daee4aea03 /gatchat/gatppp.c
parent79d81af43119a5b47715a9888191102a733ddd74 (diff)
downloadofono-36d15b4366823f59276c6d45ab4ad581a19c3bc4.tar.bz2
ppp: Keep track when read watcher dies
Diffstat (limited to 'gatchat/gatppp.c')
-rw-r--r--gatchat/gatppp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 8b1fb468..0215649a 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -321,7 +321,8 @@ static void ppp_record(GAtPPP *ppp, gboolean in, guint8 *data, guint16 length)
err = write(ppp->record_fd, data, length);
}
-static gboolean ppp_cb(GIOChannel *channel, GIOCondition cond, gpointer data)
+static gboolean ppp_read_cb(GIOChannel *channel, GIOCondition cond,
+ gpointer data)
{
GAtPPP *ppp = data;
GIOStatus status;
@@ -443,6 +444,11 @@ void ppp_generate_event(GAtPPP *ppp, enum ppp_event event)
}
}
+static void read_watcher_destroy_notify(GAtPPP *ppp)
+{
+ ppp->read_watch = 0;
+}
+
void ppp_set_auth(GAtPPP *ppp, const guint8* auth_data)
{
guint16 proto = get_host_short(auth_data);
@@ -615,9 +621,10 @@ GAtPPP *g_at_ppp_new(GIOChannel *modem)
ppp->net = ppp_net_new(ppp);
/* start listening for packets from the modem */
- ppp->read_watch = g_io_add_watch(modem,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- ppp_cb, ppp);
+ ppp->read_watch = g_io_add_watch_full(modem, G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ ppp_read_cb, ppp,
+ (GDestroyNotify)read_watcher_destroy_notify);
ppp->record_fd = -1;