| 507 | } platform_mkdtemp_worker_t; |
| 508 | |
| 509 | static void *platform_mkdtemp_concurrent_worker(void *opaque) { |
| 510 | platform_mkdtemp_worker_t *worker = opaque; |
| 511 | (void)atomic_fetch_add_explicit(worker->ready, 1, memory_order_acq_rel); |
| 512 | while (!atomic_load_explicit(worker->go, memory_order_acquire)) { |
| 513 | atomic_signal_fence(memory_order_seq_cst); |
| 514 | } |
| 515 | worker->ok = true; |
| 516 | for (int index = 0; index < PLATFORM_MKDTEMP_ITERATIONS; index++) { |
| 517 | int written = |
| 518 | snprintf(worker->paths[index], sizeof(worker->paths[index]), |
| 519 | "/tmp/cbm-mkdtemp-concurrent-%d-%d-XXXXXX", worker->worker_index, index); |
| 520 | if (written <= 0 || written >= (int)sizeof(worker->paths[index]) || |
| 521 | !cbm_mkdtemp(worker->paths[index])) { |
| 522 | worker->ok = false; |
| 523 | break; |
| 524 | } |
| 525 | worker->created++; |
| 526 | } |
| 527 | return NULL; |
| 528 | } |
| 529 | |
| 530 | /* MCP daemon sessions can enter cbm_mkdtemp simultaneously. Every request must |
| 531 | * retain its own expanded path and create a distinct directory. */ |
nothing calls this directly
no test coverage detected