celix_status_t serviceRegistry_destroy(service_registry_pt registry) { hashMap_destroy(registry->inUseMap, false, false); hashMap_destroy(registry->serviceRegistrations, false, false); hashMap_destroy(registry->serviceReferences, false, false); arrayList_destroy(registry->listenerHooks); celixThreadMutex_destroy(®istry->mutex); celixThreadMutexAttr_destroy(®istry->mutexAttr); celixThreadMutex_destroy(®istry->referencesMapMutex); registry->framework = NULL; registry->inUseMap = NULL; registry->listenerHooks = NULL; registry->serviceChanged = NULL; registry->serviceReferences = NULL; registry->serviceRegistrations = NULL; free(registry); return CELIX_SUCCESS; }
celix_status_t configuration_create2(configuration_admin_factory_pt factory, configuration_store_pt store, properties_pt dictionary, configuration_pt *configuration) { configuration_pt config; configuration_impl_pt conf_impl; celix_thread_mutexattr_t mutex_attr; char *value; config = calloc(1, sizeof(struct configuration)); if (config == NULL) return CELIX_ENOMEM; conf_impl = calloc(1, sizeof(struct configuration_impl)); if (conf_impl == NULL) { free (config); return CELIX_ENOMEM; } config->configuration_delete = configuration_delete; config->configuration_equals = configuration_equals; config->configuration_getBundleLocation = configuration_getBundleLocation; config->configuration_getFactoryPid = configuration_getFactoryPid; config->configuration_getPid = configuration_getPid; config->configuration_getProperties = configuration_getProperties; config->configuration_hashCode = configuration_hashCode; config->configuration_setBundleLocation = configuration_setBundleLocation; config->configuration_update = configuration_update; conf_impl->configurationAdminFactory = factory; conf_impl->configurationStore = store; value = properties_get(dictionary,(char *)SERVICE_FACTORYPID); if (value != NULL) conf_impl->factoryPid = strdup(value); else conf_impl->factoryPid = NULL; value = properties_get(dictionary, (char *)OSGI_FRAMEWORK_SERVICE_PID); if (value != NULL) conf_impl->pid = strdup(value); else conf_impl->pid = NULL; value = properties_get(dictionary, (char *)SERVICE_BUNDLELOCATION); if (value != NULL) conf_impl->bundleLocation = strdup(value); else conf_impl->bundleLocation = NULL; conf_impl->dictionary = NULL; conf_impl->deleted = false; conf_impl->boundBundle = NULL; celixThreadMutexAttr_create(&mutex_attr); celixThreadMutexAttr_settype(&mutex_attr, CELIX_THREAD_MUTEX_RECURSIVE); // why recursive? if( celixThreadMutex_create(&conf_impl->mutex, &mutex_attr) != CELIX_SUCCESS ) { printf("[ ERROR ]: Configuration{PID=%s} - Not created (MUTEX) \n", conf_impl->pid); return CELIX_ILLEGAL_ARGUMENT; } celixThreadMutexAttr_destroy(&mutex_attr); configuration_updateDictionary(conf_impl, dictionary); conf_impl->configuration_interface = config; config->handle = conf_impl; *configuration = config; return CELIX_SUCCESS; }
celix_status_t pubsubAdmin_destroy(pubsub_admin_pt admin) { celix_status_t status = CELIX_SUCCESS; free(admin->ipAddress); celixThreadMutex_lock(&admin->pendingSubscriptionsLock); hash_map_iterator_pt iter = hashMapIterator_create(admin->pendingSubscriptions); while(hashMapIterator_hasNext(iter)){ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); free((char*)hashMapEntry_getKey(entry)); arrayList_destroy((array_list_pt)hashMapEntry_getValue(entry)); } hashMapIterator_destroy(iter); hashMap_destroy(admin->pendingSubscriptions,false,false); celixThreadMutex_unlock(&admin->pendingSubscriptionsLock); celixThreadMutex_lock(&admin->subscriptionsLock); hashMap_destroy(admin->subscriptions,false,false); celixThreadMutex_unlock(&admin->subscriptionsLock); celixThreadMutex_lock(&admin->localPublicationsLock); hashMap_destroy(admin->localPublications,true,false); celixThreadMutex_unlock(&admin->localPublicationsLock); celixThreadMutex_lock(&admin->externalPublicationsLock); iter = hashMapIterator_create(admin->externalPublications); while(hashMapIterator_hasNext(iter)){ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); free((char*)hashMapEntry_getKey(entry)); arrayList_destroy((array_list_pt)hashMapEntry_getValue(entry)); } hashMapIterator_destroy(iter); hashMap_destroy(admin->externalPublications,false,false); celixThreadMutex_unlock(&admin->externalPublicationsLock); celixThreadMutex_lock(&admin->serializerListLock); arrayList_destroy(admin->serializerList); celixThreadMutex_unlock(&admin->serializerListLock); celixThreadMutex_lock(&admin->noSerializerPendingsLock); arrayList_destroy(admin->noSerializerSubscriptions); arrayList_destroy(admin->noSerializerPublications); celixThreadMutex_unlock(&admin->noSerializerPendingsLock); celixThreadMutex_lock(&admin->usedSerializersLock); iter = hashMapIterator_create(admin->topicSubscriptionsPerSerializer); while(hashMapIterator_hasNext(iter)){ arrayList_destroy((array_list_pt)hashMapIterator_nextValue(iter)); } hashMapIterator_destroy(iter); hashMap_destroy(admin->topicSubscriptionsPerSerializer,false,false); iter = hashMapIterator_create(admin->topicPublicationsPerSerializer); while(hashMapIterator_hasNext(iter)){ arrayList_destroy((array_list_pt)hashMapIterator_nextValue(iter)); } hashMapIterator_destroy(iter); hashMap_destroy(admin->topicPublicationsPerSerializer,false,false); celixThreadMutex_unlock(&admin->usedSerializersLock); celixThreadMutex_destroy(&admin->usedSerializersLock); celixThreadMutex_destroy(&admin->serializerListLock); celixThreadMutex_destroy(&admin->pendingSubscriptionsLock); celixThreadMutexAttr_destroy(&admin->noSerializerPendingsAttr); celixThreadMutex_destroy(&admin->noSerializerPendingsLock); celixThreadMutexAttr_destroy(&admin->pendingSubscriptionsAttr); celixThreadMutex_destroy(&admin->subscriptionsLock); celixThreadMutex_destroy(&admin->localPublicationsLock); celixThreadMutex_destroy(&admin->externalPublicationsLock); logHelper_stop(admin->loghelper); logHelper_destroy(&admin->loghelper); #ifdef BUILD_WITH_ZMQ_SECURITY if (admin->zmq_auth != NULL){ zactor_destroy(&(admin->zmq_auth)); } #endif free(admin); return status; }