from trunk: remove pending timeouts on event_base_free

svn:r628
This commit is contained in:
Niels Provos 2008-01-26 07:34:47 +00:00
parent 149c5b4306
commit d5aeeca0e8
3 changed files with 37 additions and 2 deletions

View File

@ -22,7 +22,7 @@ Changes in 1.4.1-beta:
o When building with GCC, use the "format" attribute to verify type correctness of calls to printf-like functions.
o removed linger from http server socket; reported by Ilya Martynov
o Rewrite win32.c backend to be O(n lg n) rather than O(n^2)
o remove pending timeouts on event_base_free()
Changes in 1.4.0-beta:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.

View File

@ -229,6 +229,11 @@ event_base_free(struct event_base *base)
}
ev = next;
}
while ((ev = min_heap_top(&base->timeheap)) != NULL) {
event_del(ev);
++n_deleted;
}
if (n_deleted)
event_debug(("%s: %d events were still set in base",
__func__, n_deleted));
@ -236,8 +241,9 @@ event_base_free(struct event_base *base)
if (base->evsel->dealloc != NULL)
base->evsel->dealloc(base, base->evbase);
for (i=0; i < base->nactivequeues; ++i)
for (i = 0; i < base->nactivequeues; ++i)
assert(TAILQ_EMPTY(base->activequeues[i]));
assert(min_heap_empty(&base->timeheap));
min_heap_dtor(&base->timeheap);

View File

@ -770,6 +770,33 @@ test_loopexit(void)
cleanup_test();
}
static void
test_loopexit_multiple(void)
{
struct timeval tv;
struct event_base *base;
setup_test("Loop Multiple exit: ");
base = event_base_new();
tv.tv_usec = 0;
tv.tv_sec = 1;
event_base_loopexit(base, &tv);
tv.tv_usec = 0;
tv.tv_sec = 2;
event_base_loopexit(base, &tv);
event_base_dispatch(base);
event_base_free(base);
test_ok = 1;
cleanup_test();
}
static void
break_cb(int fd, short events, void *arg)
{
@ -1369,6 +1396,8 @@ main (int argc, char **argv)
test_loopexit();
test_loopbreak();
test_loopexit_multiple();
test_multiple_events_for_same_fd();
test_want_only_once();