Commit Graph

18555 Commits

Author SHA1 Message Date
Philip Withnall
04c8691208 Revert "build: Look for copied Objective-C files in builddir again"
This reverts commit fe72b8772e.

It still fails on GNOME Continuous:
http://build.gnome.org/continuous/buildmaster/builds/2018/06/21/44/build/.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/129 for
discussion.
2018-06-22 00:21:05 +01:00
Philip Withnall
bdb6af9356 Merge branch 'fix-objc-build' into 'master'
build: Look for copied Objective-C files in builddir again

See merge request GNOME/glib!129
2018-06-21 23:03:16 +00:00
Philip Chimento
fe72b8772e build: Look for copied Objective-C files in builddir again
This reverts commit 03c324c64a and fixes
the original problem with e004d5f397 that
caused the revert.

We use $(builddir) instead of $(abs_builddir) so that Automake's
dependency generation works correctly.

See !127.
2018-06-21 14:48:29 -07:00
Philip Withnall
ca98ce4280 Merge branch 'master' into 'master'
Use posix_spawn for optimized process launching

See merge request GNOME/glib!95
2018-06-21 17:10:43 +00:00
Daniel Drake
2b560457a0 gspawn: use sane_open() for stdin
sane_open() is used for stdout and stderr, but regular open() was being
used for stdin. Spotted by Philip Withnall.
2018-06-21 11:44:59 -05:00
Daniel Drake
86e2b8d427 gspawn: document FD_CLOEXEC behaviour
G_SPAWN_LEAVE_DESCRIPTORS_OPEN must be set to enable the optimized
posix_spawn codepath, so this flag is likely to see more usage now.

Document that FD_CLOEXEC can be used to cause file descriptors to be
automatically closed while this flag is used.
2018-06-21 11:44:59 -05:00
Daniel Drake
156d009696 gdesktopappinfo: add g_desktop_app_info_launch_uris_as_manager_with_fds variant
Add an app-launching function which allows standard file descriptors
to be passed to the child process.

This will be used by gnome-shell to pass systemd journal descriptors
as stdout/stderr. gnome-shell's child_setup function can then be
eliminated, which will enable use of the posix_spawn optimized
gspawn codepath for desktop app launching.
2018-06-21 11:44:59 -05:00
Daniel Drake
742efe6232 gdesktopappinfo: enable fast posix_spawn gspawn codepath
In order to use the new posix_spawn gspawn codepath, for more robust
app launching when available memory is low, we need to meet some
conditions.

child_setup needs to be NULL for this optimization to work, so drop
the internal child_setup that is used here. Replace it with a lightweight
wrapper binary (gio-launch-desktop) that sets GIO_LAUNCHED_DESKTOP_FILE_PID
before executing the app.

Adjust PATH for gio tests so that it can execute the new binary from the
build directory.
2018-06-21 11:44:28 -05:00
Daniel Drake
61f54591ac gspawn: Optimize with posix_spawn codepath
When the amount of free memory on the system is somewhat low, gnome-shell
will sometimes fail to launch apps, reporting the error:
  fork(): Cannot allocate memory

fork() is failing here because while cloning the process virtual address
space, Linux worries that the thread being forked may end up COWing the
entire address space of the parent process (gnome-shell, which is
memory-hungry), and there is not enough free memory to permit that to
happen.

In this case we are simply calling fork() in order to quickly call exec(),
which will throw away the entirity of the duplicated VM, so we should
look for ways to avoid the overcommit check.

The well known solution to this is to use clone(CLONE_VM) or vfork(), which
completely avoids creating a new memory address space for the child.
However, that comes with a bunch of caveats and complications:

  https://gist.github.com/nicowilliams/a8a07b0fc75df05f684c23c18d7db234
  https://ewontfix.com/7/

In 2016, glibc's posix_spawn() was rewritten to use this approach
while also resolving the concerns.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ff72da471a509a8c19791efe469f47fa6977410

I experimented with a similar approach in glib, but it was not practical
because glibc has several items of important internal knowledge (such as
knowing which signals should be given special treatment because they are
NPTL implementation details) that are not cleanly exposed elsewhere.

