2010-12-03 18:28:48

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH] Fix writing to GAttrib socket without POLLOUT event

If the GIOChannel is in the buffered state (the default) the watch
function is called without receiving a POLLOUT from the socket. GLib
adds a G_IO_OUT condition just because there is space in the GIOChannel
internal buffer.

The solution is disabling the internal buffer, which in turn, makes the
call of g_io_channel_flush() useless.
---
attrib/gattrib.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ed18168..1083519 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -248,8 +248,6 @@ static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
if (iostat != G_IO_STATUS_NORMAL)
return FALSE;

- g_io_channel_flush(io, NULL);
-
if (cmd->expected == 0) {
g_queue_pop_head(attrib->queue);
command_destroy(cmd);
@@ -350,6 +348,7 @@ GAttrib *g_attrib_new(GIOChannel *io)
struct _GAttrib *attrib;

g_io_channel_set_encoding(io, NULL, NULL);
+ g_io_channel_set_buffered(io, FALSE);

attrib = g_try_new0(struct _GAttrib, 1);
if (attrib == NULL)
--
1.7.3.2



2010-12-07 20:58:18

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix writing to GAttrib socket without POLLOUT event

Hi Vinicius,

On Fri, Dec 03, 2010, Vinicius Costa Gomes wrote:
> If the GIOChannel is in the buffered state (the default) the watch
> function is called without receiving a POLLOUT from the socket. GLib
> adds a G_IO_OUT condition just because there is space in the GIOChannel
> internal buffer.
>
> The solution is disabling the internal buffer, which in turn, makes the
> call of g_io_channel_flush() useless.
> ---
> attrib/gattrib.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)

Pushed upstream. Thanks.

Johan