Repository: actix/actix (language: rust)

Issue:
SystemRegistry bug
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:
```rust
    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");
    }
```




Discussion / hints:
Could you create PR
Sure, I'll do that later today

Fix patch:
diff --git a/src/registry.rs b/src/registry.rs
index e205ab9a1..7c07d601e 100644
--- a/src/registry.rs
+++ b/src/registry.rs
@@ -146,19 +146,19 @@ impl SystemRegistry {
         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(),
+                    Some(addr) =>{
+                        return addr.clone()},
                     None =>
                         error!("Got unknown value: {:?}", addr),
                 }
-            } else {
-                let addr = Supervisor::start_in(Arbiter::system_arbiter(), false, |ctx| {
-                    let mut act = A::default();
-                    act.service_started(ctx);
-                    act
-                });
-                return addr.expect("System is dead");
             }
+            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");
     }


Test patch: