[Libwebsockets] possible to fork a process per connection (ws server)?

Andy Green andy at warmcat.com
Mon May 20 22:25:50 CEST 2019



On May 20, 2019 12:58:23 PM PDT, Dave Horton <daveh at beachdognet.com> wrote:
>Wondering if it is possible to have a ws server where I am able to fork
>a new process per incoming connection, and the service thread in that
>process takes over that connection.  I realize there are a lot of
>alternative ways of doing things, and I would not want to do it this
>way either, except that I have to process the incoming audio with a
>3rd-party library that is not thread-safe.  I’m afraid having a global
>mutex in a single multithreaded process would just slow everything down
>so for this need it would seem better if I could somehow fork
>processes..

Sure, you can do what you want once you have the thread.  Itbwouldn't 'take over' anything... the forked process would usually exec your application you want to run and the parent thread would continue monitoring the subprocess state and returning output etc.

But it's best if the thread / process does not 'go away' for the duration of the processing, but uses the 'checking in' stuff.  Otherwise it will always dumbly cokplete the work before discovering the wsi that's waiting on it went away a while ago.

-Andy

>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>https://libwebsockets.org/mailman/listinfo/libwebsockets


More information about the Libwebsockets mailing list