Commit Graph

66 Commits

Author SHA1 Message Date
Colin Walters
dd4c3695b4 goutputstream: Add clear warning about short writes to _write_bytes() and async version
Matthew Barnes noted this on IRC a few days ago.  I just had this file
open for other reasons and decided to tweak the docs to make this trap
more clear.

https://bugzilla.gnome.org/show_bug.cgi?id=709301
2013-10-02 11:23:01 -04:00
Mike Ruprecht
4e9e7d0cba GOutputStream: Use async read/write of streams in splice_async()
There are some corner cases where using the sync version of read/write
in a thread could cause thread-safety issues. In these cases it's
possible to override the output stream's splice_async() function,
but for input streams one would need to do some acrobatics to
stay thread-safe. Alternatively, some implementations may not even
override their sync read/write functions.

This patch refactors the default splice_async() implementation to
call the sync read and write functions in a thread only when both
async versions are thread-based. When one or both are non-threaded,
it calls the virtual write_async() and read_async() functions of the
involved streams within the same thread.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
87e5617a65 GOutputStream: Split _close_async for internal use
Refactor g_output_stream_close_async() into itself and an internal
variant for potential use inside other operations (splice_async).
The internal version must be called between
g_output_stream_set_pending() and g_output_stream_clear_pending().

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
416ca8ad57 GOutputStream: Rename _g_output_stream_close_internal() for consistency
https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
dec3bfeebc GOutputStream: Add g_output_stream_async_write_is_via_threads()
In implementing a better g_output_stream_splice_async() and possibly
other situtations it's helpful to know whether the output stream's
write function internally uses threads. If it and the input stream's
read async functions use threads, then the splice function could
spawn a single thread for better efficiency.

This patch adds a function to determine whether an output stream's
g_output_stream_write_async() function internally uses threads.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:40 -04:00
Emmanuele Bassi
54cc43630d Rename the generated private data getter function
As it turns out, we have examples of internal functions called
type_name_get_private() in the wild (especially among older libraries),
so we need to use a name for the per-instance private data getter
function that hopefully won't conflict with anything.
2013-06-24 15:43:04 +01:00
Emmanuele Bassi
32747def4b gio: Use the new private instance data declaration
Use the newly added macros, and remove the explicit calls to
g_type_class_add_private().

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Mike Ruprecht
b029135ed4 GOutputStream: Remove unused SpliceUserData struct 2013-02-19 08:47:45 -06:00
Colin Walters
780871d273 GOutputStream: Fix a compiler warning 2012-12-18 13:21:24 -05:00
Dan Winship
669505e354 gio: port basic I/O classes from GSimpleAsyncResult to GTask
https://bugzilla.gnome.org/show_bug.cgi?id=661767
2012-12-18 09:07:19 -05:00
Dan Winship
82d914d808 gio: add g_async_result_is_tagged()
Rather than doing a two step first-check-the-GAsyncResult-subtype-then-
check-the-tag, add a GAsyncResult-level method so that you can do them
both at once, simplifying the code for "short-circuit" async return
values where the vmethod never gets called.

https://bugzilla.gnome.org/show_bug.cgi?id=661767
2012-07-10 10:49:20 -04:00
Dan Winship
f8532a13e2 gio: Add g_async_result_legacy_propagate_error()
Finish deprecating the "handle GSimpleAsyncResult errors in the
wrapper function" idiom (and protect against future GSimpleAsyncResult
deprecation warnings) by adding a "legacy" GAsyncResult method
to do it in those classes/methods where it had been traditionally
done.

(This applies only to wrapper methods; in cases where an _async
vmethod explicitly uses GSimpleAsyncResult, its corresponding _finish
vmethod still uses g_simple_async_result_propagate_error.)

