Skip to content
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

SystemRegistry bug #21

Closed
kingoflolz opened this issue Nov 20, 2017 · 2 comments · Fixed by #22
Closed

SystemRegistry bug #21

kingoflolz opened this issue Nov 20, 2017 · 2 comments · Fixed by #22

Comments

@kingoflolz
Copy link
Member

Hi,

I think I found a bug in the SystemRegistry, it does not actually write to the hashmap when it creates a service, thus every time a service is looked up, a new one is created.

I have attached a patched version of this function below:

    pub fn get<A: SystemService + Actor<Context=Context<A>>>(&self) -> SyncAddress<A> {
        if let Ok(hm) = self.registry.lock() {
            if let Some(addr) = hm.borrow().get(&TypeId::of::<A>()) {
                match addr.downcast_ref::<SyncAddress<A>>() {
                    Some(addr) =>{
                        return addr.clone()},
                    None =>
                        error!("Got unknown value: {:?}", addr),
                }
            }
            let addr = Supervisor::start_in(Arbiter::system_arbiter(), false, |ctx| {
                let mut act = A::default();
                act.service_started(ctx);
                act
            });
            hm.borrow_mut().insert(TypeId::of::<A>(), Box::new(addr.clone().unwrap()));
            return addr.expect("System is dead")
        }
        panic!("System registry lock is poisoned");
    }
@fafhrd91
Copy link
Member

Could you create PR

@kingoflolz
Copy link
Member Author

Sure, I'll do that later today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants