Commit Graph

15398 Commits

Author SHA1 Message Date
Lukasz Skalski
1e193663b8 [kdbus] Add RequestName and ReleaseName to new API 2014-12-04 13:23:13 -05:00
Lukasz Skalski
0ee61acfa0 [kdbus] set const cookies for NameAcquired and NameLost subscriptions 2014-12-04 13:23:13 -05:00
Lukasz Skalski
f2cdea88c8 [kdbus][wip] Add matches for kernel notifications 2014-12-04 13:23:13 -05:00
Lukasz Skalski
9141fc1668 [kdbus] Initial support for decoding kernel messages 2014-12-04 13:23:13 -05:00
Lukasz Skalski
3d8d1d5629 [kdbus] Enable 'initial_read()' - is no longer needed 2014-12-04 13:23:13 -05:00
Lukasz Skalski
61e466d3f4 [kdbus] Add initial support for receiving messages 2014-12-04 13:23:13 -05:00
Lukasz Skalski
679fdbc5e3 [kdbus] Integrate acquiring and releasing names on kdbus with GLib core
Now it's possible to use GLib API for owning bus names, like:
g_bus_own_name() or g_bus_own_name_on_connection(). It is not yet
fully functional until I'll add 'Add Match' method on kdbus, so
g_bus_unown_name() still doesn't invoke proper handler, when 'name'
is lost - work in progress.
2014-12-04 13:23:13 -05:00
Lukasz Skalski
66027a29a9 [kdbus] Add support for 'ReleaseName' on kdbus 2014-12-04 13:23:13 -05:00
Lukasz Skalski
e088bbc890 [kdbus] Add support for 'RequestName' on kdbus 2014-12-04 13:23:13 -05:00
Lukasz Skalski
f85bce5b98 [kdbus] Add G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE flag
New flag is equivalent to DBUS_NAME_FLAG_DO_NOT_QUEUE flag from
dbus-1 specification [1].

[1] http://dbus.freedesktop.org/doc/dbus-specification.html

Change-Id: I8a50aa586abd5b0ffcbc0bdc41c2e98c18a2e18a
2014-12-04 13:23:13 -05:00
Lukasz Skalski
293d7ae07a [kdbus][TEMPORARY HACK] Disable 'initial read'
This patch allows perform new API test [1] without errors.
'initial_read' should be disabled till old patches from
Tizen repo [2] will be applied in this GitHub repository.

[1] https://github.com/lukasz-skalski/glib-kdbus-tests
[2] https://review.tizen.org/git/?p=platform/upstream/glib.git;a=shortlog;h=refs/heads/kdbus-integration
2014-12-04 13:23:12 -05:00
Lukasz Skalski
d14444d103 [kdbus] Catch up with latest kdbus changes 2014-12-04 13:23:12 -05:00
Lukasz Skalski
cce83618c0 [kdbus] Update kdbus interface header (commit: 017f56c7e53f) 14/10/20 2014-12-04 13:23:12 -05:00
Lukasz Skalski
c06623cbe0 [kdbus] Integrate kdbus core with new API.
Change-Id: I4c9b3853af0f25123dc0cb1dfce6a86c102ee08f
2014-12-04 13:23:12 -05:00
Lukasz Skalski
9f0bfad1ff [kdbus] Update kdbus interface header (commit: b620b72c9127) 14/10/16
Change-Id: I47d31f6cd810f452c31154f7aaff5903a5566ab3
2014-12-04 13:23:12 -05:00
Lukasz Skalski
a9e0487113 [kdbus] Rework kdbus core files
Change-Id: I09fd49dcc5557b25c49752a45d150e69e2886d47
2014-12-04 13:23:12 -05:00
Lukasz Skalski
6635fd4d84 [kdbus] Import gio/gkdbus* files from previous patchset.
With new kdbus.h header, imported files are outdated and will be
reworked soon.

Change-Id: Idfe94c7f72e81cd9910fceb8ac0664140b5eba90
2014-12-04 13:23:12 -05:00
Lukasz Skalski
5080f9bb07 [kdbus] Update kdbus interface header (commit: c34e65633b4e)
Change-Id: Ib9bd554d3bf2d7dacc6c143038253fe2e7f177a8
2014-12-04 13:23:12 -05:00
Lukasz Skalski
030b701401 [kdbus] Initial support for two new bus types: 'user' and 'machine'
Change-Id: I3976e3935a01ea8d67b9a41997d0be8a37765d00
2014-12-04 13:23:12 -05:00
Lukasz Skalski
95a3a2ebf7 [kdbus] Add "--enable-kdbus" configure switch
Change-Id: Id22e381c0d9dd9cda194ac8a3a03a1d1362a13ca
2014-12-04 13:23:12 -05:00
Lukasz Skalski
996eb6592c [kdbus] Import kdbus interface header (commit: 5df28e6dd30b)
Change-Id: Iec05e26a512c3e923442bd9d4fcc3e8ad94df36b
2014-12-04 13:23:12 -05:00
Lukasz Skalski
2c2ea3a4e0 [kdbus] Add new library API for common tasks on dbus/kdbus
For kdbus purpose we need introduce two new bus types
called "user" and "machine". Will not be possible to
make calls to the 'org.freedesktop.DBus' destination on
the new bus types, thus this patch introduce new API
for tasks such as "get Unix user ID of the process connected
to the server", "returns a list of all currently-owned names
on the bus" and so on.