https://bugzilla.gnome.org/show_bug.cgi?id=667375
https://bugzilla.gnome.org/show_bug.cgi?id=661767
2012-07-10 10:49:14 -04:00
Dan Winship
538b2f106d gio: handle GSimpleAsyncResult errors in _finish vmethods
Originally, the standard idiom with GSimpleAsyncResult was to handle
all errors in the _finish wrapper function, so that vmethods only had
to deal with successful results. But this means that chaining up to a
parent _finish vmethod won't work correctly. Fix this by also checking
for errors in all the relevant vmethods. (We have to redundantly check
in both the vmethod and the wrapper to preserve compatibility.)

https://bugzilla.gnome.org/show_bug.cgi?id=667375
https://bugzilla.gnome.org/show_bug.cgi?id=661767
2012-07-10 10:47:55 -04:00
Dan Winship
800d6ff111 gio: add GBytes-based input/output stream methods
Using a caller-supplied buffer for g_input_stream_read() doesn't
translate well to the semantics of many other languages, and using a
non-refcounted buffer for read_async() and write_async() makes it
impossible to manage the memory correctly currently in
garbage-collected languages.

Fix both of these issues by adding a new set of methods that work with
GBytes objects rather than plain buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=671139
2012-05-24 17:48:13 -04:00
Dan Winship
fd3ec4df87 Fix several recently-introduced bugs in g_output_stream_write_async()
g_output_stream_write_async() was not initializing the newly-added
members of the WriteData structure, causing various problems.

Also, g_input_stream_read_async() was now leaking its cancellable. Fix
that as well.

https://bugzilla.gnome.org/show_bug.cgi?id=674612
2012-04-27 09:27:38 -04:00
Dan Winship
00ee06e6a3 gio: use GPollable* to implement fallback read_async/write_async
If a GInputStream does not provide a read_async() implementation, but
does implement GPollableInputStream, then instead of doing
read-synchronously-in-a-thread, just use
g_pollable_input_stream_read_nonblocking() and
g_pollable_input_stream_create_source() to implement an async read in
the same thread. Similarly for GOutputStream.

Remove a bunch of existing read_async()/write_async() implementations
that are basically equivalent to the new fallback method.

https://bugzilla.gnome.org/show_bug.cgi?id=673997
2012-04-17 12:33:12 -04:00
Dan Winship
88781d5906 Fix some gtk-doc stuff 2012-04-04 15:23:31 -04:00
Evan Nemerson
c3d6595f5a GIO: add lots of annotations for Vala bindings
https://bugzilla.gnome.org/show_bug.cgi?id=667447
2012-01-11 15:50:08 -05:00
Benjamin Otte
482f226270 outputstream: Clarify docs of flush()
After questioning the semantics of flush on IRC, it seemed necessary to
clarify what flushing is supposed to do. The Linux man page for fflush()
seemed to cover it perfectly, so I just copied it.

I did not add the "via the underlying write mechanism" part as that in
my opinion is not something subclasses should need to guarantee.
2011-12-05 22:40:18 +01:00
Philip Withnall
fe27bf0037 Don't close stream twice when splicing
Ensure that the output/target stream in a g_output_stream_splice_async()
operation is marked as closed if G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET is
passed to g_output_stream_splice_async(). This removes the possibility of
local FDs being closed twice because the stream's not marked as closed.

This is implemented by calling g_output_stream_close() from within
g_output_stream_splice_async() instead of calling the stream's close_fn()
directly.

Closes: bgo#659324
2011-09-19 10:13:52 +02:00
Matthias Clasen
1b28408b8b Spelling fixes
Spelling fixes in comments and docs, provided by
Kjartan Maraas in bug 657336.
2011-08-29 14:49:32 -04:00
Dan Winship
37ab5ced31 g_output_stream_splice: deal with overflow
On 32-bit machines in particular, bytes_written may overflow a gssize.
Notice when that happens and just return G_MAXSSIZE instead.

https://bugzilla.gnome.org/show_bug.cgi?id=649246
2011-07-06 08:39:38 -04:00
Pavel Holejsovsky
89b558077f [gi] Add annotations for GFile, G[File]{Input|Output|IO}Stream.
Also make parameter names in virtual function declarations consistent
to silent g-ir-scanner.
2010-12-17 16:29:05 +01:00
Christian Persch
ba45e36932 Add g_simple_async_report_take_gerror_in_idle
... and use it where appropriate. Saves an extra GError copy.

