[Libevent-users] [PATCH] Initialize current_base only once
I have been using libevent in multithreaded code, where more than one event queue is used (i.e. event_init() is called multiple times,) and was bitten by the fact that current_base is updated on each call to event_init(). This becomes a problem when attempting to use the evhttp support in such an environment, which does not support explicit event_base specifications. The attached patch only initializes current_base to the first one created so that the behavior is at least predictable and controllable. -- paul --- libevent-1.3e.orig/event.c 2007-10-29 14:51:55.0 -0500 +++ libevent-1.3e.tmp/event.c 2007-10-29 20:07:18.0 -0500 @@ -218,7 +218,8 @@ /* allocate a single active event queue */ event_base_priority_init(base, 1); - current_base = base; +if( current_base == NULL ) +current_base = base; return (base); } ___ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users
[Libevent-users] semaphore event
Hi All, I am working on simple socket proxy/filter. To overcome the limitation of fd's per process, the main creates a semaphore, and forks after create listen socket, then the one which gets semaphore will accept. When the active process reaches this max connections, it unlocks the semaphore and stops accepting so anther process will start to work. My question is regarding reactive the first process, for now it checks (can't wait since we need keep event_dispatch running) the semaphore whenever closing a connection but I feel the code a little ugly (keep checking in an event driven app). Can I get a libevent event for semaphore notification, like the how the signal works. Thanks in advance. Cheers, Arthur ___ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users
[Libevent-users] [PATCH] TAILQ_ENTRY missing in evhttp.h on linux
In using the latest 1.3e on linux, evhttp.h fails to compile because of a missing definition of TAILQ_ENTRY in evhttp.h. This is due to the fact that the workaround in event.h is #define'd and #undef'd within event.h and not available to evhttp.h when defining struct evhttp_request. This patch obviously fixes it: --- libevent-1.3e/evhttp.h 2007-08-25 13:49:22.0 -0500 +++ libevent-1.3e.002/evhttp.h 2007-10-29 22:32:07.0 -0500 @@ -108,7 +108,14 @@ * reasonable accessors. */ struct evhttp_request { +#if defined(TAILQ_ENTRY) TAILQ_ENTRY(evhttp_request) next; +#else +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} next; +#endif /* the connection object that this request belongs to */ struct evhttp_connection *evcon; ... but it would be nice if this was coordinated with the definition in event.h, possibly by simply not #undef'ing it from event.h. Anyway, if there is a preference on how to fix this, I'd be glad to regenerate the patch. -- paul ___ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users