Fix a possible hang in xdpsock that can occur when using multiple threads. In this case, one or more of the threads might get stuck in the while-loop in tx_only after the user has signaled the main thread to stop execution. In this case, no more Tx packets will be sent, so a thread might get stuck in the aforementioned while-loop. Fix this by introducing a test inside the while-loop to check if the benchmark has been terminated. If so, return from the function.
Showing the changes to samples (1 of 1 file). Show all
Unified · Split
| @@ -1275,6 +1275,8 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size) · 1274 unmodified lines | |||
| 1275 | while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) < | 1275 | while (xsk_ring_prod__reserve(&xsk->tx, batch_size, &idx) < |
| 1276 | batch_size) { | 1276 | batch_size) { |
| 1277 | complete_tx_only(xsk, batch_size); | 1277 | complete_tx_only(xsk, batch_size); |
| 1278 | if (benchmark_done) | ||
| 1279 | return; | ||
| 1278 | } | 1280 | } |
| 1279 | 1281 | ||
| 1280 | for (i = 0; i < batch_size; i++) { | 1282 | for (i = 0; i < batch_size; i++) { |