gio: fix compilation without F_{S,G}ETPIPE_SZ

Commit a5778ef7c5 broke compilation on
architectures without F_SETPIPE_SZ and F_GETPIPE_SZ such as or1k.
If those variables are undefined, put back previous behavior, buffer
size set to 1024 * 64

Fixes:
 - http://autobuild.buildroot.net/results/398490e07343a931b25ca6ab5c90a75d7a073e9f

(Modified by Philip Withnall <withnall@endlessm.com> to add an
explanatory comment.)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795133
This commit is contained in:
Fabrice Fontaine 2018-04-10 18:55:11 +02:00 committed by Philip Withnall
parent ca0add4b8a
commit 0beb62f564

View File

@ -3012,6 +3012,7 @@ splice_stream_with_progress (GInputStream *in,
if (!g_unix_open_pipe (buffer, FD_CLOEXEC, error)) if (!g_unix_open_pipe (buffer, FD_CLOEXEC, error))
return FALSE; return FALSE;
#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
/* Try a 1MiB buffer for improved throughput. If that fails, use the default /* Try a 1MiB buffer for improved throughput. If that fails, use the default
* pipe size. See: https://bugzilla.gnome.org/791457 */ * pipe size. See: https://bugzilla.gnome.org/791457 */
buffer_size = fcntl (buffer[1], F_SETPIPE_SZ, 1024 * 1024); buffer_size = fcntl (buffer[1], F_SETPIPE_SZ, 1024 * 1024);
@ -3029,6 +3030,13 @@ splice_stream_with_progress (GInputStream *in,
goto out; goto out;
} }
} }
#else
/* If #F_GETPIPE_SZ isnt available, assume were on Linux < 2.6.35,
* but 2.6.11, meaning the pipe capacity is 64KiB. Ignore the possibility of
* running on Linux < 2.6.11 (where the capacity was the system page size,
* typically 4KiB) because its ancient. See pipe(7). */
buffer_size = 1024 * 64;
#endif
g_assert (buffer_size > 0); g_assert (buffer_size > 0);