Commit Graph

98 Commits

Author SHA1 Message Date
Peter Keresztes Schmidt 7e7b1a0b1f Logger: Try harder to obtain the DB lock
Since we are now multi-threaded it can happen quite easily that a log message should be written to the DB on one thread while the other thread executes another query. Don't bail out immediately in the logging code, instead try to obtain the lock within 1s.
2021-02-08 19:07:01 +01:00
Isaac Connor 583779438b Don't unlock db_mutex if we don't get the lock in the first place 2021-02-08 11:09:44 -05:00
Peter Keresztes Schmidt cc6ea04afe Reformat touched code 2021-02-07 13:55:08 +01:00
Peter Keresztes Schmidt aec4dbc6ff DB: Make connection initialization more predictable and avoid double-initialization
Remove calls to zmDBConnect from various places to avoid possible side-effects/double initialization.
The function should be called once from the main thread of the daemon.

Also split config loading into 2 steps: static and DB config loading. Load the static config before zmDBConnect is called so it has a chance to succeed.
2021-02-07 13:44:41 +01:00
Peter Keresztes Schmidt 0dbc39ee25 Cleanup and reorganize includes
With this commit a unified structure for includes is introduced.
The general rules:
 * Only include what you need
 * Include wherever possible in the cpp and forward-declare in the header

 The includes are sorted in a local to global fashion. This means for the include order:
  0. If cpp file: The corresponding h file and an empty line
  1. Includes from the project sorted alphabetically
  2. System/library includes sorted alphabetically
  3. Conditional includes
2021-02-04 18:02:01 +01:00
Peter Keresztes Schmidt 5a57efdfe2 Replace deprecated C header includes with the C++ ones. 2021-02-04 05:39:03 +01:00
Isaac Connor 48dcb23af0 small cleanup in logging 2020-12-31 09:14:03 -05:00
Isaac Connor df783f4835 Merge branch 'master' into zma_to_thread 2020-11-12 12:53:55 -05:00
Isaac Connor a63600ccef remove dead code 2020-10-30 16:09:24 -04:00
Isaac Connor a39a656373 Merge branch 'master' into zma_to_thread 2020-09-29 11:02:40 -04:00
Peter Keresztes Schmidt 8f980a1168 Convert NULL/0 to nullptr
The 0 -> nullptr changes should definitely improve readability.
2020-08-26 22:03:40 +02:00
Isaac Connor 4ff341a0f5 Merge branch 'master' into zma_to_thread 2020-05-02 18:03:42 -04:00
Isaac Connor 6d4ed20745 Drop lock around openFile so that we don't hang 2020-03-04 14:14:28 -05:00
Isaac Connor 6da998b0c0 code comments and parenthesis 2020-01-10 16:42:18 -05:00
Isaac Connor 09fcbad666 Merge branch 'master' into zma_to_thread 2019-11-30 14:59:39 -05:00
Isaac Connor 33aa6abf59 Only open log file if we are going to write to it. 2019-09-17 11:36:57 -04:00
Isaac Connor 1a94479751 Cleanup/rework. Handle database connection failure. This can happen if we init logging before config reading. Default terminal log level to warning. Cleanup logInit copying the options in order to populate mLogPath from config. We can handle this in the constructor now. 2019-09-17 11:10:59 -04:00
Isaac Connor 077ad75516 Merge branch 'storageareas' into origin/zma_to_thread 2019-04-25 12:41:48 -04:00
Isaac Connor 293ec20824 Must unlock mutex before destructor as we do some logging in the mutex destructor when we destroy it while locked. 2019-04-15 17:54:17 -04:00
Isaac Connor 7c8b37e08c fix mutex hang on Fatal 2019-04-15 11:21:23 -04:00
Isaac Connor f726666f54 Merge branch 'master' into h265 2019-01-14 12:36:11 -05:00
Isaac Connor 28dafd5931 Merge branch 'storageareas' into zma_to_thread 2018-12-26 12:02:00 -05:00
Isaac Connor c89bb8bc16 Merge branch 'av_logging' into storageareas 2018-11-23 12:46:27 -05:00
Isaac Connor 4d4666f5e0 add a mutex in logging functions so that multiple threads can log at the same time 2018-11-23 12:45:41 -05:00
Isaac Connor 64ce035129 Merge branch 'av_logging' into storageareas 2018-11-14 17:03:32 -05:00
Isaac Connor 70d9fda758 Implement a logging callback for avcodec to use our logging functions 2018-11-14 17:02:52 -05:00
Isaac Connor a8329465fb Merge branch 'master' into h265 2018-10-22 10:30:01 -04:00
Isaac Connor 5ab1126260 Merge branch 'storageareas' into zma_to_thread 2018-10-20 17:31:14 -04:00
Isaac Connor 8f6db1c279 Merge branch 'master' into storageareas 2018-09-25 13:54:44 -04:00
Isaac Connor b55224be30 fix setting mFlush. Just have it on for DEBUG levels 2018-09-24 14:17:16 -04:00
Isaac Connor fd2e8a530c When changing log levels by SIGUSR1 turn on flushing 2018-09-24 09:40:05 -04:00
Isaac Connor 89cd7ceaf8 Whitespace, extra parentheses, google code style 2018-09-23 16:47:06 -04:00
Isaac Connor 6b05515828 fix missing sql 2018-08-31 19:14:18 -04:00
Isaac Connor 672b4affe1 Merge branch 'storageareas' into zma_to_thread 2018-08-31 19:05:22 -04:00
Isaac Connor f2d4739838 Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas 2018-08-24 17:11:39 -04:00
Isaac Connor cd6dd28280 Merge branch 'zma_to_thread' of github.com:connortechnology/ZoneMinder into zma_to_thread 2018-08-17 16:15:30 -04:00
Isaac Connor 376e15b763 trylock was interesting for debugging, but really logging should wait for the lock 2018-08-17 16:04:12 -04:00
Isaac Connor 871e3807e6 Merge branch 'master' of github.com:ZoneMinder/ZoneMinder 2018-08-17 12:57:27 -04:00
Isaac Connor 4670a7f26b move variables into deeper block 2018-08-13 10:01:04 -04:00
Isaac Connor 979b31ffc3 Merge branch 'storageareas' into zma_to_thread 2018-08-11 10:08:30 -04:00
Isaac Connor 934ce654f9 Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas 2018-06-08 15:21:43 -04:00
Isaac Connor 4454ca0072 Merge branch 'storageareas' into zma_to_thread 2018-05-20 10:39:14 -04:00
Isaac Connor 038c5f4e1a log the log line not the uninitialized sql 2018-05-14 13:57:26 -04:00
Isaac Connor 94377a4652 Merge branch 'storageareas' into zma_to_thread 2018-05-05 12:57:50 -04:00
Isaac Connor 67adad5d5c use trylock instead of lock because our signal handler may try to log while the db is locked 2018-05-03 13:53:53 -04:00
Isaac Connor c8eab2d275 remove debug log to stdout that shouldn't be there. It messes up zms 2018-05-01 09:41:46 -04:00
Isaac Connor a4da624f4c break out of loops when zm-terminate is set 2018-04-27 13:20:38 -07:00
Isaac Connor cd3046abb3 Merge branch 'storageareas' into zma_to_thread 2018-04-14 11:03:08 -04:00
Isaac Connor fc38fdcc56 remove extra spaces 2018-04-05 11:30:01 -04:00
Isaac Connor ceb12cdd81 undo a debug thing that shouldn't have been committed 2018-04-03 09:12:18 -04:00