Parcourir la source

add schedwrk_create and schedwrk_destroy coroapi functions.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2089 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake il y a 17 ans
Parent
commit
221dddd0dd
7 fichiers modifiés avec 40 ajouts et 26 suppressions
  1. 3 2
      exec/Makefile.am
  2. 3 0
      exec/apidef.c
  3. 5 0
      exec/main.c
  4. 8 14
      exec/vsf_ykd.c
  5. 7 0
      include/corosync/engine/coroapi.h
  6. 13 9
      services/pload.c
  7. 1 1
      tools/corosync-pload.c

+ 3 - 2
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)
 

+ 3 - 0
exec/apidef.c

@@ -51,6 +51,7 @@
 #include "quorum.h"
 #include <corosync/engine/coroapi.h>
 #include "service.h"
+#include "schedwrk.h"
 #include <corosync/lcr/lcr_ifact.h>
 #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,

+ 5 - 0
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;

+ 8 - 14
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);
 }

+ 7 - 0
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);
 

+ 13 - 9
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);

+ 1 - 1
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);
 }