Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
configure.ac | 3 +-
corosync.spec.in | 1 -
cts/agents/Makefile.am | 8 +-
cts/agents/common_test_agent.c | 30 ++-
cts/agents/common_test_agent.h | 3 +-
cts/agents/confdb_test_agent.c | 1 +
cts/agents/cpg_test_agent.c | 36 ++-
cts/agents/sam_test_agent.c | 1 +
cts/agents/votequorum_test_agent.c | 14 +-
exec/Makefile.am | 4 +-
exec/coroipcs.c | 4 +-
exec/coropoll.c | 555 ------------------------------------
exec/main.c | 29 +-
exec/main.h | 4 +-
exec/timer.c | 2 +-
exec/totemconfig.h | 2 +-
exec/totemiba.c | 66 +++--
exec/totemiba.h | 3 +-
exec/totemmrp.c | 4 +-
exec/totemmrp.h | 2 +-
exec/totemnet.c | 7 +-
exec/totemnet.h | 2 +-
exec/totempg.c | 5 +-
exec/totemrrp.c | 34 ++-
exec/totemrrp.h | 4 +-
exec/totemsrp.c | 79 +++---
exec/totemsrp.h | 4 +-
exec/totemudp.c | 42 ++--
exec/totemudp.h | 3 +-
include/Makefile.am | 2 +-
include/corosync/coroipcs.h | 4 +-
include/corosync/engine/coroapi.h | 8 +-
include/corosync/totem/coropoll.h | 103 -------
include/corosync/totem/totempg.h | 4 +-
test/Makefile.am | 36 ++--
tools/Makefile.am | 10 +-
36 files changed, 258 insertions(+), 861 deletions(-)
delete mode 100644 exec/coropoll.c
delete mode 100644 include/corosync/totem/coropoll.h
diff --git a/configure.ac b/configure.ac
index ad4b6c1..2ffe547 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AC_PREREQ([2.61])
AC_INIT([corosync], [1.2.8], [openais(a)lists.osdl.org])
AM_INIT_AUTOMAKE([-Wno-portability])
-AC_CONFIG_SRCDIR([lib/coroipcc.c])
+AC_CONFIG_SRCDIR([lib/cpg.c])
AC_CONFIG_HEADER([include/corosync/config.h include/corosync/cs_config.h])
AC_CANONICAL_HOST
@@ -72,6 +72,7 @@ AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([nsl], [t_open])
AC_CHECK_LIB([rt], [sched_getscheduler])
+PKG_CHECK_MODULES([LIBQB], [libqb])
# Checks for header files.
AC_FUNC_ALLOCA
diff --git a/corosync.spec.in b/corosync.spec.in
index ed531c3..d4ed212 100644
--- a/corosync.spec.in
+++ b/corosync.spec.in
@@ -232,7 +232,6 @@ The Corosync Cluster Engine APIs.
%{_includedir}/corosync/quorum.h
%{_includedir}/corosync/votequorum.h
%dir %{_includedir}/corosync/totem/
-%{_includedir}/corosync/totem/coropoll.h
%{_includedir}/corosync/totem/totem.h
%{_includedir}/corosync/totem/totemip.h
%{_includedir}/corosync/totem/totempg.h
diff --git a/cts/agents/Makefile.am b/cts/agents/Makefile.am
index 1d73a9b..4a74a3e 100644
--- a/cts/agents/Makefile.am
+++ b/cts/agents/Makefile.am
@@ -58,19 +58,19 @@ endif
noinst_HEADERS = common_test_agent.h
cpg_test_agent_SOURCES = cpg_test_agent.c common_test_agent.c
-cpg_test_agent_LDADD = -lcpg -lcfg -lcoroipcc ../../exec/coropoll.o ../../exec/crypto.o
+cpg_test_agent_LDADD = -lcpg -lcfg -lcoroipcc ../../exec/crypto.o $(LIBQB_LIBS)
cpg_test_agent_LDFLAGS = -L../../lib -L.
confdb_test_agent_SOURCES = confdb_test_agent.c common_test_agent.c
-confdb_test_agent_LDADD = -lconfdb -lcoroipcc ../../exec/coropoll.o
+confdb_test_agent_LDADD = -lconfdb -lcoroipcc $(LIBQB_LIBS)
confdb_test_agent_LDFLAGS = -L../../lib
sam_test_agent_SOURCES = sam_test_agent.c common_test_agent.c
-sam_test_agent_LDADD = -lsam -lquorum -lcoroipcc -lconfdb ../../exec/coropoll.o
+sam_test_agent_LDADD = -lsam -lquorum -lcoroipcc -lconfdb $(LIBQB_LIBS)
sam_test_agent_LDFLAGS = -L../../lib
votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
-votequorum_test_agent_LDADD = -lvotequorum -lquorum -lcoroipcc ../../exec/coropoll.o
+votequorum_test_agent_LDADD = -lvotequorum -lquorum -lcoroipcc $(LIBQB_LIBS)
votequorum_test_agent_LDFLAGS = -L../../lib
if BUILD_DARWIN
diff --git a/cts/agents/common_test_agent.c b/cts/agents/common_test_agent.c
index 2f1c675..b3f4e04 100644
--- a/cts/agents/common_test_agent.c
+++ b/cts/agents/common_test_agent.c
@@ -47,17 +47,17 @@
#include <poll.h>
#include <unistd.h>
#include <fcntl.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include "common_test_agent.h"
int32_t parse_debug = 0;
static char big_and_buf_rx[HOW_BIG_AND_BUF];
ta_do_command_fn do_command;
-static hdb_handle_t poll_handle;
+static qb_loop_t *poll_handle;
-hdb_handle_t ta_poll_handle_get(void)
+qb_loop_t *ta_poll_handle_get(void)
{
return poll_handle;
}
@@ -102,7 +102,7 @@ static void ta_handle_command (int sock, char* msg)
free (str);
}
-static int server_process_data_fn (hdb_handle_t handle,
+static int server_process_data_fn (
int fd,
int revents,
void *data)
@@ -121,7 +121,7 @@ static int server_process_data_fn (hdb_handle_t handle,
syslog (LOG_ERR,"recv() failed: %s", strerror(errno));
}
close (fd);
- poll_stop (handle);
+ qb_loop_stop (ta_poll_handle_get());
} else {
big_and_buf_rx[nbytes] = '\0';
@@ -138,7 +138,7 @@ static int server_process_data_fn (hdb_handle_t handle,
return 0;
}
-static int server_accept_fn (hdb_handle_t handle,
+static int server_accept_fn (
int fd, int revents, void *data)
{
socklen_t addrlen;
@@ -169,7 +169,12 @@ retry_accept:
return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
}
- poll_dispatch_add (poll_handle, new_fd, POLLIN|POLLNVAL, NULL, server_process_data_fn);
+ qb_loop_poll_add (poll_handle,
+ QB_LOOP_MED,
+ new_fd,
+ POLLIN|POLLNVAL,
+ NULL,
+ server_process_data_fn);
return 0;
}
@@ -236,11 +241,16 @@ int test_agent_run(int server_port, ta_do_command_fn func)
int listener;
do_command = func;
- poll_handle = poll_create ();
+ poll_handle = qb_loop_create ();
listener = create_server_sockect (server_port);
- poll_dispatch_add (poll_handle, listener, POLLIN|POLLNVAL, NULL, server_accept_fn);
+ qb_loop_poll_add (poll_handle,
+ QB_LOOP_MED,
+ listener,
+ POLLIN|POLLNVAL,
+ NULL, server_accept_fn);
- return poll_run (poll_handle);
+ qb_loop_run (poll_handle);
+ return 0;
}
diff --git a/cts/agents/common_test_agent.h b/cts/agents/common_test_agent.h
index ca510f1..37e8e65 100644
--- a/cts/agents/common_test_agent.h
+++ b/cts/agents/common_test_agent.h
@@ -36,6 +36,7 @@
#define CORO_COMMON_TEST_AGNET_H_DEFINED
#include <corosync/hdb.h>
+#include <qb/qbloop.h>
#define OK_STR "OK"
#define FAIL_STR "FAIL"
@@ -48,7 +49,7 @@ typedef void (*ta_do_command_fn) (int sock, char* func, char*args[], int
num_arg
int test_agent_run(int server_port, ta_do_command_fn func);
-hdb_handle_t ta_poll_handle_get(void);
+qb_loop_t *ta_poll_handle_get(void);
#endif /* CORO_COMMON_TEST_AGNET_H_DEFINED */
diff --git a/cts/agents/confdb_test_agent.c b/cts/agents/confdb_test_agent.c
index 289384d..87165d3 100644
--- a/cts/agents/confdb_test_agent.c
+++ b/cts/agents/confdb_test_agent.c
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
diff --git a/cts/agents/cpg_test_agent.c b/cts/agents/cpg_test_agent.c
index e94cb6b..453f74b 100644
--- a/cts/agents/cpg_test_agent.c
+++ b/cts/agents/cpg_test_agent.c
@@ -47,8 +47,9 @@
#include <unistd.h>
#include <fcntl.h>
-#include <corosync/totem/coropoll.h>
#include <corosync/list.h>
+#include <qb/qbdefs.h>
+#include <qb/qbloop.h>
#include <corosync/cpg.h>
#include <corosync/cfg.h>
#include "../../exec/crypto.h"
@@ -318,10 +319,11 @@ static void read_messages (int sock, char* atmost_str)
static void send_some_more_messages_later (void)
{
- poll_timer_handle timer_handle;
+ qb_loop_timer_handle timer_handle;
cpg_dispatch (cpg_handle, CS_DISPATCH_ALL);
- poll_timer_add (
+ qb_loop_timer_add (
ta_poll_handle_get(),
+ QB_LOOP_MED,
300, NULL,
send_some_more_messages,
&timer_handle);
@@ -550,7 +552,7 @@ static void msg_blaster_zcb (int sock, char* num_to_send_str)
static corosync_cfg_state_notification_t notification_buffer;
-static int cfg_dispatch_wrapper_fn (hdb_handle_t handle,
+static int cfg_dispatch_wrapper_fn (
int fd,
int revents,
void *data)
@@ -558,7 +560,7 @@ static int cfg_dispatch_wrapper_fn (hdb_handle_t handle,
cs_error_t error;
if (revents & POLLHUP || revents & POLLERR) {
syslog (LOG_ERR, "%s() got POLLHUP disconnecting from CFG", __func__);
- poll_dispatch_delete (ta_poll_handle_get(), cfg_fd);
+ qb_loop_poll_del (ta_poll_handle_get(), cfg_fd);
close (cfg_fd);
cfg_fd = -1;
return -1;
@@ -566,7 +568,7 @@ static int cfg_dispatch_wrapper_fn (hdb_handle_t handle,
error = corosync_cfg_dispatch (cfg_handle, CS_DISPATCH_ALL);
if (error == CS_ERR_LIBRARY) {
syslog (LOG_ERR, "%s() got LIB error disconnecting from CFG.", __func__);
- poll_dispatch_delete (ta_poll_handle_get(), cfg_fd);
+ qb_loop_poll_del (ta_poll_handle_get(), cfg_fd);
close (cfg_fd);
cfg_fd = -1;
return -1;
@@ -574,7 +576,7 @@ static int cfg_dispatch_wrapper_fn (hdb_handle_t handle,
return 0;
}
-static int cpg_dispatch_wrapper_fn (hdb_handle_t handle,
+static int cpg_dispatch_wrapper_fn (
int fd,
int revents,
void *data)
@@ -582,7 +584,7 @@ static int cpg_dispatch_wrapper_fn (hdb_handle_t handle,
cs_error_t error;
if (revents & POLLHUP || revents & POLLERR) {
syslog (LOG_ERR, "%s() got POLLHUP disconnecting from CPG", __func__);
- poll_dispatch_delete (ta_poll_handle_get(), cpg_fd);
+ qb_loop_poll_del (ta_poll_handle_get(), cpg_fd);
close (cpg_fd);
cpg_fd = -1;
return -1;
@@ -590,7 +592,7 @@ static int cpg_dispatch_wrapper_fn (hdb_handle_t handle,
error = cpg_dispatch (cpg_handle, CS_DISPATCH_ALL);
if (error == CS_ERR_LIBRARY) {
syslog (LOG_ERR, "%s() got LIB error disconnecting from CPG", __func__);
- poll_dispatch_delete (ta_poll_handle_get(), cpg_fd);
+ qb_loop_poll_del (ta_poll_handle_get(), cpg_fd);
close (cpg_fd);
cpg_fd = -1;
return -1;
@@ -660,7 +662,12 @@ static void do_command (int sock, char* func, char*args[], int
num_args)
}
cpg_fd_get (cpg_handle, &cpg_fd);
- poll_dispatch_add (ta_poll_handle_get(), cpg_fd, POLLIN|POLLNVAL, NULL,
cpg_dispatch_wrapper_fn);
+ qb_loop_poll_add (ta_poll_handle_get(),
+ QB_LOOP_MED,
+ cpg_fd,
+ POLLIN|POLLNVAL,
+ NULL,
+ cpg_dispatch_wrapper_fn);
} else if (strcmp ("cpg_local_get", func) == 0) {
unsigned int local_nodeid;
@@ -671,7 +678,7 @@ static void do_command (int sock, char* func, char*args[], int
num_args)
} else if (strcmp ("cpg_finalize", func) == 0) {
cpg_finalize (cpg_handle);
- poll_dispatch_delete (ta_poll_handle_get(), cpg_fd);
+ qb_loop_poll_del (ta_poll_handle_get(), cpg_fd);
cpg_fd = -1;
} else if (strcmp ("record_config_events", func) == 0) {
@@ -719,7 +726,12 @@ static void do_command (int sock, char* func, char*args[], int
num_args)
corosync_cfg_state_track (cfg_handle, 0, ¬ification_buffer);
- poll_dispatch_add (ta_poll_handle_get(), cfg_fd, POLLIN|POLLNVAL, NULL,
cfg_dispatch_wrapper_fn);
+ qb_loop_poll_add (ta_poll_handle_get(),
+ QB_LOOP_MED,
+ cfg_fd,
+ POLLIN|POLLNVAL,
+ NULL,
+ cfg_dispatch_wrapper_fn);
} else {
syslog (LOG_ERR,"%s RPC:%s not supported!", __func__, func);
}
diff --git a/cts/agents/sam_test_agent.c b/cts/agents/sam_test_agent.c
index 17a91e2..430a907 100644
--- a/cts/agents/sam_test_agent.c
+++ b/cts/agents/sam_test_agent.c
@@ -42,6 +42,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
+#include <pthread.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/cts/agents/votequorum_test_agent.c b/cts/agents/votequorum_test_agent.c
index 7ebd12f..1acab8e 100644
--- a/cts/agents/votequorum_test_agent.c
+++ b/cts/agents/votequorum_test_agent.c
@@ -48,7 +48,7 @@
#include <syslog.h>
#include <poll.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include <corosync/corotypes.h>
#include <corosync/votequorum.h>
#include <corosync/quorum.h>
@@ -78,7 +78,7 @@ static void quorum_notification_fn(
}
-static int vq_dispatch_wrapper_fn (hdb_handle_t handle,
+static int vq_dispatch_wrapper_fn (
int fd,
int revents,
void *data)
@@ -86,13 +86,13 @@ static int vq_dispatch_wrapper_fn (hdb_handle_t handle,
cs_error_t error = votequorum_dispatch (vq_handle, CS_DISPATCH_ALL);
if (error == CS_ERR_LIBRARY) {
syslog (LOG_ERR, "%s() got LIB error disconnecting from corosync.",
__func__);
- poll_dispatch_delete (ta_poll_handle_get(), fd);
+ qb_loop_poll_del (ta_poll_handle_get(), fd);
close (fd);
}
return 0;
}
-static int q_dispatch_wrapper_fn (hdb_handle_t handle,
+static int q_dispatch_wrapper_fn (
int fd,
int revents,
void *data)
@@ -100,7 +100,7 @@ static int q_dispatch_wrapper_fn (hdb_handle_t handle,
cs_error_t error = quorum_dispatch (q_handle, CS_DISPATCH_ALL);
if (error == CS_ERR_LIBRARY) {
syslog (LOG_ERR, "%s() got LIB error disconnecting from corosync.",
__func__);
- poll_dispatch_delete (ta_poll_handle_get(), fd);
+ qb_loop_poll_del (ta_poll_handle_get(), fd);
close (fd);
}
return 0;
@@ -137,7 +137,7 @@ static int q_lib_init(void)
}
votequorum_fd_get (vq_handle, &fd);
- poll_dispatch_add (ta_poll_handle_get(), fd,
+ qb_loop_poll_add (ta_poll_handle_get(), QB_LOOP_MED, fd,
POLLIN|POLLNVAL, NULL, vq_dispatch_wrapper_fn);
}
}
@@ -155,7 +155,7 @@ static int q_lib_init(void)
syslog (LOG_ERR, "quorum_trackstart FAILED: %d\n", ret);
}
quorum_fd_get (q_handle, &fd);
- poll_dispatch_add (ta_poll_handle_get(), fd,
+ qb_loop_poll_add (ta_poll_handle_get(), QB_LOOP_MED, fd,
POLLIN|POLLNVAL, NULL, q_dispatch_wrapper_fn);
}
}
diff --git a/exec/Makefile.am b/exec/Makefile.am
index 938237c..00fd9e8 100644
--- a/exec/Makefile.am
+++ b/exec/Makefile.am
@@ -35,7 +35,7 @@ AM_CFLAGS = -fPIC
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include $(nss_CFLAGS)
$(rdmacm_CFLAGS) $(ibverbs_CFLAGS)
-TOTEM_SRC = coropoll.c totemip.c totemnet.c totemudp.c \
+TOTEM_SRC = totemip.c totemnet.c totemudp.c \
totemrrp.c totemsrp.c totemmrp.c totempg.c \
crypto.c wthread.c tsafe.c
if BUILD_RDMA
@@ -59,7 +59,7 @@ libcoroipcs_a_SOURCES = $(COROIPCS_SRC)
corosync_SOURCES = main.c util.c sync.c apidef.c service.c \
timer.c totemconfig.c mainconfig.c quorum.c schedwrk.c \
../lcr/lcr_ifact.c evil.c syncv2.c
-corosync_LDADD = -ltotem_pg -llogsys -lcoroipcs $(statgrab_LIBS)
+corosync_LDADD = -ltotem_pg -llogsys -lcoroipcs $(statgrab_LIBS) $(LIBQB_LIBS)
corosync_DEPENDENCIES = libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME)
libcoroipcs.so.$(SONAME)
corosync_LDFLAGS = $(OS_DYFLAGS) -L./
diff --git a/exec/coroipcs.c b/exec/coroipcs.c
index 0ca22d3..9c1bfdb 100644
--- a/exec/coroipcs.c
+++ b/exec/coroipcs.c
@@ -1262,7 +1262,7 @@ static void msg_send (void *conn, const struct iovec *iov, unsigned
int iov_len,
if (conn_info->poll_state == POLL_STATE_IN) {
conn_info->poll_state = POLL_STATE_INOUT;
api->poll_dispatch_modify (conn_info->fd,
- POLLIN|POLLOUT|POLLNVAL);
+ POLLIN|POLLOUT|POLLNVAL, conn_info);
}
}
@@ -1731,7 +1731,7 @@ int coroipcs_handler_dispatch (
}
if (conn_info->poll_state == POLL_STATE_INOUT) {
conn_info->poll_state = POLL_STATE_IN;
- api->poll_dispatch_modify (conn_info->fd, POLLIN|POLLNVAL);
+ api->poll_dispatch_modify (conn_info->fd, POLLIN|POLLNVAL, conn_info);
}
}
diff --git a/exec/coropoll.c b/exec/coropoll.c
deleted file mode 100644
index 95978df..0000000
--- a/exec/coropoll.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- * Copyright (c) 2006-2009 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake(a)redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <config.h>
-
-#include <errno.h>
-#include <pthread.h>
-#include <sys/poll.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include <corosync/hdb.h>
-#include <corosync/totem/coropoll.h>
-#include <corosync/list.h>
-#include "tlist.h"
-
-typedef int (*dispatch_fn_t) (hdb_handle_t hdb_handle, int fd, int revents, void *data);
-
-struct poll_entry {
- struct pollfd ufd;
- dispatch_fn_t dispatch_fn;
- void *data;
-};
-
-struct poll_instance {
- struct poll_entry *poll_entries;
- struct pollfd *ufds;
- int poll_entry_count;
- struct timerlist timerlist;
- int stop_requested;
- int pipefds[2];
- poll_low_fds_event_fn low_fds_event_fn;
- int32_t not_enough_fds;
-};
-
-DECLARE_HDB_DATABASE (poll_instance_database,NULL);
-
-static int dummy_dispatch_fn (hdb_handle_t handle, int fd, int revents, void *data) {
- return (0);
-}
-
-hdb_handle_t poll_create (void)
-{
- hdb_handle_t handle;
- struct poll_instance *poll_instance;
- unsigned int res;
-
- res = hdb_handle_create (&poll_instance_database,
- sizeof (struct poll_instance), &handle);
- if (res != 0) {
- goto error_exit;
- }
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- goto error_destroy;
- }
-
- poll_instance->poll_entries = 0;
- poll_instance->ufds = 0;
- poll_instance->poll_entry_count = 0;
- poll_instance->stop_requested = 0;
- poll_instance->not_enough_fds = 0;
- timerlist_init (&poll_instance->timerlist);
-
- res = pipe (poll_instance->pipefds);
- if (res != 0) {
- goto error_destroy;
- }
-
- /*
- * Allow changes in modify to propogate into new poll instance
- */
- res = poll_dispatch_add (
- handle,
- poll_instance->pipefds[0],
- POLLIN,
- NULL,
- dummy_dispatch_fn);
- if (res != 0) {
- goto error_destroy;
- }
-
- return (handle);
-
-error_destroy:
- hdb_handle_destroy (&poll_instance_database, handle);
-
-error_exit:
- return (-1);
-}
-
-int poll_destroy (hdb_handle_t handle)
-{
- struct poll_instance *poll_instance;
- int res = 0;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- free (poll_instance->poll_entries);
- free (poll_instance->ufds);
-
- hdb_handle_destroy (&poll_instance_database, handle);
-
- hdb_handle_put (&poll_instance_database, handle);
-
-error_exit:
- return (res);
-}
-
-int poll_dispatch_add (
- hdb_handle_t handle,
- int fd,
- int events,
- void *data,
- int (*dispatch_fn) (
- hdb_handle_t hdb_handle_t,
- int fd,
- int revents,
- void *data))
-{
- struct poll_instance *poll_instance;
- struct poll_entry *poll_entries;
- struct pollfd *ufds;
- int found = 0;
- int install_pos;
- int res = 0;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- for (found = 0, install_pos = 0; install_pos < poll_instance->poll_entry_count;
install_pos++) {
- if (poll_instance->poll_entries[install_pos].ufd.fd == -1) {
- found = 1;
- break;
- }
- }
-
- if (found == 0) {
- /*
- * Grow pollfd list
- */
- poll_entries = (struct poll_entry *)realloc (poll_instance->poll_entries,
- (poll_instance->poll_entry_count + 1) *
- sizeof (struct poll_entry));
- if (poll_entries == NULL) {
- res = -ENOMEM;
- goto error_put;
- }
- poll_instance->poll_entries = poll_entries;
-
- ufds = (struct pollfd *)realloc (poll_instance->ufds,
- (poll_instance->poll_entry_count + 1) *
- sizeof (struct pollfd));
- if (ufds == NULL) {
- res = -ENOMEM;
- goto error_put;
- }
- poll_instance->ufds = ufds;
-
- poll_instance->poll_entry_count += 1;
- install_pos = poll_instance->poll_entry_count - 1;
- }
-
- /*
- * Install new dispatch handler
- */
- poll_instance->poll_entries[install_pos].ufd.fd = fd;
- poll_instance->poll_entries[install_pos].ufd.events = events;
- poll_instance->poll_entries[install_pos].ufd.revents = 0;
- poll_instance->poll_entries[install_pos].dispatch_fn = dispatch_fn;
- poll_instance->poll_entries[install_pos].data = data;
-
-error_put:
- hdb_handle_put (&poll_instance_database, handle);
-
-error_exit:
- return (res);
-}
-
-int poll_dispatch_modify (
- hdb_handle_t handle,
- int fd,
- int events,
- int (*dispatch_fn) (
- hdb_handle_t hdb_handle_t,
- int fd,
- int revents,
- void *data))
-{
- struct poll_instance *poll_instance;
- int i;
- int res = 0;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- /*
- * Find file descriptor to modify events and dispatch function
- */
- for (i = 0; i < poll_instance->poll_entry_count; i++) {
- if (poll_instance->poll_entries[i].ufd.fd == fd) {
- int change_notify = 0;
-
- if (poll_instance->poll_entries[i].ufd.events != events) {
- change_notify = 1;
- }
- poll_instance->poll_entries[i].ufd.events = events;
- poll_instance->poll_entries[i].dispatch_fn = dispatch_fn;
- if (change_notify) {
- char buf = 1;
- write (poll_instance->pipefds[1], &buf, 1);
- }
-
- goto error_put;
- }
- }
-
- res = -EBADF;
-
-error_put:
- hdb_handle_put (&poll_instance_database, handle);
-
-error_exit:
- return (res);
-}
-
-int poll_dispatch_delete (
- hdb_handle_t handle,
- int fd)
-{
- struct poll_instance *poll_instance;
- int i;
- int res = 0;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- /*
- * Find dispatch fd to delete
- */
- res = -EBADF;
- for (i = 0; i < poll_instance->poll_entry_count; i++) {
- if (poll_instance->poll_entries[i].ufd.fd == fd) {
- poll_instance->ufds[i].fd = -1;
- poll_instance->poll_entries[i].ufd.fd = -1;
- poll_instance->poll_entries[i].ufd.revents = 0;
-
- res = 0;
- break;
- }
- }
-
-
- hdb_handle_put (&poll_instance_database, handle);
-
-error_exit:
- return (res);
-}
-
-int poll_timer_add (
- hdb_handle_t handle,
- int msec_duration, void *data,
- void (*timer_fn) (void *data),
- poll_timer_handle *timer_handle_out)
-{
- struct poll_instance *poll_instance;
- int res = 0;
-
- if (timer_handle_out == NULL) {
- res = -ENOENT;
- goto error_exit;
- }
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- timerlist_add_duration (&poll_instance->timerlist,
- timer_fn, data, ((unsigned long long)msec_duration) * 1000000ULL, timer_handle_out);
-
- hdb_handle_put (&poll_instance_database, handle);
-error_exit:
- return (res);
-}
-
-int poll_timer_delete (
- hdb_handle_t handle,
- poll_timer_handle th)
-{
- struct poll_instance *poll_instance;
- int res = 0;
-
- if (th == 0) {
- return (0);
- }
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- timerlist_del (&poll_instance->timerlist, (void *)th);
-
- hdb_handle_put (&poll_instance_database, handle);
-
-error_exit:
- return (res);
-}
-
-int poll_stop (
- hdb_handle_t handle)
-{
- struct poll_instance *poll_instance;
- unsigned int res;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- goto error_exit;
- }
-
- poll_instance->stop_requested = 1;
-
- hdb_handle_put (&poll_instance_database, handle);
-error_exit:
- return (res);
-}
-
-int poll_low_fds_event_set(
- hdb_handle_t handle,
- poll_low_fds_event_fn fn)
-{
- struct poll_instance *poll_instance;
-
- if (hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance) != 0) {
- return -ENOENT;
- }
-
- poll_instance->low_fds_event_fn = fn;
-
- hdb_handle_put (&poll_instance_database, handle);
- return 0;
-}
-
-/* logs, std(in|out|err), pipe */
-#define POLL_FDS_USED_MISC 50
-
-static void poll_fds_usage_check(struct poll_instance *poll_instance)
-{
- struct rlimit lim;
- static int32_t socks_limit = 0;
- int32_t send_event = 0;
- int32_t socks_used = 0;
- int32_t socks_avail = 0;
- int32_t i;
-
- if (socks_limit == 0) {
- if (getrlimit(RLIMIT_NOFILE, &lim) == -1) {
- char error_str[100];
- strerror_r(errno, error_str, 100);
- printf("getrlimit: %s\n", error_str);
- return;
- }
- socks_limit = lim.rlim_cur;
- socks_limit -= POLL_FDS_USED_MISC;
- if (socks_limit < 0) {
- socks_limit = 0;
- }
- }
-
- for (i = 0; i < poll_instance->poll_entry_count; i++) {
- if (poll_instance->poll_entries[i].ufd.fd != -1) {
- socks_used++;
- }
- }
- socks_avail = socks_limit - socks_used;
- if (socks_avail < 0) {
- socks_avail = 0;
- }
- send_event = 0;
- if (poll_instance->not_enough_fds) {
- if (socks_avail > 2) {
- poll_instance->not_enough_fds = 0;
- send_event = 1;
- }
- } else {
- if (socks_avail <= 1) {
- poll_instance->not_enough_fds = 1;
- send_event = 1;
- }
- }
- if (send_event) {
- poll_instance->low_fds_event_fn(poll_instance->not_enough_fds,
- socks_avail);
- }
-}
-
-int poll_run (
- hdb_handle_t handle)
-{
- struct poll_instance *poll_instance;
- int i;
- unsigned long long expire_timeout_msec = -1;
- int res;
- int poll_entry_count;
-
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- goto error_exit;
- }
-
- for (;;) {
-rebuild_poll:
- for (i = 0; i < poll_instance->poll_entry_count; i++) {
- memcpy (&poll_instance->ufds[i],
- &poll_instance->poll_entries[i].ufd,
- sizeof (struct pollfd));
- }
- poll_fds_usage_check(poll_instance);
- expire_timeout_msec = timerlist_msec_duration_to_expire
(&poll_instance->timerlist);
-
- if (expire_timeout_msec != -1 && expire_timeout_msec > 0xFFFFFFFF) {
- expire_timeout_msec = 0xFFFFFFFE;
- }
-
-retry_poll:
- res = poll (poll_instance->ufds,
- poll_instance->poll_entry_count, expire_timeout_msec);
- if (poll_instance->stop_requested) {
- return (0);
- }
- if (errno == EINTR && res == -1) {
- goto retry_poll;
- } else
- if (res == -1) {
- goto error_exit;
- }
-
- if (poll_instance->ufds[0].revents) {
- char buf;
- read (poll_instance->ufds[0].fd, &buf, 1);
- goto rebuild_poll;
- }
- poll_entry_count = poll_instance->poll_entry_count;
- for (i = 0; i < poll_entry_count; i++) {
- if (poll_instance->ufds[i].fd != -1 &&
- poll_instance->ufds[i].revents) {
-
- res = poll_instance->poll_entries[i].dispatch_fn (handle,
- poll_instance->ufds[i].fd,
- poll_instance->ufds[i].revents,
- poll_instance->poll_entries[i].data);
-
- /*
- * Remove dispatch functions that return -1
- */
- if (res == -1) {
- poll_instance->poll_entries[i].ufd.fd = -1; /* empty entry */
- }
- }
- }
- timerlist_expire (&poll_instance->timerlist);
- } /* for (;;) */
-
- hdb_handle_put (&poll_instance_database, handle);
-error_exit:
- return (-1);
-}
-
-#ifdef COMPILE_OUT
-void poll_print_state (
- hdb_handle_t handle,
- int fd)
-{
- struct poll_instance *poll_instance;
- int i;
- int res = 0;
- res = hdb_handle_get (&poll_instance_database, handle,
- (void *)&poll_instance);
- if (res != 0) {
- res = -ENOENT;
- exit (1);
- }
-
- for (i = 0; i < poll_instance->poll_entry_count; i++) {
- if (poll_instance->poll_entries[i].ufd.fd == fd) {
- printf ("fd %d\n", poll_instance->poll_entries[i].ufd.fd);
- printf ("events %d\n", poll_instance->poll_entries[i].ufd.events);
- printf ("dispatch_fn %p\n", poll_instance->poll_entries[i].dispatch_fn);
- }
- }
-}
-
-#endif
diff --git a/exec/main.c b/exec/main.c
index b994648..40f7974 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -59,13 +59,15 @@
#include <time.h>
#include <semaphore.h>
+#include <qb/qbdefs.h>
+#include <qb/qbloop.h>
+
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/corodefs.h>
#include <corosync/list.h>
#include <corosync/lcr/lcr_ifact.h>
-#include <corosync/totem/coropoll.h>
#include <corosync/totem/totempg.h>
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
@@ -126,7 +128,7 @@ static enum cs_sync_mode minimum_sync_mode;
static int sync_in_process = 1;
-static hdb_handle_t corosync_poll_handle;
+static qb_loop_t *corosync_poll_handle;
struct sched_param global_sched_param;
@@ -146,7 +148,7 @@ static int32_t corosync_not_enough_fds_left = 0;
static void serialize_unlock (void);
-hdb_handle_t corosync_poll_handle_get (void)
+qb_loop_t *corosync_poll_handle_get (void)
{
return (corosync_poll_handle);
}
@@ -172,7 +174,7 @@ static void unlink_all_completed (void)
*/
serialize_unlock ();
api->timer_delete (corosync_stats_timer_handle);
- poll_stop (corosync_poll_handle);
+ qb_loop_stop (corosync_poll_handle);
totempg_finalize ();
/*
@@ -1024,7 +1026,6 @@ static void ipc_fatal_error(const char *error_msg) {
}
static int corosync_poll_handler_accept (
- hdb_handle_t handle,
int fd,
int revent,
void *context)
@@ -1033,7 +1034,6 @@ static int corosync_poll_handler_accept (
}
static int corosync_poll_handler_dispatch (
- hdb_handle_t handle,
int fd,
int revent,
void *context)
@@ -1045,7 +1045,7 @@ static int corosync_poll_handler_dispatch (
static void corosync_poll_accept_add (
int fd)
{
- poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, 0,
+ qb_loop_poll_add (corosync_poll_handle, QB_LOOP_MED, fd, POLLIN|POLLNVAL, 0,
corosync_poll_handler_accept);
}
@@ -1053,15 +1053,16 @@ static void corosync_poll_dispatch_add (
int fd,
void *context)
{
- poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, context,
+ qb_loop_poll_add (corosync_poll_handle, QB_LOOP_MED, fd, POLLIN|POLLNVAL, context,
corosync_poll_handler_dispatch);
}
static void corosync_poll_dispatch_modify (
int fd,
- int events)
+ int events,
+ void *context)
{
- poll_dispatch_modify (corosync_poll_handle, fd, events,
+ qb_loop_poll_mod (corosync_poll_handle, QB_LOOP_MED, fd, events, context,
corosync_poll_handler_dispatch);
}
@@ -1069,7 +1070,7 @@ static void corosync_poll_dispatch_destroy (
int fd,
void *context)
{
- poll_dispatch_delete (corosync_poll_handle, fd);
+ qb_loop_poll_del (corosync_poll_handle, fd);
}
static hdb_handle_t corosync_stats_create_connection (const char* name,
@@ -1734,8 +1735,8 @@ int main (int argc, char **argv, char **envp)
serialize_unlock,
sched_priority);
- corosync_poll_handle = poll_create ();
- poll_low_fds_event_set(corosync_poll_handle, main_low_fds_event);
+ corosync_poll_handle = qb_loop_create ();
+ qb_loop_poll_low_fds_event_set(corosync_poll_handle, main_low_fds_event);
/*
* Sleep for a while to let other nodes in the cluster
@@ -1814,7 +1815,7 @@ int main (int argc, char **argv, char **envp)
/*
* Start main processing loop
*/
- poll_run (corosync_poll_handle);
+ qb_loop_run (corosync_poll_handle);
return EXIT_SUCCESS;
}
diff --git a/exec/main.h b/exec/main.h
index ac2e31e..9a3004a 100644
--- a/exec/main.h
+++ b/exec/main.h
@@ -39,7 +39,7 @@
#define FALSE 0
#include <corosync/corotypes.h>
#include <corosync/hdb.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include <corosync/totem/totempg.h>
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
@@ -65,6 +65,6 @@ extern void corosync_shutdown_request (void);
extern void corosync_state_dump (void);
-extern hdb_handle_t corosync_poll_handle_get (void);
+extern qb_loop_t *corosync_poll_handle_get (void);
#endif /* MAIN_H_DEFINED */
diff --git a/exec/timer.c b/exec/timer.c
index 69f9a95..207d99f 100644
--- a/exec/timer.c
+++ b/exec/timer.c
@@ -62,7 +62,7 @@
#include <corosync/coroipc_types.h>
#include <corosync/list.h>
#include <corosync/lcr/lcr_ifact.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include <corosync/totem/totempg.h>
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
diff --git a/exec/totemconfig.h b/exec/totemconfig.h
index 7169c07..9901b8c 100644
--- a/exec/totemconfig.h
+++ b/exec/totemconfig.h
@@ -38,7 +38,7 @@
#include <netinet/in.h>
#include <corosync/corotypes.h>
#include <corosync/list.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include <corosync/totem/totempg.h>
#include <corosync/engine/objdb.h>
diff --git a/exec/totemiba.c b/exec/totemiba.c
index a0379ff..58c4582 100644
--- a/exec/totemiba.c
+++ b/exec/totemiba.c
@@ -70,7 +70,7 @@
#include <corosync/list.h>
#include <corosync/hdb.h>
#include <corosync/swab.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
#include "totemiba.h"
@@ -111,9 +111,9 @@ struct totemiba_instance {
void *rrp_context;
- poll_timer_handle timer_netif_check_timeout;
+ qb_loop_timer_handle timer_netif_check_timeout;
- hdb_handle_t totemiba_poll_handle;
+ qb_loop_t *totemiba_poll_handle;
struct totem_ip_address my_id;
@@ -465,7 +465,7 @@ static inline void iba_deliver_fn (struct totemiba_instance *instance,
uint64_t
instance->totemiba_deliver_fn (instance->rrp_context, addr, bytes);
}
-static int mcast_cq_send_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int mcast_cq_send_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct ibv_wc wc[32];
@@ -488,7 +488,7 @@ static int mcast_cq_send_event_fn (hdb_handle_t poll_handle, int
events, int s
return (0);
}
-static int mcast_cq_recv_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int mcast_cq_recv_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct ibv_wc wc[64];
@@ -512,7 +512,7 @@ static int mcast_cq_recv_event_fn (hdb_handle_t poll_handle, int
events, int s
return (0);
}
-static int mcast_rdma_event_fn (hdb_handle_t poll_handle, int events, int suck, void
*context)
+static int mcast_rdma_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct rdma_cm_event *event;
@@ -581,7 +581,7 @@ static int recv_token_cq_send_event_fn (hdb_handle_t poll_handle, int
events,
return (0);
}
-static int recv_token_cq_recv_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int recv_token_cq_recv_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct ibv_wc wc[32];
@@ -627,11 +627,11 @@ static int recv_token_accept_destroy (struct totemiba_instance
*instance)
rdma_destroy_id (instance->recv_token_cma_id);
- poll_dispatch_delete (
+ qb_loop_poll_del (
instance->totemiba_poll_handle,
instance->recv_token_recv_completion_channel->fd);
- poll_dispatch_delete (
+ qb_loop_poll_del (
instance->totemiba_poll_handle,
instance->recv_token_send_completion_channel->fd);
@@ -716,13 +716,15 @@ static int recv_token_accept_setup (struct totemiba_instance
*instance)
recv_token_recv_buf_post_initial (instance);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->recv_token_recv_completion_channel->fd,
POLLIN, instance, recv_token_cq_recv_event_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->recv_token_send_completion_channel->fd,
POLLIN, instance, recv_token_cq_send_event_fn);
@@ -731,7 +733,7 @@ static int recv_token_accept_setup (struct totemiba_instance
*instance)
return (res);
};
-static int recv_token_rdma_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int recv_token_rdma_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct rdma_cm_event *event;
@@ -763,7 +765,7 @@ static int recv_token_rdma_event_fn (hdb_handle_t poll_handle, int
events, int
return (0);
}
-static int send_token_cq_send_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int send_token_cq_send_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct ibv_wc wc[32];
@@ -786,7 +788,7 @@ static int send_token_cq_send_event_fn (hdb_handle_t poll_handle, int
events,
return (0);
}
-static int send_token_cq_recv_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int send_token_cq_recv_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct ibv_wc wc[32];
@@ -809,7 +811,7 @@ static int send_token_cq_recv_event_fn (hdb_handle_t poll_handle, int
events,
return (0);
}
-static int send_token_rdma_event_fn (hdb_handle_t poll_handle, int events, int suck,
void *context)
+static int send_token_rdma_event_fn (int events, int suck, void *context)
{
struct totemiba_instance *instance = (struct totemiba_instance *)context;
struct rdma_cm_event *event;
@@ -980,18 +982,21 @@ static int send_token_bind (struct totemiba_instance *instance)
return (-1);
}
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->send_token_recv_completion_channel->fd,
POLLIN, instance, send_token_cq_recv_event_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->send_token_send_completion_channel->fd,
POLLIN, instance, send_token_cq_send_event_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->send_token_channel->fd,
POLLIN, instance, send_token_rdma_event_fn);
@@ -1005,13 +1010,13 @@ static int send_token_unbind (struct totemiba_instance *instance)
return (0);
}
- poll_dispatch_delete (
+ qb_loop_poll_del (
instance->totemiba_poll_handle,
instance->send_token_recv_completion_channel->fd);
- poll_dispatch_delete (
+ qb_loop_poll_del (
instance->totemiba_poll_handle,
instance->send_token_send_completion_channel->fd);
- poll_dispatch_delete (
+ qb_loop_poll_del (
instance->totemiba_poll_handle,
instance->send_token_channel->fd);
@@ -1060,8 +1065,9 @@ static int recv_token_bind (struct totemiba_instance *instance)
return (-1);
}
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->listen_recv_token_channel->fd,
POLLIN, instance, recv_token_rdma_event_fn);
@@ -1174,18 +1180,21 @@ static int mcast_bind (struct totemiba_instance *instance)
mcast_recv_buf_post_initial (instance);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->mcast_recv_completion_channel->fd,
POLLIN, instance, mcast_cq_recv_event_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->mcast_send_completion_channel->fd,
POLLIN, instance, mcast_cq_send_event_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemiba_poll_handle,
+ QB_LOOP_MED,
instance->mcast_channel->fd,
POLLIN, instance, mcast_rdma_event_fn);
@@ -1262,7 +1271,7 @@ int totemiba_finalize (
* Create an instance
*/
int totemiba_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *qb_poll_handle,
void **iba_context,
struct totem_config *totem_config,
int interface_no,
@@ -1292,7 +1301,7 @@ int totemiba_initialize (
instance->totem_interface = &totem_config->interfaces[interface_no];
- instance->totemiba_poll_handle = poll_handle;
+ instance->totemiba_poll_handle = qb_poll_handle;
instance->totemiba_deliver_fn = deliver_fn;
@@ -1304,7 +1313,8 @@ int totemiba_initialize (
instance->rrp_context = context;
- poll_timer_add (instance->totemiba_poll_handle,
+ qb_loop_timer_add (instance->totemiba_poll_handle,
+ QB_LOOP_MED,
100,
(void *)instance,
timer_function_netif_check_timeout,
diff --git a/exec/totemiba.h b/exec/totemiba.h
index 4b2fbbf..eb31bc6 100644
--- a/exec/totemiba.h
+++ b/exec/totemiba.h
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <corosync/hdb.h>
+#include <qb/qbloop.h>
#include <corosync/totem/totem.h>
@@ -44,7 +45,7 @@
* Create an instance
*/
extern int totemiba_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t* qb_poll_handle,
void **iba_handle,
struct totem_config *totem_config,
int interface_no,
diff --git a/exec/totemmrp.c b/exec/totemmrp.c
index dceb44a..5802fa3 100644
--- a/exec/totemmrp.c
+++ b/exec/totemmrp.c
@@ -56,7 +56,7 @@
#include <sys/poll.h>
#include <corosync/totem/totem.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#include "totemmrp.h"
#include "totemsrp.h"
@@ -116,7 +116,7 @@ void totemmrp_confchg_fn (
* Initialize the totem multiple ring protocol
*/
int totemmrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
struct totem_config *totem_config,
totempg_stats_t *stats,
diff --git a/exec/totemmrp.h b/exec/totemmrp.h
index f9b1911..10bb63d 100644
--- a/exec/totemmrp.h
+++ b/exec/totemmrp.h
@@ -56,7 +56,7 @@ extern void totemmrp_log_printf_init (
* Initialize the group messaging interface
*/
extern int totemmrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
struct totem_config *totem_config,
totempg_stats_t *stats,
diff --git a/exec/totemnet.c b/exec/totemnet.c
index 5853e66..09183e4 100644
--- a/exec/totemnet.c
+++ b/exec/totemnet.c
@@ -40,6 +40,7 @@
#endif
#include <totemudp.h>
#include <totemnet.h>
+#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
@@ -48,7 +49,7 @@ struct transport {
const char *name;
int (*initialize) (
- hdb_handle_t poll_handle,
+ qb_loop_t *loop_pt,
void **transport_instance,
struct totem_config *totem_config,
int interface_no,
@@ -230,7 +231,7 @@ int totemnet_finalize (
}
int totemnet_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *loop_pt,
void **net_context,
struct totem_config *totem_config,
int interface_no,
@@ -257,7 +258,7 @@ int totemnet_initialize (
}
totemnet_instance_initialize (instance, totem_config);
- res = instance->transport->initialize (poll_handle,
+ res = instance->transport->initialize (loop_pt,
&instance->transport_context, totem_config,
interface_no, context, deliver_fn, iface_change_fn, target_set_completed);
diff --git a/exec/totemnet.h b/exec/totemnet.h
index 96f063d..91753d6 100644
--- a/exec/totemnet.h
+++ b/exec/totemnet.h
@@ -51,7 +51,7 @@
* Create an instance
*/
extern int totemnet_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **net_context,
struct totem_config *totem_config,
int interface_no,
diff --git a/exec/totempg.c b/exec/totempg.c
index 10effc8..5025f24 100644
--- a/exec/totempg.c
+++ b/exec/totempg.c
@@ -100,7 +100,8 @@
#include <corosync/swab.h>
#include <corosync/hdb.h>
#include <corosync/list.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
+#include <qb/qbipcs.h>
#include <corosync/totem/totempg.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
@@ -704,7 +705,7 @@ int callback_token_received_fn (enum totem_callback_token_type type,
* Initialize the totem process group abstraction
*/
int totempg_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
struct totem_config *totem_config)
{
int res;
diff --git a/exec/totemrrp.c b/exec/totemrrp.c
index 0b80351..38c2865 100644
--- a/exec/totemrrp.c
+++ b/exec/totemrrp.c
@@ -62,7 +62,7 @@
#include <corosync/list.h>
#include <corosync/hdb.h>
#include <corosync/swab.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
@@ -86,8 +86,8 @@ struct passive_instance {
unsigned int *mcast_recv_count;
unsigned char token[15000];
unsigned int token_len;
- poll_timer_handle timer_expired_token;
- poll_timer_handle timer_problem_decrementer;
+ qb_loop_timer_handle timer_expired_token;
+ qb_loop_timer_handle timer_problem_decrementer;
void *totemrrp_context;
unsigned int token_xmit_iface;
unsigned int msg_xmit_iface;
@@ -101,8 +101,8 @@ struct active_instance {
unsigned char token[15000];
unsigned int token_len;
unsigned int last_token_seq;
- poll_timer_handle timer_expired_token;
- poll_timer_handle timer_problem_decrementer;
+ qb_loop_timer_handle timer_expired_token;
+ qb_loop_timer_handle timer_problem_decrementer;
void *totemrrp_context;
};
@@ -169,7 +169,7 @@ struct rrp_algo {
};
struct totemrrp_instance {
- hdb_handle_t poll_handle;
+ qb_loop_t *poll_handle;
struct totem_interface *interfaces;
@@ -668,8 +668,9 @@ static void timer_function_passive_problem_decrementer (void
*context)
static void passive_timer_expired_token_start (
struct passive_instance *passive_instance)
{
- poll_timer_add (
+ qb_loop_timer_add (
passive_instance->rrp_instance->poll_handle,
+ QB_LOOP_MED,
passive_instance->rrp_instance->totem_config->rrp_token_expired_timeout,
(void *)passive_instance,
timer_function_passive_token_expired,
@@ -679,7 +680,7 @@ static void passive_timer_expired_token_start (
static void passive_timer_expired_token_cancel (
struct passive_instance *passive_instance)
{
- poll_timer_delete (
+ qb_loop_timer_del (
passive_instance->rrp_instance->poll_handle,
passive_instance->timer_expired_token);
}
@@ -688,7 +689,8 @@ static void passive_timer_expired_token_cancel (
static void passive_timer_problem_decrementer_start (
struct passive_instance *passive_instance)
{
- poll_timer_add (
+ qb_loop_timer_add (
+ QB_LOOP_MED,
passive_instance->rrp_instance->poll_handle,
passive_instance->rrp_instance->totem_config->rrp_problem_count_timeout,
(void *)passive_instance,
@@ -699,7 +701,7 @@ static void passive_timer_problem_decrementer_start (
static void passive_timer_problem_decrementer_cancel (
struct passive_instance *passive_instance)
{
- poll_timer_delete (
+ qb_loop_timer_del (
passive_instance->rrp_instance->poll_handle,
passive_instance->timer_problem_decrementer);
}
@@ -1096,8 +1098,9 @@ static void timer_function_active_token_expired (void *context)
static void active_timer_expired_token_start (
struct active_instance *active_instance)
{
- poll_timer_add (
+ qb_loop_timer_add (
active_instance->rrp_instance->poll_handle,
+ QB_LOOP_MED,
active_instance->rrp_instance->totem_config->rrp_token_expired_timeout,
(void *)active_instance,
timer_function_active_token_expired,
@@ -1107,7 +1110,7 @@ static void active_timer_expired_token_start (
static void active_timer_expired_token_cancel (
struct active_instance *active_instance)
{
- poll_timer_delete (
+ qb_loop_timer_del (
active_instance->rrp_instance->poll_handle,
active_instance->timer_expired_token);
}
@@ -1115,8 +1118,9 @@ static void active_timer_expired_token_cancel (
static void active_timer_problem_decrementer_start (
struct active_instance *active_instance)
{
- poll_timer_add (
+ qb_loop_timer_add (
active_instance->rrp_instance->poll_handle,
+ QB_LOOP_MED,
active_instance->rrp_instance->totem_config->rrp_problem_count_timeout,
(void *)active_instance,
timer_function_active_problem_decrementer,
@@ -1126,7 +1130,7 @@ static void active_timer_problem_decrementer_start (
static void active_timer_problem_decrementer_cancel (
struct active_instance *active_instance)
{
- poll_timer_delete (
+ qb_loop_timer_del (
active_instance->rrp_instance->poll_handle,
active_instance->timer_problem_decrementer);
}
@@ -1451,7 +1455,7 @@ static void rrp_target_set_completed (void *context)
* Create an instance
*/
int totemrrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **rrp_context,
struct totem_config *totem_config,
void *context,
diff --git a/exec/totemrrp.h b/exec/totemrrp.h
index 5fa0a0f..02c366a 100644
--- a/exec/totemrrp.h
+++ b/exec/totemrrp.h
@@ -37,7 +37,7 @@
#include <sys/types.h>
#include <sys/socket.h>
-
+#include <qb/qbloop.h>
#include <corosync/totem/totem.h>
#define TOTEMRRP_NOFLUSH 0
@@ -52,7 +52,7 @@
* Create an instance
*/
extern int totemrrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **rrp_context,
struct totem_config *totem_config,
void *context,
diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index 9d15ade..917d3ed 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -79,7 +79,7 @@
#include <corosync/sq.h>
#include <corosync/list.h>
#include <corosync/hdb.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
@@ -402,23 +402,23 @@ struct totemsrp_instance {
/*
* Timers
*/
- poll_timer_handle timer_pause_timeout;
+ qb_loop_timer_handle timer_pause_timeout;
- poll_timer_handle timer_orf_token_timeout;
+ qb_loop_timer_handle timer_orf_token_timeout;
- poll_timer_handle timer_orf_token_retransmit_timeout;
+ qb_loop_timer_handle timer_orf_token_retransmit_timeout;
- poll_timer_handle timer_orf_token_hold_retransmit_timeout;
+ qb_loop_timer_handle timer_orf_token_hold_retransmit_timeout;
- poll_timer_handle timer_merge_detect_timeout;
+ qb_loop_timer_handle timer_merge_detect_timeout;
- poll_timer_handle memb_timer_state_gather_join_timeout;
+ qb_loop_timer_handle memb_timer_state_gather_join_timeout;
- poll_timer_handle memb_timer_state_gather_consensus_timeout;
+ qb_loop_timer_handle memb_timer_state_gather_consensus_timeout;
- poll_timer_handle memb_timer_state_commit_timeout;
+ qb_loop_timer_handle memb_timer_state_commit_timeout;
- poll_timer_handle timer_heartbeat_timeout;
+ qb_loop_timer_handle timer_heartbeat_timeout;
/*
* Function and data used to log messages
@@ -446,7 +446,7 @@ struct totemsrp_instance {
//TODO struct srp_addr next_memb;
- hdb_handle_t totemsrp_poll_handle;
+ qb_loop_t *totemsrp_poll_handle;
struct totem_ip_address mcast_address;
@@ -749,7 +749,7 @@ static int token_event_stats_collector (enum totem_callback_token_type
type, con
* Exported interfaces
*/
int totemsrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **srp_context,
struct totem_config *totem_config,
totemmrp_stats_t *stats,
@@ -1355,9 +1355,10 @@ static void memb_set_print (
static void reset_token_retransmit_timeout (struct totemsrp_instance *instance)
{
- poll_timer_delete (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_orf_token_retransmit_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->token_retransmit_timeout,
(void *)instance,
timer_function_token_retransmit_timeout,
@@ -1368,7 +1369,8 @@ static void reset_token_retransmit_timeout (struct totemsrp_instance
*instance)
static void start_merge_detect_timeout (struct totemsrp_instance *instance)
{
if (instance->my_merge_detect_timeout_outstanding == 0) {
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->merge_timeout,
(void *)instance,
timer_function_merge_detect_timeout,
@@ -1380,7 +1382,7 @@ static void start_merge_detect_timeout (struct totemsrp_instance
*instance)
static void cancel_merge_detect_timeout (struct totemsrp_instance *instance)
{
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_merge_detect_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_merge_detect_timeout);
instance->my_merge_detect_timeout_outstanding = 0;
}
@@ -1425,8 +1427,9 @@ static void old_ring_state_reset (struct totemsrp_instance
*instance)
static void reset_pause_timeout (struct totemsrp_instance *instance)
{
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_pause_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_pause_timeout);
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->token_timeout / 5,
(void *)instance,
timer_function_pause_timeout,
@@ -1434,8 +1437,9 @@ static void reset_pause_timeout (struct totemsrp_instance
*instance)
}
static void reset_token_timeout (struct totemsrp_instance *instance) {
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_orf_token_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_orf_token_timeout);
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->token_timeout,
(void *)instance,
timer_function_orf_token_timeout,
@@ -1443,8 +1447,9 @@ static void reset_token_timeout (struct totemsrp_instance *instance)
{
}
static void reset_heartbeat_timeout (struct totemsrp_instance *instance) {
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_heartbeat_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_heartbeat_timeout);
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->heartbeat_timeout,
(void *)instance,
timer_function_heartbeat_timeout,
@@ -1453,21 +1458,22 @@ static void reset_heartbeat_timeout (struct totemsrp_instance
*instance) {
static void cancel_token_timeout (struct totemsrp_instance *instance) {
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_orf_token_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_orf_token_timeout);
}
static void cancel_heartbeat_timeout (struct totemsrp_instance *instance) {
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_heartbeat_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_heartbeat_timeout);
}
static void cancel_token_retransmit_timeout (struct totemsrp_instance *instance)
{
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->timer_orf_token_retransmit_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_orf_token_retransmit_timeout);
}
static void start_token_hold_retransmit_timeout (struct totemsrp_instance *instance)
{
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->token_hold_timeout,
(void *)instance,
timer_function_token_hold_retransmit_timeout,
@@ -1476,7 +1482,7 @@ static void start_token_hold_retransmit_timeout (struct
totemsrp_instance *insta
static void cancel_token_hold_retransmit_timeout (struct totemsrp_instance *instance)
{
- poll_timer_delete (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->timer_orf_token_hold_retransmit_timeout);
}
@@ -1586,9 +1592,10 @@ static void memb_timer_function_state_gather (void *data)
/*
* Restart the join timeout
`*/
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->join_timeout,
(void *)instance,
memb_timer_function_state_gather,
@@ -1817,9 +1824,10 @@ static void memb_state_gather_enter (
/*
* Restart the join timeout
*/
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->join_timeout,
(void *)instance,
memb_timer_function_state_gather,
@@ -1828,10 +1836,11 @@ static void memb_state_gather_enter (
/*
* Restart the consensus timeout
*/
- poll_timer_delete (instance->totemsrp_poll_handle,
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_consensus_timeout);
- poll_timer_add (instance->totemsrp_poll_handle,
+ qb_loop_timer_add (instance->totemsrp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->consensus_timeout,
(void *)instance,
memb_timer_function_gather_consensus_timeout,
@@ -1877,11 +1886,11 @@ static void memb_state_commit_enter (
memb_state_commit_token_target_set (instance);
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_join_timeout);
instance->memb_timer_state_gather_join_timeout = 0;
- poll_timer_delete (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_consensus_timeout);
+ qb_loop_timer_del (instance->totemsrp_poll_handle,
instance->memb_timer_state_gather_consensus_timeout);
instance->memb_timer_state_gather_consensus_timeout = 0;
diff --git a/exec/totemsrp.h b/exec/totemsrp.h
index 37ef588..ae8ed71 100644
--- a/exec/totemsrp.h
+++ b/exec/totemsrp.h
@@ -36,7 +36,7 @@
#define TOTEMSRP_H_DEFINED
#include <corosync/totem/totem.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
/*
* Totem Single Ring Protocol
@@ -47,7 +47,7 @@
* Create a protocol instance
*/
int totemsrp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **srp_context,
struct totem_config *totem_config,
totemmrp_stats_t *stats,
diff --git a/exec/totemudp.c b/exec/totemudp.c
index 23d7efb..fc1886f 100644
--- a/exec/totemudp.c
+++ b/exec/totemudp.c
@@ -62,7 +62,7 @@
#include <corosync/list.h>
#include <corosync/hdb.h>
#include <corosync/swab.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>
#include "totemudp.h"
@@ -121,7 +121,7 @@ struct totemudp_instance {
unsigned int totemudp_private_key_len;
- hdb_handle_t totemudp_poll_handle;
+ qb_loop_t *totemudp_poll_handle;
struct totem_interface *totem_interface;
@@ -197,7 +197,7 @@ struct totemudp_instance {
int firstrun;
- poll_timer_handle timer_netif_check_timeout;
+ qb_loop_timer_handle timer_netif_check_timeout;
unsigned int my_memb_entries;
@@ -1143,7 +1143,7 @@ int totemudp_finalize (
if (instance->totemudp_sockets.mcast_recv > 0) {
close (instance->totemudp_sockets.mcast_recv);
- poll_dispatch_delete (instance->totemudp_poll_handle,
+ qb_loop_poll_del (instance->totemudp_poll_handle,
instance->totemudp_sockets.mcast_recv);
}
if (instance->totemudp_sockets.mcast_send > 0) {
@@ -1151,7 +1151,7 @@ int totemudp_finalize (
}
if (instance->totemudp_sockets.token > 0) {
close (instance->totemudp_sockets.token);
- poll_dispatch_delete (instance->totemudp_poll_handle,
+ qb_loop_poll_del (instance->totemudp_poll_handle,
instance->totemudp_sockets.token);
}
@@ -1163,7 +1163,6 @@ int totemudp_finalize (
*/
static int net_deliver_fn (
- hdb_handle_t handle,
int fd,
int revents,
void *data)
@@ -1299,7 +1298,8 @@ static void timer_function_netif_check_timeout (
instance->netif_bind_state == BIND_STATE_REGULAR &&
interface_up == 1)) {
- poll_timer_add (instance->totemudp_poll_handle,
+ qb_loop_timer_add (instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->downcheck_timeout,
(void *)instance,
timer_function_netif_check_timeout,
@@ -1313,7 +1313,7 @@ static void timer_function_netif_check_timeout (
if (instance->totemudp_sockets.mcast_recv > 0) {
close (instance->totemudp_sockets.mcast_recv);
- poll_dispatch_delete (instance->totemudp_poll_handle,
+ qb_loop_poll_del (instance->totemudp_poll_handle,
instance->totemudp_sockets.mcast_recv);
}
if (instance->totemudp_sockets.mcast_send > 0) {
@@ -1321,7 +1321,7 @@ static void timer_function_netif_check_timeout (
}
if (instance->totemudp_sockets.token > 0) {
close (instance->totemudp_sockets.token);
- poll_dispatch_delete (instance->totemudp_poll_handle,
+ qb_loop_poll_del (instance->totemudp_poll_handle,
instance->totemudp_sockets.token);
}
@@ -1335,7 +1335,8 @@ static void timer_function_netif_check_timeout (
/*
* Add a timer to retry building interfaces and request memb_gather_enter
*/
- poll_timer_add (instance->totemudp_poll_handle,
+ qb_loop_timer_add (instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->downcheck_timeout,
(void *)instance,
timer_function_netif_check_timeout,
@@ -1356,13 +1357,15 @@ static void timer_function_netif_check_timeout (
&instance->totemudp_sockets,
&instance->totem_interface->boundto);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totemudp_sockets.mcast_recv,
POLLIN, instance, net_deliver_fn);
- poll_dispatch_add (
+ qb_loop_poll_add (
instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totemudp_sockets.token,
POLLIN, instance, net_deliver_fn);
@@ -1383,7 +1386,8 @@ static void timer_function_netif_check_timeout (
* Add a timer to check for interface going down in single membership
*/
if (instance->my_memb_entries == 1) {
- poll_timer_add (instance->totemudp_poll_handle,
+ qb_loop_timer_add (instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->downcheck_timeout,
(void *)instance,
timer_function_netif_check_timeout,
@@ -1730,7 +1734,7 @@ static int totemudp_build_sockets (
* Create an instance
*/
int totemudp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t *poll_handle,
void **udp_context,
struct totem_config *totem_config,
int interface_no,
@@ -1817,7 +1821,8 @@ int totemudp_initialize (
* RRP layer isn't ready to receive message because it hasn't
* initialized yet. Add short timer to check the interfaces.
*/
- poll_timer_add (instance->totemudp_poll_handle,
+ qb_loop_timer_add (instance->totemudp_poll_handle,
+ QB_LOOP_MED,
100,
(void *)instance,
timer_function_netif_check_timeout,
@@ -1835,10 +1840,11 @@ int totemudp_processor_count_set (
int res = 0;
instance->my_memb_entries = processor_count;
- poll_timer_delete (instance->totemudp_poll_handle,
+ qb_loop_timer_del (instance->totemudp_poll_handle,
instance->timer_netif_check_timeout);
if (processor_count == 1) {
- poll_timer_add (instance->totemudp_poll_handle,
+ qb_loop_timer_add (instance->totemudp_poll_handle,
+ QB_LOOP_MED,
instance->totem_config->downcheck_timeout,
(void *)instance,
timer_function_netif_check_timeout,
@@ -1862,7 +1868,7 @@ int totemudp_recv_flush (void *udp_context)
ufd.events = POLLIN;
nfds = poll (&ufd, 1, 0);
if (nfds == 1 && ufd.revents & POLLIN) {
- net_deliver_fn (0, instance->totemudp_sockets.mcast_recv,
+ net_deliver_fn (instance->totemudp_sockets.mcast_recv,
ufd.revents, instance);
}
} while (nfds == 1);
diff --git a/exec/totemudp.h b/exec/totemudp.h
index 6218794..99a8490 100644
--- a/exec/totemudp.h
+++ b/exec/totemudp.h
@@ -38,6 +38,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <corosync/hdb.h>
+#include <qb/qbloop.h>
#include <corosync/totem/totem.h>
@@ -45,7 +46,7 @@
* Create an instance
*/
extern int totemudp_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t* poll_handle,
void **udp_context,
struct totem_config *totem_config,
int interface_no,
diff --git a/include/Makefile.am b/include/Makefile.am
index 3f15cf5..732c3da 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -42,7 +42,7 @@ LCR_H = lcr_ckpt.h lcr_comp.h lcr_ifact.h
ENGINE_H = config.h coroapi.h logsys.h objdb.h quorum.h
-TOTEM_H = coropoll.h totem.h totemip.h totempg.h
+TOTEM_H = totem.h totemip.h totempg.h
EXTRA_DIST = $(noinst_HEADERS)
diff --git a/include/corosync/coroipcs.h b/include/corosync/coroipcs.h
index 9f0dc1d..57645af 100644
--- a/include/corosync/coroipcs.h
+++ b/include/corosync/coroipcs.h
@@ -67,7 +67,7 @@ struct coroipcs_init_state {
void (*sending_allowed_release)(void *sending_allowed_private_data);
void (*poll_accept_add)(int fd);
void (*poll_dispatch_add)(int fd, void *context);
- void (*poll_dispatch_modify)(int fd, int events);
+ void (*poll_dispatch_modify)(int fd, int events, void *context);
void (*poll_dispatch_destroy)(int fd, void *context);
void (*fatal_error)(const char *error_msg) __attribute__ ((noreturn));
coroipcs_init_fn_lvalue (*init_fn_get)(unsigned int service);
@@ -94,7 +94,7 @@ struct coroipcs_init_state_v2 {
void (*sending_allowed_release)(void *sending_allowed_private_data);
void (*poll_accept_add)(int fd);
void (*poll_dispatch_add)(int fd, void *context);
- void (*poll_dispatch_modify)(int fd, int events);
+ void (*poll_dispatch_modify)(int fd, int events, void *context);
void (*poll_dispatch_destroy)(int fd, void *context);
void (*fatal_error)(const char *error_msg) __attribute__ ((noreturn));
coroipcs_init_fn_lvalue (*init_fn_get)(unsigned int service);
diff --git a/include/corosync/engine/coroapi.h b/include/corosync/engine/coroapi.h
index e6eae24..47962de 100644
--- a/include/corosync/engine/coroapi.h
+++ b/include/corosync/engine/coroapi.h
@@ -39,6 +39,7 @@
#include <sys/uio.h>
#endif
#include <corosync/hdb.h>
+#include <qb/qbloop.h>
#include <corosync/swab.h>
typedef struct {
@@ -602,12 +603,7 @@ struct corosync_api_v1 {
void (*state_dump) (void);
- /*
- * The use of this interface is highly discouraged.
- * Please avoid using any of coropoll apis in your service engines.
- */
- hdb_handle_t (*poll_handle_get) (void);
-
+ qb_loop_t *(*poll_handle_get) (void);
int (*object_key_create_typed) (
hdb_handle_t object_handle,
diff --git a/include/corosync/totem/coropoll.h b/include/corosync/totem/coropoll.h
deleted file mode 100644
index 238160b..0000000
--- a/include/corosync/totem/coropoll.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake(a)redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLL_H_DEFINED
-#define POLL_H_DEFINED
-
-#include <corosync/hdb.h>
-#include <pthread.h>
-#include <stdlib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*poll_low_fds_event_fn) (int32_t not_enough, int32_t fds_available);
-
-typedef void * poll_timer_handle;
-
-hdb_handle_t poll_create (void);
-
-int poll_destroy (hdb_handle_t hdb_handle);
-
-int poll_dispatch_add (
- hdb_handle_t handle,
- int fd,
- int events,
- void *data,
-
- int (*dispatch_fn) (hdb_handle_t handle,
- int fd,
- int revents,
- void *data));
-
-int poll_dispatch_modify (
- hdb_handle_t handle,
- int fd,
- int events,
-
- int (*dispatch_fn) (hdb_handle_t hdb_handle_t,
- int fd,
- int revents,
- void *data));
-
-
-int poll_dispatch_delete (
- hdb_handle_t handle,
- int fd);
-
-int poll_low_fds_event_set(
- hdb_handle_t handle,
- poll_low_fds_event_fn fn);
-
-int poll_timer_add (
- hdb_handle_t handle,
- int msec_in_future, void *data,
- void (*timer_fn) (void *data),
- poll_timer_handle *timer_handle_out);
-
-int poll_timer_delete (
- hdb_handle_t handle,
- poll_timer_handle timer_handle);
-
-int poll_run (
- hdb_handle_t handle);
-
-int poll_stop (
- hdb_handle_t handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* POLL_H_DEFINED */
diff --git a/include/corosync/totem/totempg.h b/include/corosync/totem/totempg.h
index fbf71fb..dab123e 100644
--- a/include/corosync/totem/totempg.h
+++ b/include/corosync/totem/totempg.h
@@ -42,8 +42,8 @@ extern "C" {
#include <netinet/in.h>
#include "totem.h"
-#include "coropoll.h"
#include <corosync/hdb.h>
+#include <qb/qbloop.h>
struct totempg_group {
const void *group;
@@ -62,7 +62,7 @@ struct totempg_group {
* Initialize the totem process groups abstraction
*/
extern int totempg_initialize (
- hdb_handle_t poll_handle,
+ qb_loop_t* poll_handle,
struct totem_config *totem_config
);
diff --git a/test/Makefile.am b/test/Makefile.am
index 4f32dd9..b3462d6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -38,41 +38,41 @@ noinst_PROGRAMS = testevs evsbench evsverify cpgverify testcpg
testcpg2 cpgbenc
logsys_s logsys_t1 logsys_t2 testcpgzc cpgbenchzc testzcgc \
stress_cpgzc stress_cpgfdget stress_cpgcontext cpgbound testsam
-testevs_LDADD = -levs -lcoroipcc
+testevs_LDADD = -levs -lcoroipcc $(LIBQB_LIBS)
testevs_LDFLAGS = -L../lib
-testcpg_LDADD = -lcpg -lcoroipcc
+testcpg_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpg_LDFLAGS = -L../lib
-testcpg2_LDADD = -lcpg -lcoroipcc
+testcpg2_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpg2_LDFLAGS = -L../lib
-testcpgzc_LDADD = -lcpg -lcoroipcc
+testcpgzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpgzc_LDFLAGS = -L../lib
-testzcgc_LDADD = -lcpg -lcoroipcc
+testzcgc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testzcgc_LDFLAGS = -L../lib
-stress_cpgzc_LDADD = -lcpg -lcoroipcc
+stress_cpgzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgzc_LDFLAGS = -L../lib
-stress_cpgfdget_LDADD = -lcpg -lcoroipcc
+stress_cpgfdget_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgfdget_LDFLAGS = -L../lib
-stress_cpgcontext_LDADD = -lcpg -lcoroipcc
+stress_cpgcontext_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgcontext_LDFLAGS = -L../lib
-testconfdb_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc
+testconfdb_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc $(LIBQB_LIBS)
testconfdb_LDFLAGS = -L../lib
-testquorum_LDADD = -lquorum -lcoroipcc
+testquorum_LDADD = -lquorum -lcoroipcc $(LIBQB_LIBS)
testquorum_LDFLAGS = -L../lib
-testvotequorum1_LDADD = -lvotequorum -lcoroipcc
+testvotequorum1_LDADD = -lvotequorum -lcoroipcc $(LIBQB_LIBS)
testvotequorum1_LDFLAGS = -L../lib
-testvotequorum2_LDADD = -lvotequorum -lcoroipcc
+testvotequorum2_LDADD = -lvotequorum -lcoroipcc $(LIBQB_LIBS)
testvotequorum2_LDFLAGS = -L../lib
-evsverify_LDADD = -levs -ltotem_pg -lcoroipcc
+evsverify_LDADD = -levs -ltotem_pg -lcoroipcc $(LIBQB_LIBS)
evsverify_LDFLAGS = -L../lib -L../exec
-cpgverify_LDADD = -lcpg -ltotem_pg -lcoroipcc
+cpgverify_LDADD = -lcpg -ltotem_pg -lcoroipcc $(LIBQB_LIBS)
cpgverify_LDFLAGS = -L../lib -L../exec
-cpgbound_LDADD = -lcpg -lcoroipcc
+cpgbound_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbound_LDFLAGS = -L../lib
-evsbench_LDADD = -levs -lcoroipcc
+evsbench_LDADD = -levs -lcoroipcc $(LIBQB_LIBS)
evsbench_LDFLAGS = -L../lib
-cpgbench_LDADD = -lcpg -lcoroipcc
+cpgbench_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbench_LDFLAGS = -L../lib
-cpgbenchzc_LDADD = -lcpg -lcoroipcc
+cpgbenchzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbenchzc_LDFLAGS = -L../lib
logsysbench_LDADD = -llogsys
logsysbench_LDFLAGS = -L../exec
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3a52f4a..249be00 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -40,16 +40,16 @@ bin_SCRIPTS = corosync-blackbox
EXTRA_DIST = $(bin_SCRIPTS)
-corosync_pload_LDADD = -lpload -lcoroipcc
+corosync_pload_LDADD = -lpload -lcoroipcc $(LIBQB_LIBS)
corosync_pload_LDFLAGS = -L../lib
-corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc
+corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc $(LIBQB_LIBS)
corosync_objctl_LDFLAGS = -L../lib
-corosync_cfgtool_LDADD = -lcfg -lcoroipcc
+corosync_cfgtool_LDADD = -lcfg -lcoroipcc $(LIBQB_LIBS)
corosync_cfgtool_LDFLAGS= -L../lib
-corosync_cpgtool_LDADD = -lcfg -lcpg -lcoroipcc
+corosync_cpgtool_LDADD = -lcfg -lcpg -lcoroipcc $(LIBQB_LIBS)
corosync_cpgtool_LDFLAGS= -L../lib
corosync_quorumtool_LDADD = -lconfdb -lcfg -lquorum \
- -lvotequorum -lcoroipcc ../lcr/liblcr.a
+ -lvotequorum -lcoroipcc ../lcr/liblcr.a $(LIBQB_LIBS)
corosync_quorumtool_LDFLAGS = -L../lib
lint:
--
1.7.3.1