diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-03-23 18:24:00 +0000 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-03-23 18:24:00 +0000 |
commit | 52e8ff6d0fe136b43f03b3a0ebdf59e5bbb91b74 (patch) | |
tree | 0df43153b4e157b94e1a49642bc44c1066504c26 /lib | |
parent | 53553fadffa6c3d8a1ea37ac62fffedc76cd56cb (diff) |
gibber_fd_transport_send: returns an error if something went wrong
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gibber/gibber-fd-transport.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/gibber/gibber-fd-transport.c b/lib/gibber/gibber-fd-transport.c index f1b656cb..fdf80b2a 100644 --- a/lib/gibber/gibber-fd-transport.c +++ b/lib/gibber/gibber-fd-transport.c @@ -194,7 +194,7 @@ _do_disconnect (GibberFdTransport *self) static gboolean _try_write (GibberFdTransport *self, const guint8 *data, int len, - gsize *written) + gsize *written, GError **err) { GibberFdTransportPrivate *priv = GIBBER_FD_TRANSPORT_GET_PRIVATE (self); GibberFdTransportClass *cls = GIBBER_FD_TRANSPORT_GET_CLASS (self); @@ -215,6 +215,7 @@ _try_write (GibberFdTransport *self, const guint8 *data, int len, DEBUG ("Writing data failed, closing the transport"); _do_disconnect (self); + g_propagate_error (err, error); return FALSE; break; } @@ -222,8 +223,9 @@ _try_write (GibberFdTransport *self, const guint8 *data, int len, return TRUE; } -static void -_writeout (GibberFdTransport *self, const guint8 *data, gsize len) +static gboolean +_writeout (GibberFdTransport *self, const guint8 *data, gsize len, + GError **error) { GibberFdTransportPrivate *priv = GIBBER_FD_TRANSPORT_GET_PRIVATE (self); gsize written = 0; @@ -232,16 +234,16 @@ _writeout (GibberFdTransport *self, const guint8 *data, gsize len) if (priv->output_buffer == NULL || priv->output_buffer->len == 0) { /* We've got nothing buffer yet so try to write out directly */ - if (!_try_write (self, data, len, &written)) + if (!_try_write (self, data, len, &written, error)) { - return; + return FALSE; } } if (written == len) { gibber_transport_emit_buffer_empty (GIBBER_TRANSPORT (self)); - return; + return TRUE; } if (priv->output_buffer) @@ -260,6 +262,8 @@ _writeout (GibberFdTransport *self, const guint8 *data, gsize len) priv->watch_out = g_io_add_watch (priv->channel, G_IO_OUT, _channel_io_out, self); } + + return TRUE; } static gboolean @@ -300,7 +304,7 @@ _channel_io_out (GIOChannel *source, GIOCondition condition, gpointer data) g_assert (priv->output_buffer); if (!_try_write (self, (guint8 *) priv->output_buffer->str, - priv->output_buffer->len, &written)) + priv->output_buffer->len, &written, NULL)) { return FALSE; } @@ -439,8 +443,7 @@ gboolean gibber_fd_transport_send (GibberTransport *transport, const guint8 *data, gsize size, GError **error) { - _writeout (GIBBER_FD_TRANSPORT (transport), data, size); - return TRUE; + return _writeout (GIBBER_FD_TRANSPORT (transport), data, size, error); } void |