-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The semaphore posix wrapper should not be movable. #751
Comments
Actually, it is movable without moving the underlying Since the construction/destruction API of a named semaphore differs from the unnamed semaphore it may makes sense to split them into to abstractions. Semaphore and NamedSemaphore. |
This might work for move assignment but you still have the problem with the move ctor since the move-to |
I disagree, in the move ctor it is even easier. Here you just call |
I think copy is even more dangerous than a move. I would remove both of them like in the STL |
I agree with you but I really fear the smell of the mowed meadow. Maybe we need to tweak the creation pattern with this a bit. I am thinking of something like: cxx::optional<Semaphore> mySemaphore;
createSemaphore(mySemaphore).or_else([]{ /*...*/ }); Here we do not require move and the semaphore is initialized in place. What do you think @elBoberido |
I think this might be a viable option for some use cases. But then one needs to always call We might need two options. One where the Semaphore is created by its ctor and terminates if it fails, similar to the Mutex and one with the Another option would be to have a
but this is also cumbersome and requires relative pointer if placed in the shared memory |
The developer could also write At the moment I am playing with the thought to just remove the move operations from the semaphore and we do not work with
In all those error cases I don't think that it is useful that the user is informed about it. When the abstraction has a defect the user is screwed and cannot recover and this goes even more for a misconfigured or corrupted system. So we only work with @elBoberido or did I miss an error case where we actually require an |
the only thing I can currently think of is a failed |
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
…semaphore platform does not overflow Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
… to ensure type safety, fix gcc warning unused value Signed-off-by: Christian Eltzschig <me@elchris.org>
…ency reasons, fix issue in SignalWatcher test Signed-off-by: Christian Eltzschig <me@elchris.org>
…ignalWatcher made signal safe and added comments to explain signal safe nature Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
…nal handler Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
…struction Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
… that it can be used from within a signal handler Signed-off-by: Christian Eltzschig <me@elchris.org>
…semaphore in the signal watcher and the named pipe Signed-off-by: Christian Eltzschig <me@elchris.org>
…and use signal_watcher instead, use UnnamedSemaphore instead of Semaphore in NamedPipe, PeriodicTask, WatchDog, ConditionVariableData Signed-off-by: Christian Eltzschig <me@elchris.org>
…the tests for a more efficient busy loop Signed-off-by: Christian Eltzschig <me@elchris.org>
… dds gateway, replace semaphores in test with adaptive wait Signed-off-by: Christian Eltzschig <me@elchris.org>
… notes Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
… to ensure type safety, fix gcc warning unused value Signed-off-by: Christian Eltzschig <me@elchris.org>
…ency reasons, fix issue in SignalWatcher test Signed-off-by: Christian Eltzschig <me@elchris.org>
…ignalWatcher made signal safe and added comments to explain signal safe nature Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
…struction Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
…TERM Signed-off-by: Christian Eltzschig <me@elchris.org>
…TERM Signed-off-by: Christian Eltzschig <me@elchris.org>
…TERM Signed-off-by: Christian Eltzschig <me@elchris.org>
…TERM Signed-off-by: Christian Eltzschig <me@elchris.org>
… readability Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
…able in windows Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
…six-wrapper iox-#751: remove old semaphore posix wrapper
Required information
Observed result or behaviour:
According to the documentations:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09
https://pubs.opengroup.org/onlinepubs/009695399/functions/sem_open.html
The effect of referring to a copy of the object when locking, unlocking, or destroying it is undefined.
The move operations are copying the underlying
sem_t
handle which leads to undefined behavior. It is most likely that we did not encounter this issue since the move operation was optimized away with RTVO. But it can become a problemExpected result or behaviour:
All copy- and move-operations are deleted in
posix::Semaphore
.See also #1036
The text was updated successfully, but these errors were encountered: