12 Commits

Author SHA1 Message Date
木头云
2593213d9c Fix FreeBSD shm_unlink failure by adding '/' prefix in remove()
Problem: Tests fail on the second run on FreeBSD with ShmTest.RemoveByName failing.
After the first test run completes, subsequent runs fail because shared memory
objects are not properly removed.

Root cause: FreeBSD's shm_unlink() is stricter than Linux about POSIX compliance.
The remove(char const * name) function was calling shm_unlink() without the '/'
prefix, while acquire() was using '/'+name format. This inconsistency caused:
- Linux: Silently tolerates both /name and name formats
- FreeBSD: Strictly requires /name format, shm_unlink("name") fails

When shm_unlink() fails to remove the shared memory object:
1. First test run creates /remove_by_name_test_1
2. Test calls shm::remove("remove_by_name_test_1")
3. shm_unlink("remove_by_name_test_1") fails on FreeBSD (missing '/')
4. Shared memory object remains in the system
5. Second test run tries to reuse the same name -> conflict -> test fails

Solution:
1. Fix remove(char const * name) to prepend '/' to the name for consistency
   with acquire() function, ensuring POSIX compliance
2. Add error checking for all shm_unlink() calls to log failures with errno

This ensures proper cleanup on FreeBSD and maintains compatibility with Linux.

Changes:
- Modified remove(char const * name) to use '/'+name format
- Added error logging for all three shm_unlink() calls
- Now consistent with POSIX requirement: shared memory names must be /somename

Tested on FreeBSD 15: Multiple consecutive test runs now pass without failures.
2025-12-06 07:20:33 +00:00
Aengus.Jiang
06d4aec320 posix shm open 失败时如果文件不存在打印log #2 修改逻辑错误 2025-03-07 12:33:42 +08:00
Aengus.Jiang
d69093462a open的时候不存在共享内存,则返回false,没有必要报错 2025-03-07 11:36:57 +08:00
mutouyun
2673453e66 Try to fix permission issues under linux 2024-12-01 21:06:06 +08:00
mutouyun
84bb801b6e Try to fix a communication problem caused by different permissions under linux 2024-12-01 19:53:40 +08:00
mutouyun
e1f377d7f6 Added a cleanup interface for the synchronization facilities 2024-11-17 17:39:03 +08:00
mutouyun
5071fb5db6 Added a cleanup interface for shared memory handles 2024-11-17 17:35:29 +08:00
mutouyun
fafa5e85f7 Fixed memory access exception in multithreading. 2023-10-28 16:44:16 +08:00
mutouyun
c74f78ea08 统一字符串有效性判断 2023-10-28 16:44:16 +08:00
mutouyun
fab3f6fffe Add a user interface with a custom name prefix. 2023-10-28 16:44:16 +08:00
mutouyun
22a253a72f Supplement similar demo under linux. 2023-10-28 16:44:16 +08:00
mutouyun
2e35ab7685 Added QNX support 2022-01-02 17:54:07 +08:00