Просмотр исходного кода

Synchronization base code added.

(Logical change 1.142)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@508 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 21 лет назад
Родитель
Сommit
4fc3c8e21f
7 измененных файлов с 69 добавлено и 11 удалено
  1. 6 6
      exec/Makefile
  2. 5 0
      exec/handlers.h
  3. 46 2
      exec/main.c
  4. 2 1
      exec/print.c
  5. 1 0
      exec/print.h
  6. 8 1
      exec/totemsrp.c
  7. 1 1
      exec/totemsrp.h

+ 6 - 6
exec/Makefile

@@ -29,13 +29,13 @@
 # THE POSSIBILITY OF SUCH DAMAGE.
 
 # Production mode flags
-CFLAGS = -O3 -Wall -fomit-frame-pointer
-LDFLAGS = 
+#CFLAGS = -O3 -Wall -fomit-frame-pointer
+#LDFLAGS = 
 
 # Debug mode flags
-#CFLAGS = -g -Wall
+CFLAGS = -g -Wall
 ##-DDEBUG
-#LDFLAGS = -g
+LDFLAGS = -g
 
 # Profile mode flags
 #CFLAGS = -O2 -pg
@@ -49,9 +49,9 @@ TOTEM_SRC = aispoll.c totemsrp.c totempg.c tlist.c hdb.c crypto.c
 TOTEM_OBJS = aispoll.o totemsrp.o totempg.o tlist.o hdb.o crypto.o
 
 EXEC_SRC = main.c clm.c amf.c ckpt.c evt.c evs.c parse.c print.c mempool.c \
-		util.c
+		util.c sync.c
 EXEC_OBJS = main.o clm.o amf.o ckpt.o evt.o evs.o parse.o print.o mempool.o \
-		util.o
+		util.o sync.o
 EXEC_LIBS = libtotem.a
 
 OBJS = $(TOTEM_OBJS) $(EXEC_OBJS)

+ 5 - 0
exec/handlers.h

@@ -63,6 +63,11 @@ struct service_handler {
 	int (*libais_exit_fn) (struct conn_info *conn_info);
 	int (*exec_init_fn) (void);
 	void (*exec_dump_fn) (void);
+
+	void (*sync_init) (void);
+	int (*sync_process) (void);
+	void (*sync_activate) (void);
+	void (*sync_abort) (void);
 };
 
 #endif /* HANDLERS_H_DEFINED */

+ 46 - 2
exec/main.c

@@ -65,6 +65,7 @@
 #include "parse.h"
 #include "main.h"
 #include "handlers.h"
+#include "sync.h"
 #include "evs.h"
 #include "clm.h"
 #include "amf.h"
@@ -90,6 +91,8 @@ struct service_handler *ais_service_handlers[] = {
     &ckpt_service_handler,
     &evt_service_handler
 };
+struct sync_callbacks sync_callbacks[5];
+int sync_callback_count;
 
 #define AIS_SERVICE_HANDLERS_COUNT 5
 #define AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX 40
@@ -648,7 +651,7 @@ static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */
 					1, 1, 1, 1, 1, 1, 1, 1, 1 };
 
 static int (*aisexec_handler_fns[AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX]) (void *msg, struct in_addr source_addr, int endian_conversion_required);
-static int aisexec_handler_fns_count = 0;
+static int aisexec_handler_fns_count = 1;
 
 /*
  * Builds the handler table as an optimization
@@ -657,6 +660,11 @@ static void aisexec_handler_fns_build (void)
 {
 	int i, j;
 
+	/*
+	 * Install sync handler function
+	 */
+	aisexec_handler_fns[0] = sync_deliver_fn;
+
 	for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
 		for (j = 0; j < ais_service_handlers[i]->aisexec_handler_fns_count; j++) {
 			aisexec_handler_fns[aisexec_handler_fns_count++] = 
@@ -666,6 +674,30 @@ static void aisexec_handler_fns_build (void)
 	log_printf (LOG_LEVEL_DEBUG, "built %d handler functions\n", aisexec_handler_fns_count);
 }
 
