[Patch 1/2] CLD: export a common timer implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Although we share the libtimer.a among the parts that can link it
statically, it turned out impossible to use from inside of libcldc
as it was. So, this patch makes it available to library code by
linking it in the same way we use libcommon.c already.

But if we do that, timer_add and friends become visible to all
users of libcldc, so rename them with cld_ prefix in order to
reduce namespace pollution.

Also, make the list of timers anchored outside of the library.
Not the we know of anyone who needs two in one program, but
it costs us almost nothing and is safer for the future.

Signed-Off-By: Pete Zaitcev <zaitcev@xxxxxxxxxx>

---
 include/libtimer.h     |   19 ++++++++++++-------
 lib/Makefile.am        |    4 ++--
 lib/libtimer.c         |   25 ++++++++++++++-----------
 server/Makefile.am     |    4 ++--
 server/cld.h           |    8 ++++----
 server/server.c        |   20 +++++++++-----------
 server/session.c       |   32 ++++++++++++++++++--------------
 test/Makefile.am       |    1 -
 test/it-works.c        |   13 +++++++------
 test/load-file-event.c |   13 +++++++------
 test/lock-file-event.c |   21 +++++++++++----------
 test/save-file-event.c |   13 +++++++------
 test/test.h            |    3 ++-
 test/util.c            |    4 ++--
 14 files changed, 97 insertions(+), 83 deletions(-)

commit d4eb73e875da95b7accca505eb8bd37c05e7c13d
Author: Master <zaitcev@xxxxxxxxxxxxxxxxxx>
Date:   Fri Jan 15 23:27:46 2010 -0700

    Move libtimer body inside libcldc, so it can be a shared library.
    Add cld_ prefix to reduce namespace pollution.
    This flips over all existing users inside CLD.

diff --git a/include/libtimer.h b/include/libtimer.h
index c10f993..ed74e68 100644
--- a/include/libtimer.h
+++ b/include/libtimer.h
@@ -6,21 +6,26 @@
 #include <string.h>
 #include <time.h>
 
