Commit Graph

31 Commits

Author SHA1 Message Date
Chrissie Caulfield
e038f59c52
tests: Close race condition in check_loop (#480)
Start the "check_time_left" timer before the "stop_job" timer so
that we can be sure that it exists when "check_time_left" is run.
2023-01-06 13:30:51 +00:00
Chrissie Caulfield
fde729e137
timer: Move state check to before time check (#479)
A timer in QB_POLL_ENTRY_JOBLIST doesn't necessarily
have a t->timerlist_handle so that deref can segv. Also
the comment assumes the timers are threaded - which as we have
decided is definitely not true. So it's safe to move the check
earlier.

In the tests, I've adjusted the timeouts so that they definitely
happen at different times. On some architectures they can fire
concurrently and in the wrong order.
2023-01-05 14:45:22 +00:00
Chrissie Caulfield
73472e0b13
Tidy some scripts (#454)
* Tidy some scripts

Errors reported by Centos covscan

I changed %N to %s as BSD's date command doesn't support %N.
Seconds + PID should be enough ....

* Shrink the name of the dlock tests as they cause random failures

When the PID numbers get big, the socket name overflows the allowed
limit

* Increase timeout of thread check.

It's been seen to time out too early and fail the tests
2022-01-19 12:50:45 +00:00
Jan Friesse
48fff5eb58
Implement heap based timer list (#439)
* tlist: Add heap based implementation of timer list

Previous timer was sorted list implementation of priority queue
and very slow when number of timers increased. This is mostly
not a problem because usually only few timers are used.
But for application where bigger number of timers are needed
it may become problem.

Solution is to use binary heap based priority queue which is much
faster.

API is unchanged, just timerlist_destroy is added which should be called
to free heap array. This function also destroys mutex (omitted when
mutex was added).

* tests: Fix check loop mt test

test_th was accesed both by main thread and loop_timer thread resulting in
failure. Fix is to access test_tht in loop_timer thread.

Speed test is adding only 10000 items so it is reasonable
fast even with sorted linked list implementation.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2021-03-18 07:27:25 +00:00
Chrissie Caulfield
d6e2bd1d6b
timers: Add some locking (#436)
Fix several locking issues reported by helgrind
2021-02-08 10:57:42 +00:00
Chrissie Caulfield
06ac2d43a9
cov: Quieten some covscan warnings (#427) 2020-12-03 09:39:28 +00:00
Chrissie Caulfield
d01a9e0adf
tests: Remove deprecated check macros (#412)
fail_if() and fail_unless() macros are deprecated in more
recent versions of check and are buggy in 0.15, so replace
them with ck_assert() instead.
2020-07-29 14:06:22 +01:00
Chris Murphy
08806c5301
master: Issue 390: Clarify documentation of qb_loop_timer_expire_time_get and provide new function to return previously documented behavior (#391)
Includes unit test addition by chrissie-c
2020-04-29 13:20:52 +01:00
Christine Caulfield
5889f1ea46 tests: make qb logging under check always dispose the memory
examples/tests: make qb logging dispose the memory

A.k.a. "be a good example of using this very library".

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2017-09-18 10:30:40 +01:00
Christine Caulfield
c751993c90 loop: don't override external signal handlers
qb_loop_signal_add() used to set any signals it wasn't managing
back to SIG_DFL. This is unfriendly behaviour in a library.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Pokorný <jpokorny@redhat.com>
2017-02-24 16:23:43 +00:00
Jan Pokorný
3d6135967a
tests: refactor test case defs using versatile add_tcase macro
This reduces repeated code significantly, and allows for easier
supervision of what's being grouped to the suites + possibly what
timeouts apply.

Note that some artificial test case identifiers (in check_array.c,
check_log.c, check_loop.c, check_rb.c, check_utils.c) got changed
so they now follow 1:1 the test (function) name that is being run
for the case at hand without the "test_" prefix (strict convention).
Exception to this are test_ipc_disp_* tests in check_ipc.c that got,
conversely, changed to test_ipc_dispatch_* to follow the test case
identifiers.
2016-03-01 15:11:38 +01:00
Angus Salkeld
157cec22a7 TEST: add a test to check the order of the jobs
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-03-09 19:33:35 +11:00
Angus Salkeld
bf35fb0e5a TEST: add some more signal tests.
-Make sure we only get one callback per signal
-Make sure we correctly delete a callback even if it has been
 put in the job queue.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-03-06 22:36:39 +11:00
Angus Salkeld
e37f801170 LOOP: add qb_loop_timer_is_running()
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-22 11:08:42 +11:00
Angus Salkeld
70f1eb8130 LOOP: add a function to delete jobs
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-15 22:18:43 +11:00
Angus Salkeld
1e4b33c9cf LOOP: make it possible to pass in NULL as the default loop instance
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-10 14:47:49 +11:00
Angus Salkeld
ae682d2a78 TEST: make the loop ratelimit test more forgiving.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-08 17:45:42 +11:00
Angus Salkeld
9340221261 TEST: check for a single job causing a cpu spin
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-07 09:41:00 +11:00
Angus Salkeld
a95618ddd3 Fix some issues found by clang
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-03 14:37:37 +11:00
Angus Salkeld
29d193112a LOOP: allow a timer to be created without returning the handle
This is if the user does not plan to delete the timer.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-01-23 16:04:49 +11:00
Angus Salkeld
e235412497 TESTS: add tests for signal handlers
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-01-18 22:30:35 +11:00
Angus Salkeld
45fa3b045d TESTS: use new logging API
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2011-04-14 16:05:46 +10:00
Angus Salkeld
7cd7dc106c TESTS: make sure timers are not leaking file descriptors
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-12-22 09:12:57 +11:00
Angus Salkeld
45ff679934 LOOP: change timers to be nano second based
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-12-13 12:23:45 +11:00
Angus Salkeld
1a073f7b29 LOOP: prevent timers from deleting them selves.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-11-15 16:03:31 +11:00
Angus Salkeld
f7f6c89591 TLIST: use qb_util_nano_monotonic_hz() instead of HZ
also add a test for under running.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-11-12 15:15:31 +11:00
Angus Salkeld
e7d2dd9646 LOOP: add signal support to main loop
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-11-09 11:51:22 +11:00
Angus Salkeld
920a927116 Cleanup config defines & add a check_all script
Run:
./check_all
to build with and without some common configurations.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-11-01 22:05:46 +11:00
Angus Salkeld
dc08661297 LOOP: add support for timerfd
If available use timerfd_create() as it is
much more accurate than tlist.h

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-11-01 10:14:08 +11:00
Angus Salkeld
970a4bc6d5 LOOP: add qb_loop_destroy()
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-10-30 20:51:36 +11:00
Angus Salkeld
e211caab96 LOOP: fix job poll and simplify main loop
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2010-10-29 22:26:46 +11:00