Rework processing queue threading
authorTim Pepper <timothy.c.pepper@linux.intel.com>
Mon, 8 Oct 2012 23:06:01 +0000 (16:06 -0700)
committerTim Pepper <timothy.c.pepper@linux.intel.com>
Mon, 8 Oct 2012 23:06:01 +0000 (16:06 -0700)
commit4c0117a263c9a70e693ef4b667db3f4330855bd3
tree61420fe29e54a91f7bfd0ee540c321a0727e6f32
parent00e8de8e30d0167de7cfd468425b52be6004451c
Rework processing queue threading

This patch is a large rework to simplify the processing portion
of corewatcher.  The processing queue is represented now simply
in the filesystem by the presence of *.to_process files, or
*.processed files which lack an associated summary report *.txt file.
The scan_processed_folder() function now is a thread which sleeps on a
condition variable, which in turn is set by the event threads.  Previously
that function did an opendir() on processed_folder and spawned a thread
per found corefile to process the cores, with associated complexity in
data structures and locking.  Now that function is the main loop of the
single processing thread.

- removed remaining global state in core_status struct, processing
  queue array of filenames, simplified locking, simplified state machine,
  some function renames for clarity, updated README
- removed spawning of threads per core to process, adding instead a single
  long lived thread which sleeps on a condition variable set in
  queue_backtrace() and the timer event loop
- if a summary crash report has been created already, don't re-run gdb,
  just read in the report and try to submit it
- audited object lifetimes, added some strdup()'s, free()'s, valgrind now
  shows no leaks in corewatcher code (NOTE: a valgrind warning for
  uninitialized bytes is triggered from corewatcher's submission path
  which originates in glibc 2.16.0 resolv/res_send.c, a patch has been
  submitted to the glibc project)
- added lots of additional logging, especially in error paths
- the gdb mutex is removed as it effectively became a NOOP as it would
  now be used only in one call chain that is never called in parallel

The timer thread is still needed as network issues can prevent submission.
A network event thread could now be added to attempt submission when
any network becomes present and also to attempt reprocessing when
high-bandwidth network becomes present to improve report quality in the
case of a debuginfo daemon then being able to dynamically pull in helpful
data for gdb.  Even then the timer thread would still be needed to handle
the cases of the crashdb server being down or intermediate network issues
preventing submission, situations which aren't trivially distinguished
at the client side in order to spawn an event upon their resolution.

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