Bug #633686.
2010-11-03 14:38:08 +01:00
Christian Persch
9e0c07870a Use g_simple_async_result_{new_,}take_error
Bug #633685.
2010-11-03 14:25:35 +01:00
Johan Dahlin
30132c44c1 Add a lot of missing annotations 2010-09-24 18:24:41 -03:00
Dan Winship
bff4ac15d0 g_output_stream_write: fix misleadingly ungrammatical documentation
pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=626866
2010-09-17 10:21:57 -04:00
David Zeuthen
b8e7ef6e90 Bug 627071 – g_output_stream_write() clarification
This patch guarantees that g_output_stream_write() can never fail with
G_IO_ERROR_WOULD_BLOCK. Without such a guarantee, we would need some
kind of GIOPollable interface or some way to get an event when the
stream is writable again. Which is mostly useless considering that
this method is asynchronous anyway.

Note: this patch just codifies existing behavior - GUnixOutputStream,
GSocketOutputStream and other implementations already work this way.

See also bug 626748 comment 5 for how the GDBus code relies on this
guarantee.

https://bugzilla.gnome.org/show_bug.cgi?id=627071

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-16 15:38:02 -04:00
Matthias Clasen
4bc4590c7b Declare stream base classes as abstract 2010-08-16 10:21:38 -04:00
Ryan Lortie
5b946e0504 gio/: fully remove gioalias hacks 2010-07-07 19:53:22 -04:00
Colin Walters
7c36619d26 [Gio] Merge in introspection annotations from gobject-introspection gio-2.0.c
This is not an exhaustive set, but covers everything we have so far.
2010-06-10 14:03:02 -04:00
Jesse van den Kieboom
adc5162b74 Flush when closing output stream async
https://bugzilla.gnome.org/show_bug.cgi?id=617937
2010-05-12 09:21:06 +02:00
Alexander Larsson
afe3324fca Add g_output_stream_is_closing
Need this to check how we're flushing when closing a converter
output stream.
2009-11-23 16:22:52 +01:00
Matthias Clasen
53fc10d269 Fix a lot of clang complaints
Mostly dead assignments.
2009-09-18 19:20:06 -04:00
Alexander Larsson
c20b8d4d53 Check that close_fn is not %NULL before calling (#578499)
Some streams have no close function, so this caused a crash.
2009-05-20 13:41:25 +02:00
Alexander Larsson
2bbb85633f Remove not actually used member "cancelled" 2009-05-12 13:58:18 +02:00
Matthias Clasen
cec561c2cd Add docs
svn path=/trunk/; revision=7346
2008-08-13 05:35:10 +00:00
Cody Russell
3d93bf6968 Moved all relevant typedefs into these files.
2008-07-01  Cody Russell  <bratsche@gnome.org>

        * gio/gioenums.h:
        * gio/giotypes.h:
	Moved all relevant typedefs into these	files.

        * gio/*.[ch]:
	Updated wrt added files.

        Split types into separate file	for easier maintainership. (#538564)


svn path=/trunk/; revision=7127
2008-07-01 06:32:35 +00:00
Johan Dahlin
761424465a Include "config.h" instead of <config.h> Command used: find -name
2008-06-21  Johan Dahlin  <jdahlin@async.com.br>

    * *.[ch]: Include "config.h" instead of <config.h>
    Command used:
    find -name \*.[ch]|xargs perl -p -i -e 's/^#include <config.h>/#include "config.h"/g'
    Rubberstamped by Mitch


svn path=/trunk/; revision=7092
2008-06-22 15:10:51 +00:00
Christian Persch
9c17697b56 Use g_set_error_literal where appropriate. Patch from bug #535947.
svn path=/trunk/; revision=7051
2008-06-16 16:53:58 +00:00
Michael Natterer
a4427bfff5 chain up unconditionally in finalize() and dispose(). Also don't
2008-06-16  Michael Natterer  <mitch@imendio.com>

	* *.c: chain up unconditionally in finalize() and dispose(). Also
	don't dereference these function pointers when calling them since
	that has no meaning at all.


svn path=/trunk/; revision=7048
2008-06-16 09:54:04 +00:00
Murray Cumming
d9c036f06a Tiny documentation corrections.
2008-03-04  Murray Cumming  <murrayc@murrayc.com>

* ginputstream.c:
* goutputstream.c: Tiny documentation corrections.

svn path=/trunk/; revision=6620
2008-03-04 13:15:57 +00:00
Wouter Bolsterlee
8b294f1f9d Fixup translator comments (#518578).
2008-02-25  Wouter Bolsterlee  <wbolster@svn.gnome.org>

	* gfile.c (g_file_find_enclosing_mount):
	* ginputstream.c (g_input_stream_set_pending):
	* glocalfile.c (g_local_file_find_enclosing_mount):
	* gmount.c (g_mount_unmount), (g_mount_eject), (g_mount_remount):
	* goutputstream.c (g_output_stream_set_pending):

	Fixup translator comments (#518578).

svn path=/trunk/; revision=6591
2008-02-25 14:31:19 +00:00
Wouter Bolsterlee
a9a0498007 Fix a few typos in translator comments and documentation.
2008-02-25  Wouter Bolsterlee  <wbolster@svn.gnome.org>

	* gfile.c (g_file_find_enclosing_mount):
	* giomodule.c:
	* glocalfile.c (g_local_file_find_enclosing_mount):
	* goutputstream.c:

	Fix a few typos in translator comments and documentation.

svn path=/trunk/; revision=6590
2008-02-25 14:04:38 +00:00
Alexander Larsson
9edb46455c Add translator comments (#518578)
2008-02-25  Alexander Larsson  <alexl@redhat.com>

        * gfile.c:
        * ginputstream.c:
        * glocalfile.c:
        * gmount.c:
        * goutputstream.c:
	Add translator comments (#518578)


svn path=/trunk/; revision=6589
2008-02-25 13:47:00 +00:00
Matthias Clasen
f3144c7efe Doc fixes
svn path=/trunk/; revision=6554
2008-02-21 18:20:17 +00:00
Matthias Clasen
da0e7e81c1 /bin/ksh can't handle a for-loop with no arguments, so add a "." for when
2008-02-09  Matthias Clasen <mclasen@redhat.com>

        * Makefile.decl: /bin/ksh can't handle a for-loop with no
        arguments, so add a "." for when $(SUBDIRS) is empty.

        * glib/tests/option-context.c:
        * glib/tests/testing.c:
        * gthread/gthread-posix.c:
        * tets/testingbase64.c:
        * glib/gtester.c:
        * glib/gsequence.c: Portability fixes.  (#515154)



svn path=/trunk/; revision=6487
2008-02-10 04:41:25 +00:00
Matthias Clasen
7bfc60de2e Deprecate G_GNUC_(PRETTY)_FUNCTION.
2008-01-27  Matthias Clasen  <mclasen@redhat.com>

        * glib/gmacros.h: Deprecate G_GNUC_(PRETTY)_FUNCTION.



svn path=/trunk/; revision=6389
2008-01-27 23:42:33 +00:00
Matthias Clasen
af7645a498 String fixes
svn path=/trunk/; revision=6370
2008-01-25 06:10:29 +00:00
Murray Cumming
6aaab07e0f Documentation: Fixed minor typos and added more mentions of specific
2008-01-21  Murray Cumming,,,  <murrayc@murrayc.com>

* gfileenumerator.c:
* gfileinputstream.c:
* ginputstream.c:
* goutputstream.c: Documentation: Fixed minor typos 
and added more mentions of specific _finish() functions.

svn path=/trunk/; revision=6339
2008-01-21 13:08:23 +00:00