Commit Graph

724 Commits

Author SHA1 Message Date
Chrissie Caulfield
026aaa7bde Merge pull request #230 from jnpkrn/log_thread
Med: log_thread: logt_wthread_lock is vital for logging thread
2016-10-21 15:43:17 +01:00
Chrissie Caulfield
7e5212b6a3 Merge pull request #228 from jnpkrn/maint
Various cleanups (symbol imports, typos, doc)
2016-10-21 15:31:13 +01:00
Jan Pokorný
ca710b2505
Refactor: log_thread: fix and diminish inferior comments 2016-10-21 09:42:48 +02:00
Jan Pokorný
07542cf693
Med: log_thread: logt_wthread_lock is vital for logging thread
This fixes issue with would-fail-if-applied-to-thread-right-away
qb_log_thread_priority_set invocation when logging thread doesn't
exist yet, which will arrange for calling itself at the time of
thread's birth that is the moment it will actually fail.
In this + lock-could-not-have-been-initialized corner cases, the
already running thread would proceed as allowed by error condition
handling in the main thread, trying to dereference uninitialized
(or outdated) pointer to the lock at hand, resulting in segfault.

Also include the test that would have been caught that (we use the
fact that it doesn't matter whether setting of the scheduler parameters
fails due to bad input or just because of lack of privileges as it's
the failure at the right moment that is of our interest).

See also:
https://github.com/ClusterLabs/libqb/issues/229
2016-10-21 09:42:16 +02:00
Christine Caulfield
0d6a698931 log: Remove check for HAVE_SCHED_GET_PRIORITY_MAX
it doesn't exist

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-10-20 09:50:12 +01:00
Christine Caulfield
b40c499d7d log: Don't overwrite valid tags
If a tag of 0 is passed into the logger and an existing callsite
is found with a non-zero tag, the don't overwrite the existing tag.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-10-18 14:30:28 +01:00
Jan Pokorný
6743206b72
Low: ipc_shm: fix superfluous NULL check
That's what qb_rb_chunk_reclaim does since commit
ef77398738 that made this
check redundant.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2016-10-17 19:48:19 +02:00
Jan Pokorný
ab78f2a4fd
Low: sanitize import of <poll.h> symbols 2016-10-17 17:39:09 +02:00
Jan Pokorný
b7f6dae97a
Fix typos: availabi{l -> li}ty, explici{lt -> tl}y 2016-10-12 20:10:22 +02:00
Christine Caulfield
e77383897e Merge branch 'Svante-Signell-Hurd' of https://github.com/jnpkrn/libqb into jnpkrn-Svante-Signell-Hurd 2016-10-11 15:24:50 +01:00
Jan Pokorný
db7dcd1411
Build: configure: do not check for unused "sched" functions
Do not compile-time-conditionalize based on one of them being available,
either.
2016-09-30 14:24:46 +02:00
Chrissie Caulfield
84b131c27e Merge pull request #217 from jnpkrn/log-serialize-check-char-properly
Low: log: check for appropriate space when serializing a char
2016-06-20 08:52:53 +01:00
Christine Caulfield
22ac41108e log: Add missing z,j, & t types to the logger
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Ken Gaillot <kgaillot@redhat.com>
Reviewed-by: Jan Pokorný <jpokorny@redhat.com>
2016-06-20 08:37:13 +01:00
Jan Pokorný
17e5a36b18
Low: log: check for appropriate space when serializing a char
... where appropriate space is measured for, surprisingly, a char,
not for an int.  Note that's also the actual type used for both
de-/serializing, so there's no conflict.

Also bother to explain why, now surprisingly for real, an unsigned int
is scraped out from va_list (akin to to STDARG(3)).
2016-06-17 16:42:36 +02:00
Chrissie Caulfield
67af307953 Merge pull request #196 from jnpkrn/demystify-qblog.h
Low: explain mysterious lines in a public header (qblog.h)
2016-04-01 16:01:14 +01:00
Jan Pokorný
c12f729452
build: make splint check tolerant of existing defects 2016-03-17 15:16:19 +01:00
Jan Pokorný
28341438f4
build: make the code splint-friendly where not already 2016-03-17 15:13:58 +01:00
Svante Signell
6bd3f0865a Add Hurd support
* configure.ac: Define QB_GNU.
  Add a check for a working clock_getres for the CLOCK_MONOTONIC
  option defining HAVE_CLOCK_GETRES_MONOTONIC.

  * lib/log_thread.c: Replace second argument of
  qb_log_thread_priority_set(): logt_sched_param.sched_priority by 0
  when not supported by the OS.

  * lib/util.c: Use the CLOCK_REALTIME option in clock_getres() if
  HAVE_CLOCK_GETRES_MONOTONIC os not defined.
