There is a potential race between the callback thread and the main test
thread when switching between asynchronous and synchronous modes.
The vchi_clnt_callback function tries to rapidly swallow zero-length
pong packets in asynchronous mode by looping in the callback until the
message queue is emptied. There is a danger that if the main test thread
switches to synchronous mode before the callback thread notices the
queue is empty that the callback thread will erroneously receive the
synchronous pong packet.
Remove the race by forcing the callback thread to leave dequeue loop
when a sync point (non-zero length reply) is received.
See: https://github.com/raspberrypi/linux/pull/1717
if (actual > 1)
g_server_error = pong_buf;
if (actual != 0)
+ {
/* Responses of length 0 are not sync points */
vcos_event_signal(&g_server_reply);
+ break;
+ }
}
}
}