[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] libevent http long pooling - request stuck
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] libevent http long pooling - request stuck
- From: Quentin Ambard <quentin.ambard@xxxxxxxxx>
- Date: Wed, 9 Mar 2011 21:32:59 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Wed, 09 Mar 2011 15:33:25 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=UxikbV5gHVx140FTmR52q5stSLEkfaCflAu/GmIrfVw=; b=UnPhEq/cM1Cekt5JJgEI4QDEwhiNZetyHA8gNkfYWEUbRQELOvbEOqYZqZvjzZm9Tq nil7hZwSqOIYeaFQPHCnV09c1rJEEi6qDMa54SwW/ReuEduO7pQLli2+Z0GKG9p+dtLF MUWVsW9z0kDLwU/XR/o7aNc6Wy0nrZHbiGffw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=rZLAraSyeNu/N00r8Mcn6MdGu1mGBa/+SUkP0ZheRs8RZX63h+BKtx9XJV2pVtWyYH c1k2c2GD/ACoQsIEdd4RAkxofZ58UY35GXvHkVO4hgWgCGDeFCHPqAhQTgytYTD8ARju MoMBD7kJCbFWCKy1ELOzIGO3mwx7epDpSTO4Y=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
I have a strange behaviour using libevent for long pooling.
I'd like to store a list of all the evhttp_request I receive for a specific url, without sending an answer to the client (I'ts long pooling, so I keep the connection open for x seconds).
The problem is that the very first request seems to stuck the others.
Here is a very simple example :
//First we Start the server
int main(int argc, char **argv)
{
short http_port = 8081;
char *http_addr = "192.168.1.56";
struct evhttp *http_server = NULL;
struct event_base *event = event_base_new();
http_server = evhttp_start(http_addr, http_port);
evhttp_set_gencb(http_server, generic_request_handler, NULL);
event_base_dispatch(event);
}
void generic_request_handler (struct evhttp_request *req) {
struct evbuffer *buffer = evbuffer_new();
printf("hello\n");
evhttp_send_reply_start(req, HTTP_OK, "OK");
evbuffer_add_printf(buffer, "Hi %s, this is a comet server based on libevent.", req->remote_host);
evhttp_send_reply_chunk(req, buffer);
}
First access to the server with firefox print "hello", and send a chunk. OK.
When accessing to the server in another tabs, nothing appen, firefox just wait. When I close the first tab, then "hello" is printed a second time and I get the chunk in the second tab !
If I do the same thing but opening the second connection in a chrome tab (the first one is opened in firefox), I get the second "hello" printed, but nothing more. Very strange ?!
For me, "hello" should be printed for every request executed, even if the evhttp_send_reply(...) isn't call yet.
Is it a bug ?? Am I missing something ?
How can we do long-pooling, considering this limitation ?
Thanks for your help,
--
Quentin