2016-03-17 13:47:16 +01:00
Jan Pokorný
20c35217ab
build: fix preposterous usage of $(AM_V_GEN) 2016-03-11 08:04:47 +01:00
Jan Pokorný
2468e46a56
build: extra clean-local rule instead of overriding clean-generic
Previously, stuffing CLEANFILES with anything would not work in the
affected files.
2016-03-10 21:06:29 +01:00
Christine Caulfield
41a83d1a86 build: update library soname to 0.18.0
as per guidelines here:
http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html

This shouldn't affect existing packages as the major version is still 0.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-03-08 10:28:24 +00:00
Jan Pokorný
9d696f5f5a
Low: further avoid magic in qblog.h by using named constants
Also advise to use these constants and obey this in the internal code.
2016-03-04 14:55:52 +01:00
Chrissie Caulfield
91fd29f077 Merge pull request #179 from dpejesh/socket
socket improvements for freebsd
2016-02-22 10:40:19 +00:00
Chrissie Caulfield
21ca3b4fbf Merge pull request #184 from jnpkrn/maint-no_magic-build_manpages
Maintainance: no magic + better manpages building
2016-02-22 09:46:25 +00:00
Chrissie Caulfield
7b9b72e690 Merge pull request #181 from jnpkrn/log-target-slot-enum
log: enum qb_log_target_slot introduction + qblog.h cleanup
2016-02-22 09:45:32 +00:00
Jan Pokorný
c36a00929b
Low: no magic constants + gethostname usage sanity 2016-02-18 16:45:51 +01:00
Chrissie Caulfield
c242bada46 Merge pull request #177 from jnpkrn/changing-syslog-identifier-nicer
Changing syslog identifier + testing syslog, preferred edition
2016-02-18 15:32:33 +00:00
Jan Pokorný
642f74de61
Feature: allow changing the identifier for syslog (+tests)
Original "qb_log_ctl" interface had to be extended for passing read-only
strings (new parameter), resulting in new "qb_log_ctl2" function, which
is what qb_log_ctl calls into with the new parameter set to NULL.
This ensures backward compatibility.

A new QB_LOG_CONF_IDENT configuration directive for the mentioned
interface is added with a goal to set new internal identifier
that is, notably, used for syslog sink.  This allows for switching
the identification without a need to reinitialize logging subsystem,
akin to changing target logging facility.

Also a brand new concept of testing syslog sink in particular is
introduced (finally).  During initial trial&error stage, it used
LD_PRELOAD hack but it seems that libtool is sophisticated enough
that no such extra intervention is needed and the desired symbol
resolution Just Works (tm).  However, the technique is highly
non-portable (there is even a warning about that from libtool,
which is partially on purpose as the _syslog_override.so should
rather be explicit it is by no mean a regular library) and hence
the syslog tests have to be enabled with explicit

    ./configure --enable-syslog-tests

rather than possibly break on untested platforms (far too many).
The concept can be extended upon, but initially, just the new
feature is being tested.

Post-review: thanks Chrissie for a suggestion how to deal with
extract-arg-and-forget in a less intrusive way (no defines).
2016-02-18 11:30:14 +01:00
Jan Pokorný
7a290093d0
log: convert few more instances to use enum qb_log_target_slot 2016-02-16 18:08:13 +01:00
Jan Pokorný
2198893c3e
log: refactor static target slots state initialization
It doesn't matter that also syslog is disabled first, as it will get
enabled few lines later on (uniformity + simplicity > optimization +
complexity).
2016-02-16 18:07:45 +01:00
Jan Pokorný
4ccca4bda9
log: convert log target defined values into enum values
Also use the new enum qb_log_target_slot type in for-loops together
with a proper substitute for the literal "0" initializer.

There could be more places that might be type-substituted for this enum
(and hence possibly catch more of an incorrect usage if the compiler
or checker has some notion of enum type narrowing), but leave it as
a possible enhancement for now.
2016-02-16 14:49:02 +01:00
David Shane Holden
33794cce5a ipc: return -errno when getsockopt/setsockopt fail 2016-02-14 16:44:17 -05:00
David Shane Holden
4978104ae4 ipc: set socket buffer size used by ipcs service 2016-02-14 16:29:11 -05:00
David Shane Holden
e788d618ee ipc: set socket receive buffer
Set the sockets receive buffer size to match the send buffer.  On
FreeBSD without this calls to sendto() will result in an ENOBUFS error
if the message is larger than net.local.dgram.recvspace sysctl.
2016-02-14 06:31:45 -05:00
Jan Pokorný
4f6c235470
build: avoid too keen -Wmissing-format-attribute warning
Grouped with pre-existing -Wsuggest-attribute=format treatment.
2016-02-12 23:33:13 +01:00
Jan Pokorný
ea35cfaa61
build: avoid too keen -Wsuggest-attribute=format warning
With gcc 5.3.1 20151207:
> log.c: In function 'cs_format':
> log.c:182:2: warning: function might be possible candidate for
>              'gnu_printf' format attribute [-Wsuggest-attribute=format]
>   len = vsnprintf(str, QB_LOG_MAX_LEN, cs->format, ap_copy);
>   ^

