[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] evhttp, evhttp_send_reply_start and client close
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] evhttp, evhttp_send_reply_start and client close
- From: Vincent Bernat <bernat@xxxxxxxx>
- Date: Sun, 12 Aug 2012 12:35:47 +0200
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sun, 12 Aug 2012 06:35:06 -0400
- Dkim-signature: v=1; a=rsa-sha1; c=simple; d=luffy.cx; h=from:to:subject :references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=postfix; bh=YwuKQDrSx NqT1r6gZyA1gsFkZpA=; b=m+a9+LxBkT/SsmNhodAQ7yfPK52VOGtNjvBVccxEc 4k4Mxr9SqqHssmtz6nphtC3NsmdNxGUKgYhgdQmzWaeJ+kpH6xgODR1uFPEOcrGQ yaIigfZkKlNEMLNFUhOWmKUmvrQuiuaZfh/1PyYDQBnLjSG/ChX02Pz5XkPaSf+L S8=
- Domainkey-signature: a=rsa-sha1; c=simple; d=luffy.cx; h=from:to:subject :references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=postfix; b=O8W rESOdnCKwe7ygoOzzgJQTdCgkboEKcpO4GAvTKOLjtCQRvHVxXRDt0Yccy3e99Zz iPMLg4984F+0/EuIjAL9pR+xpDJ34mLudw9L4OcnGaKt/uDUzJeaVPuzlY5feI/w WSA0NzDAYvsNXXw9yMrnCNzalJYY5kEKWYVPYqYs=
- In-reply-to: <m3y5lkv5yk.fsf@xxxxxxxxxxxx> (Vincent Bernat's message of "Sun, 12 Aug 2012 11:02:11 +0200")
- References: <m3y5lkv5yk.fsf@xxxxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
- User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (gnu/linux)
â 12 aoÃt 2012 11:02 CEST, Vincent Bernat <bernat@xxxxxxxx>Â:
> I am trying to use HTTP chunked answers to implement a publish/subscribe
> mechanism on top of evhttp. A client will subscribe to a topic by
> requesting some URL, I invoke evhttp_send_reply_start(), put the request
> into some list and once a message is available for a topic, I take my
> list and for each member, I will send the new messages with
> evhttp_send_reply_chunk().
>
> My question is: how do I handle the case where the client disconnects? I
> have found a similar problem in this post:
> http://archives.seul.org/libevent/users/Jan-2010/msg00054.html
>
> The linked gist does not crash anymore but, in my case, I need to remove
> the "dead" clients from my linked list (or I will soon run into some
> memory issue).
Reading a bit the source code, I have discovered that I can check if
`evhttp_request_get_connection(h->req)` is `NULL` or not. If it is, I
need to remove the request from my list of requests.
--
Watch out for off-by-one errors.
- The Elements of Programming Style (Kernighan & Plauger)
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.