The current service engines could use the totem APIs before totem is
fully initialized within the network layer.
This patch address that issue by adding a callback registration function
to the totempg API. This callback is called when totem is ready to
provide service. When the callback is executed, the service engines are
linked and initialized.
Regards
-steve
Index: include/corosync/totem/totempg.h
===================================================================
--- include/corosync/totem/totempg.h (revision 2371)
+++ include/corosync/totem/totempg.h (working copy)
@@ -153,6 +153,9 @@
extern int totempg_ring_reenable (void);
+extern void totempg_service_ready_register (
+ void (*totem_service_ready) (void));
+
#ifdef __cplusplus
}
#endif
Index: exec/totempg.c
===================================================================
--- exec/totempg.c (revision 2371)
+++ exec/totempg.c (working copy)
@@ -1343,3 +1343,9 @@
{
return (totemmrp_my_family_get());
}
+extern void totempg_service_ready_register (
+ void (*totem_service_ready) (void))
+{
+ totemmrp_service_ready_register (totem_service_ready);
+}
+
Index: exec/totemmrp.c
===================================================================
--- exec/totemmrp.c (revision 2371)
+++ exec/totemmrp.c (working copy)
@@ -234,3 +234,11 @@
return (res);
}
+
+extern void totemmrp_service_ready_register (
+ void (*totem_service_ready) (void))
+{
+ totemsrp_service_ready_register (
+ totemsrp_context,
+ totem_service_ready);
+}
Index: exec/totemmrp.h
===================================================================
--- exec/totemmrp.h (revision 2371)
+++ exec/totemmrp.h (working copy)
@@ -112,4 +112,7 @@
extern int totemmrp_ring_reenable (void);
+extern void totemmrp_service_ready_register (
+ void (*totem_service_ready) (void));
+
#endif /* TOTEMMRP_H_DEFINED */
Index: exec/totemrrp.c
===================================================================
--- exec/totemrrp.c (revision 2371)
+++ exec/totemrrp.c (working copy)
@@ -1536,7 +1536,6 @@
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: exec/totemsrp.c
===================================================================
--- exec/totemsrp.c (revision 2371)
+++ exec/totemsrp.c (working copy)
@@ -470,6 +470,8 @@
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 @@
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 @@
"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 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: exec/totemsrp.h
===================================================================
--- exec/totemsrp.h (revision 2371)
+++ exec/totemsrp.h (working copy)
@@ -115,4 +115,8 @@
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: exec/main.c
===================================================================
--- exec/main.c (revision 2371)
+++ exec/main.c (working copy)
@@ -716,6 +716,20 @@
#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 @@
corosync_poll_handle,
&totem_config);
+ totempg_service_ready_register (
+ main_service_ready);
+
totempg_groups_initialize (
&corosync_group_handle,
deliver_fn,
@@ -983,16 +1000,6 @@
&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 (
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais