[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Re: libevent http and lost requests



On Tue, Aug 16, 2011 at 09:47:07AM -0500, Mark Ellzey wrote:
> On Tue, Aug 16, 2011 at 12:28:21PM +0300, about bus wrote:
> > No, I don't, because they output very huge, and I don't know what exactly I
> > should looking there.
> 
> I think I have missed asking some basic questions. 
> 
> - What version of libevent are you using?
> - What operating system and event backend are you using?
> - Are there any distinguishing types of queries that cause this issue?
>   * large POST requests, large responses, requests without proper CRLF,
>     etc (this is why I asked for a tcpdump -s0 -X output)
> - Compile with -DUSE_DEBUG for libevent - and paste the output which
>   will allow us to see detailed event usage.
> - is the libevent process *hanging* or can other requests still be serviced
>   while the one query is hanging?
> 
> If I understand this right, the arch of your application is simply nginx
> talking to your libevent application, correct? 
> 


Also - if you would like, I have a more advanced API for writing
libevent based HTTP servers which has built-in thread pool support. 

At the moment it has only been tested on OSX >= LION, and Linux 2.6.x.
You can get the source here: https://github.com/ellzey/libevhtp

This API can be used just like a simple libevent http server (but is
much more flexible) just like you would with evhttp. If you wanted to
create the most simple of http servers with 4 worker threads, the code
woud look like this:

----

#include <evhtp.h>

static void
default_cb(evhtp_request_t * request, void * arg) {
	evbuffer_add_printf(request->buffer_out, "hi! %s\n", (char *)arg);

	evhtp_send_reply(req, EVHTP_RES_200);
}

int 
main(int argc, char ** argv) {
	struct event_base * evbase      = event_base_new();
	evhtp_t           * htp         = evhtp_new(evbase, NULL);
  int                 num_workers = 4;

	
	evhtp_set_gencb(htp, default_cb, "foobar");
  evhtp_use_threads(htp, num_workers);
  evhtp_bind_socket(htp, "0.0.0.0", 8080);

  event_base_loop(evbase, 0);

  return 0;
}
	
----

A more advanced example can be found here:
https://github.com/ellzey/libevhtp/blob/master/test.c


***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.