On linux the processes are canceled and detached.
This leads to possible segmentation faults, because
the ControlPoint can be destroyed, although threads
are trying to call functions on the ControlPoint
object. This bug is really severe as other upnp
ControlPoints and/or Devices which are still running
in the network could segfault or hang too.
To have the same behaviour as on (e.g.) windows. The
thread needs to be created as joinable and
cancel_deferred and on stop "pthread_join" needs to
be called to wait for the termination of the thread.
Additionally the attached patch disables the
multithreaded HTTPServer as these threads are never
stopped and could possibly produce other segmentation
faults. It should be sufficient to only have one
thread which waits for incoming udp requests. This
would also be preferred on embedded systems as it
reduces the complexity of the whole system.
The patch which is attached does the following:
- on stop wait until all threads are canceled
- make HTTPServer single threaded
One problem that exists (at least on my computer) is,
that the SSDPNotifierSocket doesn't cancel on
receive(...) although recvfrom is a cancelation point
in pthread.
Roland Moser
Threading patch to avoid segmentation faults and hangs on shutdown