Commit Graph

689 Commits

Author SHA1 Message Date
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
Ken Gaillot
780f893122 Fix: valgrind "invalid file descriptor" warning 2015-08-18 09:14:50 -05:00
Arkadiusz Bubala
0766a3ca54 Increase the length of description field.
Make description field larger to satisfy all possible pids and file
descriptor values.
2015-08-06 08:57:13 +02:00
Arkadiusz Bubala
ece408cb72 Increase the length of description field.
When both the corosync and pacemaker has PID larger or equal 10000
and when the file descriptor is larger or equal 10 the desciption
will have at least 17 characters.
2015-08-05 12:50:36 +02:00
David Vossel
35faa45558 Merge pull request #157 from davidvossel/solaris-compile-fix
Fix: resolves compile error for solaris
2015-05-15 10:32:44 -05:00
David Vossel
055c18cd81 Fix: resolves compile error for solaris 2015-05-15 09:15:30 -05:00
David Vossel
8b867a4606 Merge pull request #155 from kgaillot/splitlogging
Implement extended information logging (aka split logging)
2015-04-30 13:18:44 -05:00
Ken Gaillot
dc1311f05e Feature: Implement "extended" logging using a marker character
If a log message contains a magic character, everything after that marker
will be considered "extended" information. Log targets default to showing
this extended information but qb_log_ctl() may be used to indicate that
the extended information should be stripped instead.

The use case is a log message that has some information of value to administrators
and other information that is only of value for debugging. Two targets can be
configured such that the administrator log is not cluttered with debug information,
but a separate debug log is still available with complete information.

The magic character is the bell (\a). If someone wants to log an actual bell
character, they can do so in the extended information or via a %c format
(only the first bell is magic and only in the format string).
2015-04-30 12:14:53 -04:00
Helge Deller
85082aa059 Fix alignment issues on hppa
libqb fails to build on the hppa architecture, because the built-in
testcases fail as can be seen here:
http://buildd.debian-ports.org/status/fetch.php?pkg=libqb&arch=hppa&ver=0.17.0-2&stamp=1409458262

I did analyzed why they fail, and the reason is that on hppa we have
somewhat more complicated requirements (e.g. alignments) which needs to
be followed in order to mmap shared pages between processes. It's
different than what can be done compared to ia64 and sparc.
The attached patch fixes libqb on the hppa architecture and with it all
testcases finish successful.

By the way, I fixed a small typo in configure.ac too where arm platforms
prints "ia64"...

Forwarded-From: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760199
Signed-off-by: Christoph Berg <myon@debian.org>
2015-04-24 12:26:01 +02:00
David Vossel
b6f000f237 High: loop: fixes resource starvation in mainloop code 2015-04-14 11:52:59 -04:00
David Vossel
83552692aa Merge pull request #141 from davidvossel/recv-yield
High: yield to scheduler during connection processing
2015-03-05 16:10:34 -06:00
David Vossel
7f56f583d8 High: yield to scheduler during new connection auth processing 2015-03-05 15:36:51 -05:00
Ruben Kerkhof
5c7829662b The udata member of the kevent struct is a void *
Fixes the following warnings under clang:

loop_poll_kqueue.c:58:2: warning: incompatible integer to pointer conversion assigning to 'void *' from 'intptr_t' (aka 'long') [-Wint-conversion]
        EV_SET(&ke, fd, filters, EV_ADD | EV_ENABLE, 0, 0, (intptr_t)pe);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/event.h:54:16: note: expanded from macro 'EV_SET'
        (kevp)->udata = (f);                    \
                      ^ ~~~
2015-01-23 01:58:02 +01:00
Andreas Grueninger
01703fdf62 Fix: Unlink files before qb_ipcc_us_sock_close
Changed the #if clauses to all non linux OSe.
2015-01-13 19:01:57 +01:00
Andreas Grueninger
ea4d931563 Fix: Unlink files bound to unix domain sockets
In qb_ipcs_us_connect 4 files are created and bound.
I dont' know how this works for QB_LINUX or QB_CYGWIN.
But for the other OS the files are created and must be unlinked.
I use the same logic to construct the file names and unlink the files.

qb_ipcc_us_connect calls this
...
  res = qb_ipc_dgram_sock_connect(r->response, "response", "request",
          r->max_msg_size, &c->request.u.us.sock);
and qb_ipc_dgram_sock_connect calls
..
set_sock_addr