-struct timer {
+struct cld_timer_list {
+	void *list;
+};
+
+struct cld_timer {
 	bool			fired;
 	bool			on_list;
-	void			(*cb)(struct timer *);
+	void			(*cb)(struct cld_timer *);
 	void			*userdata;
 	time_t			expires;
 	char			name[32];
 };
 
-extern void timer_add(struct timer *timer, time_t expires);
-extern void timer_del(struct timer *timer);
-extern time_t timers_run(void);
+extern void cld_timer_add(struct cld_timer_list *tlist, struct cld_timer *timer,
+			  time_t expires);
+extern void cld_timer_del(struct cld_timer_list *tlist, struct cld_timer *timer);
+extern time_t cld_timers_run(struct cld_timer_list *tlist);
 
-static inline void timer_init(struct timer *timer, const char *name,
-			      void (*cb)(struct timer *), void *userdata)
+static inline void cld_timer_init(struct cld_timer *timer, const char *name,
+	void (*cb)(struct cld_timer *), void *userdata)
 {
 	memset(timer, 0, sizeof(*timer));
 	timer->cb = cb;
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 68be429..dfae79a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,14 +9,14 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
 
 lib_LTLIBRARIES		= libcldc.la
 
-libcldc_la_SOURCES	= cldc.c cldc-udp.c cldc-dns.c common.c
+libcldc_la_SOURCES	= cldc.c cldc-udp.c cldc-dns.c common.c libtimer.c
 
 libcldc_la_LDFLAGS = \
 	-version-info $(LIBCLDC_CURRENT):$(LIBCLDC_REVISION):$(LIBCLDC_AGE) \
 	-no-undefined \
 	-export-symbols-regex "^[^_].*"
 
-noinst_LIBRARIES	= libtimer.a
+noinst_LIBRARIES	=
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcldc.pc
diff --git a/lib/libtimer.c b/lib/libtimer.c
index 5b13fbb..2c8e441 100644
--- a/lib/libtimer.c
+++ b/lib/libtimer.c
@@ -23,12 +23,10 @@
 #include <glib.h>
 #include <libtimer.h>
 
-static GList *timer_list;
-
-static gint timer_cmp(gconstpointer a_, gconstpointer b_)
+static gint cld_timer_cmp(gconstpointer a_, gconstpointer b_)
 {
-	const struct timer *a = a_;
-	const struct timer *b = b_;
+	const struct cld_timer *a = a_;
+	const struct cld_timer *b = b_;
 
 	if (a->expires > b->expires)
 		return 1;
@@ -37,8 +35,11 @@ static gint timer_cmp(gconstpointer a_, gconstpointer b_)
 	return -1;
 }
 
-void timer_add(struct timer *timer, time_t expires)
+void cld_timer_add(struct cld_timer_list *tlist, struct cld_timer *timer,
+		   time_t expires)
 {
+	GList *timer_list = tlist->list;
+
 	if (timer->on_list)
 		timer_list = g_list_remove(timer_list, timer);
 
@@ -46,25 +47,26 @@ void timer_add(struct timer *timer, time_t expires)
 	timer->fired = false;
 	timer->expires = expires;
 
-	timer_list = g_list_insert_sorted(timer_list, timer, timer_cmp);
+	tlist->list = g_list_insert_sorted(timer_list, timer, cld_timer_cmp);
 }
 
-void timer_del(struct timer *timer)
+void cld_timer_del(struct cld_timer_list *tlist, struct cld_timer *timer)
 {
 	if (!timer->on_list)
 		return;
 
-	timer_list = g_list_remove(timer_list, timer);
+	tlist->list = g_list_remove(tlist->list, timer);
 
 	timer->on_list = false;
 }
 
-time_t timers_run(void)
+time_t cld_timers_run(struct cld_timer_list *tlist)
 {
-	struct timer *timer;
+	struct cld_timer *timer;
 	time_t now = time(NULL);
 	time_t next_timeout = 0;
 	GList *tmp, *cur;
+	GList *timer_list = tlist->list;
 	GList *exec_list = NULL;
 
 	tmp = timer_list;
@@ -99,6 +101,7 @@ time_t timers_run(void)
 			next_timeout = 1;
 	}
 
+	tlist->list = timer_list;
 	return next_timeout;
 }
 
diff --git a/server/Makefile.am b/server/Makefile.am
index faaf099..f235965 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -6,9 +6,9 @@ INCLUDES	= -I$(top_srcdir)/include @GLIB_CFLAGS@ \
 sbin_PROGRAMS	= cld cldbadm
 
 cld_SOURCES	= cldb.h cld.h \
-		  ../lib/common.c \
+		  ../lib/common.c ../lib/libtimer.c \
 		  cldb.c msg.c server.c session.c util.c
-cld_LDADD	= ../lib/libtimer.a \
+cld_LDADD	= \
 		  @CRYPTO_LIBS@ @GLIB_LIBS@ @DB4_LIBS@
 
 cldbadm_SOURCES	= cldb.h cldbadm.c
diff --git a/server/cld.h b/server/cld.h
index e6bed3c..163f0fb 100644
--- a/server/cld.h
+++ b/server/cld.h
@@ -59,13 +59,13 @@ struct session {
 
 	uint64_t		last_contact;
 	uint64_t		next_fh;
-	struct timer		timer;
+	struct cld_timer	timer;
 
 	uint64_t		next_seqid_in;
 	uint64_t		next_seqid_out;
 
 	GList			*out_q;		/* outgoing pkts (to client) */
-	struct timer		retry_timer;
+	struct cld_timer	retry_timer;
 
 	char			user[CLD_MAX_USERNAME];
 
@@ -116,9 +116,9 @@ struct server {
 
 	GHashTable		*sessions;
 
-	GQueue			*timers;
+	struct cld_timer_list	timers;
 
-	struct timer		chkpt_timer;	/* db4 checkpoint timer */
+	struct cld_timer	chkpt_timer;	/* db4 checkpoint timer */
 
 	struct server_stats	stats;		/* global statistics */
 };
diff --git a/server/server.c b/server/server.c
index 7c9c07a..2287711 100644
--- a/server/server.c
+++ b/server/server.c
@@ -576,10 +576,11 @@ static bool udp_srv_event(int fd, short events, void *userdata)
 
 static void add_chkpt_timer(void)
 {
-	timer_add(&cld_srv.chkpt_timer, time(NULL) + CLD_CHKPT_SEC);
+	cld_timer_add(&cld_srv.timers, &cld_srv.chkpt_timer,
+		      time(NULL) + CLD_CHKPT_SEC);
 }
 
-static void cldb_checkpoint(struct timer *timer)
+static void cldb_checkpoint(struct cld_timer *timer)
 {
 	DB_ENV *dbenv = cld_srv.cldb.env;
 	int rc;
@@ -898,7 +899,7 @@ static int main_loop(void)
 {
 	time_t next_timeout;
 
-	next_timeout = timers_run();
+	next_timeout = cld_timers_run(&cld_srv.timers);
 
 	while (server_running) {
 		struct pollfd *pfd;
@@ -962,7 +963,7 @@ static int main_loop(void)
 			stats_dump();
 		}
 
-		next_timeout = timers_run();
+		next_timeout = cld_timers_run(&cld_srv.timers);
 	}
 
 	return 0;
@@ -1024,19 +1025,17 @@ int main (int argc, char *argv[])
 
 	ensure_root();
 
-	timer_init(&cld_srv.chkpt_timer, "db4-checkpoint",
-		   cldb_checkpoint, NULL);
+	cld_timer_init(&cld_srv.chkpt_timer, "db4-checkpoint",
+		       cldb_checkpoint, NULL);
 	add_chkpt_timer();
 
 	rc = 1;
 
 	cld_srv.sessions = g_hash_table_new(sess_hash, sess_equal);
-	cld_srv.timers = g_queue_new();
 	cld_srv.poll_data = g_array_sized_new(FALSE, FALSE,
 					   sizeof(struct server_poll), 4);
 	cld_srv.polls = g_array_sized_new(FALSE,FALSE,sizeof(struct pollfd), 4);
-	if (!cld_srv.sessions || !cld_srv.timers || !cld_srv.poll_data ||
-	    !cld_srv.polls)
+	if (!cld_srv.sessions || !cld_srv.poll_data || !cld_srv.polls)
 		goto err_out_pid;
 
 	if (sess_load(cld_srv.sessions) != 0)
@@ -1059,7 +1058,7 @@ int main (int argc, char *argv[])
 	applog(LOG_INFO, "shutting down");
 
 	if (strict_free)
-		timer_del(&cld_srv.chkpt_timer);
+		cld_timer_del(&cld_srv.timers, &cld_srv.chkpt_timer);
 
 	if (cld_srv.cldb.up)
 		cldb_down(&cld_srv.cldb);
@@ -1073,7 +1072,6 @@ err_out:
 		net_close();
 		g_array_free(cld_srv.polls, TRUE);
 		g_array_free(cld_srv.poll_data, TRUE);
-		g_queue_free(cld_srv.timers);
 		sessions_free();
 		g_hash_table_unref(cld_srv.sessions);
 	}
diff --git a/server/session.c b/server/session.c
index 44cd65a..e102f15 100644
--- a/server/session.c
+++ b/server/session.c
@@ -46,8 +46,8 @@ struct session_outpkt {
 	void			*done_data;
 };
 
-static void session_retry(struct timer *);
-static void session_timeout(struct timer *);
+static void session_retry(struct cld_timer *);
+static void session_timeout(struct cld_timer *);
 static int sess_load_db(GHashTable *ss, DB_TXN *txn);
 static void op_unref(struct session_outpkt *op);
 
@@ -110,8 +110,8 @@ static struct session *session_new(void)
 
 	__cld_rand64(&sess->next_seqid_out);
 
-	timer_init(&sess->timer, "session-timeout", session_timeout, sess);
-	timer_init(&sess->retry_timer, "session-retry", session_retry, sess);
+	cld_timer_init(&sess->timer, "session-timeout", session_timeout, sess);
+	cld_timer_init(&sess->retry_timer, "session-retry", session_retry, sess);
 
 	return sess;
 }
@@ -126,8 +126,8 @@ static void session_free(struct session *sess, bool hash_remove)
 	if (hash_remove)
 		g_hash_table_remove(cld_srv.sessions, sess->sid);
 
-	timer_del(&sess->timer);
-	timer_del(&sess->retry_timer);
+	cld_timer_del(&cld_srv.timers, &sess->timer);
+	cld_timer_del(&cld_srv.timers, &sess->retry_timer);
 
 	tmp = sess->out_q;
 	while (tmp) {
@@ -413,7 +413,7 @@ static void session_ping(struct session *sess)
 	sess_sendmsg(sess, &resp, sizeof(resp), session_ping_done, NULL);
 }
 
-static void session_timeout(struct timer *timer)
+static void session_timeout(struct cld_timer *timer)
 {
 	struct session *sess = timer->userdata;
 	uint64_t sess_expire;
@@ -429,7 +429,8 @@ static void session_timeout(struct timer *timer)
 		    (sess->sock_fd > 0))))
 			session_ping(sess);
 