+void sync_completed (void)
+{
+}
+
+void aisexec_sync_fns_build (void)
+{
+	int i;
+
+	for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
+		if (ais_service_handlers[i]->sync_init) {
+			sync_callbacks[sync_callback_count].sync_init =
+				ais_service_handlers[i]->sync_init;
+			sync_callbacks[sync_callback_count].sync_process =
+				ais_service_handlers[i]->sync_process;
+			sync_callbacks[sync_callback_count].sync_activate =
+				ais_service_handlers[i]->sync_activate;
+			sync_callbacks[sync_callback_count].sync_abort =
+				ais_service_handlers[i]->sync_abort;
+			sync_callback_count++;
+		}
+	}
+	sync_register (sync_callbacks, sync_callback_count, sync_completed);
+}
+
 char delivery_data[MESSAGE_SIZE_MAX];
 
 static void deliver_fn (
@@ -698,7 +730,9 @@ static void deliver_fn (
 		header->id = swab32 (header->id);
 		header->size = swab32 (header->size);
 	}
-	res = aisexec_handler_fns[header->id](header, source_addr, endian_conversion_required);
+
+	res = aisexec_handler_fns[header->id](header, source_addr,
+		endian_conversion_required);
 }
 
 static void confchg_fn (
@@ -713,6 +747,14 @@ static void confchg_fn (
 {
 	int i;
 
+	/*
+	 * Execute configuration change for synchronization service
+	 */
+	sync_confchg_fn (configuration_type,
+		member_list, member_list_private, member_list_entries,
+		left_list, left_list_private, left_list_entries,
+		joined_list, joined_list_private, joined_list_entries, ring_id);
+
 	/*
 	 * Call configuration change for all services
 	 */
@@ -970,6 +1012,8 @@ int main (int argc, char **argv)
 
 	aisexec_handler_fns_build ();
 
+	aisexec_sync_fns_build ();
+
 	aisexec_mempool_init ();
 
 	res = openais_amf_config_read (&error_string);

+ 2 - 1
exec/print.c

@@ -66,7 +66,8 @@ static char *log_services[] = {
 	"[AMF  ]",
 	"[CKPT ]",
 	"[EVT  ]",
-	"[EVS  ]"
+	"[EVS  ]",
+	"[SYNC ]"
 };
 
 #define LOG_MODE_DEBUG      1

+ 1 - 0
exec/print.h

@@ -62,6 +62,7 @@
 #define LOG_SERVICE_CKPT	5
 #define LOG_SERVICE_EVT		6
 #define LOG_SERVICE_EVS		7
+#define LOG_SERVICE_SYNC	8
 
 extern void internal_log_printf (int logclass, char *format, ...);
 

+ 8 - 1
exec/totemsrp.c

@@ -1501,7 +1501,6 @@ int totemsrp_mcast (
 
 	
 	if (queue_is_full (&new_message_queue)) {
-		assert (0);
 		return (-1);
 	}
 	for (j = 0, i = 0; i < iov_len; i++) {
@@ -2495,6 +2494,14 @@ int totemsrp_callback_token_create (void **handle_out,
 	return (0);
 }
 
+void totemsrp_callback_token_destroy (void *handle)
+{
+	struct token_callback_instance *h = (struct token_callback_instance *)handle;
+	
+	list_del (&h->list);
+	free (h);
+}
+
 void totemsrp_callback_token_type (void *handle)
 {
 	struct token_callback_instance *token_callback_instance = (struct token_callback_instance *)handle;

+ 1 - 1
exec/totemsrp.h

@@ -127,7 +127,7 @@ int totemsrp_callback_token_create (
 	int (*callback_fn) (enum totemsrp_callback_token_type type, void *),
 	void *data);
 
-void totemsrp_callback_token__destroy (
+void totemsrp_callback_token_destroy (
 	void *handle);
 
 #endif /* TOTEMSRP_H_DEFINED */