Commit Graph

1422 Commits

Author SHA1 Message Date
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
Aleksei Burlakov
aae7a0aa5d
syslog: Add a message-id parameter for messages (#433)
The message-id parameter will enable systemd catalogs.
To enable message-id's the libqb should be configured with the
 --enable-systemd-journal option.

Co-authored-by: root <Aleksei Burlakov>
2021-03-01 15:58:50 +00:00
Chrissie Caulfield
c7e1afefae
tests: Fix up resources.test (#435)
resources.test has not checked the right filenames for a while.
Fix this, and also make sure we don't count (but remove) the dlock
test files.
2021-02-08 11:01:13 +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
991872eded
ipcc: Have a few goes at tidying up after a dead server (#434)
This is an attempt to make sure that /dev/shm is cleaned up when a
server exits unexpectedly. Normally it's the server's responsibility
to tidy up sockets, but if it crashes or is killed with SIGKILL then
the client (us) makes a reasonable attempt to tidy up the server sockets
we have connected. The extra delay here just gives the server chance to
disappear fully. As a client we can get here pretty quickly but shutting
down a large server may take a little longer even when SIGKILLed.
The 1/100th of a second is an arbitrary delay (of course) but seems to
catch most servers in 2 tries or less.
2021-01-25 12:19:10 +00:00
Chrissie Caulfield
5097155bdf
strlcpy: Check for maxlen underflow (#432)
* strlcpy: Check for maxlen underflow

https://github.com/ClusterLabs/libqb/issues/429

* Always terminate the string if maxlen is > 0
2021-01-13 14:12:02 +00:00
Chrissie Caulfield
47ed440397
doxygen2man: fix printing of lines starting with '.' (#431)
if a line starts with a '.' (eg the '...' in qbarray.h) then
nroff thinks it's looking for a macro called '..'.

The easiest solution is to add a dummy format at the start of the line
(just adding \ seems not to work).
2021-01-07 09:08:46 +00:00
wferi
5b16d504ff
doxygen2man: ignore all-whitespace brief descriptions (#430) 2021-01-04 09:08:18 +00:00
Christine Caulfield
def947efcf lib: Update library version for 2.0.2 release
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2020-12-03 13:05:43 +00:00
Hideo Yamauchi
51f181b3cd
ipcs : Decrease log level. (#426)
of ipcs event notification 'errors' that can occur in normal use.
2020-12-03 11:33:30 +00:00
Chrissie Caulfield
06ac2d43a9
cov: Quieten some covscan warnings (#427) 2020-12-03 09:39:28 +00:00
Chrissie Caulfield
c2dfe66584
doxygen2man: Fix a couple of covscan-detected errors (#425)
doxygen2man: Fix a couple of covscan-detected errors

 also check for strings longer than 4096
2020-10-22 08:17:31 +01:00
Chrissie Caulfield
51f64ed233
ipcs: ftruncate is not support on WIN32 (#424)
https://github.com/microsoft/WSL/issues/902
2020-10-05 08:08:48 +01:00
Chrissie Caulfield
a52d912675
ipcs: Add missing qb_list_del when freeing server (#423)
* ipcs: Remove list not used

Thanks to minhbq for pointing this out
2020-10-05 08:08:09 +01:00
Chrissie Caulfield
680db526f6
ipc: add qb_ipcc_auth_get() API call (#418)
* ipc: addd qb_ipcc_auth_get() API call

We can't use SO_PEERCRED on the client fd when using socket IPC
becayse it's a DGRAM socket (pacemaker tries this). So provide
an API to get the server credentials that libqb has already
squirreled away for its own purposes.

Also, fix some unused-variable compiler warnings in unix.c
when building on systems without posix_fallocate().
2020-09-28 09:53:21 +01:00
wferi
6853eeaea6
doc related fixups (#421)
* Fix documentation typo in qbrb.h

* Fix section number in doxygen2man manual

* Point Doxygen to our examples

* No HTML documentation anymore
2020-09-25 08:52:36 +01:00
Chrissie Caulfield
073befc1ce
doxygen2man: Remove horrible hack (#420)
It caused \f macros to get truncated and doesn't actually affect
the groffed output anyway
2020-09-25 07:50:19 +01:00
Chrissie Caulfield
07b59f50df
doxygen2man: Add support for @code blocks (#417)
* doxygen2man: Add support for @code blocks

Thanks Fabio for the review
2020-09-24 08:34:37 +01:00
Chrissie Caulfield
cb63b5798d
man: Tidy man pages (#416)
Fix doxygen2man to add a RETURN section even if the file has
no @return stanza.
Add support for @c tags

Quote the % signs in qb_log_format_add manpage
2020-09-16 09:55:32 +01:00
Chrissie Caulfield
6d35611524
doxygen2man: Add option to read copyright line from the header file (#415)
* doxygen2man: Add option to read copyright line from the header file

This should help make builds reproducible.

I tried various methods of getting the date, using 'git' is no use as
it could be run from a tarball, using the file date doesn't work either
so this seems a reasonable compromise.

* man: Use SOURCE_EPOCH to make manpage dates reproducible

Also add build-aux/update-copyright.sh to keep header file
copyright lines up-to-date.

All code taken from knet
2020-09-09 15:06:55 +01: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
Christine Caulfield
416caf2b92 Bump version for 2.0.1 2020-07-29 08:28:23 +01:00
wladmis
1c6229c171
unix.c: use posix_fallocate() (#409)
Using of posix_fallocate() guarantees that, if it succeed, the
attempting to write to allocated space range does not fail because of
lack of storage space. This prevents SIGBUS when trying to write to
mmaped file and no space left.

Co-Authored-by: Ivan Zakharyaschev <imz@altlinux.org>
Reported-by: Mikhail Kulagin <m.kulagin at postgrespro dot ru>

Co-authored-by: Ivan Zakharyaschev <imz@altlinux.org>
2020-07-29 07:37:09 +01:00
Fabio M. Di Nitto
caec56b295
[doxy] fix build when more aggressive -W options are used (#410)
make[2]: Entering directory '/builddir/build/BUILD/kronosnet-1.17/man'
gcc -DHAVE_CONFIG_H -I. -I..    -O3 -ggdb3 -Werror -Wall -Wextra -Wno-unused-parameter -pthread  -I/usr/include/libxml2   -c -o doxyxml-doxyxml.o `test -f 'doxyxml.c' || echo './'`doxyxml.c
doxyxml.c: In function 'allcaps':
doxyxml.c:414:13: error: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Werror=sign-compare]
  414 |  for (i=0; i< strlen(name); i++) {
      |             ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:623: doxyxml-doxyxml.o] Error 1
make[2]: Leaving directory '/builddir/build/BUILD/kronosnet-1.17/man'
make[1]: *** [Makefile:567: all-recursive] Error 1

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2020-07-15 08:25:06 +01:00
Christine Caulfield
71a9c8c923 doxygen2man: Tidy RETURN VALUE 2020-07-02 14:04:17 +01:00
Chrissie Caulfield
d1bbe1edd3
doxygen2man - Print structure descriptions (where available) (#408)
Tidy 'description' fields (get rid of superfluous newlines)
and fix a couple of crashes
2020-07-02 10:18:33 +01:00
Fabio M. Di Nitto
20ff7bcad5
[docs] fix man page distribution (#407)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2020-06-29 07:33:09 +01:00
Chrissie Caulfield
b19f706144
Make manpages (#405)
* man: Use doxygen2man to make the API manpages

* [build] drop unused target

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* [build] update gitignore

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* [docs] make build -j safe and drop unnecessary dox config files

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* man: Use doxygen2man to generate *.h.3 man pages

so we don't need to use the awful doxygen ones

Co-authored-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2020-06-26 13:03:48 +01:00
Chrissie Caulfield
b21d9a66db
CI: Remove .travis.yml (#406)
Travis is too old to be any use. It's just ceating work for no good
reason
2020-06-26 12:52:38 +01:00
Chrissie Caulfield
e592fb461e
doxygen2man: Fix a couple of the worst coverity errors (#404) 2020-06-22 13:58:21 +01:00
Chrissie Caulfield
59a16df610
doxygen2man - Lots of new features & fixes for parsing libqb manpages (#402)
doxygen2man: Lots of fixes and features

a) Make it quieter in normal operation
b) add options for hard coded things (like company name)
c) handle typedef members of structures
d) tidy function pointers in structs
e) get header file name from the XML or commandline
d) Add support for @ref tags in description
e) add support for @note annotations
f) Don't print (null) if there is no @brief description
g) Add include prefix option
h) use strncat rather than strcat
2020-06-22 13:04:16 +01:00
Chrissie Caulfield
b2acdea2a8
array: More locking fixes (#400)
* array: More locking fixes

helgrind threw out a couple more locking errors in the logging/array
code and we also need to protect a->max_elements
2020-06-08 14:16:58 +01:00
Chrissie Caulfield
08a165dc2c
test: Add unit test for ipcs_connection_auth_set() (#397)
Only if we are root
2020-06-03 08:26:51 +01:00
Chrissie Caulfield
49641930d8
log: Fix threading races (#396)
It's possible that cs->filename or cs->format could be read
in the 'fast' path while the 'slow' path is still constructing
the object. So we need to lock arr_next_lock before copying them
out for the caller.

Also wthread_should_exit was unprotected.
2020-06-01 15:41:26 +01:00
Chrissie Caulfield
bdc716036a
Some bugs spotted by coverity (#399) 2020-05-28 07:30:26 +01:00
Jan Pokorný
803d9242ff log: journal: fix forgotten syslog reload when flipped from journal
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2020-05-04 08:32:47 +01:00
Ferenc Wágner
2baa2791ce Let remote_tempdir() assume a NUL-terminated name
This is the case already.  We also fix a buffer overflow opportunity in
the memcpy() call by this change.

Conflicts:
	lib/ipc_shm.c
2020-05-01 12:57:51 +01:00
Ferenc Wágner
e26ad0dae1 Make it impossible to truncate or overflow the connection description
It's hard to predict the length of formatted output, so we'd better
notice (and abort) if the description is truncated.  Incidentally,
mkdtemp() does this for us in the shared memory branch, but do an
explicit check there as well for consistency, and get rid of the wrongly
parametrized strncat() risking a buffer overflow (CONNECTION_DESCRIPTION
is not the length of the source "/qb").

Similar truncation checks should be added to qb_ipcs_{shm,us}_connect()
where they build the request/response names, and possibly to other
places using snprintf().
2020-05-01 12:54:30 +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
Fabio M. Di Nitto
93f9975617
Doxygen2man (#388)
* doxygen2man: Add utility to generate man pages from doxygen

This is in here from kronosnet so it cna be used by other parts
of the cluster stack.

* [man] drop trailing white spaces

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* [build] cleanup variable names

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* [build] add conditionals to use internal or external doxygen2man

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

* Update .gitignore

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

Co-authored-by: Christine Caulfield <ccaulfie@redhat.com>
2020-03-18 10:29:38 +01:00
Chrissie Caulfield
1daca57c10
trie: Don't assume that chars are unsigned < 126 (#386)
* trie: Don't assume that chars are unsigned < 126

Trie fails on systems with unsigned chars when using characters over
126.
2020-03-09 08:14:39 +00:00
Jan Friesse
9249caf516
qblist: Retype ptr in qb_list_entry to char* (#385)
This allows pointer arithmetics without issuing warning.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2020-02-26 08:52:19 +00:00
Chrissie Caulfield
f54d150619
list: #include <stddef.h> in qblist.h (#384)
Some platforms require it.
2020-02-21 08:44:34 +00:00
Chrissie Caulfield
7f4600de1b
list: fix list handling for gcc10 (#383)
-Wpointer-arith has been removed from warnings as with GCC10 that warns every time qb_list_entry is used, which is just noise.
2020-02-20 14:29:33 +00:00