-		timer_add(&sess->timer, now + ((sess_expire - now) / 2) + 1);
+		cld_timer_add(&cld_srv.timers, &sess->timer,
+			      now + ((sess_expire - now) / 2) + 1);
 		return;	/* timer added; do not time out session */
 	}
 
@@ -589,7 +590,7 @@ static int sess_retry_output(struct session *sess, time_t *next_retry_out)
 	return rc;
 }
 
-static void session_retry(struct timer *timer)
+static void session_retry(struct cld_timer *timer)
 {
 	struct session *sess = timer->userdata;
 	time_t next_retry;
@@ -599,14 +600,15 @@ static void session_retry(struct timer *timer)
 
 	sess_retry_output(sess, &next_retry);
 
-	timer_add(&sess->retry_timer, next_retry);
+	cld_timer_add(&cld_srv.timers, &sess->retry_timer, next_retry);
 }
 
 static void session_outq(struct session *sess, GList *new_pkts)
 {
 	/* if out_q empty, start retry timer */
 	if (!sess->out_q)
-		timer_add(&sess->retry_timer, time(NULL) + CLD_RETRY_START);
+		cld_timer_add(&cld_srv.timers, &sess->retry_timer,
+			      time(NULL) + CLD_RETRY_START);
 
 	sess->out_q = g_list_concat(sess->out_q, new_pkts);
 }
