From ea56a7106759bb519775081bb90618fbcf91879e Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 28 Feb 2011 14:26:26 -0600 Subject: [PATCH] gatppp: Delay signaling ppp_down Delay signaling of ppp_down until we exit the GAtHDLC read handler. Otherwise exchanging the read handler on GAtIO might lead to funny double consumption problems. --- gatchat/gatppp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 21456bd..f8b329b 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -75,6 +75,7 @@ struct _GAtPPP { GAtDebugFunc debugf; gpointer debug_data; gboolean sta_pending; + guint ppp_dead_source; }; void ppp_debug(GAtPPP *ppp, const char *str) @@ -85,14 +86,20 @@ void ppp_debug(GAtPPP *ppp, const char *str) ppp->debugf(str, ppp->debug_data); } -static void ppp_dead(GAtPPP *ppp) +static gboolean ppp_dead(gpointer userdata) { + GAtPPP *ppp = userdata; + DBG(ppp, ""); + ppp->ppp_dead_source = 0; + /* notify interested parties */ if (ppp->disconnect_cb) ppp->disconnect_cb(ppp->disconnect_reason, ppp->disconnect_data); + + return FALSE; } static void sta_sent(gpointer userdata) @@ -243,7 +250,7 @@ static inline void ppp_enter_phase(GAtPPP *ppp, enum ppp_phase phase) ppp->phase = phase; if (phase == PPP_PHASE_DEAD && ppp->sta_pending == FALSE) - ppp_dead(ppp); + ppp->ppp_dead_source = g_idle_add(ppp_dead, ppp); } void ppp_set_auth(GAtPPP *ppp, const guint8* auth_data) @@ -498,6 +505,11 @@ void g_at_ppp_unref(GAtPPP *ppp) lcp_free(ppp->lcp); ipcp_free(ppp->ipcp); + if (ppp->ppp_dead_source) { + g_source_remove(ppp->ppp_dead_source); + ppp->ppp_dead_source = 0; + } + g_at_hdlc_unref(ppp->hdlc); g_free(ppp); -- 2.7.4