On Fri, Mar 6, 2009 at 09:16, Brian <ping...@gmail.com> wrote:
> Thanks Guillaume for the feedback. Unfortunately malloc/calloc method
> didn't work for me. I think I will just go back to how it was. Does
> anyone know if there is an inherent flaw, perhaps, with doing the
> event_init()/event_dispatch() within a posix thread?
>
> -brian

There are two things terribly wrong with what you're trying to do
here. First, you're having libevent access freed memory by giving it
pointers to freed stack variables as Guillaume said. The event struct
is added directly to libevent's internal structures; it is not copied
in any way. You *must* ensure that event structs do not go out of
scope when they're still being used.

Second, you're calling event_add from one thread while event_dispatch
is running in another. Things may have changed, but last I checked
libevent was not thread-safe in this manner and only supported having
multiple event queues, one for each thread, with add/del being done
only from the same thread event_base_dispatch was running in.

Matt
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to