[PATCH] lib: Add thread-safety to global list of handles.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones wrote:
Subject: [PATCH] lib: Add thread-safety to global list of handles.
This commit uses the Gnulib 'lock' module to implement a mutex on the global list of handles which is stored by the library.
Note that Gnulib nicely avoids explicitly linking with -lpthread unless the application program itself links to -lpthread. Locks are only enabled in multithreaded applications.
$ ldd src/.libs/libguestfs.so.0.217.0 linux-vdso.so.1 => (0x00007fffcb7ff000) libc.so.6 => /lib64/libc.so.6 (0x00007f96a4e6c000) /lib64/ld-linux-x86-64.so.2 (0x00007f96a544d000)
Please enter the commit message for your changes. Lines starting --- bootstrap | 1 + m4/.gitignore | 2 ++ src/guestfs.c | 19 ++++++++++---------
Hi Rich, That change looks fine. However, don't you want to link with $(LIBTHREAD)? This is from gnulib/modules/lock: Link: $(LTLIBTHREAD) when linking with libtool, $(LIBTHREAD) otherwise which should imply you see that advice when running gnulib-tool (albeit along with hundreds of other less-important lines)
On Mon, Dec 07, 2009 at 12:20:10PM +0100, Jim Meyering wrote:
Richard W.M. Jones wrote:
Subject: [PATCH] lib: Add thread-safety to global list of handles.
This commit uses the Gnulib 'lock' module to implement a mutex on the global list of handles which is stored by the library.
Note that Gnulib nicely avoids explicitly linking with -lpthread unless the application program itself links to -lpthread. Locks are only enabled in multithreaded applications.
$ ldd src/.libs/libguestfs.so.0.217.0 linux-vdso.so.1 => (0x00007fffcb7ff000) libc.so.6 => /lib64/libc.so.6 (0x00007f96a4e6c000) /lib64/ld-linux-x86-64.so.2 (0x00007f96a544d000)
Please enter the commit message for your changes. Lines starting --- bootstrap | 1 + m4/.gitignore | 2 ++ src/guestfs.c | 19 ++++++++++---------
Hi Rich, That change looks fine. However, don't you want to link with $(LIBTHREAD)?
This is from gnulib/modules/lock:
Link: $(LTLIBTHREAD) when linking with libtool, $(LIBTHREAD) otherwise
which should imply you see that advice when running gnulib-tool (albeit along with hundreds of other less-important lines)
Damn, I just pushed this one :-( I'll push an update with your suggested change, which seems like it is correct. (BTW I want to link with LTLIBTHREAD, right?) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Richard W.M. Jones wrote:
On Mon, Dec 07, 2009 at 12:20:10PM +0100, Jim Meyering wrote:
Richard W.M. Jones wrote:
Subject: [PATCH] lib: Add thread-safety to global list of handles.
This commit uses the Gnulib 'lock' module to implement a mutex on the global list of handles which is stored by the library.
Note that Gnulib nicely avoids explicitly linking with -lpthread unless the application program itself links to -lpthread. Locks are only enabled in multithreaded applications.
$ ldd src/.libs/libguestfs.so.0.217.0 linux-vdso.so.1 => (0x00007fffcb7ff000) libc.so.6 => /lib64/libc.so.6 (0x00007f96a4e6c000) /lib64/ld-linux-x86-64.so.2 (0x00007f96a544d000)
Please enter the commit message for your changes. Lines starting --- bootstrap | 1 + m4/.gitignore | 2 ++ src/guestfs.c | 19 ++++++++++---------
Hi Rich, That change looks fine. However, don't you want to link with $(LIBTHREAD)?
This is from gnulib/modules/lock:
Link: $(LTLIBTHREAD) when linking with libtool, $(LIBTHREAD) otherwise
which should imply you see that advice when running gnulib-tool (albeit along with hundreds of other less-important lines)
Damn, I just pushed this one :-(
I'll push an update with your suggested change, which seems like it is correct.
(BTW I want to link with LTLIBTHREAD, right?)
Oops. Yes, since we're using libtool.
Is this right? $(LIBTHREAD) and $(LTLIBTHREAD) are empty in libguestfs, which I think it right (I don't want libguestfs to unconditionally depend on -lpthread). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
Richard W.M. Jones wrote:
$(LIBTHREAD) and $(LTLIBTHREAD) are empty in libguestfs, which I think it right (I don't want libguestfs to unconditionally depend on -lpthread). ... Subject: [PATCH] lib: Link with $(LTLIBTHREAD), required by Gnulib lock module.
Looks fine.
--- src/Makefile.am | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index c3b7392..62a94c4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -115,9 +115,11 @@ libguestfs_la_SOURCES = \ guestfs-protocol.h \ gettext.h
+libguestfs_la_LIBADD = $(LTLIBTHREAD) + # Make libguestfs include the convenience library. noinst_LTLIBRARIES = libprotocol.la -libguestfs_la_LIBADD = libprotocol.la +libguestfs_la_LIBADD += libprotocol.la
libguestfs_la_CFLAGS = \ -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"' \
On Mon, Dec 07, 2009 at 12:36:44PM +0100, Jim Meyering wrote:
Richard W.M. Jones wrote:
$(LIBTHREAD) and $(LTLIBTHREAD) are empty in libguestfs, which I think it right (I don't want libguestfs to unconditionally depend on -lpthread). ... Subject: [PATCH] lib: Link with $(LTLIBTHREAD), required by Gnulib lock module.
Looks fine.
Thanks - pushed. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
participants (2)
-
Jim Meyering -
Richard W.M. Jones