Commit Graph

14885 Commits

Author SHA1 Message Date
Philip Withnall
fdf14e9e6c hmac: Make unit test const-correct
https://bugzilla.gnome.org/show_bug.cgi?id=724741
2014-02-24 16:38:08 +00:00
Ryan Lortie
393503ba5b gmain: simplify g_main_context_find_source_by_id()
Since we now keep a hashtable of sources, we can implement this function
without iteration.

https://bugzilla.gnome.org/show_bug.cgi?id=724839
2014-02-24 09:28:43 -05:00
Ryan Lortie
9e81709012 gmain: Simplify source id tracking
Simplify our tracking of issued source id integers and fix some bugs.

Previously the source's id was remove from the 'used' table from
source_remove_from_context() which was also called if the source
priority was changed (in which case it would never be added back to the
table).  The source id could be reissued in that case.

In the new approach, we just always keep a hash table of sources, by
source id.  This simplifies the logic and will also allow us to improve
performance of g_main_context_find_source_by_id() which is called in some
fairly common cases, such as g_source_remove().  These improvements will be in
the following commits.

https://bugzilla.gnome.org/show_bug.cgi?id=724839
2014-02-24 09:28:43 -05:00
Matthias Clasen
e7bde4acf4 Test content type icons more thoroughly
Check we actually get the right icon names, and check
that symbolic icons fall back to non-symbolic ones.
2014-02-23 12:11:59 -05:00
John Lindgren
e6af432b39 Add non-symbolic fallback icons in g_content_type_get_symbolic_icon().
This makes the behavior consistent with e.g. g_volume_get_symbolic_icon().

https://bugzilla.gnome.org/show_bug.cgi?id=724994
2014-02-23 12:11:59 -05:00
Ryan Lortie
356fe2cec6 asyncqueue: fix timeout math on 32bit systems
88182d375e caught this issue in
g_async_queue_timed_pop() but failed to fix the same bug in the _unlocked()
variant.

This is only a problem on 32bit systems.  On 64bit systems, the tv_sec
in a timeval is already 64 bits, so no overflow occurs.

https://bugzilla.gnome.org/show_bug.cgi?id=722604
2014-02-23 01:14:27 -05:00
Ryan Lortie
4af9b8e9cb mappedfile test: permit ENODEV on /dev/null
mmap() on /dev/null returns ENODEV on old Linux versions and also on
Hurd, so accept that in the testcase.

https://bugzilla.gnome.org/show_bug.cgi?id=722360
2014-02-23 00:47:29 -05:00
Chun-wei Fan
4825e819b2 Fix build of gio/gapplication.c on Visual C++
Visual C++ is quite zealous about checking against the types used in the
initializing of array of structures, even up to Visual C++ 2013.  Fix this
by splitting up the initializing steps.

https://bugzilla.gnome.org/show_bug.cgi?id=724609
2014-02-23 11:48:06 +08:00
Ryan Lortie
8da795de4f gsocket: use check/prepare only on win32
There is no longer any code left in the check/prepare functions on UNIX,
so put %NULL in the GSourceFuncs vtable.

This also allows us to simplify some logic.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
e8f26efe0d gsocket: use _add_unix_fd() instead of _add_poll()
Use g_source_add_unix_fd() on UNIX instead of using a GPollFD.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
04aee2d920 gsocket: make use of g_source_set_ready_time()
Drop our own hand-rolled version of the same functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
12d65f2509 GSource: mark some API as "implementation only"
Clarify that _add_poll() _remove_poll() _add_unix_fd(),
_modify_unix_fd(), _remove_unix_fd(), _query_unix_fd(),
_set_ready_time(), _add_child_source() and _remove_child_source() are only
intended to be used by the implementation of a particular GSource -- not its
consumers.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:06 -05:00
Ryan Lortie
1f7100506a gsocket: don't abuse GPollFD.revents field
We are reusing the GPollFD.revents field of the source to store a
temporary value.  Use a local variable for that instead.