We certainly don't want to disable that warning globally so make use of
diagnostic pragmas for GCC instead in one instance that we cannot
annotate properly.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2016-02-03 15:40:11 +01:00
David Shane Holden
4f131253fc update: per kgaillot review
* remove pid/euid from qb_ipcc_connection
* use proper #elif defines
* return NULL instead of 0 for pointers
* return -ENOMEM when malloc fails
* remove redundant if check
* use -1 for uid to chown()
2016-01-25 21:27:29 -05:00
David Shane Holden
8668d051c5 ipc: set gid on unix sockets
When creating a unix socket it's default gid is that of the parent
directory.  If the SOCKETDIR is owned by root:wheel with 1777 mode
some of the pacemaker daemons end up unable to communicate with one
another due to having insufficient permissions on the sockets.

This can be fixed by setting the client sockets gid to the primary
group of the server socket owner it's attempting to connect to.  And,
on the server side by setting the gid to the already captured gid
stored in the connection info.  This ensures that regardless of who
owns the socket directory, as long as the applications have r/w
access to it they should work.
2016-01-23 10:32:42 -05:00
David Shane Holden
267160634d lib: store server peer credentials in qb_ipcc_connection 2016-01-22 19:42:28 -05:00
David Shane Holden
888ef2e721 lib: add init_ipc_auth_data() to initialize ipc_auth_data 2016-01-22 19:30:13 -05:00
David Shane Holden
7c4185a72a lib: split peer credential loopup into it's own method 2016-01-22 19:22:20 -05:00
David Shane Holden
dfa7874154 lib: create mmap files in socket directory
Currently the mmap files are created in LOCALSTATEDIR/run on non-Linux
platforms which can be problematic with pacemaker since it spawns processes
as the hacluster user, which by default doesn't have write permissions to
it.  Using --with-socket-dir partially fixes the problem by allowing the
unix sockets to reside somewhere else but not the mmap files and this
patch puts them in the same directory.
2016-01-18 19:02:08 -05:00
David Shane Holden
29b2c44fb6 ipc: set file permissions on created sockets
When using sockets for IPC the file permissions default to whatever
the umask is.  This isn't a problem on Linux since it uses abstract
namespace sockets which don't have any permissions, but on other
platforms this causes problems with pacemaker which spawns processes
under the hacluster user and ends up failing to connect.
2016-01-18 18:31:49 -05:00
Christine Caulfield
9b61a2c672 lib: update library version for new release
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-01-12 11:10:18 +00:00
Gao,Yan
f5fd0c950c Fix: ipc: Prevent fd and memory leaks in handle_new_connection()
In handle_new_connection(), connection_accept() could fail, which would
leave the state of the connection inactive. Previously, in this case,
the socket and the allocated qb_ipcs_connection would be leaked.
2015-10-06 18:01:16 +02:00
Christine Caulfield
1a7ea3b8d8 log: don't call dlopen inside dl_iterate_phdr()
Some platforms (eg. FreeBSD 10+) don't support calling dlopen() from
within a dl_iterate_phdr() callback; so save all of the dlpi_names to
a list and iterate over them afterwards.

This fixes a deadlock which occurs in dlopen() when called from
within dl_iterate_phdr() on FreeBSD 10+ when linked to libthr.

Patch from dpejesh on github.
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2015-10-01 15:01:14 +01:00
Christine Caulfield
7ebcb3d3cf ipc: Revert half of a previous *BSD ipc-name patch
Only one of the strndup calls should have subtracted 9 from
the name length. The other should have remained at 8.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2015-09-24 16:15:05 +01:00
Christine Caulfield
0f68c8c828 ipc: Don't send the dispatch_del() function a closed fd
The current code closes the fd before passing it to the
provided delete function. In the default case this can generate
"epoll_ctl(del): Bad file descriptor" messages when debug logging
is enabled.

This patch swaps over the calls so that a valid FD is passed to
the delete function.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-By: Ken Gaillot <kgaillot@redhat.com>
2015-09-24 16:04:28 +01:00
Christine Caulfield
1908e6c15b Fix deletion of sockets on *BSD platforms
The code removed the last 8 characters of a socket name
to get the 'base name', but 9 are needed.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2015-09-22 09:58:23 +01:00
Ken Gaillot
7cd90f11db release version 0.17.2
This revision switches libtool soname versioning from -version-number to
-version-info, and updates the travis configuration to use their newly
recommended infrastructure.
2015-08-18 09:14:51 -05:00