cfg: When send_shutdown fails, clear shutdown_con

When (for example) CS_ERR_TRY_AGAIN is returned, shutdown_con was still
set resulting in following situation:
- It was not possible to call shutdown again
- Shutdown didn't proceed

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
cfgtool: Retry shutdown on CS_ERR_TRY_AGAIN

It may be nice to deliver macro cs_repeat as default in some include
file.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
totempg: Make iov_delv local variable

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Fix race for sending_allowed

Sending_allowed use sync_in_process. If sync_in process is set in the
middle of sending_allowed and api->handler_fn_get, results are
unpredictable. Solution is to enlarge lock.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
schedwrk: Set values before create callback

When totem callback is called before setting value, NULL can be called,
resulting in segfault.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Remove exit thread and replace it by exit pipe

When exit is called, exit thread will create schedwrk. This usually
works, but sadly there is race between main thread (coropoll) and this
thread in totemsrp_callback_token_create (main thread is reading values
and iterate thru list and exit thread is adding to list).

Solution is to remove exit thread. Create pipe and connect one end to
coropoll (so main thread) and let corosync_shutdown_request simply write
byte (= create notification) to coropoll, which executes shutdown
sequence.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
totempg: Store and restore global variables

It's used when trans_ack is changed so after change, we have clean room
and/or previous state.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Logsys: Ensure logging PID is really corosync

When serivce plugin calls fork and child uses logsys, it may lead to
corrupted fdata (idx is updated but it's not shared between child and
parent, but fdata is mmaped file and this is shared).

Solutions is to:
- Store corosync pid
- On log, check if current pid == corosync pid
- If so -> store in fdata, if not -> don't store

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
fplay: Check minimum record size

For records in fdata smaller then 4 display error, because such record
is invalid.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
corosync-fplay: Check incorrect idx and cycle

If idx is too large, segfault can happen. Also cycle is now detected
properly.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Improve handling of getpwnam_r() and getgrnam_r()

ERANGE from above functions are now correctly handled. Error is
correctly returned back (instead of using errno what is nonsense for
reentrant functions). Existence of user/group is now correctly
handled. Also numerical uid/gid works as expected.

Backport of 52f88d04eaf2ad6c65df34a3401417d0583c6a45,
005e7fd3b9de79bc32894f9f15431a7cf32a3b27 and
86b074dc1a72f9696ab5a3d302c7719b2961d8d6 from master

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Detect big scheduling pauses

Add poll timer scheduler to be called 3 times per token timeout.
If poll timer was not called for more then 0.8 * token timeout, it means
corosync process was not scheduled and ether token_timeout should be
increased or load should be reduced (useful for VM, where host is
overcommitted so VM is not scheduled as expected).

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