This is a refactor to make the next commit easier to understand.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
Ryan Lortie
ff96f88e17 gsocket: use cancellable child source
Now that GCancellable's GSource is based on _set_ready_time() instead of
an fd, we should use it as a child source, instead of forcing the
creation of the fd and adding it as a poll.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
Ryan Lortie
d8263dd793 gsocket: trivial typo fix
https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
Ryan Lortie
6147d15ea2 gmain: repeat preconditions for emphasis
g_main_context_acquire() mentions that you must have called it before
you make any calls to _prepare(), _query(), _check() or _dispatch().

For emphasis, add a note on each of those functions pointing back to the
fact that you must have called _acquire() before using them.
2014-02-22 10:23:40 -05:00
Ryan Lortie
c0aa150cb0 g_main_context_wait: add a critical to detect use
Due to its unusual interface, I suspect that nobody is using
g_main_context_wait() but there is no way to know.

Add a critical notice that will be displayed if anyone calls the
function, asking them to file a bug with us.

We'll let this go out with the 2.40 release and see if we get a response
before we proceed with actually breaking the functionality.
2014-02-21 16:42:21 -05:00
Ryan Lortie
5103c5d643 GCond: check result of pthread_condattr_setclock()
Make sure this call succeeds, aborting if it doesn't

This will prevent people from having to waste time chasing down the problems
that would otherwise be caused by this silent failure.
2014-02-21 16:42:21 -05:00
Ryan Lortie
03a43c290e gmain: abort if monotonic time is unsupported
We now depend on CLOCK_MONOTONIC, but it's possible that people may
attempt to run GLib on systems where it isn't supported at runtime.

Check the return value of clock_gettime() and abort() if it fails in
order to save these people from wasting time on debugging a tricky
issue.

https://bugzilla.gnome.org/show_bug.cgi?id=670144
2014-02-21 16:42:21 -05:00
Xavier Claessens
6fcaa7aa96 GHashTable: Explicitly document that _iter_remove() is safe while iterating
https://bugzilla.gnome.org/show_bug.cgi?id=723316
2014-02-21 15:39:31 -05:00
Aurimas Černius
59a8ae34c0 Updated Lithuanian translation 2014-02-21 22:16:16 +02:00
Chun-wei Fan
450363321d glib/Makefile.am: Dist gtranslit-data.h
This header needs to be distributed as well, which was
inadvertently missed.

https://bugzilla.gnome.org/show_bug.cgi?id=724858
2014-02-21 23:37:31 +08:00
Ryan Lortie
73060f5e78 slow-motion post-release version bump 2014-02-21 07:56:26 -05:00
Ryan Lortie
061793a726 gconvert: add note to avoid transliteration
Add a note to the documentation of g_convert() advising to avoid using
it for transliteration.  Link to g_str_to_ascii().
2014-02-20 18:52:33 -05:00
Ryan Lortie
0415930b49 gsource: document priority of child sources
Add a note to the documentation that child sources cannot have their priority
changed independently from their parent.  Add a g_return_if_fail() to the
public API in order to enforce this.

This was already a reality due to the check in
g_source_set_priority_unlocked(), but it was never explicitly documented.

https://bugzilla.gnome.org/show_bug.cgi?id=724706
2014-02-20 18:32:42 -05:00
Ryan Lortie
8491f03581 g_str_to_ascii(): a couple of minor tweaks
Add a precondition guard and use g_string_sized_new() to avoid some
reallocations.
2014-02-20 18:32:42 -05:00
Ryan Lortie
a8ea3dc03b g_str_tokenize_and_fold: do proper transliteration
g_str_tokenize_and_fold() can now do proper locale-sensitive
transliteration for ascii alternatives.

https://bugzilla.gnome.org/show_bug.cgi?id=710142
2014-02-20 18:27:48 -05:00
Ryan Lortie
d7291760df tests: test transliteration API
Add some tests for the new transliteration API.

https://bugzilla.gnome.org/show_bug.cgi?id=710142
2014-02-20 18:27:24 -05:00
Ryan Lortie
941b8979d0 Add locale-sensitive ASCII transliteration API
Add a new function, g_str_to_ascii() that does locale-dependent ASCII
transliteration of UTF-8 strings.

This function works off of an internal database.  We get the data out of
the localedata shipped with glibc, which seems to be just about the best
source of locale-sensitive transliteration information available
anywhere.