and in set_sock_addr the files are created if not Linux or Cygwin.
...
#if defined(QB_LINUX) || defined(QB_CYGWIN)
  snprintf(address->sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
#else
  snprintf(address->sun_path, sizeof(address->sun_path), "%s/%s", SOCKETDIR,
     socket_name);
#endif
...
2014-12-22 22:05:36 +01:00
David Vossel
d2b8c8cc78 Revise version to 0.17.1 The next release is only a point release 2014-08-22 10:12:07 -05:00
David Vossel
8cbae179cf Bump release version to 0.18.0
preparing for a new release
2014-08-22 09:58:50 -05:00
David Vossel
2700cddd6b Fix: ipcs: Correctly allocate receive buffer size 2014-08-21 12:07:43 -05:00
Super-User
22d0f94cd2 High: ipc_socket: Signalhandler must be resetted to Default, use only cleanup_sigpipe to return from qb_ipc_dgram_sock_setup.
Some OS like Solaris/Illumos return with ECONNRESET or EPIPE in the case of a disconnecting peer.
Change the return code to ENOTCONN and continue.
2014-08-14 14:53:59 -04:00
David Vossel
5b103cd6e4 High: trie: allow modifying the trie map during the notify callback 2014-07-30 09:58:04 -05:00
David Vossel
073f927801 Low: log: return filter type enum to preserve abi compatibilty with corosync
This returns abi compatiblity with libqb v0.16.0. There was a subtle
change in behavior caused by reordering the log filter enum in
v0.17.0.
2014-07-23 14:42:27 -05:00
Fabio M. Di Nitto
bafe834cbb Low: build: cleanup autogen warning to not overrride LDFLAGS
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2014-07-23 11:43:52 -05:00
David Vossel
01e43ead81 Merge pull request #120 from AnchorCat/shm-connect-cleanup
ipc_shm: fix error handling in qb_ipcs_shm_connect()
2014-06-19 14:41:46 -05:00
David Vossel
80fd68c263 Merge pull request #121 from AnchorCat/epoll
epoll: don't miss poll events under high load
2014-06-19 14:33:59 -05:00
Michael Chapman
2a06ffecde epoll: don't miss poll events under high load
If multiple epoll sources generate events simultaneously, it is possible
for more jobs to be added to particular priority level than will be
handled in one go by qb_loop_run_level(). If one of these epoll sources
gains a new event (say, by switching from "readable" to "readable and
writeable"), then this new event would be missed.

To fix this, merge new epoll events into revents regardless of whether
the job is on the joblist. When the job is dispatched, revents will be
cleared, or the epoll source will be deleted entirely.
2014-06-05 15:25:26 +10:00
Michael Chapman
0cdda23d1e ipc_shm: fix error handling in qb_ipcs_shm_connect()
The request and response SHM segments were being closed under the wrong
labels, and the event SHM segment wasn't being cleaned up at all.
2014-06-05 15:14:11 +10:00
Michael Chapman
fad9ce01a0 ringbuffer: fix size in qb_rb_create_from_file()
qb_rb_open() expects the size field to represent the maximum chunk size.
It adds QB_RB_CHUNK_MARGIN + 1 and rounds up to the page size to
determine the ringbuffer's total size. When creating a ringbuffer from a
file we must compensate by subtracting this amount from the file's size.
2014-06-05 14:36:56 +10:00
Michael Chapman
edd2eec16c ringbuffer: fix qb_rb_open_2() debug format string
qb_log_target_formats() does not support formatting size_t values with
%zd.  Use %ld to format them as long integers instead.
2014-06-05 14:36:43 +10:00
David Vossel
e0bca21e7a Fix: trie: fixes regression caused by ref count refactoring 2014-05-09 11:14:48 -04:00
David Vossel
76b693b8f3 Low: trie: cleanup ref count logic in trie_notify_del 2014-04-04 13:14:51 -05:00
David Vossel
ad248a733e Low: ipcs: Cleanup unnecessary reference counting 2014-04-04 12:12:58 -05:00
David Vossel
08356b84fa Fix: ipcc: Properly timeout during recv when timeout value is provided 2014-03-12 14:05:13 -04:00
David Vossel
5459350ff0 Merge pull request #113 from inouekazu/log_eagain
Low: ipc_setup.c: Add log for EAGAIN
2014-03-05 16:11:14 -06:00
David Vossel
39ed456da8 Low: build: Don't allow Bsymbolic-functions LDFLAG to be used, it breaks unit tests 2014-02-25 15:17:16 -06:00
Kazunori INOUE
f5c8c94a5f Low: ipc_setup.c: Add log for EAGAIN 2014-02-20 18:07:09 +09:00
David Vossel
532acdffa4 Bump version to 0.17.0 2014-02-19 10:33:30 -06:00