[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] [HELP] How to safely free a defer callback bufferevent in readcb
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] [HELP] How to safely free a defer callback bufferevent in readcb
- From: Zhuang Yuyao <mlistz@xxxxxxxxx>
- Date: Mon, 31 May 2010 16:48:44 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 31 May 2010 04:48:58 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=8GNX1+iBe4Kf/jNeoMmKz7uIl/x3kyIHTemvLbQotT8=; b=xUV/NDsEMUBNEOZmN9/z4T9COWPJH9HZQ8MPdqH/jy5ggnyH3dSrZrj/gumskpPrPy cbjGLuycKOtk+YIbFtLP+FtJ9G72vmx1sZLLGeqwxB+kD285rkqIHWxRKIMStSHvnW6O vqoBFtiB7/7n3j/ef0r+VEDiUcKI5JNNxDPiI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Zh4p0CUFWdq+NF77nfGJu5harGgj7qzoM7J1lPX6CEL4JuQX3apHK10smmIucB4ytZ Hmz7cl083eupEi3WUdQXp0CjcATwjfa1D19Hp9PLWyCDbe6ysIX9NLXD3/BOt0UieegJ a1iQ75D+KXmjc/vF8n2mPlUkOsizADwJQNXsE=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
I am working on a http proxy program based on le-proxy. the proxy has
a feature to block requests to some special urls, then return to the
client a 403 forbidden or 302 redirect response.
I tried to do it in bufferevent readcb, here are the code sample i wrote:
static void
readcb(struct bufferevent *bev, void *ctx)
{
struct bufferevent *partner = (struct bufferevent *)ctx;
int r = session_handle(bev, partner);
if (r == 1) { //the url need to be blocked and the output evbuffer
of bev has been set to "HTTP/1.0 403\r\n\r\n"
bufferevent_disable(bev, EV_READ);
struct evbuffer *b = bufferevent_get_input(bev);
evbuffer_drain(b, evbuffer_get_length(b));
if (partner) {
bufferevent_disable(partner, EV_READ|EV_WRITE);
bufferevent_free(partner);
}
if (evbuffer_get_length(bufferevent_get_output(bev))) {
bufferevent_setcb(bev, NULL, close_on_finished_writecb, eventcb, NULL);
}
else {
bufferevent_free(bev);
}
}
//otherwise
.....
}
with defer callback, when the above code is called, (ie. a request to
the to-be-blocked url is found)
I got the following warnings:
[warn] Epoll MOD on fd 10 failed. Old events were 6; read change was
2; write change was 0.: Bad file descriptor
The warning does not appear if the BEV_OPT_DEFER_CALLBACKS is not set.
Can anyone please explain where this warning comes from, and how to
avoid such a warning?
Thanks very much.
Best regards,
Zhuang
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.