Просмотр исходного кода

libqb: convert coropoll calls to qb_loop calls.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Angus Salkeld 14 лет назад
Родитель
Сommit
fce8a3c3b6

+ 2 - 1
configure.ac

@@ -10,7 +10,7 @@ AC_INIT([corosync],
 
 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

+ 0 - 1
corosync.spec.in

@@ -282,7 +282,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

+ 4 - 4
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

+ 20 - 10
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;
 }
 

+ 2 - 1
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 */
 

+ 1 - 0
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>

+ 24 - 12
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"
@@ -319,12 +320,13 @@ static void read_messages (int sock, char* atmost_str)
 	send (sock, big_and_buf, strlen (big_and_buf), 0);
 }
 
-static poll_timer_handle more_messages_timer_handle;
+static qb_loop_timer_handle more_messages_timer_handle;
 static void send_some_more_messages_later (void)
 {
 	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,
 		&more_messages_timer_handle);
@@ -553,7 +555,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)
@@ -561,7 +563,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;
@@ -569,7 +571,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;
@@ -577,7 +579,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)
@@ -585,7 +587,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;
@@ -593,7 +595,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;
@@ -663,7 +665,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;
@@ -674,7 +681,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) {
@@ -722,7 +729,12 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 
 		corosync_cfg_state_track (cfg_handle, 0, &notification_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);
 	}

+ 1 - 0
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>

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

+ 3 - 3
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 \
 			  totemudpu.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./
 
@@ -75,7 +75,7 @@ noinst_HEADERS		= apidef.h crypto.h mainconfig.h main.h tsafe.h \
 			  quorum.h service.h sync.h timer.h tlist.h \
 			  totemconfig.h totemmrp.h totemnet.h totemudp.h \
 			  totemudpu.h totemiba.h totemrrp.h totemsrp.h util.h \
-			  vsf.h wthread.h schedwrk.h evil.h syncv2.h fsm.h
+			  vsf.h schedwrk.h evil.h syncv2.h fsm.h
 
 EXTRA_DIST		= $(LCRSO_SRC)
 

+ 3 - 3
exec/apidef.c

@@ -144,9 +144,9 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = {
 	.fatal_error = _corosync_public_exit_error,
 	.shutdown_request = corosync_shutdown_request,
 	.state_dump = corosync_state_dump,
-	.poll_handle_get = corosync_poll_handle_get,
-	.poll_dispatch_add = poll_dispatch_add,
-	.poll_dispatch_delete = poll_dispatch_delete
+	.poll_handle_get = cs_poll_handle_get,
+	.poll_dispatch_add = cs_poll_dispatch_add,
+	.poll_dispatch_delete = cs_poll_dispatch_delete
 };
 
 void apidef_init (struct objdb_iface_ver0 *objdb) {

+ 2 - 2
exec/coroipcs.c

@@ -1252,7 +1252,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);
 		}
 	}
 
@@ -1766,7 +1766,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);
 		}
 	}
 

+ 0 - 558
exec/coropoll.c

@@ -1,558 +0,0 @@
-/*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- * Copyright (c) 2006-2009 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@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"
-#include "util.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;
-retry_write:
-				if (write (poll_instance->pipefds[1], &buf, 1) < 0 && errno == EINTR )
-					goto retry_write;
-			}
-
-			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) {
-			perror("getrlimit() failed");
-			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;
-retry_read:
-			if (read (poll_instance->ufds[0].fd, &buf, 1) < 0 && errno == EINTR)
-				goto retry_read;
-			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

+ 33 - 14
exec/main.c

@@ -95,13 +95,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>
@@ -164,7 +166,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;
 
@@ -186,11 +188,29 @@ static void serialize_unlock (void);
 
 static void serialize_lock (void);
 
-hdb_handle_t corosync_poll_handle_get (void)
+qb_loop_t *cs_poll_handle_get (void)
 {
 	return (corosync_poll_handle);
 }
 
+int cs_poll_dispatch_add (qb_loop_t * handle,
+		int fd,
+		int events,
+		void *data,
+
+		int (*dispatch_fn) (int fd,
+			int revents,
+			void *data))
+{
+	return qb_loop_poll_add(handle, QB_LOOP_MED, fd, events, data,
+				dispatch_fn);
+}
+
+int cs_poll_dispatch_delete(qb_loop_t * handle, int fd)
+{
+	return qb_loop_poll_del(handle, fd);
+}
+
 void corosync_state_dump (void)
 {
 	int i;
@@ -212,7 +232,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);
 	serialize_lock ();
 }
 
@@ -1088,7 +1108,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)
@@ -1097,7 +1116,6 @@ static int corosync_poll_handler_accept (
 }
 
 static int corosync_poll_handler_dispatch (
-	hdb_handle_t handle,
 	int fd,
 	int revent,
 	void *context)
@@ -1109,7 +1127,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);
 }
 
@@ -1117,15 +1135,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);
 }
 
@@ -1133,7 +1152,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,
@@ -1800,8 +1819,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
@@ -1880,7 +1899,7 @@ int main (int argc, char **argv, char **envp)
 	/*
 	 * Start main processing loop
 	 */
