All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 1/2] tabled: drop dependency on libevent from libcldc
@ 2009-11-28  3:52 Pete Zaitcev
  2009-11-28  5:09 ` Jeff Garzik
  2009-11-28  9:11 ` Jeff Garzik
  0 siblings, 2 replies; 5+ messages in thread
From: Pete Zaitcev @ 2009-11-28  3:52 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

This patch makes it so that tabled stops relying on libcldc using libevent.
Thus, libcldc would be free to drop libevent dependency.

The patched tabled can build and work with the "old" libcldc too.

Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>

---
 server/cldu.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff -urp -X dontdiff tabled-m/server/cldu.c tabled-tip/server/cldu.c
--- tabled-m/server/cldu.c	2009-11-26 17:49:06.127387256 -0700
+++ tabled-tip/server/cldu.c	2009-11-22 22:26:57.872388630 -0700
@@ -34,6 +34,7 @@ struct cld_session {
 	bool forced_hosts;		/* Administrator overrode default CLD */
 	bool sess_open;
 	struct cldc_udp *lib;		/* library state */
+	struct event lib_timer;
 	int retry_cnt;
 
 	/*
@@ -216,7 +217,16 @@ static bool cldu_p_timer_ctl(void *priv,
 			     void *cb_priv, time_t secs)
 {
 	struct cld_session *sp = priv;
-	return cldc_levent_timer(sp->lib, add, cb, cb_priv, secs);
+	struct cldc_udp *udp = sp->lib;
+	struct timeval tv = { secs, 0 };
+
+	if (add) {
+		udp->cb = cb;
+		udp->cb_private = cb_priv;
+		return evtimer_add(&sp->lib_timer, &tv) == 0;
+	} else {
+		return evtimer_del(&sp->lib_timer) == 0;
+	}
 }
 
 static int cldu_p_pkt_send(void *priv, const void *addr, size_t addrlen,
@@ -226,6 +236,16 @@ static int cldu_p_pkt_send(void *priv, c
 	return cldc_udp_pkt_send(sp->lib, addr, addrlen, buf, buflen);
 }
 
+static void cldu_udp_timer_event(int fd, short events, void *userdata)
+
+{
+	struct cld_session *sp = userdata;
+	struct cldc_udp *udp = sp->lib;
+
+	if (udp->cb)
+		udp->cb(udp->sess, udp->cb_private);
+}
+
 static void cldu_p_event(void *priv, struct cldc_session *csp,
 			 struct cldc_fh *fh, uint32_t what)
 {
@@ -287,6 +307,8 @@ static int cldu_set_cldc(struct cld_sess
 	}
 	hp = &sp->cldv[sp->actx].h;
 
+	evtimer_set(&sp->lib_timer, cldu_udp_timer_event, sp);
+
 	rc = cldc_udp_new(hp->host, hp->port, &sp->lib);
 	if (rc) {
 		applog(LOG_ERR, "cldc_udp_new(%s,%u) error: %d",

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-28  9:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-28  3:52 [Patch 1/2] tabled: drop dependency on libevent from libcldc Pete Zaitcev
2009-11-28  5:09 ` Jeff Garzik
2009-11-28  7:07   ` Pete Zaitcev
2009-11-28  9:08     ` Jeff Garzik
2009-11-28  9:11 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.