[Patch 1/2] tabled: drop dependency on libevent from libcldc

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

 



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@xxxxxxxxxx>

---
 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",
--
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