Instead, this patch adapts the gspawn code to use posix_spawn() where
possible, which will reap the benefits of that implementation.
The posix_spawn API is more limited than the gspawn API though,
partly due to natural limitations of using CLONE_VM, so the posix_spawn
path is added as a separate codepath which is only executed when the
conditions are right. Callers such as gnome-shell will have to be modified
to meet these conditions, such as not having a child_setup function.

In addition to allowing for the gnome-shell "Cannot allocate memory"
failure to be avoided, this should result in a general speedup in this
area, because fork()'s behaviour of cloning the entire VM space
has a cost which is now avoided. posix_spawn() has also recently
been optimized on OpenSolaris as the most performant way to spawn
a child process.
2018-06-21 11:43:32 -05:00
Daniel Drake
3524de16e4 gspawn: Add g_spawn_async_with_fds variant
Add a new process spawning function variant which allows the caller
to pass specific file descriptors for stdin, stdout and stderr.
It is otherwise identical to g_spawn_async_with_pipes.

Allow the same fd to be passed in multiple parameters. To make this
workable, the child process logic that closes the fd after the first time
it has been dup2'ed needed tweaking; we now just set those fds to be
closed upon exec using the CLOEXEC flag. Add a test for this case.

This will be used by gnome-shell to avoid performing equivalent
dup2 actions in a child_setup function. Dropping use of child_setup will
enable use of an upcoming optimized process spawning codepath.
2018-06-21 11:43:32 -05:00
Philip Withnall
6700101495 Merge branch 'support-tcrypt' into 'master'
Add support for TCRYPT volumes to GMountOperation

See merge request GNOME/glib!120
2018-06-21 14:29:13 +00:00
segfault
76b4d0ab3f Add support for TCRYPT volumes to GMountOperation
Add G_ASK_PASSWORD_TCRYPT flag to GAskPasswordFlags and add the
following properties to GMountOperation:

- hidden_volume [1]
- system_volume [2]
- pim [3]

[1] https://www.veracrypt.fr/en/Hidden%20Volume.html
[2] https://www.veracrypt.fr/en/System%20Encryption.html
[3] https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20(PIM).html
2018-06-21 15:32:04 +02:00
Jehan
2b6bfdb125 glib: Win32 does not accept "wb+" mode for fopen().
Nevertheless it accepts "w+b".
When checking the Win32 documentation of fopen()/_wfopen(), it clearly
states:
> In addition to the earlier values, the following characters can be
> appended to mode to specify the translation mode for newline
> characters.

This implementation expects 'b' or 't' to be appended, and therefore
"wb+" ends up with an error, whereas the alias "w+b" works perfectly
while it is exactly the same thing. So let's just have glib "translate"
the mode when it can to have it working transparently the same way on
every platform.
2018-06-21 13:55:19 +02:00
Philip Withnall
03c324c64a Revert "build: Look for copied Objective-C files in builddir"
This reverts commit e004d5f397.

It broke the GNOME Continuous build, which uses autotools. This wasn’t
caught by CI because we don’t do an autotools CI build.

http://build.gnome.org/continuous/buildmaster/builds/2018/06/21/19/build/

Discussion in https://gitlab.gnome.org/GNOME/glib/merge_requests/127.
2018-06-21 11:52:54 +01:00
Philip Withnall
6e784963f4 Merge branch '1377-g-assert-cmpfloat' into 'master'
Resolve "g_assert_cmpfloat trips -Wdouble-promotion on Clang"

Closes #1377

See merge request GNOME/glib!127
2018-06-21 10:35:37 +00:00
Philip Chimento
9e46b2ef11 gtester: Explicitly convert arguments of g_assert_cmpfloat()
Using g_assert_cmpfloat() with a float or double causes warnings on the
newest Clang version, because the macro internally promotes all values to
a long double, which Clang warns about. Casting explicitly removes the
warning.

Closes: #1377
2018-06-21 00:20:55 -07:00
Philip Chimento
e004d5f397 build: Look for copied Objective-C files in builddir
Without this, the build fails in the OS_COCOA case due to not finding
gnextstepsettingsbackend.c in $(srcdir).
2018-06-20 23:03:21 -07:00
Xavier Claessens
b9aed426d1 Merge branch '258-variable-names' into 'master'
gobject: Add prefixes to variables in G_VALUE_COLLECT*() macros