@@ -777,7 +779,7 @@ void msg_ack(struct msg_params *mp)
 	}
 
 	if (!sess->out_q)
-		timer_del(&sess->retry_timer);
+		cld_timer_del(&cld_srv.timers, &sess->retry_timer);
 }
 
 void msg_new_sess(struct msg_params *mp, const struct client *cli)
@@ -838,7 +840,8 @@ void msg_new_sess(struct msg_params *mp, const struct client *cli)
 	g_hash_table_insert(cld_srv.sessions, sess->sid, sess);
 
 	/* begin session timer */
-	timer_add(&sess->timer, time(NULL) + (CLD_SESS_TIMEOUT / 2));
+	cld_timer_add(&cld_srv.timers, &sess->timer,
+		      time(NULL) + (CLD_SESS_TIMEOUT / 2));
 
 	resp_ok(sess, mp->msg);
 	return;
@@ -969,7 +972,8 @@ static int sess_load_db(GHashTable *ss, DB_TXN *txn)
 		g_hash_table_insert(ss, sess->sid, sess);
 
 		/* begin session timer */
-		timer_add(&sess->timer, time(NULL) + (CLD_SESS_TIMEOUT / 2));
+		cld_timer_add(&cld_srv.timers, &sess->timer,
+			      time(NULL) + (CLD_SESS_TIMEOUT / 2));
 	}
 
 	cur->close(cur);
diff --git a/test/Makefile.am b/test/Makefile.am
index 20dba03..f9b3347 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,7 +25,6 @@ check_PROGRAMS		= it-works \
 			  save-file-event load-file-event lock-file-event
 
 TESTLDADD		= ../lib/libcldc.la	\
-			  ../lib/libtimer.a	\
 			  libtest.a		\
 			  @GLIB_LIBS@ @CRYPTO_LIBS@
 it_works_LDADD		= $(TESTLDADD)
diff --git a/test/it-works.c b/test/it-works.c
index ec6ff4c..1a20a77 100644
--- a/test/it-works.c
+++ b/test/it-works.c
@@ -31,7 +31,8 @@
 #include "test.h"
 
 static struct cldc_udp *udp;
