58
60
#include <corosync/swab.h>
59
#include <corosync/saAis.h>
61
#include <corosync/corotypes.h>
62
#include <corosync/coroipc_types.h>
63
#include <corosync/corodefs.h>
60
64
#include <corosync/list.h>
61
#include <corosync/queue.h>
62
65
#include <corosync/lcr/lcr_ifact.h>
63
66
#include <corosync/totem/coropoll.h>
64
67
#include <corosync/totem/totempg.h>
65
68
#include <corosync/engine/objdb.h>
66
69
#include <corosync/engine/config.h>
67
70
#include <corosync/engine/logsys.h>
71
#include <corosync/coroipcs.h>
69
74
#include "totemsrp.h"
71
75
#include "mainconfig.h"
72
76
#include "totemconfig.h"
81
83
#include "apidef.h"
82
84
#include "service.h"
83
86
#include "version.h"
85
89
LOGSYS_DECLARE_SYSTEM ("corosync",
86
LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_BUFFER_BEFORE_CONFIG,
90
LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED | LOGSYS_MODE_FORK,
90
LOGSYS_DECLARE_SUBSYS ("MAIN", LOG_INFO);
99
LOGSYS_DECLARE_SUBSYS ("MAIN");
92
101
#define SERVER_BACKLOG 5
94
static int ais_uid = 0;
96
static int gid_valid = 0;
103
static int sched_priority = 0;
98
105
static unsigned int service_count = 32;
107
#if defined(HAVE_PTHREAD_SPIN_LOCK)
108
static pthread_spinlock_t serialize_spin;
100
110
static pthread_mutex_t serialize_mutex = PTHREAD_MUTEX_INITIALIZER;
102
113
static struct totem_logging_configuration totem_logging_configuration;
104
static char delivery_data[MESSAGE_SIZE_MAX];
106
115
static int num_config_modules;
108
117
static struct config_iface_ver0 *config_modules[MAX_DYNAMIC_SERVICES];
112
121
static struct corosync_api_v1 *api = NULL;
114
unsigned long long *(*main_clm_get_by_nodeid) (unsigned int node_id);
123
static enum cs_sync_mode minimum_sync_mode;
125
static enum cs_sync_mode minimum_sync_mode;
127
static int sync_in_process = 1;
129
static hdb_handle_t corosync_poll_handle;
131
struct sched_param global_sched_param;
133
hdb_handle_t corosync_poll_handle_get (void)
135
return (corosync_poll_handle);
138
void corosync_state_dump (void)
142
for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
143
if (ais_service[i] && ais_service[i]->exec_dump_fn) {
144
ais_service[i]->exec_dump_fn ();
116
149
static void sigusr2_handler (int num)
120
for (i = 0; ais_service[i]; i++) {
121
if (ais_service[i]->exec_dump_fn) {
122
ais_service[i]->exec_dump_fn ();
152
* TODO remove this from sigusr2 handler and access via cfg service
153
* engine api - corosync-cfgtool
155
corosync_state_dump ();
127
static void *aisexec_exit (void *arg)
159
* TODO this function needs some love
161
void corosync_shutdown_request (void)
130
164
corosync_service_unlink_all (api);
134
int stats_inuse[MEMPOOL_GROUP_SIZE];
135
int stats_avail[MEMPOOL_GROUP_SIZE];
136
int stats_memoryused[MEMPOOL_GROUP_SIZE];
139
mempool_getstats (stats_inuse, stats_avail, stats_memoryused);
140
log_printf (LOG_LEVEL_DEBUG, "Memory pools:\n");
141
for (i = 0; i < MEMPOOL_GROUP_SIZE; i++) {
142
log_printf (LOG_LEVEL_DEBUG, "order %d size %d inuse %d avail %d memory used %d\n",
143
i, 1<<i, stats_inuse[i], stats_avail[i], stats_memoryused[i]);
147
168
totempg_finalize ();
169
coroipcs_ipc_exit ();
150
171
corosync_exit_error (AIS_DONE_EXIT);
156
pthread_t aisexec_exit_thread;
157
static void init_shutdown(void *data)
159
pthread_create (&aisexec_exit_thread, NULL, aisexec_exit, NULL);
163
static poll_timer_handle shutdown_handle;
164
174
static void sigquit_handler (int num)
166
/* avoid creating threads from within the interrupt context */
167
poll_timer_add (aisexec_poll_handle, 500, NULL, init_shutdown, &shutdown_handle);
176
corosync_shutdown_request ();
179
static void sigintr_handler (int num)
181
corosync_shutdown_request ();
171
184
static void sigsegv_handler (int num)
173
signal (SIGSEGV, SIG_DFL);
186
(void)signal (SIGSEGV, SIG_DFL);
188
logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
178
192
static void sigabrt_handler (int num)
180
signal (SIGABRT, SIG_DFL);
194
(void)signal (SIGABRT, SIG_DFL);
196
logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
185
200
#define LOCALHOST_IP inet_addr("127.0.0.1")
187
totempg_groups_handle corosync_group_handle;
202
static hdb_handle_t corosync_group_handle;
189
struct totempg_group corosync_group = {
204
static struct totempg_group corosync_group = {
194
void sigintr_handler (int signum)
196
poll_timer_add (aisexec_poll_handle, 500, NULL, init_shutdown, &shutdown_handle);
200
static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */
201
1024, 0, 1, 4096, 0, 0, 0, 0, /* 65536 */
202
1, 1, 1, 1, 1, 1, 1, 1, 1 };
204
void serialize_mutex_lock (void)
211
#if defined(HAVE_PTHREAD_SPIN_LOCK)
212
static void serialize_lock (void)
214
pthread_spin_lock (&serialize_spin);
217
static void serialize_unlock (void)
219
pthread_spin_unlock (&serialize_spin);
222
static void serialize_lock (void)
206
224
pthread_mutex_lock (&serialize_mutex);
209
void serialize_mutex_unlock (void)
227
static void serialize_unlock (void)
211
229
pthread_mutex_unlock (&serialize_mutex);
215
233
static void corosync_sync_completed (void)
235
log_printf (LOGSYS_LEVEL_NOTICE,
236
"Completed service synchronization, ready to provide service.\n");
219
240
static int corosync_sync_callbacks_retrieve (int sync_id,
220
241
struct sync_callbacks *callbacks)
222
243
unsigned int ais_service_index;
223
unsigned int ais_services_found = 0;
225
246
for (ais_service_index = 0;
226
247
ais_service_index < SERVICE_HANDLER_MAXIMUM_COUNT;
227
248
ais_service_index++) {
229
if (ais_service[ais_service_index] != NULL) {
230
if (ais_services_found == sync_id) {
250
if (ais_service[ais_service_index] != NULL
251
&& ais_service[ais_service_index]->sync_mode == CS_SYNC_V1) {
252
if (ais_service_index == sync_id) {
233
ais_services_found += 1;
258
* Try to load backwards compat sync engines
236
260
if (ais_service_index == SERVICE_HANDLER_MAXIMUM_COUNT) {
237
memset (callbacks, 0, sizeof (struct sync_callbacks));
261
res = evil_callbacks_load (sync_id, callbacks);
240
264
callbacks->name = ais_service[ais_service_index]->name;
241
265
callbacks->sync_init = ais_service[ais_service_index]->sync_init;
248
static struct memb_ring_id aisexec_ring_id;
272
static int corosync_sync_v2_callbacks_retrieve (
274
struct sync_callbacks *callbacks)
278
if (minimum_sync_mode == CS_SYNC_V2 && service_id == CLM_SERVICE && ais_service[CLM_SERVICE] == NULL) {
279
res = evil_callbacks_load (service_id, callbacks);
282
if (minimum_sync_mode == CS_SYNC_V2 && service_id == EVT_SERVICE && ais_service[EVT_SERVICE] == NULL) {
283
res = evil_callbacks_load (service_id, callbacks);
286
if (ais_service[service_id] == NULL) {
289
if (minimum_sync_mode == CS_SYNC_V1 && ais_service[service_id]->sync_mode != CS_SYNC_V2) {
293
callbacks->name = ais_service[service_id]->name;
294
callbacks->sync_init = ais_service[service_id]->sync_init;
295
callbacks->sync_process = ais_service[service_id]->sync_process;
296
callbacks->sync_activate = ais_service[service_id]->sync_activate;
297
callbacks->sync_abort = ais_service[service_id]->sync_abort;
301
static struct memb_ring_id corosync_ring_id;
250
303
static void confchg_fn (
251
304
enum totem_configuration_type configuration_type,
252
unsigned int *member_list, int member_list_entries,
253
unsigned int *left_list, int left_list_entries,
254
unsigned int *joined_list, int joined_list_entries,
255
struct memb_ring_id *ring_id)
305
const unsigned int *member_list, size_t member_list_entries,
306
const unsigned int *left_list, size_t left_list_entries,
307
const unsigned int *joined_list, size_t joined_list_entries,
308
const struct memb_ring_id *ring_id)
311
int abort_activate = 0;
259
memcpy (&aisexec_ring_id, ring_id, sizeof (struct memb_ring_id));
313
if (sync_in_process == 1) {
318
memcpy (&corosync_ring_id, ring_id, sizeof (struct memb_ring_id));
262
321
* Call configuration change for all services
269
328
joined_list, joined_list_entries, ring_id);
274
static void aisexec_uid_determine (struct main_config *main_config)
276
struct passwd *passwd;
278
passwd = getpwnam(main_config->user);
280
log_printf (LOG_LEVEL_ERROR, "ERROR: The '%s' user is not found in /etc/passwd, please read the documentation.\n", main_config->user);
281
corosync_exit_error (AIS_DONE_UID_DETERMINE);
283
ais_uid = passwd->pw_uid;
287
static void aisexec_gid_determine (struct main_config *main_config)
290
group = getgrnam (main_config->group);
292
log_printf (LOG_LEVEL_ERROR, "ERROR: The '%s' group is not found in /etc/group, please read the documentation.\n", group->gr_name);
293
corosync_exit_error (AIS_DONE_GID_DETERMINE);
295
gid_valid = group->gr_gid;
299
static void aisexec_priv_drop (void)
306
static void aisexec_mempool_init (void)
310
res = mempool_init (pool_sizes);
312
log_printf (LOG_LEVEL_ERROR, "Couldn't allocate memory pools, not enough memory");
313
corosync_exit_error (AIS_DONE_MEMPOOL_INIT);
317
static void aisexec_tty_detach (void)
333
if (abort_activate) {
336
if (minimum_sync_mode == CS_SYNC_V2 && configuration_type == TOTEM_CONFIGURATION_REGULAR) {
337
sync_v2_start (member_list, member_list_entries, ring_id);
341
static void priv_drop (void)
343
return; /* TODO: we are still not dropping privs */
346
static void corosync_tty_detach (void)
399
408
/* under FreeBSD a process with locked page cannot call dlopen
400
409
* code disabled until FreeBSD bug i386/93396 was solved
402
log_printf (LOG_LEVEL_WARNING, "Could not lock memory of service to avoid page faults\n");
411
log_printf (LOGSYS_LEVEL_WARNING, "Could not lock memory of service to avoid page faults\n");
404
413
res = mlockall (MCL_CURRENT | MCL_FUTURE);
406
log_printf (LOG_LEVEL_WARNING, "Could not lock memory of service to avoid page faults: %s\n", strerror (errno));
415
log_printf (LOGSYS_LEVEL_WARNING, "Could not lock memory of service to avoid page faults: %s\n", strerror (errno));
412
420
static void deliver_fn (
413
421
unsigned int nodeid,
423
unsigned int msg_len,
416
424
int endian_conversion_required)
418
mar_req_header_t *header;
426
const coroipc_request_header_t *header;
425
* Build buffer without iovecs to make processing easier
426
* This is only used for messages which are multicast with iovecs
427
* and self-delivered. All other mechanisms avoid the copy.
430
for (i = 0; i < iov_len; i++) {
431
memcpy (&delivery_data[pos], iovec[i].iov_base, iovec[i].iov_len);
432
pos += iovec[i].iov_len;
433
assert (pos < MESSAGE_SIZE_MAX);
435
header = (mar_req_header_t *)delivery_data;
433
if (endian_conversion_required) {
434
id = swab32 (header->id);
435
size = swab32 (header->size);
437
header = (mar_req_header_t *)iovec[0].iov_base;
439
if (endian_conversion_required) {
440
header->id = swab32 (header->id);
441
header->size = swab32 (header->size);
444
// assert(iovec->iov_len == header->size);
447
442
* Call the proper executive handler
449
service = header->id >> 16;
450
fn_id = header->id & 0xffff;
449
if (ais_service[service] == NULL && service == EVT_SERVICE) {
450
evil_deliver_fn (nodeid, service, fn_id, msg,
451
endian_conversion_required);
454
if (!ais_service[service]) {
451
459
if (endian_conversion_required) {
452
460
assert(ais_service[service]->exec_engine[fn_id].exec_endian_convert_fn != NULL);
453
461
ais_service[service]->exec_engine[fn_id].exec_endian_convert_fn
457
465
ais_service[service]->exec_engine[fn_id].exec_handler_fn
461
471
void main_get_config_modules(struct config_iface_ver0 ***modules, int *num)
478
const struct iovec *iovec,
479
unsigned int iov_len,
470
480
unsigned int guarantee)
472
482
return (totempg_groups_mcast_joined (corosync_group_handle, iovec, iov_len, guarantee));
475
extern int main_send_ok (
479
return (totempg_groups_send_ok_joined (corosync_group_handle, iovec, iov_len));
485
int message_source_is_local (const mar_message_source_t *source)
489
assert (source != NULL);
490
if (source->nodeid == totempg_my_nodeid_get ()) {
496
void message_source_set (
497
mar_message_source_t *source,
500
assert ((source != NULL) && (conn != NULL));
501
memset (source, 0, sizeof (mar_message_source_t));
502
source->nodeid = totempg_my_nodeid_get ();
507
* Provides the glue from corosync to the IPC Service
509
static int corosync_private_data_size_get (unsigned int service)
511
return (ais_service[service]->private_data_size);
514
static coroipcs_init_fn_lvalue corosync_init_fn_get (unsigned int service)
516
return (ais_service[service]->lib_init_fn);
519
static coroipcs_exit_fn_lvalue corosync_exit_fn_get (unsigned int service)
521
return (ais_service[service]->lib_exit_fn);
524
static coroipcs_handler_fn_lvalue corosync_handler_fn_get (unsigned int service, unsigned int id)
526
return (ais_service[service]->lib_engine[id].lib_handler_fn);
530
static int corosync_security_valid (int euid, int egid)
532
struct list_head *iter;
533
if (euid == 0 || egid == 0) {
537
for (iter = uidgid_list_head.next; iter != &uidgid_list_head;
540
struct uidgid_item *ugi = list_entry (iter, struct uidgid_item,
543
if (euid == ugi->uid || egid == ugi->gid)
550
static int corosync_service_available (unsigned int service)
552
return (ais_service[service] != NULL);
555
struct sending_allowed_private_data_struct {
559
static int corosync_sending_allowed (
560
unsigned int service,
563
void *sending_allowed_private_data)
565
struct sending_allowed_private_data_struct *pd =
566
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
567
struct iovec reserve_iovec;
568
coroipc_request_header_t *header = (coroipc_request_header_t *)msg;
571
reserve_iovec.iov_base = (char *)header;
572
reserve_iovec.iov_len = header->size;
574
pd->reserved_msgs = totempg_groups_joined_reserve (
575
corosync_group_handle,
579
(corosync_quorum_is_quorate() == 1 ||
580
ais_service[service]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) &&
581
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_NOT_REQUIRED) ||
582
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_REQUIRED) &&
583
(pd->reserved_msgs) &&
584
(sync_in_process == 0)));
586
return (sending_allowed);
589
static void corosync_sending_allowed_release (void *sending_allowed_private_data)
591
struct sending_allowed_private_data_struct *pd =
592
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
594
totempg_groups_joined_release (pd->reserved_msgs);
597
static int ipc_subsys_id = -1;
599
static void ipc_log_printf (const char *format, ...) __attribute__((format(printf, 1, 2)));
600
static void ipc_log_printf (const char *format, ...) {
603
va_start (ap, format);
605
_logsys_log_vprintf (
606
LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_ERROR,
609
__FUNCTION__, __FILE__, __LINE__,
615
static void ipc_fatal_error(const char *error_msg) {
617
LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_ERROR,
620
__FUNCTION__, __FILE__, __LINE__,
625
static int corosync_poll_handler_accept (
631
return (coroipcs_handler_accept (fd, revent, context));
634
static int corosync_poll_handler_dispatch (
640
return (coroipcs_handler_dispatch (fd, revent, context));
644
static void corosync_poll_accept_add (
647
poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, 0,
648
corosync_poll_handler_accept);
651
static void corosync_poll_dispatch_add (
655
poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, context,
656
corosync_poll_handler_dispatch);
659
static void corosync_poll_dispatch_modify (
663
poll_dispatch_modify (corosync_poll_handle, fd, events,
664
corosync_poll_handler_dispatch);
667
static struct coroipcs_init_state ipc_init_state = {
668
.socket_name = COROSYNC_SOCKET_NAME,
669
.sched_policy = SCHED_OTHER,
670
.sched_param = &global_sched_param,
673
.log_printf = ipc_log_printf,
674
.fatal_error = ipc_fatal_error,
675
.security_valid = corosync_security_valid,
676
.service_available = corosync_service_available,
677
.private_data_size_get = corosync_private_data_size_get,
678
.serialize_lock = serialize_lock,
679
.serialize_unlock = serialize_unlock,
680
.sending_allowed = corosync_sending_allowed,
681
.sending_allowed_release = corosync_sending_allowed_release,
682
.poll_accept_add = corosync_poll_accept_add,
683
.poll_dispatch_add = corosync_poll_dispatch_add,
684
.poll_dispatch_modify = corosync_poll_dispatch_modify,
685
.init_fn_get = corosync_init_fn_get,
686
.exit_fn_get = corosync_exit_fn_get,
687
.handler_fn_get = corosync_handler_fn_get
690
static void corosync_setscheduler (void)
692
#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX)
695
sched_priority = sched_get_priority_max (SCHED_RR);
696
if (sched_priority != -1) {
697
global_sched_param.sched_priority = sched_priority;
698
res = sched_setscheduler (0, SCHED_RR, &global_sched_param);
700
global_sched_param.sched_priority = 0;
701
log_printf (LOGSYS_LEVEL_WARNING, "Could not set SCHED_RR at priority %d: %s\n",
702
global_sched_param.sched_priority, strerror (errno));
705
* Turn on SCHED_RR in ipc system
707
ipc_init_state.sched_policy = SCHED_RR;
710
log_printf (LOGSYS_LEVEL_WARNING, "Could not get maximum scheduler priority: %s\n", strerror (errno));
714
log_printf(LOGSYS_LEVEL_WARNING,
715
"The Platform is missing process priority setting features. Leaving at default.");
482
719
int main (int argc, char **argv)
485
struct main_config main_config;
721
const char *error_string;
486
722
struct totem_config totem_config;
487
unsigned int objdb_handle;
488
unsigned int config_handle;
723
hdb_handle_t objdb_handle;
724
hdb_handle_t config_handle;
489
725
unsigned int config_version = 0;
491
727
struct config_iface_ver0 *config;
729
const char *config_iface_init;
493
730
char *config_iface;
496
733
int background, setprio;
497
int totem_log_service;
734
struct stat stat_out;
735
char corosync_lib_dir[PATH_MAX];
737
#if defined(HAVE_PTHREAD_SPIN_LOCK)
738
pthread_spin_init (&serialize_spin, 0);
499
741
/* default configuration
504
746
while ((ch = getopt (argc, argv, "fp")) != EOF) {
509
logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR|LOG_MODE_FLUSH_AFTER_CONFIG);
751
logsys_config_mode_set (NULL, LOGSYS_MODE_OUTPUT_STDERR|LOGSYS_MODE_THREADED|LOGSYS_MODE_FORK);
518
760
" -p : Do not set process priority. \n");
519
761
return EXIT_FAILURE;
524
aisexec_tty_detach ();
526
log_printf (LOG_LEVEL_NOTICE, "Corosync Executive Service RELEASE '%s'\n", RELEASE_VERSION);
527
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
528
log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2006-2008 Red Hat, Inc.\n");
530
signal (SIGINT, sigintr_handler);
531
signal (SIGUSR2, sigusr2_handler);
532
signal (SIGSEGV, sigsegv_handler);
533
signal (SIGABRT, sigabrt_handler);
534
signal (SIGQUIT, sigquit_handler);
766
corosync_tty_detach ();
769
* Set round robin realtime scheduling with priority 99
770
* Lock all memory to avoid page faults which may interrupt
771
* application healthchecking
774
corosync_setscheduler ();
777
corosync_mlockall ();
779
log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.\n", RELEASE_VERSION);
781
(void)signal (SIGINT, sigintr_handler);
782
(void)signal (SIGUSR2, sigusr2_handler);
783
(void)signal (SIGSEGV, sigsegv_handler);
784
(void)signal (SIGABRT, sigabrt_handler);
785
(void)signal (SIGQUIT, sigquit_handler);
786
#if MSG_NOSIGNAL == 0
787
(void)signal (SIGPIPE, SIG_IGN);
536
790
corosync_timer_init (
537
serialize_mutex_lock,
538
serialize_mutex_unlock);
540
log_printf (LOG_LEVEL_NOTICE, "Corosync Executive Service: started and ready to provide service.\n");
542
aisexec_poll_handle = poll_create (
543
serialize_mutex_lock,
544
serialize_mutex_unlock);
795
corosync_poll_handle = poll_create ();
547
798
* Load the object database interface
595
849
config = (struct config_iface_ver0 *)config_p;
597
log_printf (LOG_LEVEL_ERROR, "Corosync Executive couldn't open configuration component '%s'\n", iface);
851
log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't open configuration component '%s'\n", iface);
598
852
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
601
855
res = config->config_readconfig(objdb, &error_string);
603
log_printf (LOG_LEVEL_ERROR, error_string);
857
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
604
858
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
606
log_printf (LOG_LEVEL_NOTICE, error_string);
860
log_printf (LOGSYS_LEVEL_NOTICE, "%s", error_string);
607
861
config_modules[num_config_modules++] = config;
609
863
iface = strtok(NULL, ":");
614
res = corosync_main_config_read (objdb, &error_string, &main_config);
867
res = corosync_main_config_read (objdb, &error_string);
616
log_printf (LOG_LEVEL_ERROR, error_string);
870
* if we are here, we _must_ flush the logsys queue
871
* and try to inform that we couldn't read the config.
872
* this is a desperate attempt before certain death
873
* and there is no guarantee that we can print to stderr
874
* nor that logsys is sending the messages where we expect.
876
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
877
fprintf(stderr, "%s", error_string);
878
syslog (LOGSYS_LEVEL_ERROR, "%s", error_string);
617
879
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
881
logsys_fork_completed();
883
res = logsys_thread_priority_set (SCHED_RR, &global_sched_param, 10);
885
log_printf (LOGSYS_LEVEL_ERROR,
886
"Could not set logsys thread priority. Can't continue because of priority inversions.");
887
corosync_exit_error (AIS_DONE_LOGSETUP);
890
res = logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
894
* Make sure required directory is present
896
sprintf (corosync_lib_dir, "%s/lib/corosync", LOCALSTATEDIR);
897
res = stat (corosync_lib_dir, &stat_out);
898
if ((res == -1) || (res == 0 && !S_ISDIR(stat_out.st_mode))) {
899
log_printf (LOGSYS_LEVEL_ERROR, "Required directory not present %s. Please create it.\n", corosync_lib_dir);
900
corosync_exit_error (AIS_DONE_DIR_NOT_PRESENT);
620
903
res = totem_config_read (objdb, &totem_config, &error_string);
622
log_printf (LOG_LEVEL_ERROR, error_string);
905
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
623
906
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
626
909
res = totem_config_keyread (objdb, &totem_config, &error_string);
628
log_printf (LOG_LEVEL_ERROR, error_string);
911
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
629
912
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
632
915
res = totem_config_validate (&totem_config, &error_string);
634
log_printf (LOG_LEVEL_ERROR, error_string);
917
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
635
918
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
638
logsys_config_facility_set ("corosync", main_config.syslog_facility);
639
logsys_config_mode_set (main_config.logmode);
640
logsys_config_file_set (&error_string, main_config.logfile);
642
aisexec_uid_determine (&main_config);
644
aisexec_gid_determine (&main_config);
647
* Set round robin realtime scheduling with priority 99
648
* Lock all memory to avoid page faults which may interrupt
649
* application healthchecking
652
aisexec_setscheduler ();
656
921
totem_config.totem_logging_configuration = totem_logging_configuration;
657
totem_log_service = _logsys_subsys_create ("TOTEM", LOG_INFO);
658
totem_config.totem_logging_configuration.log_level_security = logsys_mkpri (LOG_LEVEL_SECURITY, totem_log_service);
659
totem_config.totem_logging_configuration.log_level_error = logsys_mkpri (LOG_LEVEL_ERROR, totem_log_service);
660
totem_config.totem_logging_configuration.log_level_warning = logsys_mkpri (LOG_LEVEL_WARNING, totem_log_service);
661
totem_config.totem_logging_configuration.log_level_notice = logsys_mkpri (LOG_LEVEL_NOTICE, totem_log_service);
662
totem_config.totem_logging_configuration.log_level_debug = logsys_mkpri (LOG_LEVEL_DEBUG, totem_log_service);
663
totem_config.totem_logging_configuration.log_printf = logsys_log_printf;
922
totem_config.totem_logging_configuration.log_subsys_id =
923
_logsys_subsys_create ("TOTEM");
925
if (totem_config.totem_logging_configuration.log_subsys_id < 0) {
926
log_printf (LOGSYS_LEVEL_ERROR,
927
"Unable to initialize TOTEM logging subsystem\n");
928
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
931
totem_config.totem_logging_configuration.log_level_security = LOGSYS_LEVEL_WARNING;
932
totem_config.totem_logging_configuration.log_level_error = LOGSYS_LEVEL_ERROR;
933
totem_config.totem_logging_configuration.log_level_warning = LOGSYS_LEVEL_WARNING;
934
totem_config.totem_logging_configuration.log_level_notice = LOGSYS_LEVEL_NOTICE;
935
totem_config.totem_logging_configuration.log_level_debug = LOGSYS_LEVEL_DEBUG;
936
totem_config.totem_logging_configuration.log_printf = _logsys_log_printf;
938
res = corosync_main_config_compatibility_read (objdb,
942
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
943
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
946
res = corosync_main_config_compatibility_read (objdb,
950
log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
951
corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
666
955
* Sleep for a while to let other nodes in the cluster
667
956
* understand that this node has been away (if it was
668
* an aisexec restart).
957
* an corosync restart).
671
960
// TODO what is this hack for? usleep(totem_config.token_timeout * 2000);