Closes #258

See merge request GNOME/glib!126
2018-06-20 16:07:59 +00:00
Philip Withnall
877f20d0d8 gobject: Add prefixes to variables in G_VALUE_COLLECT*() macros
This makes them a bit more unique (and, crucially, in the g_* namespace)
to avoid shadowing collisions with calling code.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/258
2018-06-20 16:00:48 +01:00
Philip Withnall
0b9cdf07f7 Merge branch 'lrn/attachconsole' into 'master'
W32: add std stream redirection envvar options

Closes #1304

See merge request GNOME/glib!104
2018-06-20 11:21:43 +00:00
Philip Withnall
a3a6c516c4 gunixmounts: Stop considering cifs/nfs as system file systems
They’re network file systems, but not system file systems (in the sense
that procfs is a system file system). This fixes them disappearing from
the sidebar in the UI.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1424
2018-06-20 12:16:34 +01:00
Руслан Ижбулатов
460cc723ad W32: add std stream redirection envvar options
This commit adds two W32-only environmental variable checks:
* G_WIN32_ALLOC_CONSOLE, if set to 1, will force glib to create
  a new console if the process has no console by itself.
  This option is for GUI apps that are launched from GUI
  processes, in which case there's no console anywhere near them.
* G_WIN32_ATTACH_CONSOLE, if set to a comma-separated list of
  standard stream names (stdint, stdout, stderr), will reopen
  a given std stream and tie it to the console (using existing console
  or parent console).
  This works either with the other option (to create a console),
  or if the app is launched from a console process (often the
  case for developers).
  The redirection is done with freopen(), dup() and dup2().
  If everything goes well, C file descriptors 0, 1 or 2 will
  be bound to stdin, stdout and stderr respectively (only for
  streams listed in the envrionmental variable), and so will
  be stdio streams by the same names.

With these it's possible to see the output of g_log*() functions
when running GTK4 applications, which are linked as GUI applications,
and thus do not get a console by default.

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

Fixes issue #1304
2018-06-20 10:53:30 +00:00
Philip Withnall
d4cb3dfcaf Merge branch '1423-gmountoperation-tests' into 'master'
Add unit tests for GMountOperation

Closes #1423

See merge request GNOME/glib!124
2018-06-20 09:44:56 +00:00
Allison Lortie
83a2e85ec8 glib-compile-schemas: Handle per-desktop overrides
Add a new syntax to override files: if the group name has a ':' in it,
it indicates that we want to override the default values of keys for
only one desktop. For example:

[org.gnome.desktop.interface:Unity]
font-name='Ubuntu 12'

Will override the settings, only if "Unity" is found in
XDG_CURRENT_DESKTOP. Multiple per-desktop overrides can be specified
for a given key: the one which comes first in XDG_CURRENT_DESKTOP will
be used.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Allison Lortie
6ca449672d gsettingsschema: Allow per-desktop overrides
Recognise a new 'd' option in schema keys which gives a dictionary of
per-desktop default values. This dictionary is searched for the items
found in XDG_CURRENT_DESKTOP, in the order. If nothing matches (or if
the option is missing) then the default value is used as before.

This feature was requested by Alberts Muktupāvels and this patch is
based on an approach devised by them.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Allison Lortie
c2e7f31697 gsettings: cleanup default value lookup
There are a couple of different ways (and soon one more) to access the
default value of a key. Clean up the various places that access this to
avoid duplication.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Philip Withnall
1c673535fe tests: Add basic tests for GMountOperation
There were previously no tests for it. These take gmountoperation.c up
to 85.5% coverage of lines.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1423
2018-06-19 15:46:59 +01:00
Emmanuele Bassi
df28cfe0b5 Merge branch '896-variant-type-docs' into 'master'
Documentation and typing improvements for GVariant bytes

Closes #896

See merge request GNOME/glib!117
2018-06-19 14:15:37 +00:00
Xavier Claessens
720fc3fadc Merge branch '807-g-file-dup-docs' into 'master'
Document why g_file_dup() is useful, instead of g_object_ref()

