Commit Graph

1329 Commits

Author SHA1 Message Date
Kazunori INOUE
9b50aa4e5b configure: define AS_VAR_COPY (#267) 2017-09-18 11:31:43 +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
4bdb80bdeb config: Fix check for fdatasync
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-08-24 10:54:18 +01:00
Jan Pokorný
333fc80a80 log: use fdatasync instead of fsync where possible (#263)
Using years-old benchmark attached to PostreSQL ML[1], I've observed
tiny bit more than double boost in speed when using fdatasync instead of
traditional fsync, on two Linux machines, each equipped with an SSD.
While the observation may be disputable (there are various
interpretations to what "synchronized I/O" actually means), by logical
extension of what the two are supposed to do, one can expect fdatasync
will perform no worse than fsync.  Having the timestamps correct is
really not a priority, compared to timely processing of the message
stream.  So let's use it whenever possible with QB_LOG_CONF_FILE_SYNC
requested.

As an aside, PostreSQL seems to be be using "fdatasync" method of
updating out to disk by default on Linux till today[2].

[1] https://www.postgresql.org/message-id/1095055866.414539fadb90d@webmail.rawbw.com
    https://www.postgresql.org/message-id/attachment/20659/syncbench.c
[2] https://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-WAL-SYNC-METHOD

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-08-07 10:52:02 +01:00
Jan Pokorný
37b4e73a27 Typo fix + qb blackbox(8) tweaks and extension + gitignore follow-up (#262)
* Fix typo: occur{ -> r}(ed|ing)

* doc: qb-blackbox(8): cosmetic touches

* doc: qb-blackbox(8): add "Portability notes" subsection

* Low: build: git-ignore build-aux/release.mk "overhead" files
This should have been part of ae5138d.

* build: release.mk: ensure checksum file generated even w/o signing
This should have been part of d20e48a.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-08-07 10:21:25 +01:00
Jan Pokorný
1fa701489a Low hanging bits (#264)
* Low: log: prevent static vs. implicit non-static declaration clash
...of qb_log_callsites_dump_sect, that could happen when its usage
in qb_log_callsites_register was uncommented.

* Low: tests: fix duplicate "const" declaration specifier
This is a follow-up for d69cc7b (making the pointer itself constant was
meant as a self-defense, no-overwrite measure).

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-08-07 10:18:30 +01:00
Jan Pokorný
ef4c3a15ea Doc tweaking (#261)
* Fix typo: p{rr -> r}ocess
* doc: qbrb.h: several fixes to punctuation
* doc: qbrb.h: reindent example writer's error label as per reader
* doc: qbhdb.h: explain former importance to libqb itself
* doc: ipcc.c: explain why client would timebox recv from server
          Also refer to commit d633b4e.
* doc: qblog.h: minor stylistic/doxygen markup cosmetics
* doc: qblog.h: note qb_log_format_set vs. fork interaction wrt. PIDs

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-07-20 15:21:51 +01:00
Jan Pokorný
4af8966a57
build: release.mk: reflect current release publishing practice
In the previous maintenance epoch, libqb release files used to be
published at fedorahosted.org[1], but since the sunset of that
hosting[2] (original files now preserved[3] at [4]), only GitHub is
used to host the releases.  In fact, there was a short overlap period
(comprising just v0.17.2 tag; beware, prior archives are just autoserved
directly from the tree at that particular tag), until Chrissie decided
there's no point to handle both[5] (providentially, long before that
sunset of the former).

Unfortunately, publish-by-scp convenience of fedorahosted.org won't fly
with GitHub that insists on the (primarily REST) API to get things
automated, so update "publish" recipe to that effect, providing some
hints on possible adaption of the process.

Also, turn "git push --tags" to a bit safer "git push --follow-tags"
for good measure.

[1] https://fedorahosted.org/releases/q/u/quarterback/ (now defunct)
[2] https://lists.fedoraproject.org/archives/list/announce@lists.fedoraproject.org/message/BWSMCGZPPNG3JOCFQ6Z74MIBU7FG3KGB/
[3] http://oss.clusterlabs.org/pipermail/developers/2017-February/000438.html
[4] http://releases.pagure.org/ClusterLabs/libqb/
[5] http://oss.clusterlabs.org/pipermail/developers/2016-April/000198.html

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-13 19:55:45 +02:00
Jan Pokorný
f7e6a766fb
build: release.mk: simplify the default goal, declare .PHONY targets
The default goal line now serves mainly the documentation purpose,
otherwise it could be squashed down to "sign" target.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-13 18:43:26 +02:00
Jan Pokorný
d20e48a0b2
build: release.mk: move soft guard for no GPG key up the supply chain
It also means the missing key specification is now a hard error when
ASCII armored files are to be created (directly or by other rules).

Leveraging the previous commit, it is now unnecessary to guard against
release mode not being requested, so this guard is dropped completely
in the transition, allowing for the full-fledged (incl. GPG signing)
release delivery testing without mangling with in-tree tags.

To allow "sign" target to (possibly eventually) become the implicit goal
even if "gpgsignkey" variable is explicitly unspecified, make it depend
on "tarballs".

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-13 18:37:30 +02:00
Jan Pokorný
ae5138d3e0
build: release.mk: fix no-release conflict (implied-required version)
Previously, generating custom versioned tarballs without requiring
a "release" (which comprises also tagging hence in turn making the
implied version match the required one as desired) would not allow
to test the release routines thoroughly incl. GPG signing.
Unfortunately, allowing for a temporary tag is prone to accidentally
slipping it to the distributed tree, so that should rather be avoided.
Now it can.

Another step to blur the boundaries between whether "release" is
specified or not is make checksums file generated unconditionally.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-13 18:26:13 +02:00
Jan Pokorný
69fe0c3f16
build: release.mk: simplify/generalize GPG signing rule
Pattern matching is a brilliant DRY technique in makefile's composition,
so it would be a pity to miss such a nonconflicting application related
to the previous, "sign tarballs" commit.

For that to work reliably for the complete dependency backtrack, though,
a pre-existing issue with parallelized work on the prerequisites needs
to be fixed first.  The problem was "tarballs" (phony) target missing
in the linearized supply chain for the signed tarballs, as opposed to
to supply chain for the checksums file that can be worked on in an
(unordered!) interleave with the work on these signed tarballs.
Hence fix this race condition by stretching "tarballs" target as
progress barrier (using it as a prerequisite) uniformly for all the
deliverables that are going to be signed (used to be just for "sha256"
target)).  And when at it, make "deliverables" variable list them
conveniently (along with reformatting definitions of other variables
for uniformity).

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-13 17:58:51 +02:00
Christine Caulfield
80cfb8f461 sign tarballs 2017-06-08 15:09:10 +01:00
Jan Pokorný
833298e265
Fix typo: repeat{ivi -> ed}ly
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-08 12:32:22 +02:00
Jan Pokorný
70423655d2 Low: loop: don't bring runtime down for a trivial API misuse
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-06 14:04:46 +01:00
Jan Pokorný
2d2974e0e4 Fix typos: in{ -> s}tance, d{e -> i}stinguished
The instances of the former in a private static variable name, the
latter in the comment to an internal-use-only function-like construct.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-06-06 14:04:46 +01:00
Michael Jones
05b48a9766 Adds no-format-nonliteral 2017-06-06 13:31:14 +01:00
Michael Jones
7eea796ad9 Adds additional warnings 2017-06-06 13:31:14 +01:00
jonesmz
f50fb44cea Point the link to the Linux kernel coding style document to the right place (#256) 2017-05-26 14:15:32 +01:00
Christine Caulfield
8cbfeec9f4 test: Disable test_max_dgram_size() test as it often breaks on CI
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-05-23 14:38:34 +01:00
Christine Caulfield
9123d9a242 tests: Fix signal handling in check_ipc.c
Also return pid_t from run_ipc_server()

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-05-23 14:11:01 +01:00
Christine Caulfield
608de6d59a lib: update library version for upcoming 1.0.2 release
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-05-19 14:59:20 +01:00
Jan Pokorný
e7e6961a66
build: follow-up on introducing custom m4 macros
Various "configure" commits by wferi recently introduced new
compat/custom m4 macro files in m4 directory, which itself was,
so far, assumed ephemeral (not strictly needed for reproducing
the build successfully, i.e., bits that can be completely purged
when cutting down the project files to the bone).  Apparently,
this assumption no longer holds so several places need to be
adapted.

Amonst others, m4 directory no longer needs to be reinsured in
autogen.sh, and special care must be taken with .gitignore
and maintainer-clean-local target of the main Makafile.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-05-19 15:32:55 +02:00
Chrissie Caulfield
f7ec9a055c ipc: fix compile warning on non-Linux platforms (#252)
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-05-18 16:16:22 +01:00
jonesmz
a95b81ba2b Require c99 language support or newer (#251) 2017-05-18 13:44:01 +01:00
Jan Pokorný
41ae3e1267 Memleak fixes (#194)
* memleak: ipc_socket: properly dispose local-scoped strndup values

Leaking memory was only possible when using filesystem sockets (see
use_filesystem_sockets function) and either:
- client is deliberately disconnecting from a server (continued run
  imposes a risk of exhausting memory)
- server is deliberately disconnecting from its client (ditto, but
  more substantial risk due to the common shared-resource nature
  of the server)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>

* memleak: ipc_socket: properly dispose inter-function strdup values

Leaking memory was only possible when the server accepted the client,
but didn't get (or was too shy) to talk to it prior to proceeding with
a disconnect.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>

* ipc_socket: care to explain what's going on with file name inference

Related to the code parts at hand, there was an investigation/fix in
the past, initiated by "make check" failure on FreeBSD 9 [rhbz#1256701].
Unfortunately, not only the magic constant being modified was not
explained in 1908e6c, but (one can derive because of a lack of solid
background of what's going on here, which might have caused that),
it was modified incorrectly at one instance (see also [PR165 comment]),
which was then reinstated in 7ebcb3d.

So, finally de-mystify those magic constants.  Also break the symmetry
between the client/server further with depending on the canonical
"request socket" alias at the server side (the former worked equally but
it was unnecessarily confusing and there's a risk this artificial alias
will get removed in the future).

[rhbz#1256701] https://bugzilla.redhat.com/1256701
[PR165 comment] https://github.com/ClusterLabs/libqb/issues/165#issuecomment-142949541

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-05-18 11:29:15 +01:00
Christine Caulfield
536b4c25ed doc: Clarify IPC caution text
It was not clear to non-native English speakers.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed by: Jan Pokorný <jpokorny@redhat.com>
2017-05-02 10:29:44 +01:00
Chrissie Caulfield
41a24a3df7 Allow Linux to use filesystem sockets (#248)
* IPC: Allow filesystem sockets to be chosen at run-time on Linux

Most of this patch came from Andrew Beekhof.
Keep a global variable that decides whether or not to use filesystem sockets
or abstract sockets for IPC connections. This variable is set by the presence of a file (default /etc/libqb/force-filesystem-sockets).

* tests: Fix test_ipcc_truncate_when_unlink_fails_shm test using FS sockets

When using filesystem sockets, the
test_ipcc_truncate_when_unlink_fails_shm test always fails, this was
because the unlink() call is wrapped to fail and so it never cleans up
the old version of the socket.
The fix is to preemptively remove the file before unlink gets wrapped.

* doc: Explain the force-filesystem-sockets option

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-04-28 16:13:02 +01:00
Chrissie Caulfield
63d79c93cc Merge pull request #250 from jnpkrn/test-ipc-random-name
test: Fix random number generation in IPC tests
2017-04-28 14:47:19 +01:00
Jan Pokorný
d69cc7b3f6
test: Fix random number generation in IPC tests
The sockets are named using a random() suffix in at attempt to isolate
concurrent test.  However random() always returns the same random number
by design ... unless pre-seeded with some value being unique enough for
the particular execution.

Borrowing the most of the above message from original "srandom" fix by
Chrissie who also discovered this issue (nice!), I thought it would be
more viable if we encoded such "unique enough" variables directly to
IPC name being generated, not relying on pseudorandom generators in any
way.  Hence this other fix.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2017-04-28 14:55:06 +02:00
Christine Caulfield
f38a877889 doc: Remove unclear part of the clarification on IPC threading.
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-04-05 09:49:45 +01:00
Christine Caulfield
60122a4a4e doc: clarify thread-safety (or not) in IPC doc
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-03-24 13:44:17 +00:00
Christine Caulfield
59eacf07dd loop: Fix splint error
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-03-06 14:31:57 +00:00
Christine Caulfield
e336b716cc loop: Also set signals changed in qb_loop_signal_mod() back to SIG_DFL
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-02-24 16:36:35 +00: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
Christine Caulfield
afdff97f1a [tests] Fix qb_rb_chunk_peek test so it's consistent with qb_rb_read
Now that the library code is too.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-01-31 10:41:29 +00:00
Christine Caulfield
a7faca1682 [ringbuffer] Return error from peek if RB is corrupted.
This should prevent libqb from looping in the server if the
ringbuffer gets corrupted. Instead the client will be disconnected.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2017-01-31 09:47:27 +00:00
Chrissie Caulfield
75345a0a23 Merge pull request #242 from jnpkrn/travis-issue-234
CI: travis: fix du -> df and capture it also directly from test
2016-12-16 15:16:29 +00:00
Jan Pokorný
991ef77d11
build: tito: unify custom.py with pacemaker's version 2016-12-16 15:48:25 +01:00
Jan Pokorný
524042d797
CI: travis: fix du -> df and capture it also directly from test 2016-12-16 15:48:10 +01:00
Chrissie Caulfield
5a54a51883 Merge pull request #241 from jnpkrn/PR240-addendum
PR #240 + addendum (drop syslog-tests opt-in switch)
2016-12-16 14:21:52 +00:00
Jan Pokorný
602d04dacf
build: drop allegedly no longer intrusive syslog-tests opt-in switch
The intention behind enabling the syslog tests on demand (642f74d) was
to tread cautiously as libtool used to alert that something controversial
is going on:

$ ./autogen.sh && ./configure --enable-syslog-tests && make check
> ...
> *** Warning: Linking the executable log.test against the loadable module
> *** _syslog_override.so is not portable!
> ...

owing to the fact that _syslog_override.so is being linked (through
libtool) with LDFLAGS=-module.

In fact, the issue did go away with a fix to the "make install" process
(ebcff54) for which _syslog_override.so* files were being picked
undesirably prior to the fix, which manifested itself also on
"make rpm" (hence the respective commit message):

> RPM build errors:
>     Installed (but unpackaged) file(s) found:
>    /usr/lib64/_syslog_override.so
>    /usr/lib64/_syslog_override.so.0
>    /usr/lib64/_syslog_override.so.0.0.0

The explanation for the secondary positive effect on the mentioned
libtool's warning going away is rather simple:
"lib" prefix switches the expectations about the result as a library
(also due to "libdir" destination) rather than as an executable object.
Change like that ensures the result is what libtool's manual calls
"dynamic module that can be opened by lt_dlopen" rather than "runtime
library that cannot" in the context of Mac OS X, which was likely the
cause of the portability warning.
(https://www.gnu.org/software/libtool/manual/libtool.html#FOOT10)

And because the tests themselves are run through the libtool wrapper
scripts capable of relinking and other magic

What libtool manual has to say on this topic:
> Note that libtool modules don’t need to have a "lib" prefix. However,
> Automake 1.4 or higher is required to build such modules.
referring to version released 15+ years back, which is assumed anyway.
(https://www.gnu.org/software/libtool/manual/libtool.html#Modules-for-libltdl)

* * *

That being said, there's now no longer a reason to have "syslog-tests"
enablement conditionalized (no longer supposed intrusive), hence enable
them unconditionally along the other libcheck-based tests
-- whenever libcheck is detected.

This changeset also drops any trace of --enable-syslog-tests switch
in various places using that (spec file, Travis CI configuration)
making for a complete vaporizatio of this choice.
2016-12-12 12:18:37 +01:00
Ferenc Wágner
8fad8acb67 configure: restrict nsl lib to where it's actually needed 2016-12-12 11:47:21 +01:00
Ferenc Wágner
1a9b4128e4 configure: restrict socket lib to where it's actually needed 2016-12-12 11:47:21 +01:00
Ferenc Wágner
cb5ee921c0 configure: restrict pthreads to where it's actually needed
mq_open() is no longer relevant beyond 70a9623 (Remove message queues).
2016-12-12 11:46:13 +01:00
Ferenc Wágner
56754d0509 configure: restrict -ldl to where it's actually needed
This reduces overlinking of qb-blackbox.  Being a seldom used executable,
the gains are mostly theoretical, but at least this silences warnings
from some QA tools.
2016-12-08 14:14:57 +01:00
Ferenc Wágner
64371306a6 configure: LTLIBOBJS is also a Make variable
So let's use the more friendly syntax.
2016-12-08 14:14:57 +01:00
Ferenc Wágner
ff7a3f4047 configure: help string cleanup
The [ default="no" ] branches were sense- and (mostly) harmless.
2016-12-08 14:11:28 +01:00
Ferenc Wágner
27d9b3b829 Fix typos: synchonization -> synchronization, paramaters -> parameters 2016-12-08 14:10:55 +01:00
Chrissie Caulfield
52db4997d7 Merge pull request #238 from jnpkrn/travis-issue-234
Continue with investigation of intermittent failures in Travis CI (#234)
2016-11-29 14:20:34 +00:00