Dynamically allocated GMutex and GCond variables
authorTim Pepper <timothy.c.pepper@linux.intel.com>
Thu, 11 Oct 2012 20:48:08 +0000 (13:48 -0700)
committerTim Pepper <timothy.c.pepper@linux.intel.com>
Thu, 11 Oct 2012 20:48:08 +0000 (13:48 -0700)
commit14074ad4d7ff3b13997e9329958de272c8223e05
tree45200c4df72a9ecc6887f63c7df350f8de24f5fe
parente696e6780fb7d63bd6f503c85e69236317e753c3
Dynamically allocated GMutex and GCond variables

The GLib documentation says statically allocated GMutex and GCond
variables do not need initialized.  This seems to imply magic on
first use.  That magic could be possible, but would be inefficient.
More likely is that they meant statical globals don't need initialization
because they are zero'd, where static locals are on the stack and could
be / are uninitialized?  But even that doesn't mesh with some runtime
behavior I've sometimes seen with my two statically allocated global
GMutex/GCond pairs:

+ Not running as daemon
+ Begin scanning /var/lib/corewatcher/...
GLib (gthread-posix.c): Unexpected error from C library during
'pthread_mutex_lock': Invalid argument.  Aborting.

Converting them to dynamically allocated variables, with the whole slough
of new/init/clear/free calls seems to fix this as expected.  Of course
the clear/free calls are never reached, since the threads only end/exit
via an (currently) unhandled signal and thus add to the list of things
about which valgrind complains at exit.

Signed-off-by: Tim Pepper <timothy.c.pepper@linux.intel.com>
src/coredump.c
src/corewatcher.c
src/corewatcher.h
src/submit.c