-
Notifications
You must be signed in to change notification settings - Fork 5
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
Why the port must be dropped when the context is dropped? #48
Comments
What I understand is that changing the signature of // Before
pub trait Port: std::fmt::Debug + Send + Sync + 'static {
fn call(&self, packet: PacketView) -> Packet;
fn delete_request(&self, id: ServiceObjectId);
fn register(&self, service_object: Arc<dyn Dispatch>) -> HandleToExchange;
}
// After
pub trait Port: std::fmt::Debug + Send + Sync + 'static {
// Return Error if port is shutdown
fn call(&self, packet: PacketView) -> Result<Packet>;
// Return Error if port is shutdown
fn delete_request(&self, id: ServiceObjectId) -> Result<()>;
// Return Error if port is shutdown
fn register(&self, service_object: Arc<dyn Dispatch>) -> Result<HandleToExchange>;
} It looks good to me. |
@majecty I think calling those methods for already shutdown port is a bug, not an error to handle. |
@junha1 I don't understand your opinion. |
@majecty I thought |
So the original shutdown code has the problem: |
@sgkim126 If such situation (other holders have not released) happens, it should be a bug. |
remote-trait-object/remote-trait-object/src/context.rs
Line 63 in 7ac07c7
Currently, it fails to drop the context when the port is still held by others. But, there is no way to guarantee whether all other holders released before the context dropped.
How about dropping context calls shutdown and making the methods of the
Port
returns aResult
?It also should make the shutdown of the
Port
takes the mutable reference of the self. It means the user can access the port after shutdown, but I think this would be safer.The text was updated successfully, but these errors were encountered: