[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] pthread adds a socket to libevent but exits - undefined behavior ?
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] pthread adds a socket to libevent but exits - undefined behavior ?
- From: Ani A <aniruddha.a@xxxxxxxxx>
- Date: Wed, 10 Apr 2019 13:53:21 +0530
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Wed, 10 Apr 2019 04:23:33 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=q7RgBWo8VieTa+7arRxgNy5DEGyAGxgUc+rv99CnfYU=; b=IZH7rKyKTjarwZCrHsmITXGv/SA2n6j6fB6hZv80yXLW0aiM9lsIf0X2O3Qq5frCnB e26oXKZnCuP8UJkUP/LNHnbMn5mwxGIAxgmpeYlbphHrd8YD6/2PaByPLCf8m+1wky4k ojWhz13901yEeDTt8NQEWgk1kP/CjtD31VnWaQQ0cEAMWCLk+rAITZef1kzf4ECiWgf+ Iwelzhk1b+yJm0qBSm3Rjq1igjtHqeqQoEfYA8g8dvmcY/WA4yX1NWFCuxwxEPJBOOgY Mi17ai1pskDOep5WMau1ij7xo/2ftQfbAXG3xmes+qUsrSmRicFnVLuZMlBTD5wnxajw 8rPA==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
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.