-static struct timer udp_tm;
+static struct cld_timer udp_tm;
+static struct cld_timer_list tlist;
 
 static bool do_timer_ctl(void *priv, bool add,
 			 int (*cb)(struct cldc_session *, void *),
@@ -45,15 +46,15 @@ static bool do_timer_ctl(void *priv, bool add,
 	if (add) {
 		udp->cb = cb;
 		udp->cb_private = cb_priv;
-		timer_add(&udp_tm, time(NULL) + secs);
+		cld_timer_add(&tlist, &udp_tm, time(NULL) + secs);
 	} else {
-		timer_del(&udp_tm);
+		cld_timer_del(&tlist, &udp_tm);
 	}
 
 	return true;
 }
 
-static void timer_udp_event(struct timer *timer)
+static void timer_udp_event(struct cld_timer *timer)
 {
 	if (timer->userdata != udp) {
 		fprintf(stderr, "IE1: misuse of timer\n");
@@ -126,7 +127,7 @@ static int init(void)
 	if (rc)
 		return rc;
 
-	timer_init(&udp_tm, "udp-timer", timer_udp_event, udp);
+	cld_timer_init(&udp_tm, "udp-timer", timer_udp_event, udp);
 
 	memset(&copts, 0, sizeof(copts));
 	copts.cb = new_sess_cb;
@@ -147,7 +148,7 @@ int main (int argc, char *argv[])
 	cldc_init();
 	if (init())
 		return 1;
-	test_loop(udp);
+	test_loop(&tlist, udp);
 	return 0;
 }
 
diff --git a/test/load-file-event.c b/test/load-file-event.c
index 7b309b3..cefd521 100644
--- a/test/load-file-event.c
+++ b/test/load-file-event.c
@@ -36,7 +36,8 @@
 
 struct run {
 	struct cldc_udp *udp;
-	struct timer tmr_udp;
+	struct cld_timer_list tlist;
+	struct cld_timer tmr_udp;
 	struct cldc_fh *fh;
 	char *fname;
 };
@@ -56,9 +57,9 @@ static bool do_timer_ctl(void *priv, bool add,
 	if (add) {
 		rp->udp->cb = cb;
 		rp->udp->cb_private = cb_priv;
-		timer_add(&rp->tmr_udp, time(NULL) + secs);
+		cld_timer_add(&rp->tlist, &rp->tmr_udp, time(NULL) + secs);
 	} else {
-		timer_del(&rp->tmr_udp);
+		cld_timer_del(&rp->tlist, &rp->tmr_udp);
 	}
 
 	return true;
@@ -71,7 +72,7 @@ static int do_pkt_send(void *priv, const void *addr, size_t addrlen,
 	return cldc_udp_pkt_send(rp->udp, addr, addrlen, buf, buflen);
 }
 
-static void timer_udp_event(struct timer *timer)
+static void timer_udp_event(struct cld_timer *timer)
 {
 	struct run *rp = timer->userdata;
 	struct cldc_udp *udp = rp->udp;
@@ -233,7 +234,7 @@ static int init(char *name)
 	if (port == 0)
 		return -1;
 
-	timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
+	cld_timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
 
 	rc = cldc_udp_new(TEST_HOST, port, &run.udp);
 	if (rc)
@@ -258,7 +259,7 @@ int main(int argc, char *argv[])
 	cldc_init();
 	if (init(TFNAME))
 		return 1;
-	test_loop(run.udp);
+	test_loop(&run.tlist, run.udp);
 	return 0;
 }
 
diff --git a/test/lock-file-event.c b/test/lock-file-event.c
index 0772e4e..f0ab285 100644
--- a/test/lock-file-event.c
+++ b/test/lock-file-event.c
@@ -36,8 +36,9 @@
 
 struct run {
 	struct cldc_udp *udp;
-	struct timer tmr_test;
-	struct timer tmr_udp;
+	struct cld_timer_list tlist;
+	struct cld_timer tmr_test;
+	struct cld_timer tmr_udp;
 	struct cldc_fh *fh;
 	char buf[LOCKLEN];
 };
@@ -59,9 +60,9 @@ static bool do_timer_ctl(void *priv, bool add,
 	if (add) {
 		rp->udp->cb = cb;
 		rp->udp->cb_private = cb_priv;
-		timer_add(&rp->tmr_udp, time(NULL) + secs);
+		cld_timer_add(&rp->tlist, &rp->tmr_udp, time(NULL) + secs);
 	} else {
-		timer_del(&rp->tmr_udp);
+		cld_timer_del(&rp->tlist, &rp->tmr_udp);
 	}
 
 	return true;
@@ -74,7 +75,7 @@ static int do_pkt_send(void *priv, const void *addr, size_t addrlen,
 	return cldc_udp_pkt_send(rp->udp, addr, addrlen, buf, buflen);
 }
 
-static void timer_udp_event(struct timer *timer)
+static void timer_udp_event(struct cld_timer *timer)
 {
 	struct run *rp = timer->userdata;
 	struct cldc_udp *udp = rp->udp;
@@ -176,11 +177,11 @@ static int lock_1_cb(struct cldc_call_opts *coptarg, enum cle_err_codes errc)
 	}
 
 	/* Idle for 40s to verify that session sustains a protocol ping. */
-	timer_add(&rp->tmr_test, time(NULL) + 40);
+	cld_timer_add(&rp->tlist, &rp->tmr_test, time(NULL) + 40);
 	return 0;
 }
 
-static void timer_test_event(struct timer *timer)
+static void timer_test_event(struct cld_timer *timer)
 {
 	struct run *rp = timer->userdata;
 
@@ -259,8 +260,8 @@ static int init(void)
 	if (port == 0)
 		return -1;
 
-	timer_init(&run.tmr_test, "lock-timer", timer_test_event, &run);
-	timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
+	cld_timer_init(&run.tmr_test, "lock-timer", timer_test_event, &run);
+	cld_timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
 
 	rc = cldc_udp_new(TEST_HOST, port, &run.udp);
 	if (rc)
@@ -285,7 +286,7 @@ int main (int argc, char *argv[])
 	cldc_init();
 	if (init())
 		return 1;
-	test_loop(run.udp);
+	test_loop(&run.tlist, run.udp);
 	return 0;
 }
 
diff --git a/test/save-file-event.c b/test/save-file-event.c
index 2b13bc8..4ca7be5 100644
--- a/test/save-file-event.c
+++ b/test/save-file-event.c
@@ -38,7 +38,8 @@
 
 struct run {
 	struct cldc_udp *udp;
-	struct timer tmr_udp;
+	struct cld_timer_list tlist;
+	struct cld_timer tmr_udp;
 	struct cldc_fh *fh;
 	char *fname;
 	char *buf;
@@ -61,9 +62,9 @@ static bool do_timer_ctl(void *priv, bool add,
 	if (add) {
 		rp->udp->cb = cb;
 		rp->udp->cb_private = cb_priv;
-		timer_add(&rp->tmr_udp, time(NULL) + secs);
+		cld_timer_add(&rp->tlist, &rp->tmr_udp, time(NULL) + secs);
 	} else {
-		timer_del(&rp->tmr_udp);
+		cld_timer_del(&rp->tlist, &rp->tmr_udp);
 	}
 	return true;
 }
@@ -75,7 +76,7 @@ static int do_pkt_send(void *priv, const void *addr, size_t addrlen,
 	return cldc_udp_pkt_send(rp->udp, addr, addrlen, buf, buflen);
 }
 
-static void timer_udp_event(struct timer *timer)
+static void timer_udp_event(struct cld_timer *timer)
 {
 	struct run *rp = timer->userdata;
 	struct cldc_udp *udp;
@@ -238,7 +239,7 @@ static int init(char *name)
 	if (port == 0)
 		return -1;
 
-	timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
+	cld_timer_init(&run.tmr_udp, "udp-timer", timer_udp_event, &run);
 
 	rc = cldc_udp_new(TEST_HOST, port, &run.udp);
 	if (rc)
@@ -263,7 +264,7 @@ int main(int argc, char *argv[])
 	cldc_init();
 	if (init(TFNAME))
 		return 1;
-	test_loop(run.udp);
+	test_loop(&run.tlist, run.udp);
 	return 0;
 }
 
diff --git a/test/test.h b/test/test.h
index 8e87684..84b52d4 100644
--- a/test/test.h
+++ b/test/test.h
@@ -3,6 +3,7 @@
 
 #include <stdbool.h>
 #include <cldc.h>
+#include <libtimer.h>
 
 #define TESTSTR          "longertestdata\n"
 #define TESTLEN  (sizeof("longertestdata\n")-1)
@@ -20,6 +21,6 @@
 
 #define TEST_PORTFILE_CLD	"cld.port"
 
-extern void test_loop(struct cldc_udp *udp);
+extern void test_loop(struct cld_timer_list *tlist, struct cldc_udp *udp);
 
 #endif
diff --git a/test/util.c b/test/util.c
index fcf84f3..0b360b0 100644
--- a/test/util.c
+++ b/test/util.c
@@ -33,7 +33,7 @@
 #include <cldc.h>
 #include "test.h"
 
-void test_loop(struct cldc_udp *udp)
+void test_loop(struct cld_timer_list *tlist, struct cldc_udp *udp)
 {
 	int ufd = udp->fd;
 	fd_set rset;
@@ -45,7 +45,7 @@ void test_loop(struct cldc_udp *udp)
 		FD_ZERO(&rset);
 		FD_SET(ufd, &rset);
 
-		tmo = timers_run();
+		tmo = cld_timers_run(tlist);
 		if (tmo) {
 			tm.tv_sec = tmo;
 			tm.tv_usec = 0;
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux