Re: [Libevent-users] Implementing a deadline timer

2008-10-09 Thread Christopher Layne
On Tue, Sep 09, 2008 at 04:48:40PM -0500, Andrew Troschinetz wrote: > Hi all, > > I'm just getting started with libevent and I was wondering how I might > implement a simple deadline timer with it. > > I'd like to be able to use do something like: > > void do_something(...) ... > deadl

Re: [Libevent-users] [PATCH] relative timer with EV_PERSIST support + move event_del logic into event_active + regression tests

2007-11-13 Thread Christopher Layne
On Tue, Nov 13, 2007 at 06:27:58PM -0800, William Ahern wrote: > > event_set(ev, fd, EV_READ | EV_PERSIST, read_cb, obj); > > event_add(ev, &timeout); > > > > read_cb() will be called whenever a read event happens, and it's timeout > > as passed to event_add() will be reset to the original

[Libevent-users] [PATCH] relative timer with EV_PERSIST support + move event_del logic into event_active + regression tests

2007-11-13 Thread Christopher Layne
1. Make EV_PERSIST reschedule timeouts automatically. 2. New function: timeout_schedule: (nothing really new within it, just modular wrapping of timeout rescheduling). 3. New macro: evutil_timercpy: tv_dst = tv_src in one line type deal; 3. Regression tests for persistent timeouts, include read/

[Libevent-users] EV_PERSIST + relative timeouts discussion

2007-11-13 Thread Christopher Layne
As it is, EV_PERSIST is somewhat obtuse when trying to use it in combination with EV_READ or EV_WRITE while still handling timeout events. The standard idiom is basically: if (select_epoll_etc_indicates_something) do_something_and_add_fd_back_to_something_set(); else if (time_since_last_so

[Libevent-users] [PATCH] event.c: event_base_free(): dealloc min_heap

2007-11-12 Thread Christopher Layne
==00:00:00:08.662 19894== 64 bytes in 1 blocks are definitely lost in loss record 4 of 7 ==00:00:00:08.662 19894==at 0x4A06B92: malloc (vg_replace_malloc.c:149) ==00:00:00:08.662 19894==by 0x4A06C06: realloc (vg_replace_malloc.c:306) ==00:00:00:08.662 19894==by 0x4C24E16: min_heap_rese

Re: [Libevent-users] [OT] craigslist: libevent programmer wanted

2007-11-11 Thread Christopher Layne
On Mon, Nov 12, 2007 at 06:38:33AM +0100, Marc Lehmann wrote: > On Fri, Nov 09, 2007 at 12:39:37AM +0100, Hannah Schroeter <[EMAIL > PROTECTED]> wrote: > > I see less problems with the writing away of the data sucked from the > > web servers, as most Unix like systems write stuff asynchronously, s

[Libevent-users] [PATCH] event.c: timeout_process(): let event_del() handle queue management

2007-11-11 Thread Christopher Layne
event_del() calls event_queue_remove(base, ev, EVLIST_TIMEOUT). -cl Index: event.c === --- event.c (revision 515) +++ event.c (working copy) @@ -815,7 +815,6 @@ while ((ev = min_heap_top(&base->timeheap))) {

[Libevent-users] [PATCH] test/Makefile.am: out of srcdir fix

2007-11-11 Thread Christopher Layne
Index: test/Makefile.am === --- test/Makefile.am(revision 515) +++ test/Makefile.am(working copy) @@ -31,6 +31,6 @@ test: test-init test-eof test-weof test-time regress verify: test - @./test.sh + @$(srcdir)/te

Re: [Libevent-users] [PATCH] event.c: make internal signal event count as active

2007-11-10 Thread Christopher Layne
On Sat, Nov 10, 2007 at 06:49:58PM -0800, Christopher Layne wrote: > On Sat, Nov 10, 2007 at 06:44:12PM -0800, Christopher Layne wrote: > > 11. here's the funny part: evsignal_process() increments event_count_active > > - but since our Here's a better patch: This

Re: [Libevent-users] [PATCH] event.c: make internal signal event count as active

2007-11-10 Thread Christopher Layne
On Sat, Nov 10, 2007 at 06:44:12PM -0800, Christopher Layne wrote: > 11. here's the funny part: evsignal_process() increments event_count_active - > but since our should be: evsignal_process() adds the internal event to the active queue as normal. before we call event_pro

[Libevent-users] [PATCH] event.c: make internal signal event count as active

2007-11-10 Thread Christopher Layne
[ WARNING: Long and ardorous - difficult to trace behaviour ] Behaviour described is without EV_PERSIST on internal signal handler (as it's been for months): 1. signal comes in, we jump to our internal signal handler, it writes to pipe. 2. epoll_wait() returns -1/EINTR because a signal handler wa

[Libevent-users] [PATCH] signal.c: debug cleanups

2007-11-10 Thread Christopher Layne
1. Fix a debugging call with wrong format, (we should probably use __attr__((format(printf))) eventually). 2. Add additional debugging calls for sanity. -cl Index: signal.c === --- signal.c(revision 507) +++ signal.c(working

Re: [Libevent-users] [PATCH] epoll.c: epoll_dispatch() clarity/simplification/branch reduction cleanups

2007-11-10 Thread Christopher Layne
On Sat, Nov 10, 2007 at 12:18:25AM -0500, Nick Mathewson wrote: > On Fri, Nov 09, 2007 at 02:27:07AM -0800, Christopher Layne wrote: > > Regress checks out OK with both -O0 and -Os. Both size are with -O0. > > Applied; thanks! Unfortunately I'm noticing that it's cau

[Libevent-users] [PATCH] sample/Makefile.am: additional include

2007-11-09 Thread Christopher Layne
Separate build dir issue. Index: sample/Makefile.am === --- sample/Makefile.am (revision 506) +++ sample/Makefile.am (working copy) @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies LDADD = ../libevent.la -AM_CFLAGS = -I

Re: [Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

2007-11-09 Thread Christopher Layne
On Fri, Nov 09, 2007 at 06:23:33PM -0500, Nick Mathewson wrote: > On Fri, Nov 09, 2007 at 06:27:04AM -0800, Christopher Layne wrote: > > [ Warning: this is long and detailed, but includes details of a present > > bug in libevent. ] > > > Hi, Christopher! This all see

Re: [Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

2007-11-09 Thread Christopher Layne
On Fri, Nov 09, 2007 at 04:38:43PM -0800, Scott Lamb wrote: > >Fix in same, or sweep up in a later patch? How many other places are > >there where we're not currently checking the return value of > >event_add()? If there are more than this, we might as well just do it > >separately. > > > >-cl > >

Re: [Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

2007-11-09 Thread Christopher Layne
On Fri, Nov 09, 2007 at 04:03:46PM -0800, Scott Lamb wrote: > Christopher Layne wrote: > >+/* save previous handler setup */ > >+if (sigaction(evsignal, NULL, sig->sa_old[evsignal]) == -1 > >+|| sigaction(evsignal, &sa, NULL) == -1) > > Not wo

[Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

2007-11-09 Thread Christopher Layne
[ Warning: this is long and detailed, but includes details of a present bug in libevent. ] While building libevent with -W -Wall -pedantic, I came across this: signal.c: In function 'evsignal_del': signal.c:162: warning: ISO C forbids conversion of function pointer to object pointer type Which

[Libevent-users] [PATCH] epoll.c: epoll_dispatch() clarity/simplification/branch reduction cleanups

2007-11-09 Thread Christopher Layne
Regress checks out OK with both -O0 and -Os. Both size are with -O0. $ size .libs/libevent-1.4.so.2 textdata bss dec hex filename 9373510887084 101907 18e13 .libs/libevent-1.4.so.2 $ size .libs/libevent-1.4.so.2 textdata bss dec hex filename 93

Re: [Libevent-users] [OT] craigslist: libevent programmer wanted

2007-11-08 Thread Christopher Layne
On Thu, Nov 08, 2007 at 08:11:55AM -0800, Garth Patil wrote: > http://sfbay.craigslist.org/pen/cpg/472325599.html > > libevent programmer wanted (san mateo) > - NOT BLOCK ON ANY STEP close() can block. *boom tsst*. -cl ___ Libevent-users mailing list L

Re: [Libevent-users] [UPDATE] Using the sourceforge.net bugtracker.

2007-11-05 Thread Christopher Layne
On Tue, Nov 06, 2007 at 02:05:30AM -0500, Nick Mathewson wrote: > Update: I have added 2 patches, 10 feature requests, and 12 bug > reports to the tracker. I re-read or skimmed about 500 emails to do > this, so it is likely I missed something, or added a bug that has > already been fixed. My apol

Re: [Libevent-users] announcing libev, towards a faster and more featureful libevent

2007-11-04 Thread Christopher Layne
On Sun, Nov 04, 2007 at 09:37:52PM -0800, Scott Lamb wrote: > For this program, it's important to know more than that an error has > occurred. EV_ERROR is totally inadequate. You're using it for several > different cases. I spotted at least these three: > > * malloc() failed in ev_once - transient

Re: [Libevent-users] sensible thread-safe signal handling proposal

2007-11-04 Thread Christopher Layne
On Sun, Nov 04, 2007 at 04:23:01PM -0800, Scott Lamb wrote: > > It wasn't what I expected; I was fully confident at first that the > > thread-pool, work-queue model would be the way to go, since it's one > > I've implemented in many applications in the past. But the numbers said > > otherwise. > >

Re: [Libevent-users] announcing libev, towards a faster and more featureful libevent

2007-11-04 Thread Christopher Layne
On Mon, Nov 05, 2007 at 02:46:36AM +0100, Marc Lehmann wrote: > On Sun, Nov 04, 2007 at 04:09:08PM -0800, Scott Lamb <[EMAIL PROTECTED]> > wrote: > > Have you seen the new Linux timerfd API? Where available, you can wait > > for CLOCK_MONOTONIC and CLOCK_REALTIME events independently. Beats > > he

Re: [Libevent-users] announcing libev, towards a faster and more featureful libevent

2007-11-04 Thread Christopher Layne
On Mon, Nov 05, 2007 at 02:42:16AM +0100, Marc Lehmann wrote: > On Sun, Nov 04, 2007 at 05:19:36PM -0800, Christopher Layne <[EMAIL > PROTECTED]> wrote: > > Not to put on my O-face, but binary heap insert is *average* O(1). There > > should be a performance win for li

Re: [Libevent-users] announcing libev, towards a faster and more featureful libevent

2007-11-04 Thread Christopher Layne
On Sun, Nov 04, 2007 at 05:04:25PM -0800, Scott Lamb wrote: > > * timers are managed by a priority queue (O(1) for important operations > > as opposed to O(log n) in libevent, also resulting in much simpler code). > > In terms of concrete data types, you appear to have used a binary heap? > So b

Re: [Libevent-users] sensible thread-safe signal handling proposal

2007-11-04 Thread Christopher Layne
On Sun, Nov 04, 2007 at 12:15:56PM -0800, Steven Grimm wrote: > On Nov 4, 2007, at 8:13 AM, Marc Lehmann wrote: > >This would create additional loops (event_bases). The difference is > >that > >these cannot handle signals (or child watchers) at all, with the > >default loop > >being the only on

Re: [Libevent-users] [PATCH] TAILQ_ENTRY missing in evhttp.h on linux

2007-11-03 Thread Christopher Layne
On Sat, Nov 03, 2007 at 05:53:42PM -0700, Niels Provos wrote: > Well, Rob Pike has many great insights. He also does not like > conditional compilation. However, you are right, evhttp.h could > resolve the dependency on queue.h internally. I will look into it. Agreed, Rob Pike is true blue - an

Re: [Libevent-users] [PATCH] TAILQ_ENTRY missing in evhttp.h on linux

2007-11-03 Thread Christopher Layne
On Sat, Nov 03, 2007 at 04:56:07PM -0700, Niels Provos wrote: > Try > > #include > > before including evhttp.h > > Niels. Why is this a usercode issue? Shouldn't evhttp.h be more interested in handling it's dependencies than non-event parent code? It's similar to the being a usercode, but eve

Re: [Libevent-users] [PATCH] Add autoconf/make functionality for --disable-dns, --disable-http, and --disable-bevents

2007-09-27 Thread Christopher Layne
On Thu, Sep 27, 2007 at 08:31:32AM -0700, Niels Provos wrote: > Hi Christopher, > > I am not sure if this is necessarily the right way to go for a > library, esp if it can impact backwards compatibility for > bufferevents. As for reducing the size of the library, do you really > think that 30K ma

[Libevent-users] [PATCH] Add autoconf/make functionality for --disable-dns, --disable-http, and --disable-bevents

2007-09-26 Thread Christopher Layne
$ ./configure --help [...] Optional Features: [...] --enable-dnsbuild with support for dns layer [default=yes] --enable-http build with support for http layer [default=yes] --enable-beventsbuild with support for buffer events [default=yes] Changes: 1. This requ

[Libevent-users] [PATCH] libevent/event.3: small cleanup and additional notes

2007-09-26 Thread Christopher Layne
It's really difficult to have a diff explain manpage changes due to the nature of ROFF markup, etc. Positional changes: Moved the opening paragraphs about signal specific issues to right under the signal_add(), signal_set() section, since they're related. Moved the opening paragraphs about event_

Re: [Libevent-users] [PATCH] Do not call gettime in timeout_process if the timetree is empty

2007-09-20 Thread Christopher Layne
On Thu, Sep 20, 2007 at 01:52:31PM +0200, Trond Norbye wrote: > The result of gettime is not used if the timetree is empty (and might > cause a context switch to get the system clock). > > --Trond > Index: event.c > === > --- event.

Re: [Libevent-users] event_add() failure return handling

2007-09-18 Thread Christopher Layne
On Tue, Sep 18, 2007 at 10:10:42PM -0500, M.H.VanLeeuwen wrote: > Hi, > > When event_add(&ev, &tv) returns -1, what is the proper way to clean up. > > For example function XYZZY() takes socket fd as an argument > > XYZZY(int sockfd) > { > allocate event structure related memory... > ... >

[Libevent-users] [PATCH] test/Makefile.am: Correct a relative path issue

2007-09-18 Thread Christopher Layne
1. event_rpcgen.py will fail to open regress.rpc if building outside the source directory. -cl -- Index: Makefile.am === --- Makefile.am (revision 433) +++ Makefile.am (working copy) @@ -18,7 +18,7 @@ bench_SOURCES = bench.c reg

[Libevent-users] [PATCH] Alter output of test/bench and add option flags

2007-09-18 Thread Christopher Layne
1. Change output to provide a single line pct done + avg/min/max. 2. Add "-l" flag to support previous style. 3. Add "-x n" flag to specify max loop iterations. In a nutshell, output looks like this: $ debug/test/bench -x 8192 done avg min max 17% 942

[Libevent-users] [PATCH] http.c build errors and a segfault (USE_DEBUG only)

2007-09-15 Thread Christopher Layne
Compilation errors in http.c and a segfault during "make verify" when USE_DEBUG is defined. Index: libevent/http.c === --- libevent/http.c (revision 429) +++ libevent/http.c (working copy) @@ -1174,7 +1174,7 @@ if (str

Re: [Libevent-users] [PATCH] initialize ev_res

2007-08-04 Thread Christopher Layne
On Sat, Aug 04, 2007 at 07:21:46PM -0700, Scott Lamb wrote: > Christopher Layne wrote: > >On Thu, Jul 19, 2007 at 01:14:58PM -0700, Scott Lamb wrote: > >>When I use "valgrind --tool=memcheck" on a libevent-based program, it > >>gives the following complaint: &

Re: [Libevent-users] [PATCH] initialize ev_res

2007-08-04 Thread Christopher Layne
On Thu, Jul 19, 2007 at 01:14:58PM -0700, Scott Lamb wrote: > When I use "valgrind --tool=memcheck" on a libevent-based program, it > gives the following complaint: > > ==15442== Conditional jump or move depends on uninitialised value(s) > ==15442==at 0x4C0F2D3: event_add (event.c:632) > ==154

[Libevent-users] event.c:673 failed assertion

2007-06-01 Thread Christopher Layne
recv timeout, event == 1, 3, 0 ^ From my own code, just debugging data, but pertinent in that it was just a timeout event which was received. Since it seems one cannot have a persistent time out event with a relative timeout (mentioned previously) - I always delete and re-add the specific receiv

Re: [Libevent-users] EV_PERSIST behavior

2007-05-08 Thread Christopher Layne
On Tue, May 08, 2007 at 06:38:51PM -0700, William Ahern wrote: > > received a non-timeout event. In a way this is absolute, not in the epoch > > sense, but that it's tied to the time event_add() was called and not > > relative > > to when the last valid event was received. > > That may or may not

Re: [Libevent-users] EV_PERSIST behavior

2007-05-08 Thread Christopher Layne
On Tue, May 08, 2007 at 02:03:17PM -0700, Niels Provos wrote: > On 5/8/07, Phil Oleson <[EMAIL PROTECTED]> wrote: > >So.. To fix your implementation you will need to do something like I did. > >I reimplemented libevents' gettime() function (because it's not exposed > >via event.h) and use it inste

[Libevent-users] EV_PERSIST behavior

2007-05-08 Thread Christopher Layne
I understand that EV_PERSIST basically means that one does not have to continually reschedule the event upon the event occuring. Consider the following simple test case and my following question on it... #include #include #include #include #include #include int pfd[2]; int persist[2]; stru