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

Merge trunk revision 2372:
r2372 | sdake | 2009-07-26 19:00:05 -0700 (Sun, 26 Jul 2009) | 6 lines

Add notification when totem has completed initialization.

This triggers the initialization of the service engines which may need totem
for initialization.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2490 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 лет назад
Родитель
Сommit
db30a51a88
8 измененных файлов с 56 добавлено и 12 удалено
  1. 17 10
      exec/main.c
  2. 8 0
      exec/totemmrp.c
  3. 3 0
      exec/totemmrp.h
  4. 6 0
      exec/totempg.c
  5. 0 1
      exec/totemrrp.c
  6. 15 1
      exec/totemsrp.c
  7. 4 0
      exec/totemsrp.h
  8. 3 0
      include/corosync/totem/totempg.h

+ 17 - 10
exec/main.c

@@ -734,6 +734,20 @@ static void corosync_setscheduler (void)
 #endif
 }
 
+void main_service_ready (void)
+{
+	int res;
+	/*
+	 * This must occur after totempg is initialized because "this_ip" must be set
+	 */
+	res = corosync_service_defaults_link_and_init (api);
+	if (res == -1) {
+		log_printf (LOGSYS_LEVEL_ERROR, "Could not initialize default services\n");
+		corosync_exit_error (AIS_DONE_INIT_SERVICES);
+	}
+	evil_init (api);
+}
+
 int main (int argc, char **argv)
 {
 	const char *error_string;
@@ -992,6 +1006,9 @@ int main (int argc, char **argv)
 		corosync_poll_handle,
 		&totem_config);
 
+	totempg_service_ready_register (
+		main_service_ready);
+
 	totempg_groups_initialize (
 		&corosync_group_handle,
 		deliver_fn,
@@ -1002,16 +1019,6 @@ int main (int argc, char **argv)
 		&corosync_group,
 		1);
 
-	/*
-	 * This must occur after totempg is initialized because "this_ip" must be set
-	 */
-	res = corosync_service_defaults_link_and_init (api);
-	if (res == -1) {
-		log_printf (LOGSYS_LEVEL_ERROR, "Could not initialize default services\n");
-		corosync_exit_error (AIS_DONE_INIT_SERVICES);
-	}
-	evil_init (api);
-
 	if (minimum_sync_mode == CS_SYNC_V2) {
 		log_printf (LOGSYS_LEVEL_NOTICE, "Compatibility mode set to none.  Using V2 of the synchronization engine.\n");
 		sync_v2_init (

+ 8 - 0
exec/totemmrp.c

@@ -234,3 +234,11 @@ extern int totemmrp_ring_reenable (void)
 
 	return (res);
 }
+
+extern void totemmrp_service_ready_register (
+        void (*totem_service_ready) (void))
+{
+	totemsrp_service_ready_register (
+		totemsrp_context,
+		totem_service_ready);
+}

+ 3 - 0
exec/totemmrp.h

@@ -112,4 +112,7 @@ extern int totemmrp_crypto_set (unsigned int);
 
 extern int totemmrp_ring_reenable (void);
 
+extern void totemmrp_service_ready_register (
+        void (*totem_service_ready) (void));
+
 #endif /* TOTEMMRP_H_DEFINED */

+ 6 - 0
exec/totempg.c

@@ -1358,3 +1358,9 @@ int totempg_my_family_get (void)
 {
 	return (totemmrp_my_family_get());
 }
+extern void totempg_service_ready_register (
+	void (*totem_service_ready) (void))
+{
+	totemmrp_service_ready_register (totem_service_ready);
+}
+

+ 0 - 1
exec/totemrrp.c

@@ -1536,7 +1536,6 @@ int totemrrp_initialize (
 		deliver_fn_context->instance = instance;
 		deliver_fn_context->context = context;
 		deliver_fn_context->iface_no = i;
-printf ("deliver fn context %p\n", deliver_fn_context);
 
 		totemnet_initialize (
 			poll_handle,

+ 15 - 1
exec/totemsrp.c

@@ -461,6 +461,8 @@ struct totemsrp_instance {
 		const unsigned int *joined_list, size_t joined_list_entries,
 		const struct memb_ring_id *ring_id);
 
+        void (*totemsrp_service_ready_fn) (void);
+
 	int global_seqno;
 
 	int my_token_held;
@@ -906,7 +908,7 @@ int totemsrp_ifaces_get (
 	unsigned int *iface_count)
 {
 	struct totemsrp_instance *instance = (struct totemsrp_instance *)srp_context;
-	int res;
+	int res = 0;
 	unsigned int found = 0;
 	unsigned int i;
 
@@ -4233,6 +4235,9 @@ void main_iface_change_fn (
 			"Created or loaded sequence id %lld.%s for this ring.\n",
 			instance->my_ring_id.seq,
 			totemip_print (&instance->my_ring_id.rep));
+		if (instance->totemsrp_service_ready_fn) {
+			instance->totemsrp_service_ready_fn ();
+		}
 
 	}
 	if (instance->iface_changes >= instance->totem_config->interface_count) {
@@ -4243,3 +4248,12 @@ void main_iface_change_fn (
 void totemsrp_net_mtu_adjust (struct totem_config *totem_config) {
 	totem_config->net_mtu -= sizeof (struct mcast);
 }
+
+void totemsrp_service_ready_register (
+	void *context,
+        void (*totem_service_ready) (void))
+{
+	struct totemsrp_instance *instance = (struct totemsrp_instance *)context;
+
+	instance->totemsrp_service_ready_fn = totem_service_ready;
+}

+ 4 - 0
exec/totemsrp.h

@@ -115,4 +115,8 @@ extern int totemsrp_crypto_set (
 extern int totemsrp_ring_reenable (
 	void *srp_context);
 
+void totemsrp_service_ready_register (
+	void *srp_context,
+	void (*totem_service_ready) (void));
+
 #endif /* TOTEMSRP_H_DEFINED */

+ 3 - 0
include/corosync/totem/totempg.h

@@ -153,6 +153,9 @@ extern int totempg_crypto_set (unsigned int type);
 
 extern int totempg_ring_reenable (void);
 
+extern void totempg_service_ready_register (
+	void (*totem_service_ready) (void));
+
 #ifdef __cplusplus
 }
 #endif