We include a update script with this commit that's not used by anything
at all -- it will just sit in git.  It is intended to be run manually
from time to time.

https://bugzilla.gnome.org/show_bug.cgi?id=710142
2014-02-20 18:27:24 -05:00
Ryan Lortie
436d77f70a tests: add a test for g_cond_wait_until()
https://bugzilla.gnome.org/show_bug.cgi?id=673607
2014-02-20 17:57:57 -05:00
Ryan Lortie
1de36e7755 Fix g_cond_wait_until() vs. monotonic time
We've had a relatively rocky path with g_cond_wait_until() on systems
that either don't support pthread_condattr_setclock() or where
g_get_monotonic_time() is not based on CLOCK_MONOTONIC (ie: Android and
Mac OS).

Fortunately, both of these platforms seem to share
pthread_cond_timedwait_relative_np() which allows us to implement
g_cond_wait_until() without races.

With this patch, we now require that one of pthread_condattr_setclock()
or pthread_cond_timedwait_relative_np() exists.  A quick look around
suggests that this is true for all platforms that we care about.

This patch removes our use of pthread_cond_timedwait_monotonic() and
pthread_cond_timedwait_monotonic_np() which were Android-only APIs.

https://bugzilla.gnome.org/show_bug.cgi?id=673607
2014-02-20 17:55:09 -05:00
Ryan Lortie
d614312546 gmain: rework g_get_monotonic_time() a bit
We now assume the existence of clock_gettime() and CLOCK_MONOTONIC as
specified by POSIX.1-2001.  This means that we always return truly
monotonic time, which will prevent problems in the case that the user
changes the time.

Mac OS doesn't have clock_gettime() but it does have
mach_absolute_time(), so we can use that there.

We keep our Windows case as well (although we should simplify it once XP
hits EOL later this year).

This patch removes the fallback to gettimeofday() in case of missing
clock_gettime().  We no longer have any way to test this codepath and
therefore it must go.

This patch also restructures the #ifdef a bit so that we repeat the
entire function definition inside of #ifdef instead of just the entire
body of one function.

https://bugzilla.gnome.org/show_bug.cgi?id=724687
2014-02-20 17:52:49 -05:00
William Jon McCann
20f4d1820b docs: use "Returns:" consistently
Instead of "Return value:".
2014-02-19 19:41:52 -05:00
Chun-wei Fan
9cb53851be gio/gresolver.c: Fix build on Windows
Windows does not come with inet_aton(), and this check on IPv4 addresses
is actually not needed on Windows as the getaddrinfo() implementation on
Windows already rejects non-standard and non-real IPv4 numbers-and-dots
addresses.

https://bugzilla.gnome.org/show_bug.cgi?id=724609
2014-02-20 08:36:54 +08:00
Kjartan Maraas
a5ae016359 Updated Norwegian bokmål translation 2014-02-19 23:57:40 +01:00
Xavier Claessens
0ffa1ea8dd Add G_ÂTYPE_VARIANT_DCT into the doc 2014-02-19 15:51:27 -05:00
Ryan Lortie
ec17605d4f GLib 2.39.90 2014-02-17 18:33:34 -05:00
Ryan Lortie
c37cd19fee Work around test failure in gdbus-names
This is caused by g_test_dbus_down() returning too soon.

Add a sleep for now.

https://bugzilla.gnome.org/show_bug.cgi?id=711807
2014-02-17 18:18:20 -05:00
Ryan Lortie
53d5b17f62 GApplication: disable some more tests
Disable some racy GApplication testcases.  We need some better non-hacky
GApplication tests...

https://bugzilla.gnome.org/show_bug.cgi?id=724126
2014-02-17 17:44:58 -05:00
Matthias Clasen
c81834c089 Bump gtk-doc dep to 1.20 2014-02-17 16:57:13 -05:00
Dan Winship
4139b26f3e gsocket: fix g_socket_condition_timed_wait() recovery after EINTR
After getting an EINTR, g_socket_condition_timed_wait() has to adjust
its timeout, but it was trying to convert from nanoseconds to
microseconds by multiplying by 1000 rather than dividing... Oops.