-	poll_run (corosync_poll_handle);
+	qb_loop_run (corosync_poll_handle);
 
 	/*
 	 * Exit was requested

+ 16 - 2
exec/main.h

@@ -46,7 +46,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>
@@ -69,6 +69,20 @@ 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 *cs_poll_handle_get (void);
+
+extern int cs_poll_dispatch_add (qb_loop_t * handle,
+		int fd,
+		int events,
+		void *data,
+
+		int (*dispatch_fn) (int fd,
+			int revents,
+			void *data));
+
+extern int cs_poll_dispatch_delete (
+		qb_loop_t * handle,
+		int fd);
+
 
 #endif /* MAIN_H_DEFINED */

+ 1 - 1
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>

+ 1 - 1
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>
 

+ 38 - 28
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;
 
@@ -467,7 +467,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];
@@ -490,7 +490,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];
@@ -514,7 +514,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;
@@ -583,7 +583,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];
@@ -629,11 +629,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);
 
@@ -718,13 +718,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);
 
@@ -733,7 +735,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;
@@ -765,7 +767,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];
@@ -788,7 +790,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];
@@ -811,7 +813,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;
@@ -982,18 +984,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);
 
@@ -1007,13 +1012,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);
 
@@ -1062,8 +1067,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);
 
@@ -1176,18 +1182,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);
 
@@ -1264,7 +1273,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,
@@ -1294,7 +1303,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;
 
@@ -1306,7 +1315,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,

+ 2 - 1
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,

+ 2 - 2
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,
 

+ 1 - 1
exec/totemmrp.h

@@ -60,7 +60,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,
 

+ 4 - 3
exec/totemnet.c

@@ -43,6 +43,7 @@
 #include <totemudp.h>
 #include <totemudpu.h>
 #include <totemnet.h>
+#include <qb/qbloop.h>
 
 #define LOGSYS_UTILS_ONLY 1
 #include <corosync/engine/logsys.h>
@@ -51,7 +52,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,
@@ -265,7 +266,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,
@@ -292,7 +293,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);
 

+ 1 - 1
exec/totemnet.h

@@ -55,7 +55,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,

+ 3 - 2
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>
@@ -727,7 +728,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;

+ 26 - 19
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;
 };
 
