On Sat, 22 Apr 2006 14:04:48 -0700, "Niels Provos"
<[EMAIL PROTECTED]> said:
> Bug reports work the best if their are accompanied by patches and a
> unittest that proves them.

Ok, here they are.
Mind you, I have no idea what the contracts are with internal events,
so I have no idea whether this is a suitable patch or not.

--------- test-base_free.c ---------

#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include "event.h"

void write_handler(int fd, short evtype, void* arg) {
}

main() {
  void* base = event_init();
  struct timeval tv = {1, 0};
  struct event ev;

  event_set(&ev, 1, EV_WRITE|EV_PERSIST, write_handler, 0);
  event_add(&ev, &tv);
  event_dispatch();
  event_del(&ev);
  event_base_free((struct event_base*)base);
}

--------------- patch --------------

Index: event.c
===================================================================
RCS file: /cvsroot/levent/libevent/event.c,v
retrieving revision 1.49
diff -r1.49 event.c
210c210,222
<       assert(TAILQ_EMPTY(&base->eventqueue));
---
>
>       {
>         struct event* ev;
>         TAILQ_FOREACH(ev, &base->eventqueue, ev_next) {
>           if (ev->ev_flags & EVLIST_INTERNAL) {
>             event_msgx("still an internal event on the eventqueue");
>           }
>           else {
>             event_errx(1, "there is a non-internal event still in the 
> eventqueue");
>             assert(TAILQ_EMPTY(&base->eventqueue));
>           }
>         }
>       }


-mda


> On 4/22/06, Mark D. Anderson <[EMAIL PROTECTED]> wrote:
> > in event.c cvs, in event_base_free there is:
> >       assert(TAILQ_EMPTY(&base->eventqueue));
> >
> > this assert fails, because there is typically still the internal event
> > ev_signal from signal.c still on the queue.
> > Right now, there is nothing the outside programmer can do about that,
> > as far as i can see -- it is a file static variable, and the file
> > signal.c
> > never does anything but event_add on it, never event_del.
> >
> > -mda
> >
> > _______________________________________________
> > Libevent-users mailing list
> > Libevent-users@monkey.org
> > http://monkey.org/mailman/listinfo/libevent-users
> >
> >
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to