Closes #807

See merge request GNOME/glib!122
2018-06-19 13:47:37 +00:00
Philip Withnall
6284749487 gfile: Document usefulness of g_file_dup()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/807
2018-06-19 12:36:37 +01:00
Philip Withnall
40a84b3d1c Merge branch 'wip/lantw/freebsd-kqueue-complex' into 'master'
FreeBSD kqueue file monitor fixes: the complex parts

See merge request GNOME/glib!77
2018-06-19 11:19:43 +00:00
Philip Withnall
dd51b05e19 Merge branch 'non-atomicity-of-g_file_set_contents' into 'master'
gfileutils: document non-atomicity of g_file_set_contents()

See merge request GNOME/glib!118
2018-06-19 11:13:50 +00:00
Philip Withnall
f784df722d Merge branch 'wip/hughsie/EOPNOTSUPP' into 'master'
Handle EOPNOTSUPP error from splice()

See merge request GNOME/glib!112
2018-06-19 11:13:37 +00:00
Philip Withnall
e0f4439cad Merge branch 'wip/oholy/gio-bash-completion' into 'master'
Add bash completion for gio tool

See merge request GNOME/glib!115
2018-06-19 11:12:00 +00:00
Philip Withnall
0e49e22ce0 Merge branch 'strlcpy-comment' into 'master'
Meson: Add comment telling why we test strlcpy/strlcat

See merge request GNOME/glib!121
2018-06-18 13:45:47 +00:00
Xavier Claessens
b97453c3e6 Meson: Add comment telling why we test strlcpy/strlcat 2018-06-18 09:28:55 -04:00
Ting-Wei Lan
e714e1e951 kqueue: Use the worker context to schedule rescanning of missing files
This makes it consistent with the file monitor itself, which already
attaches kqueue event sources to the worker context.
2018-06-17 11:26:32 +08:00
Ting-Wei Lan
454a9f8de9 tests: Make testfilemonitor test work with kqueue
check_expected_events is heavily modified in this commit to tolerate
event loss and allow renaming to be reported as creation and deletion.

This fixes test failure on FreeBSD.
2018-06-17 11:26:32 +08:00
Ting-Wei Lan
09c019a4f0 kqueue: Make it possible to pass file monitor tests
Previously, kqueue file monitor only add event sources for directories
regardless of the type of the file being monitored. Doing so may be
possible on inotify, but it is not sufficient on kqueue. Watching a
directory on kqueue doesn't report changes made to files under it, and
we must watch files themselves to get notified. This problem is fixed
by adding a second watch for non-directory file monitors, and the result
is that we are now able to receive 'CHANGED' and 'ATTRIBUTE_CHANGED'
events for non-directory files.

Since having two watches on one file monitor requires many code changes
to work properly, this commit also changes the following things:

 - NOTE_ALL macro is now replaced by note_all inline function. Since the
   kqueue backend is shared by all BSD operating systems, there are a
   few difference between these systems. It is easier to do '#ifdef'
   check in a function than in a macro.

 - Both g_kqueue_file_monitor_callback and g_kqueue_file_monitor_cancel
   now holds a lock before accessing kqueue_sub structs. This fixes a
   crash when these two functions are called from different threads,
   causing g_kqueue_file_monitor_callback to access freed memory.

 - 'mask' variable in g_kqueue_file_monitor_callback is now removed.
   The usage of 'mask' was wrong because of the 'mask > 0' check.
   'CHANGED' event has value 0 so the 'mask > 0' check made it
   impossible to emit 'CHANGED' events.

 - kqueue-missing scans can now be triggered from the kqueue event
   callback instead of always waiting for 4 seconds.

 - Don't remove a file from kqueue on unlink unless its hard link count
   has dropped to zero.

 - Don't use 'else if' in the check of 'fflags'. It is possible for a
   kevent to have multiple flags set.

 - Don't use g_file_monitor_emit_event directly. Always use
   g_file_monitor_source_handle_event to report events.
   Events submitted to g_file_monitor_emit_event are delivered
   immediately, but events sent to g_file_monitor_source_handle_event
   are scheduled by GLocalFileMonitor. If we mix the two, the order of
   events will be wrong and tests will fail.

 - Report 'CHANGES_DONE_HINT' immediately after 'CREATED' if the file
   created is not a regular file. This is copied from ih_event_callback.
