summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/4a-hal-manager/4a-hal-manager.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/4a-hal-manager/4a-hal-manager.c b/src/4a-hal-manager/4a-hal-manager.c
index 383b920..d4dc813 100644
--- a/src/4a-hal-manager/4a-hal-manager.c
+++ b/src/4a-hal-manager/4a-hal-manager.c
@@ -23,6 +23,7 @@
#include <afb/afb-binding.h>
#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-hal-api-handler.h"
#include "../4a-internals-hal/4a-internals-hal-api-loader.h"
@@ -52,6 +53,10 @@ afb_verb_t HalManagerApiStaticVerbs[] =
static int HalMgrInitApi(afb_api_t apiHandle)
{
+ int err;
+
+ char *toDeleteApiName;
+
struct HalData *currentHalData;
struct HalMgrData *halMgrData;
@@ -69,8 +74,34 @@ static int HalMgrInitApi(afb_api_t apiHandle)
cds_list_for_each_entry(currentHalData, &halMgrData->halDataListHead, node) {
if(! currentHalData->apiName)
return -4;
- else if(afb_api_require_api(apiHandle, currentHalData->apiName, 1))
- return -5;
+
+ if(afb_api_require_api(apiHandle, currentHalData->apiName, 1)) {
+ AFB_API_ERROR(apiHandle,
+ "Error caught during '%s' api require, this api won't be reachable",
+ currentHalData->apiName);
+
+ toDeleteApiName = strdup(currentHalData->apiName);
+ if(! toDeleteApiName) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to store (allocate) 'apiName' string");
+ return -5;
+ }
+
+ err = HalUtlRemoveHalDataAndDeleteHalApi(apiHandle, currentHalData, &halMgrData->halDataListHead);
+ if(err) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i happened while trying to delete '%s' api and to remove all its data",
+ err,
+ toDeleteApiName);
+ free(toDeleteApiName);
+ return -6;
+ }
+
+ AFB_API_ERROR(apiHandle,
+ "Api '%s' and all its data has been deleted",
+ toDeleteApiName);
+
+ free(toDeleteApiName);
+ }
}
return 0;