@@ -181,7 +181,7 @@ struct rrp_algo {
 };
 
 struct totemrrp_instance {
-	hdb_handle_t poll_handle;
+	qb_loop_t *poll_handle;
 
 	struct totem_interface *interfaces;
 
@@ -247,7 +247,7 @@ struct totemrrp_instance {
 
 	void *deliver_fn_context[INTERFACE_MAX];
 
-	poll_timer_handle timer_active_test_ring_timeout[INTERFACE_MAX];
+	qb_loop_timer_handle timer_active_test_ring_timeout[INTERFACE_MAX];
 };
 
 /*
@@ -631,7 +631,8 @@ static void timer_function_test_ring_timeout (void *context)
 		totemnet_token_send (
 			rrp_instance->net_handles[iface_no],
 			&msg, sizeof (struct message_header));
-		poll_timer_add (rrp_instance->poll_handle,
+		qb_loop_timer_add (rrp_instance->poll_handle,
+			QB_LOOP_MED,
 			rrp_instance->totem_config->rrp_autorecovery_check_timeout,
 			(void *)deliver_fn_context,
 			timer_function_test_ring_timeout,
@@ -837,8 +838,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,
@@ -848,7 +850,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);
 }
@@ -857,7 +859,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,
@@ -868,7 +871,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);
 }
@@ -962,7 +965,8 @@ static void passive_monitor (
 			(max - recv_count[i] >
 			rrp_instance->totem_config->rrp_problem_count_threshold)) {
 			passive_instance->faulty[i] = 1;
-			poll_timer_add (rrp_instance->poll_handle,
+			qb_loop_timer_add (rrp_instance->poll_handle,
+				QB_LOOP_MED,
 				rrp_instance->totem_config->rrp_autorecovery_check_timeout,
 				rrp_instance->deliver_fn_context[i],
 				timer_function_test_ring_timeout,
@@ -1320,7 +1324,8 @@ static void timer_function_active_token_expired (void *context)
 		if (active_instance->counter_problems[i] >= rrp_instance->totem_config->rrp_problem_count_threshold)
 		{
 			active_instance->faulty[i] = 1;
-			poll_timer_add (rrp_instance->poll_handle,
+			qb_loop_timer_add (rrp_instance->poll_handle,
+				QB_LOOP_MED,
 				rrp_instance->totem_config->rrp_autorecovery_check_timeout,
 				rrp_instance->deliver_fn_context[i],
 				timer_function_test_ring_timeout,
@@ -1348,8 +1353,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,
@@ -1359,7 +1365,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);
 }
@@ -1367,8 +1373,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,
@@ -1378,7 +1385,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);
 }
@@ -1782,7 +1789,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,

+ 2 - 2
exec/totemrrp.h

@@ -45,7 +45,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-
+#include <qb/qbloop.h>
 #include <corosync/totem/totem.h>
 
 #define TOTEMRRP_NOFLUSH	0
@@ -55,7 +55,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,

+ 44 - 35
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>
 
@@ -403,23 +403,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
@@ -447,7 +447,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;
 
@@ -757,7 +757,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,
@@ -1383,9 +1383,10 @@ static void totemsrp_buffer_release (struct totemsrp_instance *instance, void *p
 
 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,
@@ -1396,7 +1397,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,
@@ -1408,7 +1410,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;
 }
 
@@ -1448,8 +1450,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,
@@ -1457,8 +1460,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,
@@ -1466,8 +1470,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,
@@ -1476,21 +1481,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,
@@ -1499,7 +1505,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);
 }
 
@@ -1615,9 +1621,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,
@@ -1864,9 +1871,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,
@@ -1875,10 +1883,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,
@@ -1939,11 +1948,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;
 

+ 2 - 2
exec/totemsrp.h

@@ -44,13 +44,13 @@
 #define TOTEMSRP_H_DEFINED
 
 #include <corosync/totem/totem.h>
-#include <corosync/totem/coropoll.h>
+#include <qb/qbloop.h>
 
 /**
  * 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,

+ 24 - 18
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"
@@ -122,7 +122,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;
 
@@ -198,7 +198,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;
 
@@ -1138,7 +1138,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) {
@@ -1146,7 +1146,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);
 	}
 
@@ -1158,7 +1158,6 @@ int totemudp_finalize (
  */
 
 static int net_deliver_fn (
-	hdb_handle_t handle,
 	int fd,
 	int revents,
 	void *data)
@@ -1290,7 +1289,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,
@@ -1304,7 +1304,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) {
@@ -1312,7 +1312,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);
 	}
 
@@ -1326,7 +1326,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,
@@ -1347,13 +1348,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);
 
@@ -1374,7 +1377,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,
@@ -1737,7 +1741,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,
@@ -1824,7 +1828,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,
@@ -1852,10 +1857,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,
@@ -1879,7 +1885,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);

+ 2 - 1
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,

+ 20 - 15
exec/totemudpu.c

@@ -57,11 +57,12 @@
 #include <sys/poll.h>
 #include <limits.h>
 
