Commit Graph

23 Commits

Author SHA1 Message Date
Dan Winship
cde9f4598b gio/tests/socket: fix warning building on win32
setsockopt() has a broken prototype on win32. Fix this by just using
g_socket_set_option() instead.
2013-08-31 11:40:44 -04:00
Sebastian Dröge
02393e6faf gio/tests/socket: add test for g_socket_get_available_bytes()
https://bugzilla.gnome.org/show_bug.cgi?id=686786
2013-08-31 11:40:44 -04:00
Dan Winship
547df5937c GSocket: fix g_socket_bind() allow_reuse semantics
With UDP sockets, g_socket_bind() with allow_reuse=TRUE on Linux
behaved in a way that the documentation didn't suggest, and that
didn't match other OSes. (Specifically, it allowed binding multiple
multicast sockets to the same address.)

Since this behavior is useful, and since allow_reuse didn't have any
other meaning with UDP sockets, update the docs to reflect the Linux
behavior, and make it do the same thing on non-Linux.

https://bugzilla.gnome.org/show_bug.cgi?id=689245
2013-08-17 13:26:42 -04:00
Dan Winship
a60014f1b6 GInetSocketAddress: fix the byte order of flowinfo and scope_id
The flowinfo and scope_id fields of struct sockaddr_in6 are in host
byte order, but the code previously assumed they were in network byte
order. Fix that.

This is an ABI-breaking change (since before you would have had to use
g_ntohl() and g_htonl() with them to get the correct values, and now
that would give the wrong values), but the previous behavior was
clearly wrong, and no one ever reported it, so it is likely that no
one was actually using it.

https://bugzilla.gnome.org/show_bug.cgi?id=684404
2013-01-30 16:46:02 -05:00
Antoine Jacoutot
cb1876b4a7 ipv6_v4mapped: force pass even if we don't speak IPv4
Some OS (e.g. OpenBSD) do not implement IP v4-mapped addresses. When
this is the case, then we get a "Connection refused", so force the test
to pass to that further tests can run.

https://bugzilla.gnome.org/show_bug.cgi?id=686058
2013-01-09 16:29:29 +01:00
Dan Winship
b377e69685 Add gnetworking.h
Install a public "gnetworking.h" header that can be used to include
the relevant OS-dependent networking headers. This does not really
abstract away unix-vs-windows however; error codes, in particular,
are incompatible.

gnetworkingprivate.h now contains just a few internal URI-related
functions

Also add a g_networking_init() function to gnetworking.h, which can be
used to explicitly initialize OS-level networking, rather than having
that happen as a side-effect of registering GInetAddress.

https://bugzilla.gnome.org/show_bug.cgi?id=623187
2012-12-12 15:20:22 +01:00
Dan Winship
9fb3082070 Revert "Return correct value for g_socket_get_available_bytes() on Windows and OSX"
This neither compiles nor does what it's supposed to on Windows.

This reverts commit 1e598600a1.
2012-11-11 14:14:04 -05:00
Sebastian Dröge
1e598600a1 Return correct value for g_socket_get_available_bytes() on Windows and OSX
https://bugzilla.gnome.org/show_bug.cgi?id=686786
2012-11-09 21:57:50 -05:00
Antoine Jacoutot
475edeb2ed Allow slightly too big poll duration in /socket/timed_wait test
Sometimes the poll duration in the /socket/timed_wait test is slightly
bigger than the requested 100000, causing failures like:

GLib-GIO:ERROR:socket.c:620:test_timed_wait:
    assertion failed (poll_duration < 110000): (110057 < 110000)

Adjust the test to allow some jitter in the "too high" direction.

https://bugzilla.gnome.org/show_bug.cgi?id=686458
2012-10-19 14:34:18 +02:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Martin Pitt
72af44cb12 Allow slightly too small poll duration in /socket/timed_wait test
Sometimes the poll duration in the /socket/timed_wait test is slightly lower
than the requested 100000, causing failures like

ERROR:/build/buildd/glib2.0-2.33.2/./gio/tests/socket.c:619:test_timed_wait:
  assertion failed (poll_duration > = 100000): (99240 >= 100000)
FAIL

Adjust the test to also allow some jitter in the "too small" direction, similar
to the already existing span for "slightly too large".

https://bugzilla.gnome.org/show_bug.cgi?id=678881
2012-06-26 18:34:08 +02:00
Dan Winship
726257ab97 gsocket: add g_socket_condition_timed_wait()
https://bugzilla.gnome.org/show_bug.cgi?id=667755
2012-02-20 18:29:51 -05:00
Marc-André Lureau
6ca817c3f2 gio/tests: add /socket/close_graceful test
Add a test to check that remaining data is read before the close
event is received.

https://bugzilla.gnome.org/show_bug.cgi?id=669810
2012-02-10 19:07:29 +01:00
Dan Winship
bf7408c30b GInetSocketAddress: add IPv6 flowinfo and scope_id fields
struct sin6_addr has two additional fields that struct sin_addr
doesn't. Add support for those to GInetSocketAddress, and make sure
they don't get lost when converting between glib and native types.

https://bugzilla.gnome.org/show_bug.cgi?id=635554
2012-01-16 13:37:02 -05:00
Simon McVittie
995a2eb50b Plug some leaks in the GIO tests
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:41:15 +00:00
Ryan Lortie
430c5635f2 g_thread_new: never fail
Remove the GError argument from g_thread_new() and abort on failure.
Introduce g_thread_try() for those who want to handle failure.
2011-10-13 01:00:57 -04:00
Ryan Lortie
015f4b4513 thread: nuke the concept of 'joinable'
And remove the 'joinable' argument from g_thread_new() and
g_thread_new_full().

Change the wording in the docs.  Clarify expectations for
(deprecated) g_thread_create().
2011-10-13 00:43:33 -04:00
Matthias Clasen
93e49aea1b Don't use deprecated GThread API in gio tests 2011-10-10 09:49:50 -04:00
Dan Winship
fb74f6e303 GSocketAddress: create IPv4 addresses for IPv6 mapped-IPv4 addresses
IPv6-mapped-IPv4 addresses are annoying. Just translate them to real
IPv4 addresses.

based on a patch from Jonny Lamb
https://bugzilla.gnome.org/show_bug.cgi?id=646082
2011-08-29 23:42:39 -04:00
Dan Winship
cef679d004 GSocket: fix GIOCondition on timed-out socket operation
The docs for g_socket_set_timeout() claimed that if an async operation
timed out, the GIOCondition passed to the source callback would be
G_IO_IN or G_IO_OUT (thus prompting the caller to call
g_socket_receive/send and get a G_IO_ERROR_TIMED_OUT), but in fact it
ended up being 0, and gio/tests/socket.c was erroneously testing for
that instead of the correct value. Fix this.
2011-08-27 12:28:03 -04:00
Dan Winship
eac8d47e37 gio/tests/socket: add some basic IPv4 and IPv6 tests 2011-07-24 14:55:05 -04:00
Daiki Ueno
c0208940c5 Make g_unix_connection_send_fd() work as expected.
https://bugzilla.gnome.org/show_bug.cgi?id=637696
2011-01-12 16:01:32 -05:00
Dan Winship
87d06109ab GSocket: set protocol when using g_socket_new_from_fd()
Otherwise, attempting to create a GSocketConnection from the socket
will likely return the wrong type, since the protocol won't match any
of the registered subtypes.

Also add the start of a GSocket test program (from davidz).

https://bugzilla.gnome.org/show_bug.cgi?id=627171
2010-10-22 14:42:41 -04:00