From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 1/2] tabled: drop dependency on libevent from libcldc
Date: Fri, 27 Nov 2009 20:52:41 -0700 [thread overview]
Message-ID: <20091127205241.56dcf301@redhat.com> (raw)
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",
next reply other threads:[~2009-11-28 3:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-28 3:52 Pete Zaitcev [this message]
2009-11-28 5:09 ` [Patch 1/2] tabled: drop dependency on libevent from libcldc Jeff Garzik
2009-11-28 7:07 ` Pete Zaitcev
2009-11-28 9:08 ` Jeff Garzik
2009-11-28 9:11 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091127205241.56dcf301@redhat.com \
--to=zaitcev@redhat.com \
--cc=hail-devel@vger.kernel.org \
--cc=jeff@garzik.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.