cmcfarlen commented on code in PR #13658:
URL: https://github.com/apache/trafficserver/pull/13658#discussion_r3973697104
##########
src/iocore/cache/unit_tests/test_CacheShmShutdown.cc:
##########
@@ -48,14 +48,22 @@ namespace
{
// Our own prefix so these can never touch a real instance's segments, short
enough to stay under the 31-char POSIX limit.
-constexpr const char *TEST_PREFIX_WORD = "atsunittest";
+// Per process: POSIX shm names are system global and every TEST_CASE runs as
its own
+// ctest process, so a fixed word would let concurrent cases fight over one
segment.
+std::string const &
+test_prefix_word()
+{
+ static std::string const word{"atsunittest" + std::to_string(getpid())};
+ return word;
+}
Review Comment:
Adjusted in 0993e1446d, though the arithmetic worked out with room to spare
rather than overflowing.
The budget: `normalize_name_prefix()` plus `control_segment_name()` turn
`<word>` into `"/<word>-control"`, so `len(word) + 9` must be under
`MAX_SHM_NAME_LEN` (31) — i.e. `len(word) <= 21`.
| word | pid digits | control name | vs limit |
|---|---|---|---|
| `atsunittest` (11) | 5 (macOS) | 25 | ok |
| `atsunittest` (11) | 7 (Linux `PID_MAX_LIMIT` 4194304) | 27 | ok |
| `atspurgetest` (12) | 7 | 28 | ok, 2 to spare |
| `atspurgetest` (12) | 10 | 31 | would overflow |
So it fits on every platform that exists today, but two characters of
headroom is thinner than I'd like. Shortened to `atsunit`/`atspurge`, which
leaves 14 digits of pid room, and noted the budget next to each so the
constraint isn't just implicit.
One correction on the failure mode: it wouldn't be an `ENAMETOOLONG` from
`shm_open`. `CacheShm.cc:579` checks the derived length first and emits `"shm
name_prefix too long ...; shm disabled"` before setting `Mode::Disabled`, so an
overrun would surface as a loud test failure with that warning, not an
environment-dependent `shm_open` error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]