wifihal: Fix SIGPIPE when stopHal calls writing into exit sockets
This SIGPIPE happens when stopHAL, and two threads are doing below:
- THREAD_1: WifiLegacyHal::stop -> wifi_cleanup()
- THREAD_2: WifiLegacyHal::runEventLoop() -> wifi_event_loop()
With below sequence, SIGPIPE may happen.
- wifi_cleanup() sets info->clean_up to true.
- wifi_event_loop() poll unblocked by driver event, and exit due to
info->clean_up to true, then close the exit_sockets.
- wifi_cleanup() write an āEā to exit_sockets[0] triggers SIGPIPE.
Enhance the stopHAL callflow:
- wifi_cleanup() writes an 'E' to exit_sockets and wait for
wifi_event_loop() to exit.
- wifi_event_loop() on recv 'E' echo 'S' as a reply, then exits.
- wifi_cleanup() sets info->clean_up=true to ensure wifi_event_loop()
can be terminated, then close the exit_sockets.
CRs-Fixed: 2404562
Change-Id: I4d321b59d53459c3c62db9c025a5de5568aeb4ec
1 file changed