How to create client in child thread

Pekka Paalanen ppaalanen at gmail.com
Fri Jun 24 08:45:39 UTC 2016


On Fri, 24 Jun 2016 11:15:32 +0800 (CST)
袁嘉伟 <yuanjw1025 at 163.com> wrote:

> 在 2016-06-23 21:13:28,"Pekka Paalanen" <ppaalanen at gmail.com> 写道:

> >Hi,
> >
> >sorry, but I can't make sense from the spaghetti above, nor do I have
> >time to debug your application for you, especially when it has huge
> >parts outside of my expertise (everything about SurfaceManager). If you
> >can create a stand-alone C program that shows the problem, then it
> >might be possible to take a look, but no promises.
> >
> >Also signals will be delivered to random threads unless you
> >specifically block them.
> >
> >I have no idea why wl_display_connect() from a secondary thread would
> >block.
> >
> >
> >Thanks,
> >pq
> 
> Hi:
> I have created a stand-alone C program, which could show the problem.
> It was blocked in wl_display_dispatch this time.I was very helpless.
> I hope you might take a look if you have time. 

Hi,

I could only take a very quick peek for now, but this look a bit
odd to me, as your main() is:

int
main(int argc, char **argv)
{
    pthread_t lifeThread;
    pthread_create(&lifeThread, NULL, &renderFrames, NULL);

    return 0;
}

You are not waiting for the thread to finish, or even to start,
before you already return from main(). pthread_create() manual says:

       The new thread terminates in one of the following ways:
...
       * Any of the threads in the process calls exit(3), or the  main  thread
         performs  a  return  from main().  This causes the termination of all
         threads in the process.

So in that light, your program should just quit and not really do
anything. The strange thing is that the thread does not seem to get
terminated, but maybe that is because it is blocked in a polling
call.

Could you fix it to wait for the thread to finish before returning
from main()?


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160624/c70e1fa9/attachment.sig>


More information about the wayland-devel mailing list