celix_status_t discovery_destroy(discovery_pt discovery) { celix_status_t status = CELIX_SUCCESS; discovery->context = NULL; discovery->poller = NULL; discovery->server = NULL; celixThreadMutex_lock(&discovery->discoveredServicesMutex); hashMap_destroy(discovery->discoveredServices, false, false); discovery->discoveredServices = NULL; celixThreadMutex_unlock(&discovery->discoveredServicesMutex); celixThreadMutex_destroy(&discovery->discoveredServicesMutex); celixThreadMutex_lock(&discovery->listenerReferencesMutex); hashMap_destroy(discovery->listenerReferences, false, false); discovery->listenerReferences = NULL; celixThreadMutex_unlock(&discovery->listenerReferencesMutex); celixThreadMutex_destroy(&discovery->listenerReferencesMutex); logHelper_destroy(&discovery->loghelper); free(discovery); return status; }
celix_status_t wiringAdmin_destroy(wiring_admin_pt* admin) { celix_status_t status; status = wiringAdmin_stopWebserver(*admin); if (status == CELIX_SUCCESS) { celixThreadMutex_lock(&((*admin)->exportedWiringEndpointLock)); hashMap_destroy((*admin)->wiringReceiveServices, false, false); hashMap_destroy((*admin)->wiringReceiveTracker, false, false); celixThreadMutex_unlock(&((*admin)->exportedWiringEndpointLock)); celixThreadMutex_destroy(&((*admin)->exportedWiringEndpointLock)); celixThreadMutex_lock(&((*admin)->importedWiringEndpointLock)); hashMap_destroy((*admin)->wiringSendServices, false, false); hashMap_destroy((*admin)->wiringSendRegistrations, false, false); celixThreadMutex_unlock(&((*admin)->importedWiringEndpointLock)); celixThreadMutex_destroy(&((*admin)->importedWiringEndpointLock)); properties_destroy((*admin)->adminProperties); free(*admin); *admin = NULL; } return status; }
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 pubsub_topicSubscriptionDestroy(topic_subscription_pt ts){ celix_status_t status = CELIX_SUCCESS; celixThreadMutex_lock(&ts->ts_lock); ts->running = false; free(ts->ifIpAddress); serviceTracker_destroy(ts->tracker); arrayList_clear(ts->sub_ep_list); arrayList_destroy(ts->sub_ep_list); hashMap_destroy(ts->servicesMap,false,false); celixThreadMutex_lock(&ts->socketMap_lock); hashMap_destroy(ts->socketMap,true,true); celixThreadMutex_unlock(&ts->socketMap_lock); celixThreadMutex_destroy(&ts->socketMap_lock); celixThreadMutex_lock(&ts->pendingConnections_lock); arrayList_destroy(ts->pendingConnections); celixThreadMutex_unlock(&ts->pendingConnections_lock); celixThreadMutex_destroy(&ts->pendingConnections_lock); celixThreadMutex_lock(&ts->pendingDisconnections_lock); arrayList_destroy(ts->pendingDisconnections); celixThreadMutex_unlock(&ts->pendingDisconnections_lock); celixThreadMutex_destroy(&ts->pendingDisconnections_lock); largeUdp_destroy(ts->largeUdpHandle); #if defined(__APPLE__) && defined(__MACH__) //TODO: Use kqueue for OSX #else close(ts->topicEpollFd); #endif celixThreadMutex_unlock(&ts->ts_lock); celixThreadMutex_destroy(&ts->ts_lock); free(ts); return status; }
celix_status_t managedServiceTracker_destroy(bundle_context_pt context, managed_service_tracker_pt mgServTr, service_tracker_pt tracker) { updatedThreadPool_destroy(mgServTr->updatedThreadPool); celixThreadMutex_destroy(&mgServTr->managedServicesReferencesMutex); serviceTracker_destroy(tracker); hashMap_destroy(mgServTr->managedServices, true, true); hashMap_destroy(mgServTr->managedServicesReferences, true, true); free(mgServTr); return CELIX_SUCCESS; }
celix_status_t pubsub_discovery_destroy(pubsub_discovery_pt ps_discovery) { celix_status_t status = CELIX_SUCCESS; celixThreadMutex_lock(&ps_discovery->discoveredPubsMutex); hash_map_iterator_pt iter = hashMapIterator_create(ps_discovery->discoveredPubs); while (hashMapIterator_hasNext(iter)) { array_list_pt pubEP_list = (array_list_pt) hashMapIterator_nextValue(iter); for(int i=0; i < arrayList_size(pubEP_list); i++) { pubsubEndpoint_destroy(((pubsub_endpoint_pt)arrayList_get(pubEP_list,i))); } arrayList_destroy(pubEP_list); } hashMapIterator_destroy(iter); hashMap_destroy(ps_discovery->discoveredPubs, true, false); ps_discovery->discoveredPubs = NULL; celixThreadMutex_unlock(&ps_discovery->discoveredPubsMutex); celixThreadMutex_destroy(&ps_discovery->discoveredPubsMutex); celixThreadMutex_lock(&ps_discovery->listenerReferencesMutex); hashMap_destroy(ps_discovery->listenerReferences, false, false); ps_discovery->listenerReferences = NULL; celixThreadMutex_unlock(&ps_discovery->listenerReferencesMutex); celixThreadMutex_destroy(&ps_discovery->listenerReferencesMutex); free(ps_discovery); return status; }
celix_status_t serviceRegistration_destroy(service_registration_pt registration) { free(registration->className); registration->className = NULL; registration->registry = NULL; properties_destroy(registration->properties); celixThreadMutex_destroy(®istration->mutex); free(registration); registration = NULL; return CELIX_SUCCESS; }
celix_status_t bundle_destroy(bundle_pt bundle) { array_list_iterator_pt iter = arrayListIterator_create(bundle->modules); while (arrayListIterator_hasNext(iter)) { module_pt module = arrayListIterator_next(iter); module_destroy(module); } arrayListIterator_destroy(iter); arrayList_destroy(bundle->modules); celixThreadMutex_destroy(&bundle->lock); free(bundle); return CELIX_SUCCESS; }
celix_status_t configuration_delete(void *handle) { configuration_impl_pt conf = (configuration_impl_pt)handle; printf("TODO: Implement configuration_delete\n"); celixThreadMutex_destroy(&conf->mutex); if (conf->factoryPid != NULL) free(conf->factoryPid); if (conf->pid != NULL) free(conf->pid); if (conf->bundleLocation != NULL) free(conf->bundleLocation); free(conf->configuration_interface); free(conf); return CELIX_SUCCESS; }
void etcdWriter_destroy(etcd_writer_pt writer) { char dir[MAX_ROOTNODE_LENGTH]; const char *rootPath = etcdWriter_getRootPath(writer->pubsub_discovery->context); writer->running = false; celixThread_join(writer->writerThread, NULL); celixThreadMutex_lock(&writer->localPubsLock); for(int i = 0; i < arrayList_size(writer->localPubs); i++) { pubsub_endpoint_pt pubEP = (pubsub_endpoint_pt)arrayList_get(writer->localPubs,i); memset(dir,0,MAX_ROOTNODE_LENGTH); snprintf(dir,MAX_ROOTNODE_LENGTH,"%s/%s/%s/%s",rootPath,pubEP->scope,pubEP->topic,pubEP->frameworkUUID); etcd_del(dir); pubsubEndpoint_destroy(pubEP); } arrayList_destroy(writer->localPubs); celixThreadMutex_unlock(&writer->localPubsLock); celixThreadMutex_destroy(&(writer->localPubsLock)); free(writer); }
celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher) { celix_status_t status = CELIX_SUCCESS; char localNodePath[MAX_LOCALNODE_LENGTH]; celixThreadMutex_lock(&(watcher->watcherLock)); watcher->running = false; celixThreadMutex_unlock(&(watcher->watcherLock)); watcher->running = false; celixThread_join(watcher->watcherThread, NULL); celixThreadMutex_destroy(&(watcher->watcherLock)); // remove own registration status = etcdWatcher_getLocalNodePath(watcher->node_discovery->context, watcher->node_discovery->ownNode, &localNodePath[0]); if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false) { printf("Cannot remove local discovery registration."); } free(watcher); return status; }
void phase2b_destroy(phase2b_cmp_t *cmp) { celixThreadMutex_lock(&cmp->mutex); celixThreadMutex_destroy(&cmp->mutex); free(cmp); printf("destroy phase2b\n"); }
void phase2a_destroy(phase2a_cmp_t *cmp) { celixThreadMutex_destroy(&cmp->mutex); free(cmp); printf("destroy phase2a\n"); }
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; }