* [PATCH] gatio: do not read if no read_handler
@ 2010-05-03 22:45 Kristen Carlson Accardi
2010-05-10 14:11 ` Denis Kenzior
0 siblings, 1 reply; 6+ messages in thread
From: Kristen Carlson Accardi @ 2010-05-03 22:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]
If no read_handler specified, leave data alone in case someone
else wants to read it.
---
gatchat/gatio.c | 4 ++++
gatchat/gsmdial.c | 12 ++++--------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/gatchat/gatio.c b/gatchat/gatio.c
index 61b0260..b4a3806 100644
--- a/gatchat/gatio.c
+++ b/gatchat/gatio.c
@@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
if (cond & G_IO_NVAL)
return FALSE;
+ /* if nobody wants this data, leave it alone */
+ if (io->read_handler == NULL)
+ return TRUE;
+
/* Regardless of condition, try to read all the data available */
do {
toread = ring_buffer_avail_no_wrap(io->buf);
diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index a531aa3..5fb406d 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -235,6 +235,8 @@ static void ppp_connect(const char *iface, const char *ip,
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
g_print("PPP Link down: %d\n", reason);
+ g_at_chat_resume(control);
+ g_at_chat_resume(modem);
}
static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -249,14 +251,8 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
/* get the data IO channel */
channel = g_at_chat_get_channel(modem);
- /*
- * shutdown gatchat or else it tries to take all the input
- * from the modem and does not let PPP get it.
- */
- g_at_chat_unref(control);
- control = NULL;
- g_at_chat_unref(modem);
- modem = NULL;
+ g_at_chat_suspend(control);
+ g_at_chat_suspend(modem);
/* open ppp */
ppp = g_at_ppp_new(channel);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] gatio: do not read if no read_handler
2010-05-03 22:45 [PATCH] gatio: do not read if no read_handler Kristen Carlson Accardi
@ 2010-05-10 14:11 ` Denis Kenzior
2010-05-10 17:12 ` Kristen Carlson Accardi
0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2010-05-10 14:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2175 bytes --]
Hi Kristen,
> If no read_handler specified, leave data alone in case someone
> else wants to read it.
> ---
> gatchat/gatio.c | 4 ++++
> gatchat/gsmdial.c | 12 ++++--------
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/gatchat/gatio.c b/gatchat/gatio.c
> index 61b0260..b4a3806 100644
> --- a/gatchat/gatio.c
> +++ b/gatchat/gatio.c
> @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel,
> GIOCondition cond, if (cond & G_IO_NVAL)
> return FALSE;
>
> + /* if nobody wants this data, leave it alone */
> + if (io->read_handler == NULL)
> + return TRUE;
> +
This is a really bad idea, we should never have cases where the read handler
is unset, and if we do we should end up closing the socket when the buffer is
full.
> /* Regardless of condition, try to read all the data available */
> do {
> toread = ring_buffer_avail_no_wrap(io->buf);
> diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
> index a531aa3..5fb406d 100644
> --- a/gatchat/gsmdial.c
> +++ b/gatchat/gsmdial.c
> @@ -235,6 +235,8 @@ static void ppp_connect(const char *iface, const char
> *ip, static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer
> user_data) {
> g_print("PPP Link down: %d\n", reason);
> + g_at_chat_resume(control);
> + g_at_chat_resume(modem);
> }
>
> static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
> @@ -249,14 +251,8 @@ static void connect_cb(gboolean ok, GAtResult *result,
> gpointer user_data) /* get the data IO channel */
> channel = g_at_chat_get_channel(modem);
>
> - /*
> - * shutdown gatchat or else it tries to take all the input
> - * from the modem and does not let PPP get it.
> - */
> - g_at_chat_unref(control);
> - control = NULL;
> - g_at_chat_unref(modem);
> - modem = NULL;
> + g_at_chat_suspend(control);
> + g_at_chat_suspend(modem);
>
Please send gsmdial patches separately. Also, can you make g_at_ppp use the
new_from_io constructor? In that case you don't need the gatio modifications
above.
> /* open ppp */
> ppp = g_at_ppp_new(channel);
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] gatio: do not read if no read_handler
2010-05-10 14:11 ` Denis Kenzior
@ 2010-05-10 17:12 ` Kristen Carlson Accardi
2010-05-10 17:23 ` Denis Kenzior
0 siblings, 1 reply; 6+ messages in thread
From: Kristen Carlson Accardi @ 2010-05-10 17:12 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]
On Mon, 10 May 2010 09:11:52 -0500
Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Kristen,
>
> > If no read_handler specified, leave data alone in case someone
> > else wants to read it.
> > ---
> > gatchat/gatio.c | 4 ++++
> > gatchat/gsmdial.c | 12 ++++--------
> > 2 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/gatchat/gatio.c b/gatchat/gatio.c
> > index 61b0260..b4a3806 100644
> > --- a/gatchat/gatio.c
> > +++ b/gatchat/gatio.c
> > @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel,
> > GIOCondition cond, if (cond & G_IO_NVAL)
> > return FALSE;
> >
> > + /* if nobody wants this data, leave it alone */
> > + if (io->read_handler == NULL)
> > + return TRUE;
> > +
>
> This is a really bad idea, we should never have cases where the read handler
> is unset, and if we do we should end up closing the socket when the buffer is
> full.
In your implementation of g_at_chat_suspend, you set the read handler to NULL.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gatio: do not read if no read_handler
2010-05-10 17:12 ` Kristen Carlson Accardi
@ 2010-05-10 17:23 ` Denis Kenzior
2010-05-10 17:22 ` Kristen Carlson Accardi
0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2010-05-10 17:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]
Hi Kristen,
> On Mon, 10 May 2010 09:11:52 -0500
>
> Denis Kenzior <denkenz@gmail.com> wrote:
> > Hi Kristen,
> >
> > > If no read_handler specified, leave data alone in case someone
> > > else wants to read it.
> > > ---
> > > gatchat/gatio.c | 4 ++++
> > > gatchat/gsmdial.c | 12 ++++--------
> > > 2 files changed, 8 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/gatchat/gatio.c b/gatchat/gatio.c
> > > index 61b0260..b4a3806 100644
> > > --- a/gatchat/gatio.c
> > > +++ b/gatchat/gatio.c
> > > @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel,
> > > GIOCondition cond, if (cond & G_IO_NVAL)
> > > return FALSE;
> > >
> > > + /* if nobody wants this data, leave it alone */
> > > + if (io->read_handler == NULL)
> > > + return TRUE;
> > > +
> >
> > This is a really bad idea, we should never have cases where the read
> > handler is unset, and if we do we should end up closing the socket when
> > the buffer is full.
>
> In your implementation of g_at_chat_suspend, you set the read handler to
> NULL.
>
Correct, with the intent that someone else sets the read handler (e.g.
g_at_ppp)
Regards,
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gatio: do not read if no read_handler
2010-05-10 17:23 ` Denis Kenzior
@ 2010-05-10 17:22 ` Kristen Carlson Accardi
2010-05-10 17:48 ` Denis Kenzior
0 siblings, 1 reply; 6+ messages in thread
From: Kristen Carlson Accardi @ 2010-05-10 17:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]
On Mon, 10 May 2010 12:23:04 -0500
Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Kristen,
>
> > On Mon, 10 May 2010 09:11:52 -0500
> >
> > Denis Kenzior <denkenz@gmail.com> wrote:
> > > Hi Kristen,
> > >
> > > > If no read_handler specified, leave data alone in case someone
> > > > else wants to read it.
> > > > ---
> > > > gatchat/gatio.c | 4 ++++
> > > > gatchat/gsmdial.c | 12 ++++--------
> > > > 2 files changed, 8 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/gatchat/gatio.c b/gatchat/gatio.c
> > > > index 61b0260..b4a3806 100644
> > > > --- a/gatchat/gatio.c
> > > > +++ b/gatchat/gatio.c
> > > > @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel *channel,
> > > > GIOCondition cond, if (cond & G_IO_NVAL)
> > > > return FALSE;
> > > >
> > > > + /* if nobody wants this data, leave it alone */
> > > > + if (io->read_handler == NULL)
> > > > + return TRUE;
> > > > +
> > >
> > > This is a really bad idea, we should never have cases where the read
> > > handler is unset, and if we do we should end up closing the socket when
> > > the buffer is full.
> >
> > In your implementation of g_at_chat_suspend, you set the read handler to
> > NULL.
> >
>
> Correct, with the intent that someone else sets the read handler (e.g.
> g_at_ppp)
What if you receive data after the read handler is set to NULL, but before
someone else sets the read handler? shouldn't we safe guard against that?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gatio: do not read if no read_handler
2010-05-10 17:22 ` Kristen Carlson Accardi
@ 2010-05-10 17:48 ` Denis Kenzior
0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2010-05-10 17:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1863 bytes --]
Hi Kristen,
> On Mon, 10 May 2010 12:23:04 -0500
>
> Denis Kenzior <denkenz@gmail.com> wrote:
> > Hi Kristen,
> >
> > > On Mon, 10 May 2010 09:11:52 -0500
> > >
> > > Denis Kenzior <denkenz@gmail.com> wrote:
> > > > Hi Kristen,
> > > >
> > > > > If no read_handler specified, leave data alone in case someone
> > > > > else wants to read it.
> > > > > ---
> > > > > gatchat/gatio.c | 4 ++++
> > > > > gatchat/gsmdial.c | 12 ++++--------
> > > > > 2 files changed, 8 insertions(+), 8 deletions(-)
> > > > >
> > > > > diff --git a/gatchat/gatio.c b/gatchat/gatio.c
> > > > > index 61b0260..b4a3806 100644
> > > > > --- a/gatchat/gatio.c
> > > > > +++ b/gatchat/gatio.c
> > > > > @@ -91,6 +91,10 @@ static gboolean received_data(GIOChannel
> > > > > *channel, GIOCondition cond, if (cond & G_IO_NVAL)
> > > > > return FALSE;
> > > > >
> > > > > + /* if nobody wants this data, leave it alone */
> > > > > + if (io->read_handler == NULL)
> > > > > + return TRUE;
> > > > > +
> > > >
> > > > This is a really bad idea, we should never have cases where the read
> > > > handler is unset, and if we do we should end up closing the socket
> > > > when the buffer is full.
> > >
> > > In your implementation of g_at_chat_suspend, you set the read handler
> > > to NULL.
> >
> > Correct, with the intent that someone else sets the read handler (e.g.
> > g_at_ppp)
>
> What if you receive data after the read handler is set to NULL, but before
> someone else sets the read handler? shouldn't we safe guard against that?
>
We do safe guard, once the buffer runs out of space we close the GAtIO.
However, letting GAtIO enter the event-loop (since only then the io watch will
fire) without a read handler is a user error. Having an active GAtIO without a
read handler is useless...
Regards,
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-10 17:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03 22:45 [PATCH] gatio: do not read if no read_handler Kristen Carlson Accardi
2010-05-10 14:11 ` Denis Kenzior
2010-05-10 17:12 ` Kristen Carlson Accardi
2010-05-10 17:23 ` Denis Kenzior
2010-05-10 17:22 ` Kristen Carlson Accardi
2010-05-10 17:48 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.