2018-06-17 11:26:32 +08:00
Xavier Claessens
75fd0109db Merge branch 'str-equal-docs' into 'master'
docs: Amend the docs for g_str_equal() to reflect current general usage

See merge request GNOME/glib!109
2018-06-15 14:53:19 +00:00
Will Thompson
c1a8e93dc4
gfileutils: document non-atomicity of g_file_set_contents()
This function only calls fsync() if @target exists and is non-empty. If
not, it doesn't provide the "old contents or new contents" guarantee
that one might expect. This has been the case since
d20a188b12, and is justified either as a
performance optimization or by asserting that this function only
guarantees to not destroy existing data (implicitly defining
non-existence or emptiness as not data).

In addition, explicitly spell out that whether it's atomic in the
non-empty case is system-dependent. If the system administrator has
configured some funky filesystem options, they may be out of luck on the
atomicity front.

https://gitlab.gnome.org/GNOME/glib/issues/1302
2018-06-15 14:47:47 +01:00
Xavier Claessens
acb4f54833 Merge branch 'meson-functions' into 'master'
Meson: Add missing checks for functions

See merge request GNOME/glib!114
2018-06-15 13:27:18 +00:00
Xavier Claessens
a633e260c7 Merge branch 'gitlab' into 'master'
docs: Change Bugzilla references to GitLab

See merge request GNOME/glib!116
2018-06-15 13:23:52 +00:00
Philip Withnall
5e46a97ac6 gvariant: Document differences between GVariant bytestrings and arrays
https://gitlab.gnome.org/GNOME/glib/issues/896
2018-06-15 13:17:25 +01:00
Philip Withnall
09419fdeb4 gvariant: Change type of ‘y’ variants from guchar to guint8
This fits better with the convention in the rest of GLib where arbitrary
8-bit values are represented as guint8, avoiding the potential confusing
of a name which references ‘char’s.

This is not an API break, as both guint8 and guchar are unconditionally
typedeffed to unsigned char.

https://gitlab.gnome.org/GNOME/glib/issues/896
2018-06-15 13:10:36 +01:00
Philip Withnall
77dba8537c docs: Rename README.commits to CONTRIBUTING.md
That means GitLab will automatically pick it up and link people to it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-15 13:05:00 +01:00
Philip Withnall
c200c1d1df docs: Rename README.in to README.md for GitLab
There seems to be little point in substituting the version number into
README (using autotools). Rename it to README.md and distribute that
verbatim (with autotools and Meson) instead.

Autotools still requires that README exists, so leave a stub README file
in place which redirects people to README.md. This can be dropped when
we drop autotools support.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-15 13:04:59 +01:00
Olivier Crête
8e65417c6e docs: Change Bugzilla references to GitLab
Including modifications by Philip Withnall <withnall@endlessm.com>
2018-06-15 13:04:39 +01:00
Philip Withnall
3126f73c80 Merge branch '1368-codegen-interface-info' into 'master'
gdbus-codegen: Add a mode to generate GDBusInterfaceInfo structures

Closes #1368

See merge request GNOME/glib!13
2018-06-15 10:35:46 +00:00
Ondrej Holy
e0e0f259c3 gio: Add bash completion for gio tool
GVfs utils used to have bash completion, which was pretty useful. However,
it hasn't been ported to gio tool unfortunately. GLib provides completion
for various utils already, so it would be nice to provide completion also
for gio tool. I've updated old bash completion code and merged with some
my old unmerged fixes.

The gvfs completion used "gvfs-ls --show-completions" helper. This mentioned
option hasn't been obviously ported to "gio list" and the proposed completion
doesn't add this option in "gio list" to not pollute the codes, but maybe it
is a bit slower as consequence.

The proposed bash completion suggests subcommands, uris and paths including
the remote mounts. It contains some workarounds, especially because of proper
handling of paths with colons and other special chars (like spaces)...
2018-06-15 12:34:10 +02:00