From 221dddd0dd840f9fefb0454bc6b9a1277d01d30f Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Sat, 18 Apr 2009 14:39:57 +0000 Subject: [PATCH] add schedwrk_create and schedwrk_destroy coroapi functions. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2089 fd59a12c-fef9-0310-b244-a6a79926bd2f --- exec/Makefile.am | 5 +++-- exec/apidef.c | 3 +++ exec/main.c | 5 +++++ exec/vsf_ykd.c | 22 ++++++++-------------- include/corosync/engine/coroapi.h | 7 +++++++ services/pload.c | 22 +++++++++++++--------- tools/corosync-pload.c | 2 +- 7 files changed, 40 insertions(+), 26 deletions(-) diff --git a/exec/Makefile.am b/exec/Makefile.am index 9c996658..61e0c153 100644 --- a/exec/Makefile.am +++ b/exec/Makefile.am @@ -52,7 +52,8 @@ liblogsys_a_SOURCES = $(LOGSYS_SRC) libcoroipcs_a_SOURCES = $(COROIPCS_SRC) corosync_SOURCES = main.c mempool.c util.c sync.c apidef.c service.c \ - timer.c totemconfig.c mainconfig.c quorum.c ../lcr/lcr_ifact.c + timer.c totemconfig.c mainconfig.c quorum.c schedwrk.c \ + ../lcr/lcr_ifact.c corosync_LDADD = -ltotem_pg -llogsys -lcoroipcs corosync_DEPENDENCIES = libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME) libcoroipcs.so.$(SONAME) corosync_LDFLAGS = $(OS_DYFLAGS) -L./ @@ -68,7 +69,7 @@ SHARED_LIBS_SO_TWO = $(SHARED_LIBS:%.so.$(SONAME)=%.so.$(SOMAJOR)) noinst_HEADERS = apidef.h crypto.h mainconfig.h main.h mempool.h \ quorum.h service.h sync.h timer.h tlist.h totemconfig.h \ totemmrp.h totemnet.h totemrrp.h totemsrp.h util.h \ - version.h vsf.h wthread.h + version.h vsf.h wthread.h schedwrk.h EXTRA_DIST = $(LCRSO_SRC) diff --git a/exec/apidef.c b/exec/apidef.c index 40cf5acc..f751f68e 100644 --- a/exec/apidef.c +++ b/exec/apidef.c @@ -51,6 +51,7 @@ #include "quorum.h" #include #include "service.h" +#include "schedwrk.h" #include #include "apidef.h" @@ -125,6 +126,8 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = { .tpg_groups_mcast = (typedef_tpg_groups_mcast_groups)totempg_groups_mcast_groups, .tpg_groups_reserve = NULL, .tpg_groups_release = NULL, + .schedwrk_create = schedwrk_create, + .schedwrk_destroy = schedwrk_destroy, .sync_request = NULL, //sync_request, .quorum_is_quorate = corosync_quorum_is_quorate, .quorum_register_callback = corosync_quorum_register_callback, diff --git a/exec/main.c b/exec/main.c index 4b258d2d..34811e9a 100644 --- a/exec/main.c +++ b/exec/main.c @@ -80,6 +80,7 @@ #include "util.h" #include "apidef.h" #include "service.h" +#include "schedwrk.h" #include "version.h" LOGSYS_DECLARE_SYSTEM ("corosync", @@ -916,6 +917,10 @@ int main (int argc, char **argv) corosync_mempool_init (); + schedwrk_init ( + serialize_lock, + serialize_unlock); + ipc_subsys_id = _logsys_subsys_create ("IPC", LOG_INFO); ipc_init_state.sched_priority = sched_priority; diff --git a/exec/vsf_ykd.c b/exec/vsf_ykd.c index 683959c3..81759b8e 100644 --- a/exec/vsf_ykd.c +++ b/exec/vsf_ykd.c @@ -138,9 +138,9 @@ static int primary_designated = 0; static struct memb_ring_id ykd_ring_id; -static void *ykd_attempt_send_callback_token_handle = 0; +hdb_handle_t schedwrk_attempt_send_callback_handle; -static void *ykd_state_send_callback_token_handle = 0; +hdb_handle_t schedwrk_state_send_callback_handle; static struct corosync_api_v1 *api; @@ -159,8 +159,7 @@ static void ykd_state_init (void) ykd_state.last_primary.member_list_entries = 0; } -static int ykd_state_send_msg (enum totem_callback_token_type type, - const void *context) +static int ykd_state_send_msg (const void *context) { struct iovec iovec[2]; struct ykd_header header; @@ -181,16 +180,13 @@ static int ykd_state_send_msg (enum totem_callback_token_type type, static void ykd_state_send (void) { - api->totem_callback_token_create ( - &ykd_state_send_callback_token_handle, - TOTEM_CALLBACK_TOKEN_SENT, - 1, /* delete after callback */ + api->schedwrk_create ( + &schedwrk_state_send_callback_handle, ykd_state_send_msg, NULL); } -static int ykd_attempt_send_msg (enum totem_callback_token_type type, - const void *context) +static int ykd_attempt_send_msg (const void *context) { struct iovec iovec; struct ykd_header header; @@ -209,10 +205,8 @@ static int ykd_attempt_send_msg (enum totem_callback_token_type type, static void ykd_attempt_send (void) { - api->totem_callback_token_create ( - &ykd_attempt_send_callback_token_handle, - TOTEM_CALLBACK_TOKEN_SENT, - 1, /* delete after callback */ + api->schedwrk_create ( + &schedwrk_attempt_send_callback_handle, ykd_attempt_send_msg, NULL); } diff --git a/include/corosync/engine/coroapi.h b/include/corosync/engine/coroapi.h index 0b554b08..8d980a5f 100644 --- a/include/corosync/engine/coroapi.h +++ b/include/corosync/engine/coroapi.h @@ -505,6 +505,13 @@ struct corosync_api_v1 { int (*tpg_groups_release) ( int reserved_msgs); + int (*schedwrk_create) ( + hdb_handle_t *handle, + int (schedwrk_fn) (const void *), + const void *context); + + void (*schedwrk_destroy) (hdb_handle_t handle); + int (*sync_request) ( const char *service_name); diff --git a/services/pload.c b/services/pload.c index 424abe6e..27e22ba2 100644 --- a/services/pload.c +++ b/services/pload.c @@ -247,6 +247,12 @@ static void message_handler_req_pload_start (void *conn, const void *msg) iov.iov_base = &req_exec_pload_start; iov.iov_len = sizeof (struct req_exec_pload_start); + msgs_delivered = 0; + + msgs_wanted = 0; + + msgs_sent = 0; + api->totem_mcast (&iov, 1, TOTEM_AGREED); } @@ -258,7 +264,7 @@ static void req_exec_pload_mcast_endian_convert (void *msg) { } -static int send_message (enum totem_callback_token_type type, const void *arg) +static int send_message (const void *arg) { struct req_exec_pload_mcast req_exec_pload_mcast; struct iovec iov[2]; @@ -285,7 +291,7 @@ static int send_message (enum totem_callback_token_type type, const void *arg) msgs_sent++; msg_code++; } - } while (msgs_sent <= msgs_wanted); + } while (msgs_sent < msgs_wanted); if (msgs_sent == msgs_wanted) { return (0); } else { @@ -293,15 +299,14 @@ static int send_message (enum totem_callback_token_type type, const void *arg) } } -static void *token_callback; +hdb_handle_t start_mcasting_handle; + static void start_mcasting (void) { - api->totem_callback_token_create ( - &token_callback, - TOTEM_CALLBACK_TOKEN_RECEIVED, - 1, + api->schedwrk_create ( + &start_mcasting_handle, send_message, - &token_callback); + &start_mcasting_handle); } static void message_handler_req_exec_pload_start ( @@ -338,7 +343,6 @@ static void message_handler_req_exec_pload_mcast ( { const struct req_exec_pload_mcast *pload_mcast = msg; - assert (pload_mcast->msg_code - 1 == last_msg_no); last_msg_no = pload_mcast->msg_code; if (msgs_delivered == 0) { gettimeofday (&tv1, NULL); diff --git a/tools/corosync-pload.c b/tools/corosync-pload.c index 4b65dffb..8ee2e0ef 100644 --- a/tools/corosync-pload.c +++ b/tools/corosync-pload.c @@ -72,7 +72,7 @@ int main (void) { result = pload_start ( handle, 0, /* code */ - 150000000, /* count */ + 150000, /* count */ 300); /* size */ return (0); }