Change-Id: Ib9ba65346290d597341d4157b09cb45bd3d1151d
2014-12-04 13:23:12 -05:00
Lukasz Skalski
898ee827d9 [kdbus] Add SipHash algorithm
Change-Id: I83f28c2249efd6dc8cf78e0383916c46d71df075
2014-12-04 13:23:12 -05:00
Lukasz Skalski
fa74bf059d [kdbus] Add README.md file
Change-Id: I064de04278990abe97bea28d1b80ddc3f42a05e0
2014-12-04 13:23:12 -05:00
Ryan Lortie
f64cc2f745 grow our __NR_memfd_create collection
Also add a fallback case in case we don't know the arch.
2014-12-04 13:20:40 -05:00
Ryan Lortie
f3311a01fb oops 2014-12-03 21:28:24 -05:00
Ryan Lortie
62e9a485f9 further cleanup 2014-12-03 21:20:32 -05:00
Ryan Lortie
5722ad3a43 cleanup 2014-12-03 21:06:28 -05:00
Ryan Lortie
e1903e40d8 finish up vector deserialiser
seems to have stopped crashing now...
2014-12-03 20:35:18 -05:00
Ryan Lortie
e3df37be73 tests: add GBytes memfd testcase 2014-12-03 17:17:17 -05:00
Ryan Lortie
c123516f63 Add new internal header glib-linux.h
This defines some constants and syscall wrappers for features which may
not yet have appeared in the libc.
2014-12-03 17:15:31 -05:00
Ryan Lortie
98f143767a GBytes: two memfd tweaks
1) mmap() of a 0-sized region is EINVAL, so don't try that

 2) MAP_SHARED on a sealed memfd fails for some reason, so use
    MAP_PRIVATE instead
2014-12-03 17:13:43 -05:00
Ryan Lortie
185449c5c6 start fleshing out guts of vector deserialiser 2014-12-03 03:12:06 -05:00
Ryan Lortie
3468ab849b GVariant vector deserialiser WIP 2014-12-03 02:14:19 -05:00
Ryan Lortie
a169f1d1a8 GVariant: clean up g_variant_get_child_value()
Remove this one outstanding case of direct construction of GVariant
instances and port it to use g_variant_alloc() like everyone else.
2014-12-03 02:10:24 -05:00
Ryan Lortie
fd40045eaf GVariant: use GVariantTypeInfo on internal constructors
Take GVariantTypeInfo instead of a GVariantType on the internal
constructors for GVariant.

Although this results in a bit more code for almost every call, it turns
out that it makes most uses more convenient -- that fact that we consume
the GVariantInfo means that we don't have to go back to free the type
when we're done.

This change will allow us to port g_variant_get_child() over to using
g_variant_alloc().  It was the one outstanding place where we
constructed GVariant instances that was not yet using it.
2014-12-03 02:04:33 -05:00
Ryan Lortie
127fc04592 GVariant: clean up serialised data handling API
Add a new pair of internal helpers to gvariant-core.c to provide a
unified way to construct and query the content of serialised GVariant
instances.

Rewrite g_variant_new_from_data() to use this.

Move g_variant_new_from_bytes() and g_variant_get_data_as_bytes() out of
-core and into gvariant.c, also rewriting them to use the same.

Take the time to do some cleanup and make some general improvements in
consistency:

 - move the checks for improperly sized fixed-sized data out of
   _new_from_bytes() and into the common code so that we do this check
   on _new_from_data() as well

 - correctly deal with the case of NULL data in _get_data_as_bytes().
   This would have crashed before.  Add a test for that.

 - if the user hands us data with a size of zero then unref and/or
   destroy-notify things immediately.

The idea that every GVariant must have an associated GBytes remains.
This could potentially be optimsed a bit further in the future, but the
cases where it could be avoided are only a few (errors, zero-size,
static stoarge) so let's not pursue that now.
2014-12-02 21:14:16 -05:00
Ryan Lortie
bae9239da3 GVariant: fix a trivial typo in a comment 2014-12-02 21:14:16 -05:00
Ryan Lortie
37a2fdf134 GVariant: add support for single precision floats
Add a new type 'f' to correspond to single precision floating point
values.

