Because finishing of corosync 1.0 is very close, I think it's time to remember topic, we discussed 1-2 months ago (make /etc/corosync default config directory for corosync and openais and make openais to use coroparse and remove openaisparser).
Included patches are same patches I send before, only forward-ported to current trunk. If we want this feature to 1.0 (and don't find any problems) please ACK so I can commit. Regards, Honza
>From 8e3c925c619265f6cab4cfefe0d64d081716a439 Mon Sep 17 00:00:00 2001 From: Jan Friesse <[email protected]> Date: Thu, 11 Jun 2009 17:32:52 +0200 Subject: [PATCH] etccorosync --- trunk/Makefile.am | 4 +- trunk/configure.ac | 2 +- trunk/services/Makefile.am | 4 +- trunk/services/aisexec | 2 +- trunk/services/openaisparser.c | 243 ---------------------------------------- 5 files changed, 5 insertions(+), 250 deletions(-) delete mode 100644 trunk/services/openaisparser.c diff --git a/trunk/Makefile.am b/trunk/Makefile.am index 851961b..ad7c39b 100644 --- a/trunk/Makefile.am +++ b/trunk/Makefile.am @@ -30,7 +30,6 @@ # THE POSSIBILITY OF SUCH DAMAGE. EXTRA_DIST = autogen.sh \ - conf/openais.conf.example \ conf/amf.conf.example AUTOMAKE_OPTIONS = foreign @@ -41,8 +40,7 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \ dist_doc_DATA = LICENSE README.amf AUTHORS -sysconf_DATA = conf/openais.conf.example \ - conf/amf.conf.example +sysconf_DATA = conf/amf.conf.example SUBDIRS = include lib services test pkgconfig man # init diff --git a/trunk/configure.ac b/trunk/configure.ac index 02bd770..5246d2d 100644 --- a/trunk/configure.ac +++ b/trunk/configure.ac @@ -24,7 +24,7 @@ if test "$prefix" = "NONE"; then fi dnl Fix "sysconfdir" variable if not specified if test "$sysconfdir" = "\${prefix}/etc"; then - sysconfdir="/etc/ais" + sysconfdir="/etc/corosync" fi dnl Fix "libdir" variable if not specified if test "$libdir" = "\${exec_prefix}/lib"; then diff --git a/trunk/services/Makefile.am b/trunk/services/Makefile.am index fd438ce..eab3219 100644 --- a/trunk/services/Makefile.am +++ b/trunk/services/Makefile.am @@ -39,11 +39,11 @@ src = amfapp.c amfcluster.c amfnode.c amfsi.c amfutil.c \ SERVICE_LCRSO = clm ckpt evt lck msg tmr -REGULAR_LCRSO = openaisserviceenable openaisparser +REGULAR_LCRSO = openaisserviceenable AMF_OBJECTS = $(src:%.c=%.o) -SOURCES = $(SERVICE_LCRSO:%=%.c) $(src) openaisserviceenable.c openaisparser.c +SOURCES = $(SERVICE_LCRSO:%=%.c) $(src) openaisserviceenable.c EXTRA_DIST = $(SOURCES) aisexec diff --git a/trunk/services/aisexec b/trunk/services/aisexec index 250b508..57f2ff2 100755 --- a/trunk/services/aisexec +++ b/trunk/services/aisexec @@ -1,3 +1,3 @@ #!/bin/sh -export COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenableexperimental:openaisparser" +export COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenableexperimental:corosync_parser" corosync "$@" diff --git a/trunk/services/openaisparser.c b/trunk/services/openaisparser.c deleted file mode 100644 index 50a638e..0000000 --- a/trunk/services/openaisparser.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2006, 2009 Red Hat, Inc. - * - * All rights reserved. - * - * Author: Patrick Caulfield ([email protected]) - * - * This software licensed under BSD license, the text of which follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the MontaVista Software, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <sys/types.h> -#include <sys/uio.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <signal.h> -#include <string.h> - -#include <corosync/lcr/lcr_comp.h> -#include <corosync/engine/objdb.h> -#include <corosync/engine/config.h> - -static int read_config_file_into_objdb( - struct objdb_iface_ver0 *objdb, - const char **error_string); -static char error_string_response[512]; - -static char *strstr_rs (const char *haystack, const char *needle) -{ - char *end_address; - char *new_needle; - - new_needle = (char *)strdup (needle); - new_needle[strlen (new_needle) - 1] = '\0'; - - end_address = strstr (haystack, new_needle); - if (end_address) { - end_address += strlen (new_needle); - end_address = strstr (end_address, needle + strlen (new_needle)); - } - if (end_address) { - end_address += 1; /* skip past { or = */ - do { - if (*end_address == '\t' || *end_address == ' ') { - end_address++; - } else { - break; - } - } while (*end_address != '\0'); - } - - free (new_needle); - return (end_address); -} - -static int aisparser_readconfig ( - struct objdb_iface_ver0 *objdb, - const char **error_string) -{ - if (read_config_file_into_objdb(objdb, error_string)) { - return -1; - } - - return 0; -} - - -static char *remove_whitespace(char *string) -{ - char *start = string+strspn(string, " \t"); - char *end = start+(strlen(start))-1; - - while ((*end == ' ' || *end == '\t' || *end == ':' || *end == '{') && end > start) - end--; - if (end != start) - *(end+1) = '\0'; - - return start; -} - -static int parse_section(FILE *fp, - struct objdb_iface_ver0 *objdb, - hdb_handle_t parent_handle, - const char **error_string) -{ - char line[512]; - int i; - char *loc; - - while (fgets (line, 255, fp)) { - if (strlen(line) > 0) { - line[strlen(line) - 1] = '\0'; - } - /* - * Clear out white space and tabs - */ - for (i = strlen (line) - 1; i > -1; i--) { - if (line[i] == '\t' || line[i] == ' ') { - line[i] = '\0'; - } else { - break; - } - } - /* - * Clear out comments and empty lines - */ - if (line[0] == '#' || line[0] == '\0') { - continue; - } - - /* New section ? */ - if ((loc = strstr_rs (line, "{"))) { - hdb_handle_t new_parent; - char *section = remove_whitespace(line); - - loc--; - *loc = '\0'; - objdb->object_create (parent_handle, &new_parent, - section, strlen (section)); - if (parse_section(fp, objdb, new_parent, error_string)) - return -1; - } - - /* New key/value */ - if ((loc = strstr_rs (line, ":"))) { - char *key; - char *value; - - *(loc-1) = '\0'; - key = remove_whitespace(line); - value = remove_whitespace(loc); - objdb->object_key_create (parent_handle, key, - strlen (key), - value, strlen (value) + 1); - } - - if ((loc = strstr_rs (line, "}"))) { - return 0; - } - } - - if (parent_handle != OBJECT_PARENT_HANDLE) { - *error_string = "Missing closing brace"; - return -1; - } - - return 0; -} - - - -/* Read config file and load into objdb */ -static int read_config_file_into_objdb( - struct objdb_iface_ver0 *objdb, - const char **error_string) -{ - FILE *fp; - const char *filename = "/etc/ais/openais.conf"; - char *error_reason = error_string_response; - int res; - - fp = fopen (filename, "r"); - if (fp == 0) { - sprintf (error_reason, "Can't read file %s reason = (%s)\n", - filename, strerror (errno)); - *error_string = error_reason; - return -1; - } - - res = parse_section(fp, objdb, OBJECT_PARENT_HANDLE, error_string); - - fclose(fp); - - sprintf (error_reason, "Successfully read main configuration file '%s'.\n", filename); - *error_string = error_reason; - - return res; -} - -/* - * Dynamic Loader definition - */ - -struct config_iface_ver0 aisparser_iface_ver0 = { - .config_readconfig = aisparser_readconfig, - .config_writeconfig = NULL -}; - -struct lcr_iface openais_aisparser_ver0[1] = { - { - .name = "openaisparser", - .version = 0, - .versions_replace = 0, - .versions_replace_count = 0, - .dependencies = 0, - .dependency_count = 0, - .constructor = NULL, - .destructor = NULL, - .interfaces = NULL, - } -}; - -struct openais_service_handler *aisparser_get_handler_ver0 (void); - -struct lcr_comp aisparser_comp_ver0 = { - .iface_count = 1, - .ifaces = openais_aisparser_ver0 -}; - - -__attribute__ ((constructor)) static void aisparser_comp_register (void) { - lcr_interfaces_set (&openais_aisparser_ver0[0], &aisparser_iface_ver0); - lcr_component_register (&aisparser_comp_ver0); -} -- 1.5.5.6
>From c76cf66ab291752f1c0e2ae635223a9bd5656666 Mon Sep 17 00:00:00 2001 From: Jan Friesse <[email protected]> Date: Thu, 11 Jun 2009 17:26:22 +0200 Subject: [PATCH] Lcr patch. LCR is nice component with one not so nice thing. Not so nice thing is ... global variable g_component_handle. This variable has only one desire. Keep handle of loaded component. If this variable has magic value (0xFFFFFFFF) it means, "we loaded library, but that library doesn't have any component_register call -> don't try to destroy interfaces list). If this variable has other value, it means "we loaded library, it registers, but it exports some interface, what we currently don't need, so we can delete that handle from libraries/interfaces list" and variable is set to magic value, or "we loaded library, it registers and exports what we need -> great return some nice value", but nobody resets variable to it's magic value. And what happend, if you have some library, which was sucessfully loaded BEFORE Of course, we have nice optimalization. It just skip that away. Now join optimalization and destroying list with setting magic value only on loading unneeded library and what you get? PROBLEM. Sadly this problem happened to clm and quorum services, and cause, that loaded clm handle was destroyed, so EVT (which need clm) just falls. --- trunk/lcr/lcr_ifact.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/trunk/lcr/lcr_ifact.c b/trunk/lcr/lcr_ifact.c index ca10e9e..e13696d 100644 --- a/trunk/lcr/lcr_ifact.c +++ b/trunk/lcr/lcr_ifact.c @@ -426,6 +426,7 @@ static int interface_find_and_load ( } free (scandir_list); } + g_component_handle = 0xFFFFFFFF; return -1; found: @@ -437,6 +438,7 @@ found: } free (scandir_list); } + g_component_handle = 0xFFFFFFFF; return 0; } -- 1.5.5.6
>From 1564588c6b32594549c75000246d13e7c3b072ea Mon Sep 17 00:00:00 2001 From: Jan Friesse <[email protected]> Date: Thu, 11 Jun 2009 17:29:06 +0200 Subject: [PATCH] Corosync configuration in /etc/corosync --- trunk/configure.ac | 2 +- trunk/exec/coroparse.c | 2 +- trunk/exec/totemconfig.c | 2 +- trunk/tools/corosync-keygen.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/trunk/configure.ac b/trunk/configure.ac index d0f5432..52902e8 100644 --- a/trunk/configure.ac +++ b/trunk/configure.ac @@ -24,7 +24,7 @@ if test "$prefix" = "NONE"; then fi dnl Fix "sysconfdir" variable if not specified if test "$sysconfdir" = "\${prefix}/etc"; then - sysconfdir="/etc" + sysconfdir="/etc/corosync" fi dnl Fix "libdir" variable if not specified if test "$libdir" = "\${exec_prefix}/lib"; then diff --git a/trunk/exec/coroparse.c b/trunk/exec/coroparse.c index 0891917..edf3146 100644 --- a/trunk/exec/coroparse.c +++ b/trunk/exec/coroparse.c @@ -219,7 +219,7 @@ static int read_uidgid_files_into_objdb( int res = 0; struct stat stat_buf; - dirname = SYSCONFDIR "/corosync/uidgid.d"; + dirname = SYSCONFDIR "/uidgid.d"; dp = opendir (dirname); if (dp == NULL) diff --git a/trunk/exec/totemconfig.c b/trunk/exec/totemconfig.c index f500708..69bc184 100644 --- a/trunk/exec/totemconfig.c +++ b/trunk/exec/totemconfig.c @@ -764,7 +764,7 @@ int totem_config_keyread ( if (!got_key) { const char *filename = getenv("COROSYNC_TOTEM_AUTHKEY_FILE"); if (!filename) - filename = SYSCONFDIR "/ais/authkey"; + filename = SYSCONFDIR "/authkey"; res = read_keyfile(filename, totem_config, error_string); if (res) goto key_error; diff --git a/trunk/tools/corosync-keygen.c b/trunk/tools/corosync-keygen.c index c7f2e2e..50512dd 100644 --- a/trunk/tools/corosync-keygen.c +++ b/trunk/tools/corosync-keygen.c @@ -44,7 +44,7 @@ #include <netinet/in.h> -#define KEYFILE SYSCONFDIR "/ais/authkey" +#define KEYFILE SYSCONFDIR "/authkey" int main (void) { int authkey_fd; @@ -57,7 +57,7 @@ int main (void) { printf ("Error: Authorization key must be generated as root user.\n"); exit (1); } - if (mkdir (SYSCONFDIR "/ais", 0700)) { + if (mkdir (SYSCONFDIR, 0700)) { if (errno != EEXIST) { perror ("Failed to create directory: " SYSCONFDIR "/ais"); exit (1); -- 1.5.5.6
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
