Commit graph

15 commits

Author SHA1 Message Date
Robin Sommer
4558195dab Merge remote-tracking branch 'origin/topic/bernhard/log-threads' into topic/robin/log-threads
* origin/topic/bernhard/log-threads:
  remove unnecessary error function from manger
2012-02-27 19:07:06 -08:00
Robin Sommer
d24cdd3ba3 Merge remote-tracking branch 'origin/master' into topic/robin/log-threads
Conflicts:
	src/LogMgr.h
	src/RemoteSerializer.cc
	src/logging/Manager.cc
	src/logging/writers/Ascii.cc
	src/net_util.cc
2012-02-27 19:05:47 -08:00
Bernhard Amann
bc6ebe53cc remove unnecessary error function from manger 2012-02-16 11:31:30 -08:00
Robin Sommer
1f8b299aaf Shortening file names a bit. 2012-02-14 10:12:09 -08:00
Robin Sommer
e2794c809f Merge remote-tracking branch 'origin/topic/bernhard/log-threads' into topic/robin/log-threads
* origin/topic/bernhard/log-threads:
  typo
  fix CreateBackend function - the way that the right backend was chosen & backends were initialized did not make sense...
  backend does not need friend access to manager
  move Value and Field from the logging namespace to the threading namespace, because other modules using threading will need them.
  send enum instead of string
  memleak fix.
  make logging framework send the protocol to the writer.
2012-02-14 10:08:46 -08:00
Bernhard Amann
1e4a93c767 Merge remote-tracking branch 'origin/topic/bernhard/log-threads' into topic/bernhard/log-threads 2012-02-13 02:35:10 -08:00
Bernhard Amann
8a6dfee00c Merge remote-tracking branch 'origin/topic/robin/log-threads' into topic/bernhard/log-threads 2012-02-13 02:30:24 -08:00
Robin Sommer
b8ec653ebf Bugfixes.
- Data queued at termination wasn't written out completely.

    - Fixed some race conditions.

    - Fixing IOSource integration.

    - Fixing setting thread names on Linux.

    - Fixing minor leaks.

All tests now pass for me on Linux in debug and non-debug compiles.

Remaining TODOs:

        - Needs leak check.

        - Test on MacOS and FreeBSD.

        - More testing:
            - High volume traffic.
            - Different platforms.
2012-02-12 13:07:26 -08:00
Bernhard Amann
f76bbf01a4 fix CreateBackend function - the way that the right backend was chosen & backends were initialized did not make sense... 2012-02-06 13:15:01 -08:00
Bernhard Amann
115e6a18b4 Merge branch 'topic/bernhard/log-send-proto' into topic/bernhard/log-threads
Send protocol type to log writers - the ascii writer simply ignores this, but the input reader needs support for this.

Conflicts:
	src/LogMgr.h
	src/logging/Manager.cc
2012-02-06 11:08:32 -08:00
Bernhard Amann
a0487ecb30 move Value and Field from the logging namespace to the threading namespace, because other modules using threading will need them. 2012-02-03 14:12:29 -08:00
Robin Sommer
70fe7876a1 Updating thread naming.
Also includes experimental code to adapt the thread name as shown by
top, but it's untested.
2012-02-03 04:04:38 -08:00
Robin Sommer
ffb4094d36 Bugfixes 2012-02-03 04:04:38 -08:00
Robin Sommer
29fc56105d Documenting logging API. 2012-02-03 04:04:37 -08:00
Robin Sommer
e4e770d475 Threaded logging framework.
This is based on Gilbert's code but I ended up refactoring it quite a
bit. That's why I didn't do a direct merge but started with a new
branch and copied things over to adapt. It looks quite a bit different
now as I tried to generalize things a bit more to also support the
Input Framework.

The larger changes code are:

    - Moved all logging code into subdirectory src/logging/. Code
      here is in namespace "logging".

    - Moved all threading code into subdirectory src/threading/. Code
      here is in namespace "threading".

    - Introduced a central thread manager that tracks threads and is
      in charge of termination and (eventually) statistics.

    - Refactored logging independent threading code into base classes
      BasicThread and MsgThread. The former encapsulates all the
      pthread code with simple start/stop methods and provides a
      single Run() method to override.

      The latter is derived from BasicThread and adds bi-directional
      message passing between main and child threads. The hope is that
      the Input Framework can reuse this part quite directly.

    - A log writer is now split into a general WriterFrontend
      (LogEmissary in Gilbert's code) and a type-specific
      WriterBackend. Specific writers are implemented by deriving from
      the latter. (The plugin interface is almost unchanged compared
      to the 2.0 version.).

      Frontend and backend communicate via MsgThread's message
      passing.

    - MsgThread (and thus WriterBackend) has a Heartbeat() method that
      a thread can override to execute code on a regular basis. It's
      triggered roughly once a second by the main thread.

    - Integration into "the rest of Bro". Threads can send messages to
      the reporter and do debugging output; they are hooked into the
      I/O loop for sending messages back; and there's a new debugging
      stream "threading" that logs, well, threading activity.

This all seems to work for the most part, but it's not done yet.

TODO list:

    - Not all tests pass yet. In particular, diffs for the external
      tests seem to indicate some memory problem (no crashes, just an
      occasional weird character).

    - Only tested in --enable-debug mode.

    - Only tested on Linux.

    - Needs leak check.

    - Each log write is currently a single inter-thread message. Bring
      Gilbert's bulk writes back.

    - Code needs further cleanup.

    - Document the class API.

    - Document the internal structure of the logging framework.

    - Check for robustness: live traffic, aborting, signals, etc.

    - Add thread statistics to profile.log (most of the code is there).

    - Customize the OS-visible thread names on platforms that support it.
2012-01-27 17:16:14 -08:00
Renamed from src/LogMgr.cc (Browse further)