Discussion:
Are event_base's reference counted?
(too old to reply)
Jeffrey Walton
2014-02-25 02:02:28 UTC
Permalink
Raw Message
I'm experimenting with timers. In the timer callback, I perform the
following (to exit after a few callbacks):

void timeout_cb(evutil_socket_t fd, short events, void *arg) {

static int count = 0;
int rc;

event* timer = (event *) arg;
AC_ASSERT(timer != NULL);
if (timer == NULL) return;

struct timeval tv = { WATCHDOG_TIMER_SECONDS, 0 };
rc = event_add(timer, &tv);
AC_ASSERT(rc == 0);

count++;
if (count == 3) {
event_base* base = NULL;
event_get_assignment(timer, &base, NULL, NULL, NULL, NULL);

if (base) {
struct timeval delay = { 1, 0 };
rc = event_base_loopexit(base, &delay);
AC_ASSERT(rc == 0);
}
}
}

Do I need to call event_base_free on the base returned from
event_get_assignment? The docs on event_get_assignment don't say what
needs to be done.
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Nick Mathewson
2014-02-25 15:10:52 UTC
Permalink
Raw Message
Post by Jeffrey Walton
I'm experimenting with timers. In the timer callback, I perform the
event_base objects are not reference-counted. You generally don't
free one until you're shutting down the whole event loop permanently.
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Loading...