-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
When ev_signal is used, the assertion on line 220 fails on
event_base_free(). This is because the signal stuff is not dealloced.
Two solutions: remove that assertion (since the event that is not
removed is static in signal.c, there is no memory leak here) or use the
patch I have attached. The patch I attached also closes the pipe that
evsignal_init opened.
Hmm, ev_signal does not look at which event_base is used. Is that
threadsafe?
Best regards,
Wouter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFFx2NJkDLqNwOhpPgRAqM/AJ4hUuJAkaR5lcSXrl5jXRUQ12y0uQCfXpX3
f11V0I0NasvuBD4ti0x+DiI=
=wofl
-----END PGP SIGNATURE-----
Index: poll.c
===================================================================
--- poll.c (revision 319)
+++ poll.c (working copy)
@@ -383,6 +383,7 @@
{
struct pollop *pop = arg;
+ evsignal_dealloc();
if (pop->event_set)
free(pop->event_set);
if (pop->event_r_back)
Index: select.c
===================================================================
--- select.c (revision 319)
+++ select.c (working copy)
@@ -358,6 +358,7 @@
{
struct selectop *sop = arg;
+ evsignal_dealloc();
if (sop->event_readset_in)
free(sop->event_readset_in);
if (sop->event_writeset_in)
Index: devpoll.c
===================================================================
--- devpoll.c (revision 319)
+++ devpoll.c (working copy)
@@ -409,6 +409,7 @@
{
struct devpollop *devpollop = arg;
+ evsignal_dealloc();
if (devpollop->fds)
free(devpollop->fds);
if (devpollop->events)
Index: epoll.c
===================================================================
--- epoll.c (revision 319)
+++ epoll.c (working copy)
@@ -357,6 +357,7 @@
{
struct epollop *epollop = arg;
+ evsignal_dealloc();
if (epollop->fds)
free(epollop->fds);
if (epollop->events)
Index: evsignal.h
===================================================================
--- evsignal.h (revision 319)
+++ evsignal.h (working copy)
@@ -33,5 +33,6 @@
int evsignal_deliver(sigset_t *);
int evsignal_add(sigset_t *, struct event *);
int evsignal_del(sigset_t *, struct event *);
+void evsignal_dealloc(void);
#endif /* _EVSIGNAL_H_ */
Index: signal.c
===================================================================
--- signal.c (revision 319)
+++ signal.c (working copy)
@@ -47,6 +47,7 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include <assert.h>
#include "event.h"
#include "evsignal.h"
@@ -121,10 +122,6 @@
return (0);
}
-/*
- * Nothing to be done here.
- */
-
int
evsignal_del(sigset_t *evsigmask, struct event *ev)
{
@@ -210,3 +207,14 @@
evsignal_caught = 0;
}
+void
+evsignal_dealloc(void)
+{
+ if(ev_signal_added) {
+ event_del(&ev_signal);
+ ev_signal_added = 0;
+ }
+ assert(TAILQ_EMPTY(&signalqueue));
+ close(ev_signal_pair[0]);
+ close(ev_signal_pair[1]);
+}
Index: event.c
===================================================================
--- event.c (revision 319)
+++ event.c (working copy)
@@ -217,7 +217,6 @@
current_base = NULL;
assert(base);
- assert(TAILQ_EMPTY(&base->eventqueue));
for (i=0; i < base->nactivequeues; ++i)
assert(TAILQ_EMPTY(base->activequeues[i]));
@@ -229,6 +228,7 @@
if (base->evsel->dealloc != NULL)
base->evsel->dealloc(base->evbase);
+ assert(TAILQ_EMPTY(&base->eventqueue));
free(base);
}
_______________________________________________
Libevent-users mailing list
[email protected]
http://monkey.org/mailman/listinfo/libevent-users