https://bugzilla.gnome.org/show_bug.cgi?id=724239
2014-02-17 11:38:11 -05:00
Dan Winship
5a4478664b gtestutils: make the new assert messages more detailed
g_assert_true(), g_assert_false(), g_assert_null(), and
g_assert_nonnull() simply printed out the expression they were
checking, without any further explanation of what went wrong. (In
particular, "g_assert_true(x)" and "g_assert_false(x)" would both
print the same thing on failure.) Add a little bit more context.

https://bugzilla.gnome.org/show_bug.cgi?id=724385
2014-02-17 11:33:37 -05:00
Ross Burton
299ca6dc1e gio/tests: fix race when generating code
There is a race condition in the makefile that can result in build failures like this in parallel builds:

| ./gdbus-test-codegen-generated.h:7:0: error: unterminated #ifndef
|  #ifndef __GDBUS_TEST_CODEGEN_GENERATED_H__

This is because a rule like this:

x.c x.h: prerequisites
	@commands

doesn't consider x.c and x.h together. Instead, it expands to two rules, one to
generate x.c and one to generate x.h, which happen to run the same commands.  In
the worst case they execute in parallel, overwriting each other's output.

Signed-off-by: Ross Burton <ross.burton@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723616
2014-02-17 10:21:31 +00:00
Olivier Crête
ed017994c9 subprocess: Init and clear the mutex
Fixes the leak of the GMutexImpl allocated inside the first call to g_mutex_lock()
on an uninitialized GMutex.

https://bugzilla.gnome.org/show_bug.cgi?id=724401
2014-02-16 19:59:44 -05:00
Paolo Borelli
a732f2966d Annotate g_application_add_main_option_entries 2014-02-16 22:06:11 +01:00
Dan Winship
8902276101 g_simple_async_result_is_valid: fix for NULL source tag
If a GSimpleAsyncResult has a NULL source tag, allow it to compare
valid to a non-NULL source tag in g_simple_async_result_is_valid(), to
simplify cases where, eg, g_simple_async_result_new() and
g_simple_async_result_report_error_in_idle() are both used.

https://bugzilla.gnome.org/show_bug.cgi?id=721458
2014-02-16 09:24:04 -05:00
Koop Mast
9c135707cb Fix the build on FreeBSD by replacing EAI_NODATA with EAI_NONAME.
https://bugzilla.gnome.org/show_bug.cgi?id=724434
2014-02-15 18:35:57 -05:00
Ryan Lortie
7cbff954b9 win32: fixup lib.exe invocation
We have a configure.ac check for lib.exe that attempts to enable
creation of .lib files for our 5 public libraries.  That has been broken
for a long time for two reasons:

 1) the Makefiles hardcode 'lib' instead of 'lib.exe'

 2) we dropped generation of .def files quite some time ago (except for
    in gthread where we have the two-symbol file under version control)

Add new rules for creating .def files from dumpbin.exe (which you should
have if you have lib.exe) and fix the .lib rules to use lib.exe.

Add a bit of $(AM_V_GEN) all around, as well.

https://bugzilla.gnome.org/show_bug.cgi?id=722033
2014-02-15 16:55:25 -05:00
Ryan Lortie
08533cae05 only '#pragma GCC' outside of functions
Don't use #pragma GCC inside of function scope.

https://bugzilla.gnome.org/show_bug.cgi?id=724417
2014-02-15 10:31:52 -05:00
Dan Winship
5575a3e9cb gio: don't accept nonstandard IPv4 "numbers-and-dots" addresses
In addition to the standard "192.168.1.1" format, there are numerous
legacy IPv4 address formats (such as "192.168.257",
"0xc0.0xa8.0x01.0x01", "0300.0250.0001.0001", "3232235777", and
"0xc0a80101"). However, none of these forms are ever used any more
except in phishing attempts. GLib wasn't supposed to be accepting
these addresses (neither g_hostname_is_ip_address() nor
g_inet_address_new_from_string() recognizes them), but getaddrinfo()
accepts them, and so the parts of gio that use getaddrinfo()
accidentally did accept those formats.

Fix GNetworkAddress and GResolver to reject these address formats.

https://bugzilla.gnome.org/show_bug.cgi?id=679957
2014-02-15 10:22:24 -05:00