This type was never added to D-Bus for two reasons:

 1) there is no benefit to using float rather than doubles as parameters
    for RPC

 2) classically, you shouldn't move bulk data over D-Bus

Now that we've decided that we want to use D-Bus for bulk data
transfers, it makes a good deal of sense to want to send an array of
floats or an array of fixed-sized tuples containing floats.

https://bugzilla.gnome.org/show_bug.cgi?id=740897
2014-12-02 21:14:16 -05:00
Ryan Lortie
04240e4154 GVariant test: add a new vector serialisation test
Generate a random value and make sure we get the same result as doing it
the 'usual' way (which is already subject to a whole lot of testing).
2014-12-02 16:30:21 -05:00
Ryan Lortie
8209b34016 GVariant: support serialising to GVariantVectors
Add code for serialising GVariant to GVariantVectors.

Export that internally via the glib-private machanism so that we can use
it from GDBus.
2014-12-02 16:30:21 -05:00
Ryan Lortie
025e670810 GVariant: add GVariantVectors utility struct
This structure (and its associated functions) will be used as an
intermediate step for serialising GVariant instance onto kdbus without
copying large amounts of data.
2014-12-02 16:30:21 -05:00
Ryan Lortie
87226d3b2f GVariant: refactor locking a bit more
Change the internal g_variant_ensure_serialised() helper over to working
on unlocked instances and have it conditionally acquire the lock using
the utility function added in the last commit.
2014-12-02 16:30:21 -05:00
Ryan Lortie
2c1fb2915d GVariant: add internal tree-form locking helper
Many of the core GVariant operations have two modes: one for tree-form
and one for serialised.

Once a GVariant is in serialised form it will always be serialised, so
it is safe to simply check for that and proceed with the operation in
that case.

A tree-form GVariant instance always has a chance of being implicitly
serialised, however, so we have to take locks when performing operations
on these.

Write a helper function that reliably checks if the instance is in
tree-form, locking it if it is.  Rewrite some of the other functions to
use this helper.  In some cases this simplifies the code and in others
it reduces locking.
2014-12-02 16:30:21 -05:00
Ryan Lortie
67520c60fa GVariant: calculate size at construction
It's always possible to determine the serialised size of a GVariant
instance, even in the case that it is not yet serialised.  This can be
done by calling g_variant_get_size() which will base its answer on the
size of each child (which must be recursively determined).

We must perform this process before we can allocate the buffer to
serialise a GVariant into (since we must know the size of the buffer).
This means that serialising a GVariant involves two steps that recurse
through the entire tree of values.  We must take locks twice.

Simplify this by always determining the size when the instance is first
created, from the sizes of its children (which now will always be known
as well).  We can do this without taking any locks because the
newly-created instance has never been exposed and because the size on
the children is now a constant that can be directly accessed without a
lock.

This is a reduction in complexity and will also be a performance
improvement in all cases where a GVariant is serialised.  It will be a
slight performance hit in the case that we construct tree-form instances
and never serialise them.
2014-12-02 16:30:21 -05:00
Ryan Lortie
f2437b7f1c GBytes: add g_bytes_get_zero_copy_fd()
Add a way to get the zero-copy fd back out of a GBytes that was created
from one.
2014-12-02 16:30:21 -05:00
Ryan Lortie
0da5aef9fc GBytes: add new g_bytes_take_zero_copy_fd() function
This function takes a memfd, seals it, and creates a GBytes based on it.
2014-12-02 16:30:21 -05:00
David King
e1734aa73e glib-unix: add function to ensure an fd is sealed
Add a function that checks if a fd is sealed and, if it's not, seals it.

On Linux this is more or less an operation on memfd.  On other systems,
it currently always returns FALSE.
2014-12-02 16:29:11 -05:00
Ryan Lortie
dccedf8844 GBytes: substantial internal rework
We have a wide variety of different sources of data for GBytes.

Instead of having all possibilities inside of a single structure type,
add a 'type' field and a couple of subtypes.

This also forces us to clean up our access to the ->data pointer from
all over the code which may become a problem in the future if we want to
lazy-map memfd GBytes instances by keeping the data pointer as NULL
until we are ready to use it.

We also introduce a new type of GBytes: 'inline'.  This allows us to
make a single allocation instead of two in the g_bytes_new() case.
2014-12-02 13:24:00 -05:00
Ryan Lortie
39ca9d3383 macros: add side-effecting variants of asserts
Add g_assert_se(), g_return_if_fail_se() and g_return_val_if_fail_se()
as variants of the existing macros that are guaranteed to evaluate side
effects in their expression argument.  Inspired by similar macros in
systemd.

These are just macros, so they come at no extra cost.

https://bugzilla.gnome.org/show_bug.cgi?id=741026
2014-12-02 13:03:02 -05:00