| 416 | } |
| 417 | |
| 418 | static void *frontend_eof_writer(void *opaque) { |
| 419 | frontend_eof_writer_t *writer = opaque; |
| 420 | static const char first[] = |
| 421 | "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"test/block\",\"params\":{}}\n"; |
| 422 | bool ok = frontend_eof_write_all(writer->fd, first, sizeof(first) - 1); |
| 423 | uint64_t deadline = cbm_now_ms() + FRONTEND_EOF_TEST_REQUEST_TIMEOUT_MS; |
| 424 | while ( |
| 425 | ok && |
| 426 | !atomic_load_explicit(&writer->application->first_request_started, memory_order_acquire) && |
| 427 | cbm_now_ms() < deadline) { |
| 428 | cbm_usleep(1000); |
| 429 | } |
| 430 | ok = ok && |
| 431 | atomic_load_explicit(&writer->application->first_request_started, memory_order_acquire); |
| 432 | for (int index = 0; ok && writer->overflow && index < FRONTEND_EOF_TEST_OVERFLOW_MESSAGES; |
| 433 | index++) { |
| 434 | char message[160]; |
| 435 | int written = |
| 436 | snprintf(message, sizeof(message), |
| 437 | "{\"jsonrpc\":\"2.0\",\"id\":%d,\"method\":\"test/queued\",\"params\":{}}\n", |
| 438 | index + 2); |
| 439 | ok = written > 0 && written < (int)sizeof(message) && |
| 440 | frontend_eof_write_all(writer->fd, message, (size_t)written); |
| 441 | } |
| 442 | ok = close(writer->fd) == 0 && ok; |
| 443 | writer->fd = -1; |
| 444 | if (writer->overflow) { |
| 445 | /* Everything — 32 over-capacity frames AND the EOF behind them — is now |
| 446 | * committed to the pipe. Only now release the held first request: the |
| 447 | * queue was provably full while it blocked, so the drain that follows |
| 448 | * exercises enqueue-wait, not a conveniently fast worker. */ |
| 449 | atomic_store_explicit(&writer->application->release_first_request, true, |
| 450 | memory_order_release); |
| 451 | } |
| 452 | atomic_store_explicit(&writer->succeeded, ok, memory_order_release); |
| 453 | atomic_store_explicit(&writer->finished, true, memory_order_release); |
| 454 | return NULL; |
| 455 | } |
| 456 | |
| 457 | static bool frontend_eof_fixture_start(frontend_eof_fixture_t *fixture, const char *parent) { |
| 458 | memset(fixture, 0, sizeof(*fixture)); |
nothing calls this directly
no test coverage detected