[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Retry buffered event writes on partial write or error?
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] Retry buffered event writes on partial write or error?
- From: Jeffrey Walton <noloader@xxxxxxxxx>
- Date: Tue, 25 Feb 2014 10:43:22 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 25 Feb 2014 10:43:26 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:date:message-id:subject:from:to:content-type; bh=URC85FVq9f7ccg6N/6rCNcbzWiwTryiCMF+e9ENKTTk=; b=AbOrf9xceX/F99QPXj2kh53r/f6BogFSA8xXznn3+KXbqB+CqZOVyRpNjfqC7Ac+4N qSKCiF1kd3mZrhl4qwc8NhzGYwrMy6PnMTO/dgcTrhdwJR0F32a/GAR9v9po3c0ghq83 +BL+T1hrYP/mISEm0wSmCW/tz0WF/C0E+i9DF2KKIB+QAgcpTXgl+jJggQIvFgvekvNp da1N+5ItOHwI9vikBCbUl4BcaW/t++f63U6bhQfW+b15EatLjBSvAdSwiPcaqgWgMrJx 3kOoPo3ek3JLrnx90OTXaDFJg3w2T3nzd++nqC9AAopkt9YAKJWMt2vAZvDoU4Y6MLv4 CyIA==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
I'm trying to understand retry strategies on buffered events. I'm
using the hello-world.c as an example.
Suppose I have a listener created with evconnlistener_new_bind. A
connection is made and the listener_cb is invoked.
The listener_cb sets two callbacks for the write - conn_writecb and
conn_eventcb:
bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE);
bufferevent_setcb(bev, NULL, conn_writecb, conn_eventcb, NULL);
bufferevent_write(bev, MESSAGE, strlen(MESSAGE));
The conn_writecb is shown below.
conn_writecb(struct bufferevent *bev, void *user_data)
{
struct evbuffer *output = bufferevent_get_output(bev);
if (evbuffer_get_length(output) == 0) {
bufferevent_free(bev);
}
}
I see the buffered event is cleaned up on a successful write.
conn_eventcb(struct bufferevent *bev, short events, void *user_data)
{
if (events & BEV_EVENT_EOF) {
printf("Connection closed.\n");
} else if (events & BEV_EVENT_ERROR) {
printf("Got an error on the connection: %s\n",
strerror(errno));/*XXX win32*/
}
bufferevent_free(bev);
}
In the case of an error, I only see the close.
How do I retry it if there's a partial write? Is this a case, should I
call event_add an attempt to finish the write? Would that occur in
conn_writecb or conn_eventcb?
Thanks in advance.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.