[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] pthread adds a socket to libevent but exits - undefined behavior ?



Hello,

I am trying to understand some legacy code, which is mostly single
thread libevent based, there are some cases where pthreads are spawned
and die out instantly. The scenario is

pthread_create
  --> thread_callback
    --> In thread callback, create fd; event_new( ..cbk, &fd) -> uses
evbase of main
    <thread ends>
 cbk() gets called and fd is used.

But is this correct ? or just works because of undefined behavior ?
The thread need not be present when the event callback is invoked ?
(since the fd was created in thread context)

P.S. libevent is initialised with evthread_use_pthreads()  and linked
with libevent_pthreads
--
Ani
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.