Closed
Description
Hi All,
We are observing an issue where in sockets created in child process do not work after forking.
Below is the sequence of code and I have also attached test code that reproduces issue and as well as working code:
- Our design has a server which listens to multiple clients and responds
- Clients uses wrapper API (example : test_tx_rx()) that exchanges messages with server
- the issue observed when a client calls test_tx_rx() from parent and then fork and if you call test_tx_rx() from child it fails to communicate with server
- The fix is to call zsys_shutdown() from child to clean up all initialization done by parent and assume that ZSYS is already initialized. However, as part of this fix we also noticed that there is a mutex that should be re-initialized to avoid deadlock. Hence, we are also attaching a patch that defines new API for re-initializing the mutex.
Please let us know if the patch is valid or how to avoid deadlock in case if the parents threads are accessing the mutex at the same when child is clearing mutex in zsys_shutdown().
Thanks,
Santosh Bidaralli