Try to unfuck a bit glib2 functions with pthreads(3).

Remove the non-blocking flag from the fd passed to
g_daemon_file_input_stream_new(). This is needed because our userland
threads set the fd to non-blocking where g_input_stream_*() functions
are blocking operations.
This fixes the progress bar display and allows to write to remote
directories like ftp, sftp, webdav. Reading from these remote locations
is "somehow" working now too, but there is still something fishy when
copying directories.
You have been warned. However, it's much better than it was.
This commit is contained in:
ajacoutot 2010-07-24 16:04:21 +00:00
parent 0aa15ad152
commit f7a8b003d0
3 changed files with 45 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.30 2010/07/13 16:14:28 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.31 2010/07/24 16:04:21 ajacoutot Exp $
COMMENT-main= GNOME virtual file system
COMMENT-smb= samba module for GVFS
@ -9,6 +9,8 @@ GNOME_VERSION= 1.6.3
PKGNAME-main= ${DISTNAME}
PKGNAME-smb= ${GNOME_PROJECT}-smb-${GNOME_VERSION}
REVISION-main= 0
SHARED_LIBS += gvfscommon 3.0 # .0.0
SHARED_LIBS += gvfscommon-dnssd 1.0 # .0.0

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-client_gdaemonfileinputstream_c,v 1.1 2010/07/24 16:04:21 ajacoutot Exp $
XXX Remove non-blocking flag from fd. This is needed because the
g_input_stream_*() functions are blocking but we compile with -pthread
which sets all fds to non-blocking. See pthreads(3).
--- client/gdaemonfileinputstream.c.orig Mon Oct 19 15:11:03 2009
+++ client/gdaemonfileinputstream.c Fri Jul 23 20:15:17 2010
@@ -376,6 +376,12 @@ g_daemon_file_input_stream_new (int fd,
{
GDaemonFileInputStream *stream;
+#ifdef __OpenBSD__
+ int flags = fcntl(fd, F_GETFL);
+ if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) < 0)
+ g_warning ("Couldn't remove non-blocking I/O from fd %d, fd");
+#endif
+
stream = g_object_new (G_TYPE_DAEMON_FILE_INPUT_STREAM, NULL);
stream->command_stream = g_unix_output_stream_new (fd, FALSE);

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-client_gdaemonfileoutputstream_c,v 1.1 2010/07/24 16:04:21 ajacoutot Exp $
XXX Remove non-blocking flag from fd. This is needed because the
g_input_stream_*() functions are blocking but we compile with -pthread
which sets all fds to non-blocking. See pthreads(3).
--- client/gdaemonfileoutputstream.c.orig Mon Oct 19 15:11:03 2009
+++ client/gdaemonfileoutputstream.c Fri Jul 23 20:15:29 2010
@@ -297,6 +297,12 @@ g_daemon_file_output_stream_new (int fd,
{
GDaemonFileOutputStream *stream;
+#ifdef __OpenBSD__
+ int flags = fcntl(fd, F_GETFL);
+ if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) < 0)
+ g_warning ("Couldn't remove non-blocking I/O from fd %d, fd");
+#endif
+
stream = g_object_new (G_TYPE_DAEMON_FILE_OUTPUT_STREAM, NULL);
stream->command_stream = g_unix_output_stream_new (fd, FALSE);