Exemple #1
0
static void done_async_write(GObject *obj, GAsyncResult *res, gpointer user_data) {
	struct ekg_connection *c = user_data;
	GError *err = NULL;
	gboolean ret;
	GOutputStream *of = G_OUTPUT_STREAM(obj);

	ret = g_output_stream_flush_finish(of, res, &err);

	if (!ret) {
		debug_error("done_async_write(), write failed: %s\n", err ? err->message : NULL);
		/* XXX */
		failed_write(c);
		g_error_free(err);
		return;
	}

	if (c->wr_buffer->len > 0) {
		/* the stream should not have any pending writes ATM
		 * we need to ensure that to have the data written to stream
		 * rather than re-appended to the buffer*/
		g_assert(!g_output_stream_has_pending(of));

		ekg_connection_write_buf(G_DATA_OUTPUT_STREAM(of),
				c->wr_buffer->str, c->wr_buffer->len);
		g_string_truncate(c->wr_buffer, 0);
	}

	/* XXX: anything to do? */
}
/* Called when a flush completes */
static void
vfs_data_flush_done (GObject *source, GAsyncResult *res, gpointer callback_data) 
{
    VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;

    if(ah->state == VFS_ASYNC_PROCESSING) {
        g_assert (ah->operation == VFS_OP_FLUSHING);
	g_clear_error (&ah->error);
    
        g_output_stream_flush_finish (ah->ostream, res, &ah->error);
        ah->state = VFS_ASYNC_READY;
    }
}
Exemple #3
0
static gboolean
g_filter_output_stream_flush_finish (GOutputStream  *stream,
                                     GAsyncResult   *result,
                                     GError        **error)
{
  GFilterOutputStream *filter_stream;
  gboolean res;

  filter_stream = G_FILTER_OUTPUT_STREAM (stream);

  res = g_output_stream_flush_finish (filter_stream->base_stream,
                                      result,
                                      error);

  return res;
}
static void
on_output_flushed (GObject *stream,
                   GAsyncResult *result,
                   gpointer user_data)
{
  CockpitWebResponse *self = COCKPIT_WEB_RESPONSE (user_data);
  GOutputStream *output = G_OUTPUT_STREAM (stream);
  GError *error = NULL;

  if (g_output_stream_flush_finish (output, result, &error))
    {
      g_debug ("%s: flushed output", self->logname);
    }
  else
    {
      if (!cockpit_web_should_suppress_output_error (self->logname, error))
        g_message ("%s: couldn't flush web output: %s", self->logname, error->message);
      self->failed = TRUE;
      g_error_free (error);
    }

  cockpit_web_response_done (self);
  g_object_unref (self);
}