]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - frsh_api/frsh_core.c
Destroy forb in the correct order
[frescor/frsh.git] / frsh_api / frsh_core.c
index 79012b1b833146920a3f33349616d90ecd8b84eb..1e17525f152f9aced0f34833df4e2e46ece28f82 100644 (file)
@@ -62,7 +62,7 @@
 #include "frsh_forb.h"
 #include <frsh_resources.h>
 
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
 #include <frsh_distributed.h>
 #endif
 
@@ -90,7 +90,7 @@ struct frsh_forb frsh_forb_global;
 
 static void *alloc_executor_thread(void *arg)
 {
-       return (void*)forb_executor_run(&frsh_forb_global.alloc_executor);
+       return (void*)(uintptr_t)forb_executor_run(&frsh_forb_global.alloc_executor);
 }
 
 
@@ -118,8 +118,9 @@ int frsh_init()
        ret = forb_executor_init(&frsh_forb_global.alloc_executor);
        if (ret) goto err;
 
-       fra_registry_init(frsh_forb_global.orb, frsh_forb_global.fcb,
-                         &frsh_forb_global.alloc_executor);
+       ret = fra_registry_init(frsh_forb_global.orb, frsh_forb_global.fcb,
+                               &frsh_forb_global.alloc_executor);
+       if (ret) goto err;
        
 #ifdef CONFIG_AQUOSA
        ret = aqcpu_fra_init();
@@ -139,7 +140,7 @@ int frsh_init()
        if (ret) goto err;
 #endif
 
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
        ret = frsh_distributed_init();
        if (ret) goto err;
 #endif
@@ -158,8 +159,31 @@ err:
        return ret;
 }
 
+void frsh_destroy()
+{
+       forb_destroy(frsh_forb_global.orb);
+       
+       pthread_cancel(frsh_forb_global.alloc_executor_thread.pthread_id);
+       pthread_join(frsh_forb_global.alloc_executor_thread.pthread_id, NULL);
+
+       /* TODO: Destroy all FRAs etc. */
+}
+
+
+
 bool frsh_config_is_admission_test_enabled()
 {
        return true;
 }
 
+frsh_resource_id_t frsh_get_local_cpu_id(void)
+{
+       long int ret =  FRSH_CPU_ID_DEFAULT;
+       if (getenv("FRSH_CPU_ID")) {
+               errno = 0;      /* See strtol(1) */
+               ret = strtol(getenv("FRSH_CPU_ID"), NULL, 10);
+               if (errno != 0)
+                       ret = FRSH_CPU_ID_DEFAULT;
+       }
+       return ret;
+}