MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / frontend_eof_writer

Function frontend_eof_writer

tests/test_daemon_frontend.c:248–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248static void *frontend_eof_writer(void *opaque) {
249 frontend_eof_writer_t *writer = opaque;
250 static const char first[] =
251 "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"test/block\",\"params\":{}}\n";
252 bool ok = frontend_eof_write_all(writer->fd, first, sizeof(first) - 1);
253 uint64_t deadline = cbm_now_ms() + FRONTEND_EOF_TEST_REQUEST_TIMEOUT_MS;
254 while (
255 ok &&
256 !atomic_load_explicit(&writer->application->first_request_started, memory_order_acquire) &&
257 cbm_now_ms() < deadline) {
258 cbm_usleep(1000);
259 }
260 ok = ok &&
261 atomic_load_explicit(&writer->application->first_request_started, memory_order_acquire);
262 for (int index = 0; ok && writer->overflow && index < FRONTEND_EOF_TEST_OVERFLOW_MESSAGES;
263 index++) {
264 char message[160];
265 int written =
266 snprintf(message, sizeof(message),
267 "{\"jsonrpc\":\"2.0\",\"id\":%d,\"method\":\"test/queued\",\"params\":{}}\n",
268 index + 2);
269 ok = written > 0 && written < (int)sizeof(message) &&
270 frontend_eof_write_all(writer->fd, message, (size_t)written);
271 }
272 ok = close(writer->fd) == 0 && ok;
273 writer->fd = -1;
274 atomic_store_explicit(&writer->succeeded, ok, memory_order_release);
275 atomic_store_explicit(&writer->finished, true, memory_order_release);
276 return NULL;
277}
278
279static bool frontend_eof_fixture_start(frontend_eof_fixture_t *fixture, const char *parent) {
280 memset(fixture, 0, sizeof(*fixture));

Callers

nothing calls this directly

Calls 2

frontend_eof_write_allFunction · 0.85
cbm_now_msFunction · 0.85

Tested by

no test coverage detected