]> git.proxmox.com Git - mirror_corosync.git/commitdiff
Add notification when totem has completed initialization.
authorSteven Dake <sdake@redhat.com>
Mon, 27 Jul 2009 02:00:05 +0000 (02:00 +0000)
committerSteven Dake <sdake@redhat.com>
Mon, 27 Jul 2009 02:00:05 +0000 (02:00 +0000)
This triggers the initialization of the service engines which may need totem
for initialization.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2372 fd59a12c-fef9-0310-b244-a6a79926bd2f

exec/main.c
exec/totemmrp.c
exec/totemmrp.h
exec/totempg.c
exec/totemrrp.c
exec/totemsrp.c
exec/totemsrp.h
include/corosync/totem/totempg.h

index 2fdb62e50ea0ac0efed4deed23b2a472ce473eb7..96919b63b8024dd5e95d071383598bf887be2914 100644 (file)
@@ -716,6 +716,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;
@@ -973,6 +987,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,
@@ -983,16 +1000,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 (
index 1bd538a23c9194e9559bb8c1457cd8a46e82939d..d014300bb6252fd236fc58f217f095df726fdeca 100644 (file)
@@ -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);
+}
index fda10c0df016b0df1fdaef5b4324099c0eae7f2b..aa19c1b7727adde1f1fc84047eef4bd39e32f3ca 100644 (file)
@@ -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 */
index f77bedf74560d547f3630fe617c54ecc7bd3e1ae..93f7eb268ea0f2aa448487e3a9d13790215c38cf 100644 (file)
@@ -1343,3 +1343,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);
+}
+
index 406d4fdd86c43d2788e5e2815a36e12d38bcb31a..0b80351209e6e69936537f8a588fa48517354010 100644 (file)
@@ -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,
index 574edb637913c0ba9847535d6c1e7d1f1ad5dad2..2194411e1a8567326acb06596a6ffd2b07aac6e7 100644 (file)
@@ -470,6 +470,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;
@@ -917,7 +919,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;
 
@@ -4246,6 +4248,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) {
@@ -4256,3 +4261,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;
+}
index e003d7d2e30b0469f0ac1b35b4def675e6dacdca..743aaad844b24648789d81cc1bce65fb58f821f9 100644 (file)
@@ -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 */
index f4bad95cd93afc92cc280bcaa5d49d3928e11e18..4609092af20540672e6f628985edadc921befd54 100644 (file)
@@ -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