Commit Graph

1465 Commits

Author SHA1 Message Date
Stanisław Pitucha
4e7ebfac9a
Add fdatasync declaration on darwin (#496) 2024-08-28 15:34:04 +01:00
wferi
40542f314e
doxygen2man: Fix typos and inconsistencies in help text (#497) 2024-05-18 17:12:47 +02:00
Ken Gaillot
1070cbc17c
Make some logs less noisy (#495)
* log: lower IPC connection issues to info level

... in handle_new_connection(). The caller has better context for whether a
problem merits a warning or error, and the function's return code is
sufficiently descriptive to do so. Some problems may be expected or able to be
worked around.

For example, Pacemaker's crm_mon attempts to contact pacemakerd IPC. On a
Pacemaker Remote node, that IPC will be unavailable, and crm_mon can check the
libqb return code to detect and handle that situation gracefully.

* log: lower some ringbuffer debug messages to trace level

They're rather noisy, with every shm-based IPC connection generating multiple
obscure messages like:

  debug: shm size:1048589; real_size:1052672; rb->word_size:263168

and every disconnect generating the rather unhelpful:

  debug: qb_ipcc_disconnect()

along with multiple messages like:

  debug: Closing ringbuffer: /dev/shm/qb-10986-11014-34-26VRvs/qb-request-cmap-header

All of these seem appropriate to trace level.
2024-01-31 09:44:16 +00:00
Chrissie Caulfield
c7528139dc
doxygen2man: Include libxml/parser.h (#494)
This seems to be needed for newer versions of libxml
but shouldn't break older ones (CI to confirm!)
2023-11-20 13:15:21 +01:00
Chrissie Caulfield
a3201f55fa
tests: Fix shebang on ipc_sock_test (#493) 2023-11-15 10:46:21 +00:00
Chrissie Caulfield
9297df4e48
Change assert in ringbuffer to a return code (#492)
Why just this one?

There are LOADS of asserts in libqb, some are OK and some may be
overkill. This one in particular is causing CI failures
and so annoys me more than the rest.
2023-11-15 09:03:52 +00:00
Christine Caulfield
002171bbcf Update library version for 2.0.8 2023-07-21 12:30:39 +01:00
Chrissie Caulfield
1bbaa929b7
log: fix potential overflow with long log messages (#490)
qb_vsnprintf_serialize was called with 'max_size' as the
limiting number for the length of the formatted log
message. But the buffer also needs to contain the
log header (given by 'actual_size'), so we now pass
't->max_line_length' as the maximum length of the
formatted log message to limit space to the actual 
bytes left

Also added error checks to the blackbox calls at
the end of the test, as these now provide a proper
test that the BB is functioning. Before they were
masking failures.
2023-07-20 07:19:01 +01:00
Chrissie Caulfield
92ddd7c929
test - fix test dependancies (#489)
Fix a ridiculous thinko in the test deps for -j
2023-06-10 05:21:55 +02:00
Christine Caulfield
06c8641de2 Update -version info for 2.0.7 2023-06-07 07:50:17 +01:00
Jan Friesse
066508666e
spec: Migrate to SPDX license (#487)
Both Fedora and openSUSE now recommends to use SPDX shortname format
for License.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2023-06-07 07:18:46 +01:00
Chrissie Caulfield
5862acbaef
blackbox: fix potential overlow/memory corruption (#486)
if the message was too long, then msg_len was added to the
buffer size twice, thus causing potential data corruption
(seen VERY rarely in the CI test - or, at least, I think it was
this).

Also fix a double close() spotted by gcc13's -fanalyzer
2023-06-05 09:51:38 +01:00
Chrissie Caulfield
a3aedbc419
tests: allow -j to work (#485)
build: fix several issues with building tests

- MAINTAINERCLEANFILES should not rely on conditionals
  that could or could not clean files.

- EXTRA_DIST should not rely on conditonals that could
  or could not add files to the final tarball.
  sources should always ship.

- CLEANFILES should not rely on conditionals as
  ./configure can be done in between builds leaving
  stray files around.

- (cosmetic) move distclean-local: target with clean-local.

- drop old ipc_sock.test, start.test and resources.test
  shell files.

- fix make distcheck -j:
  - stop shipping or not shipping libstat_wrapper.so.
    libtool will only generate the .so when installing
    a shared library (--enable-install-tests).
  - make libstat_wrapper a module in a similar fashion
    of _failure_injection.
  - build ipc_sock.test in a similar fashion as ipc.test
    and link as module _libstat_wrapper.la.
    this solves multiple issues of having the binary
    in the final test builddir, no need to detect if
    libstat_wrapper.so is installed or not and workaround
    libtool different linking methods for inst vs noinst
    libraries.

- fix ipc.test linking with GLIB that should not be
  dependent on HAVE_FAILURE_INJECTION.

Run tests in parallel with dependancies
Make sure the two IPC tests use different socket names
Shortedn some names so they fit with the new ipc-names
remove ipc-test-name-sock
Fix resources.test now that ipc_sock is being run properly

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2023-05-26 20:21:43 +02:00
Chrissie Caulfield
335dbb6e34
test: Remove gnu/lib-names.h from libstat_wrapper.c (#482)
It doesn't appear to be needed!
2023-03-23 14:49:35 +00:00
wferi
4dcdfe9856
strlcpy: avoid compiler warning from strncpy (#473)
Otherwise GCC complains about ‘__builtin_strncpy’ specified bound
depends on the length of the source argument.

Signed-off-by: Ferenc Wágner <wferi@debian.org>
2023-03-23 12:56:19 +00:00
Fabrice Fontaine
1a32a6062c
Add --disable-tests option (#475)
Add --disable-tests to allow the user to disable tests. As a
side-effect, this will avoid the following build failure when check is
found:

libstat_wrapper.c:11:10: fatal error: gnu/lib-names.h: No such file or directory
   11 | #include <gnu/lib-names.h>
      |          ^~~~~~~~~~~~~~~~~

This build failure is raised since version 2.0.5 and
78df90b180

Fixes:
 - http://autobuild.buildroot.org/results/450cfc36d4fd6dc71c138bec45f05b5a2d92a08d

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2023-03-23 10:32:27 +00:00
wferi
10b0623533
m4/ax_pthread.m4: update to latest upstream version (serial 31) (#472)
To avoid the warning: $as_echo is obsolete message.
2023-03-23 10:20:30 +00:00
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
5594d377ac
ipc: Retry receiving credentials if the the message is short (#476)
ipc: Retry receiving credentials if the the message is short

rhbz#2111711 refers
2022-11-25 07:38:20 +00:00
growdu
e8129a34cc
add simplified chinese readme (#474) 2022-10-31 14:44:53 +00:00
Chrissie Caulfield
eaa95ecf03
lib: Fix some small bugs spotted by newest covscan (#471)
* lib: Fix some small bugs spotted by newest covscan
2022-08-17 13:17:33 +01:00
Jan Friesse
14507d538d
configure: Modernize configure.ac a bit (#470)
... to make 2.71 happy. Also increase minimum version to 2.69 (10 years
old version so should be compatible enough).

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2022-07-27 08:00:19 +01:00
Chrissie Caulfield
8325d84047
tests: Fix tests on FreeBSD-devel (#469)
FreeBSD-devel can allocate more space than requested which causes
the check to fail. So check for >= allocated rather than ==
2022-07-07 08:30:38 +01:00
Chrissie Caulfield
e407874c9c
doxygen2man: Fix function parameter alignment (#468)
Also, prevent truncation of parameter descriptions in the
body of the man page due to strtok() usage.
2022-06-16 12:38:22 +01:00
Chrissie Caulfield
0eb0991ad6
tests: cleanup the last of the empty directories (#467)
This should, FINALLY, allow the libqb tests to run
and properly cleanup up after themselves.
2022-06-16 07:17:59 +01:00
Chrissie Caulfield
44a4cb2989
tests: Make ipc test more portable (#466)
fix a couple of errors reported by covscan

1. /usr/lib64/libqb/tests/resources.test:8:34: warning[SC2039]: In POSIX sh, UID is undefined.
1. /usr/lib64/libqb/tests/resources.test:8:30: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
1. /usr/lib64/libqb/tests/ipc_sock.test:10:34: warning[SC2039]: In POSIX sh, UID is undefined.
1. /usr/lib64/libqb/tests/ipc_sock.test:10:30: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
2022-06-08 09:51:49 +01:00
Chrissie Caulfield
758044bed5
test: Include ipc_sock.test in the libqb-tests rpm (#463)
...but don't run it unless we are root
2022-03-23 09:54:07 +00:00
Christine Caulfield
ccdaadabe6 Bump version for 2.0.5 release 2022-03-21 09:14:52 +00:00
Chrissie Caulfield
78df90b180
tests: Run IPC with use-filesystem-sockets active (#455)
* tests: Run IPC with use-filesystem-sockets active

Provide an LD_PRELOAD library that simulates the presence
of /etc/libqb/use-filesystem-sockets so that we can test
that functionality without actually having the file on
the system and affecting everything else running on the
box.

* use $() rather than ``

* Cope with spaces in directory names

* Docs: quote DOXYGEN2MAN in Makefile.am rather than configure.ac
2022-03-21 09:10:35 +00:00
Chrissie Caulfield
06e318fdc0
blackbox: Sanitize items read from the blackbox header (#438)
covscan complained we don't check the blackbox header when
reading it in. (quite reasonably)

Note that we still get a covscan error for ->shared_data, but that's
really impossible to verify in the read routine, so I'll leave the
covscan waiver to handle that.
2022-03-18 10:04:58 +00:00
Chrissie Caulfield
2d3cd761cf
test: Clean /dev/shm a bit better (#459)
* test: Clean /dev/shm a bit better

This isn't perfect, but it does tidy more of /dev/shm than
previously. Because some of the tests leave empty directories
we have no way of telling (in resources.test) whether they
belong to this test run, another test run, or a running
application.
2022-03-18 10:04:23 +00:00
Chrissie Caulfield
2d03793eb0
unix: Don't fail on FreeBSD running ZFS (#461)
* unix: Don't fail on FreeBSD running ZFS

ZFS doesn't support posix_fallocate() so libqb IPC or RB would
always fail with EINVAL.

As there seems to be no prospect of a more useful return code,
trap it in a QB_BSD #ifdef. That way if we do have actual errors
in the posix_fallocate() call the Linux tests should still find them.

Also, stick a small sleep in the test_ipc_disconnect_after_created
test to allow the server to shutdown before killing it with SIGTERM
and causing a test failure. all the other uses of it seem to have this
sleep!
2022-03-17 07:47:39 +00:00
Christine Caulfield
f5106342d0 ipcc: Fix errno returned from qb_ipcc_connect
The errno value from qb_ipcc_connect was incorrectly negated
when I introduced qb_ipcc_async_connect()
2022-03-03 07:29:07 +00:00
Ken Gaillot
3fb2b59751 util: reimplement time functions as a series of fallbacks
Previously, when clock_gettime() was available, the time functions would use
that (regardless of success or failure), otherwise they would use
gettimeofday() if available.

Now, the functions first try clock_gettime() if available, but if that is
unavailable or fails, they then try gettimeofday() if available, but if that is
not available or fails, they try time().
2022-02-14 12:25:19 +00:00
Ken Gaillot
da12cc9695 util: use HAVE_GETTIMEOFDAY where appropriate
configure.ac already defined HAVE_GETTIMEOFDAY, but the uses of gettimeofday()
weren't guarded by it. It obviously doesn't matter on any currently supported
platforms, but it will be needed for planned changes.
2022-02-14 12:25:19 +00:00
Ken Gaillot
354c0c2531 util: drop HAVE_CLOCK_GETRES_MONOTONIC configure constant
It doesn't provide a significant benefit over just trying the call.
It was added by 6bd3f086 for Hurd support.
2022-02-14 12:25:19 +00:00
Ken Gaillot
1e67908580 util: add constant for which realtime clock to use
... to reduce code duplication and improve readability
2022-02-14 12:25:19 +00:00
Ken Gaillot
4f82b0b6c4 util: refactor so ifdef's are withing each time-related function
The time-related functions have two implementations, one if clock_gettime() is
available and the other if not.

Previously, there was one big ifdef-else with the clock_gettime()
implementation of each function followed by the other implementation of each
function.

With this commit, each function is defined once, with an ifdef-else inside it
with the two implementations of that function. For ease of review, no other
code changes are made, but the intent will become obvious with later changes.
2022-02-14 12:25:19 +00:00
Chrissie Caulfield
5f8278ac60
Bring the INSTALL guide up-to-date (#456) 2022-02-02 07:21:26 +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
Jakub Jankowski
176eae8f13
Retry if posix_fallocate is interrupted with EINTR (#453)
Every now and then Pacemaker reports errors:

  (pcmk__new_client)        debug: New IPC client 3efdbecf-c2d9-44bc-b4a6-9bcd48021ba1 for PID 27492 with uid 0 and gid 0
  (handle_new_connection)   debug: IPC credentials authenticated (/dev/shm/qb-7271-27492-12-hfPbKY/qb)
  (qb_ipcs_shm_connect)     debug: connecting to client [27492]
  (qb_rb_open_2)    debug: shm size:524301; real_size:528384; rb->word_size:132096
  (qb_rb_open_2)    debug: shm size:524301; real_size:528384; rb->word_size:132096
  (qb_sys_mmap_file_open)   error: couldn't allocate file /dev/shm/qb-7271-27492-12-hfPbKY/qb-event-cib_rw-data: Interrupted system call (4)
  (qb_rb_open_2)    error: couldn't create file for mmap
  (qb_ipcs_shm_rb_open)     error: qb_rb_open:/dev/shm/qb-7271-27492-12-hfPbKY/qb-event-cib_rw: Interrupted system call (4)
  (qb_rb_close_helper)      debug: Free'ing ringbuffer: /dev/shm/qb-7271-27492-12-hfPbKY/qb-response-cib_rw-header
  (qb_rb_close_helper)      debug: Free'ing ringbuffer: /dev/shm/qb-7271-27492-12-hfPbKY/qb-request-cib_rw-header
  (qb_ipcs_shm_connect)     error: shm connection FAILED: Interrupted system call (4)
  (handle_new_connection)   error: Error in connection setup (/dev/shm/qb-7271-27492-12-hfPbKY/qb): Interrupted system call (4)

While it probably might be addressed in Pacemaker code, a simple retry
loop in case posix_fallocate(3) returns EINTR seems to be a decent
workaround.

Fixes: #451

Signed-off-by: Jakub Jankowski <shasta@toxcorp.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2022-01-14 07:57:25 +00:00
Chrissie Caulfield
de5ab3029c
ipcc: Add an async connect API (#450) 2022-01-05 10:53:09 +00:00
Christine Caulfield
a2691b9618 Bump library version for v2.0.4 2021-11-12 13:18:47 +00:00
Chrissie Caulfield
d4b49fb5e9
poll: Don't log in a signal handler (#447)
qb_log calls malloc() and probably many other non-signal-safe
functions, so don't call it in the signal handler.

Thanks to Honza for spotting this

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2021-11-10 12:35:07 +00:00
Chrissie Caulfield
a60ca50b67
Fix pthread returns (#444)
pthread calls do not set errno, they return the error directly
2021-08-11 07:55:42 +01:00
Chrissie Caulfield
fa59903037
doxygen2man: print structure descriptions (#443)
* doxygen2man: print structure descriptions
* get rid of double-cast as it doesn't seem to do anything
2021-07-01 09:33:58 +01: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
orbea
9e1e3a2f4b
build: Fix undefined pthread reference. (#440) 2021-03-17 09:32:51 +00:00
Christine Caulfield
404adbcd99 release: bump library version for 2.0.3 release 2021-03-03 08:32:09 +00:00