+#include <qb/qbloop.h>
+
 #include <corosync/sq.h>
 #include <corosync/list.h>
 #include <corosync/hdb.h>
 #include <corosync/swab.h>
-#include <corosync/totem/coropoll.h>
 #define LOGSYS_UTILS_ONLY 1
 #include <corosync/engine/logsys.h>
 #include "totemudpu.h"
@@ -115,7 +116,7 @@ struct totemudpu_instance {
 
 	unsigned int totemudpu_private_key_len;
 
-	hdb_handle_t totemudpu_poll_handle;
+	qb_loop_t *totemudpu_poll_handle;
 
 	struct totem_interface *totem_interface;
 
@@ -183,7 +184,7 @@ struct totemudpu_instance {
 
 	int firstrun;
 
-	poll_timer_handle timer_netif_check_timeout;
+	qb_loop_timer_handle timer_netif_check_timeout;
 
 	unsigned int my_memb_entries;
 
@@ -1047,7 +1048,7 @@ int totemudpu_finalize (
 
 	if (instance->token_socket > 0) {
 		close (instance->token_socket);
-		poll_dispatch_delete (instance->totemudpu_poll_handle,
+		qb_loop_poll_del (instance->totemudpu_poll_handle,
 			instance->token_socket);
 	}
 
@@ -1055,7 +1056,6 @@ int totemudpu_finalize (
 }
 
 static int net_deliver_fn (
-	hdb_handle_t handle,
 	int fd,
 	int revents,
 	void *data)
@@ -1183,7 +1183,8 @@ static void timer_function_netif_check_timeout (
 		instance->netif_bind_state == BIND_STATE_REGULAR &&
 		interface_up == 1)) {
 
-		poll_timer_add (instance->totemudpu_poll_handle,
+		qb_loop_timer_add (instance->totemudpu_poll_handle,
+			QB_LOOP_MED,
 			instance->totem_config->downcheck_timeout,
 			(void *)instance,
 			timer_function_netif_check_timeout,
@@ -1197,7 +1198,7 @@ static void timer_function_netif_check_timeout (
 
 	if (instance->token_socket > 0) {
 		close (instance->token_socket);
-		poll_dispatch_delete (instance->totemudpu_poll_handle,
+		qb_loop_poll_del (instance->totemudpu_poll_handle,
 			instance->token_socket);
 	}
 
@@ -1211,7 +1212,8 @@ static void timer_function_netif_check_timeout (
 		/*
 		 * Add a timer to retry building interfaces and request memb_gather_enter
 		 */
-		poll_timer_add (instance->totemudpu_poll_handle,
+		qb_loop_timer_add (instance->totemudpu_poll_handle,
+			QB_LOOP_MED,
 			instance->totem_config->downcheck_timeout,
 			(void *)instance,
 			timer_function_netif_check_timeout,
@@ -1230,8 +1232,8 @@ static void timer_function_netif_check_timeout (
 		bind_address,
 		&instance->totem_interface->boundto);
 
-	poll_dispatch_add (
-		instance->totemudpu_poll_handle,
+	qb_loop_poll_add (instance->totemudpu_poll_handle,
+		QB_LOOP_MED,
 		instance->token_socket,
 		POLLIN, instance, net_deliver_fn);
 
@@ -1252,7 +1254,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->totemudpu_poll_handle,
+			qb_loop_timer_add (instance->totemudpu_poll_handle,
+				QB_LOOP_MED,
 				instance->totem_config->downcheck_timeout,
 				(void *)instance,
 				timer_function_netif_check_timeout,
@@ -1382,7 +1385,7 @@ static int totemudpu_build_sockets (
  * Create an instance
  */
 int totemudpu_initialize (
-	hdb_handle_t poll_handle,
+	qb_loop_t *poll_handle,
 	void **udpu_context,
 	struct totem_config *totem_config,
 	int interface_no,
@@ -1455,7 +1458,8 @@ int totemudpu_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->totemudpu_poll_handle,
+	qb_loop_timer_add (instance->totemudpu_poll_handle,
+		QB_LOOP_MED,
 		100,
 		(void *)instance,
 		timer_function_netif_check_timeout,
@@ -1483,10 +1487,11 @@ int totemudpu_processor_count_set (
 	int res = 0;
 
 	instance->my_memb_entries = processor_count;
-	poll_timer_delete (instance->totemudpu_poll_handle,
+	qb_loop_timer_del (instance->totemudpu_poll_handle,
 		instance->timer_netif_check_timeout);
 	if (processor_count == 1) {
-		poll_timer_add (instance->totemudpu_poll_handle,
+		qb_loop_timer_add (instance->totemudpu_poll_handle,
+			QB_LOOP_MED,
 			instance->totem_config->downcheck_timeout,
 			(void *)instance,
 			timer_function_netif_check_timeout,

+ 2 - 1
exec/totemudpu.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 totemudpu_initialize (
-	hdb_handle_t poll_handle,
+	qb_loop_t *poll_handle,
 	void **udpu_context,
 	struct totem_config *totem_config,
 	int interface_no,

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

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

+ 5 - 9
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,11 +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,
@@ -636,19 +633,18 @@ struct corosync_api_v1 {
 		int (schedwrk_fn) (const void *),
 		const void *context);
 
-	int (*poll_dispatch_add) (hdb_handle_t handle,
+	int (*poll_dispatch_add) (qb_loop_t * handle,
 		int fd,
 		int events,
 		void *data,
 
-		int (*dispatch_fn) (hdb_handle_t handle,
-			int fd,
+		int (*dispatch_fn) (int fd,
 			int revents,
 			void *data));
 
 
 	int (*poll_dispatch_delete) (
-		hdb_handle_t handle,
+		qb_loop_t * handle,
 		int fd);
 
 };

+ 0 - 103
include/corosync/totem/coropoll.h

@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@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 */

+ 2 - 2
include/corosync/totem/totempg.h

@@ -49,8 +49,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;
@@ -64,7 +64,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
 );
 

+ 2 - 5
services/confdb.c

@@ -52,7 +52,6 @@
 #include <corosync/lcr/lcr_comp.h>
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/coroapi.h>
-#include <corosync/totem/coropoll.h>
 
 LOGSYS_DECLARE_SUBSYS ("CONFDB");
 
@@ -87,8 +86,7 @@ static int confdb_exec_exit_fn(void);
 
 static int fd_set_nonblocking(int fd);
 
-static int objdb_notify_dispatch(hdb_handle_t handle,
-		int fd,	int revents, void *data);
+static int objdb_notify_dispatch(int fd, int revents, void *data);
 
 static int confdb_lib_init_fn (void *conn);
 static int confdb_lib_exit_fn (void *conn);
@@ -857,8 +855,7 @@ static void message_handler_req_lib_confdb_reload (void *conn,
 	api->ipc_response_send(conn, &res_lib_confdb_reload, sizeof(res_lib_confdb_reload));
 }
 
-static int objdb_notify_dispatch(hdb_handle_t handle,
-		int fd,	int revents, void *data)
+static int objdb_notify_dispatch(int fd, int revents, void *data)
 {
 	struct confdb_ipc_message_holder *holder;
 	ssize_t rc;

+ 18 - 18
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

+ 6 - 6
tools/Makefile.am

@@ -42,20 +42,20 @@ bin_SCRIPTS		= corosync-blackbox
 
 EXTRA_DIST		= $(bin_SCRIPTS) corosync-notifyd.sysconfig.example
 
-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
 
 corosync_notifyd_LDADD = -lcfg -lconfdb ../lcr/liblcr.a -lcoroipcc \
-			   ../exec/coropoll.o $(DBUS_LIBS) $(SNMPLIBS) \
+			   $(LIBQB_LIBS) $(DBUS_LIBS) $(SNMPLIBS) \
 			   -lquorum
 corosync_notifyd_LDFLAGS = -L../lib
 corosync_notifyd_CPPFLAGS = $(DBUS_CFLAGS)

+ 33 - 17
tools/corosync-notifyd.c

@@ -51,8 +51,10 @@
 #include <signal.h>
 #include <syslog.h>
 
+#include <qb/qbdefs.h>
+#include <qb/qbloop.h>
+
 #include <corosync/corotypes.h>
-#include <corosync/totem/coropoll.h>
 #include <corosync/confdb.h>
 #include <corosync/cfg.h>
 #include <corosync/quorum.h>
@@ -87,7 +89,7 @@ static int num_notifiers = 0;
 static struct notify_callbacks notifiers[MAX_NOTIFIERS];
 static uint32_t local_nodeid = 0;
 static char local_nodename[CS_MAX_NAME_LENGTH];
-static hdb_handle_t poll_handle;
+static qb_loop_t *main_loop;
 static quorum_handle_t quorum_handle;
 
 static void _cs_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip);
@@ -356,8 +358,7 @@ _cs_confdb_find_object (confdb_handle_t handle,
 }
 
 static int
-_cs_confdb_dispatch(hdb_handle_t handle,
-	int fd,	int revents, void *data)
+_cs_confdb_dispatch(int fd, int revents, void *data)
 {
 	confdb_dispatch(confdb_handle, CS_DISPATCH_ONE);
 	return 0;
@@ -380,8 +381,7 @@ static void _cs_quorum_notification(quorum_handle_t handle,
 }
 
 static int
-_cs_quorum_dispatch(hdb_handle_t handle,
-	int fd,	int revents, void *data)
+_cs_quorum_dispatch(int fd, int revents, void *data)
 {
 	quorum_dispatch(quorum_handle, CS_DISPATCH_ONE);
 	return 0;
@@ -403,7 +403,7 @@ _cs_quorum_init(void)
 		return;
 	}
 	quorum_fd_get(quorum_handle, &fd);
-	poll_dispatch_add (poll_handle, fd, POLLIN|POLLNVAL, NULL,
+	qb_loop_poll_add(main_loop, QB_LOOP_MED, fd, POLLIN|POLLNVAL, NULL,
 		_cs_quorum_dispatch);
 	quorum_trackstart(quorum_handle, CS_TRACK_CHANGES);
 }
@@ -881,10 +881,11 @@ _cs_application_connection_event(char *app_name, const char *state)
 	}
 }
 
-static void
-sig_exit_handler (int num)
+static int32_t
+sig_exit_handler(int32_t num, void *data)
 {
-	poll_stop(poll_handle);
+	qb_loop_stop(main_loop);
+	return 0;
 }
 
 static void
@@ -901,7 +902,7 @@ _cs_confdb_init(void)
 	}
 	confdb_fd_get(confdb_handle, &conf_fd);
 
-	poll_dispatch_add (poll_handle, conf_fd, POLLIN|POLLNVAL, NULL,
+	qb_loop_poll_add(main_loop, QB_LOOP_MED, conf_fd, POLLIN|POLLNVAL, NULL,
 		_cs_confdb_dispatch);
 
 	rc = _cs_confdb_find_object (confdb_handle, "runtime.connections.",
@@ -1056,7 +1057,7 @@ main(int argc, char *argv[])
 		num_notifiers++;
 	}
 
-	poll_handle = poll_create();
+	main_loop = qb_loop_create();
 
 	_cs_confdb_init();
 	_cs_quorum_init();
@@ -1073,11 +1074,26 @@ main(int argc, char *argv[])
 	}
 #endif /* ENABLE_SNMP */
 
-	(void)signal (SIGINT, sig_exit_handler);
-	(void)signal (SIGQUIT, sig_exit_handler);
-	(void)signal (SIGTERM, sig_exit_handler);
-
-	poll_run(poll_handle);
+	qb_loop_signal_add(main_loop,
+			   QB_LOOP_HIGH,
+			   SIGINT,
+			   NULL,
+			   sig_exit_handler,
+			   NULL);
+	qb_loop_signal_add(main_loop,
+			   QB_LOOP_HIGH,
+			   SIGQUIT,
+			   NULL,
+			   sig_exit_handler,
+			   NULL);
+	qb_loop_signal_add(main_loop,
+			   QB_LOOP_HIGH,
+			   SIGTERM,
+			   NULL,
+			   sig_exit_handler,
+			   NULL);
+
+	qb_loop_run(main_loop);
 
 #ifdef HAVE_DBUS
 	if (conf[CS_NTF_DBUS]) {