Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
celix_status_t deviceManager_destroy(device_manager_pt manager) {
	celix_status_t status = CELIX_SUCCESS;

	printf("DEVICE_MANAGER: Stop\n");
	hashMap_destroy(manager->devices, false, false);
	hashMap_destroy(manager->drivers, false, false);
	arrayList_destroy(manager->locators);

	return status;
}
Пример #4
0
celix_status_t deviceManager_destroy(device_manager_pt manager) {
	celix_status_t status = CELIX_SUCCESS;

	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Stop");

	hashMap_destroy(manager->devices, false, false);
	hashMap_destroy(manager->drivers, false, false);
	arrayList_destroy(manager->locators);

	return status;
}
Пример #5
0
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;
}
Пример #6
0
/**
 * Destroys and frees up memory for a given endpoint_discovery_poller struct.
 */
celix_status_t endpointDiscoveryPoller_destroy(endpoint_discovery_poller_pt poller) {
    celix_status_t status;

    poller->running = false;

    celixThread_join(poller->pollerThread, NULL);

    hash_map_iterator_pt iterator = hashMapIterator_create(poller->entries);
	while (hashMapIterator_hasNext(iterator)) {
		hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);

		if ( endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, (char*) hashMapEntry_getKey(entry)) == CELIX_SUCCESS) {
			hashMapIterator_destroy(iterator);
			iterator = hashMapIterator_create(poller->entries);
		}
	}
	hashMapIterator_destroy(iterator);

	status = celixThreadMutex_lock(&poller->pollerLock);

	if (status != CELIX_SUCCESS) {
		return CELIX_BUNDLE_EXCEPTION;
	}

	hashMap_destroy(poller->entries, true, false);

    status = celixThreadMutex_unlock(&poller->pollerLock);

    poller->loghelper = NULL;

    free(poller);

	return status;
}
Пример #7
0
celix_status_t requirement_destroy(requirement_pt requirement) {
	hash_map_iterator_pt attrIter = hashMapIterator_create(requirement->attributes);
	while (hashMapIterator_hasNext(attrIter)) {
		attribute_pt attr = hashMapIterator_nextValue(attrIter);
		hashMapIterator_remove(attrIter);
	}
	hashMapIterator_destroy(attrIter);
	hashMap_destroy(requirement->attributes, false, false);
	hashMap_destroy(requirement->directives, false, false);

	requirement->attributes = NULL;
	requirement->directives = NULL;
	requirement->versionRange = NULL;

	return CELIX_SUCCESS;
}
Пример #8
0
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(&registry->mutex);
    celixThreadMutexAttr_destroy(&registry->mutexAttr);
    celixThreadMutex_destroy(&registry->referencesMapMutex);
    registry->framework = NULL;
    registry->inUseMap = NULL;
    registry->listenerHooks = NULL;
    registry->serviceChanged = NULL;
    registry->serviceReferences = NULL;
    registry->serviceRegistrations = NULL;
    free(registry);

    return CELIX_SUCCESS;
}
Пример #9
0
celix_status_t pubsub_discovery_stop(pubsub_discovery_pt ps_discovery) {
    celix_status_t status = CELIX_SUCCESS;

    const char* fwUUID = NULL;

    bundleContext_getProperty(ps_discovery->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &fwUUID);
    if (fwUUID == NULL) {
        printf("PSD: Cannot retrieve fwUUID.\n");
        return CELIX_INVALID_BUNDLE_CONTEXT;
    }

    celixThreadMutex_lock(&ps_discovery->watchersMutex);

    hash_map_iterator_pt iter = hashMapIterator_create(ps_discovery->watchers);
    while (hashMapIterator_hasNext(iter)) {
        struct watcher_info * wi = hashMapIterator_nextValue(iter);
        etcdWatcher_stop(wi->watcher);
    }
    hashMapIterator_destroy(iter);

    celixThreadMutex_lock(&ps_discovery->discoveredPubsMutex);

    /* Unexport all publishers for the local framework, and also delete from ETCD publisher belonging to the local framework */

    iter = hashMapIterator_create(ps_discovery->discoveredPubs);
    while (hashMapIterator_hasNext(iter)) {
        array_list_pt pubEP_list = (array_list_pt) hashMapIterator_nextValue(iter);

        int i;
        for (i = 0; i < arrayList_size(pubEP_list); i++) {
            pubsub_endpoint_pt pubEP = (pubsub_endpoint_pt) arrayList_get(pubEP_list, i);
            if (strcmp(pubEP->frameworkUUID, fwUUID) == 0) {
                etcdWriter_deletePublisherEndpoint(ps_discovery->writer, pubEP);
            } else {
                pubsub_discovery_informPublishersListeners(ps_discovery, pubEP, false);
                arrayList_remove(pubEP_list, i);
                pubsubEndpoint_destroy(pubEP);
                i--;
            }
        }
    }

    hashMapIterator_destroy(iter);

    celixThreadMutex_unlock(&ps_discovery->discoveredPubsMutex);
    etcdWriter_destroy(ps_discovery->writer);

    iter = hashMapIterator_create(ps_discovery->watchers);
    while (hashMapIterator_hasNext(iter)) {
        struct watcher_info * wi = hashMapIterator_nextValue(iter);
        etcdWatcher_destroy(wi->watcher);
    }
    hashMapIterator_destroy(iter);
    hashMap_destroy(ps_discovery->watchers, true, true);
    celixThreadMutex_unlock(&ps_discovery->watchersMutex);
    return status;
}
Пример #10
0
void properties_destroy(properties_pt properties) {
	hash_map_iterator_pt iter = hashMapIterator_create(properties);
	while (hashMapIterator_hasNext(iter)) {
		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
		free(hashMapEntry_getKey(entry));
		free(hashMapEntry_getValue(entry));
	}
	hashMapIterator_destroy(iter);
	hashMap_destroy(properties, false, false);
}
Пример #11
0
celix_status_t manifest_destroy(manifest_pt manifest) {
	if (manifest != NULL) {
	    properties_destroy(manifest->mainAttributes);
		hashMap_destroy(manifest->attributes, true, false);
		manifest->mainAttributes = NULL;
		manifest->attributes = NULL;
		free(manifest);
		manifest = NULL;
	}
	return CELIX_SUCCESS;
}
Пример #12
0
celix_status_t statistic_tracker_destroy(statistic_tracker_pt statTracker) {
	celix_status_t status = CELIX_SUCCESS;

	pthread_rwlock_wrlock(&statTracker->statLock);
	hashMap_destroy(statTracker->statServices, false, false);
	pthread_rwlock_unlock(&statTracker->statLock);

	pthread_rwlock_destroy(&statTracker->statLock);

	return status;
}
Пример #13
0
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;
}
Пример #14
0
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;
}
Пример #15
0
apr_status_t driverMatcher_destroy(void *matcherP) {
	driver_matcher_pt matcher = matcherP;
	arrayList_destroy(matcher->matches);
	hash_map_iterator_pt iter = hashMapIterator_create(matcher->attributes);
	while (hashMapIterator_hasNext(iter)) {
		array_list_pt list = hashMapIterator_nextValue(iter);
		if (list != NULL) {
			arrayList_destroy(list);
		}
	}
	hashMapIterator_destroy(iter);
	hashMap_destroy(matcher->attributes, false, false);
	return APR_SUCCESS;
}
Пример #16
0
celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
	celix_status_t status = CELIX_SUCCESS;

	if (!shell_service_ptr || !*shell_service_ptr) {
		status = CELIX_ILLEGAL_ARGUMENT;
	}

	if (status == CELIX_SUCCESS) {
		if ((*shell_service_ptr)->shell) {
			if ((*shell_service_ptr)->shell->command_name_map_ptr) {
				hashMap_destroy((*shell_service_ptr)->shell->command_name_map_ptr, false, false);
			}
			if ((*shell_service_ptr)->shell->command_reference_map_ptr) {
				hashMap_destroy((*shell_service_ptr)->shell->command_reference_map_ptr, false, false);
			}
			free((*shell_service_ptr)->shell);
			(*shell_service_ptr)->shell = NULL;
		}
		free(*shell_service_ptr);
		*shell_service_ptr = NULL;
	}

	return status;
}
Пример #17
0
celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin) {
    celix_status_t status = CELIX_SUCCESS;

    celixThreadMutex_lock(&admin->exportedServicesLock);

    hash_map_iterator_pt iter = hashMapIterator_create(admin->exportedServices);
    while (hashMapIterator_hasNext(iter)) {
        array_list_pt exports = hashMapIterator_nextValue(iter);
        int i;
        for (i = 0; i < arrayList_size(exports); i++) {
            export_registration_pt export = arrayList_get(exports, i);
            if (export != NULL) {
                exportRegistration_stop(export);
                exportRegistration_destroy(export);
            }
        }
        arrayList_destroy(exports);
    }
    hashMapIterator_destroy(iter);
    celixThreadMutex_unlock(&admin->exportedServicesLock);

    celixThreadMutex_lock(&admin->importedServicesLock);
    int i;
    int size = arrayList_size(admin->importedServices);
    for (i = 0; i < size ; i += 1) {
        import_registration_pt import = arrayList_get(admin->importedServices, i);
        if (import != NULL) {
            importRegistration_stop(import);
            importRegistration_destroy(import);
        }
    }
    celixThreadMutex_unlock(&admin->importedServicesLock);

    if (admin->ctx != NULL) {
        logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Stopping webserver...");
        mg_stop(admin->ctx);
        admin->ctx = NULL;
    }

    hashMap_destroy(admin->exportedServices, false, false);
    arrayList_destroy(admin->importedServices);

    logHelper_stop(admin->loghelper);
    logHelper_destroy(&admin->loghelper);

    return status;
}
Пример #18
0
void importRegistration_destroy(import_registration_pt import) {
    if (import != NULL) {
        if (import->proxies != NULL) {
            importRegistration_clearProxies(import);
            hashMap_destroy(import->proxies, false, false);
            import->proxies = NULL;
        }

        pthread_mutex_destroy(&import->mutex);
        pthread_mutex_destroy(&import->proxiesMutex);

        if (import->factory != NULL) {
            free(import->factory);
        }
        free(import);
    }
}
Пример #19
0
celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher) {
    arrayList_destroy((*matcher)->matches);
    hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
    while (hashMapIterator_hasNext(iter)) {
        array_list_pt list = hashMapIterator_nextValue(iter);
        if (list != NULL) {
            arrayList_destroy(list);
        }
    }
    hashMapIterator_destroy(iter);
    hashMap_destroy((*matcher)->attributes, false, false);

    logHelper_stop((*matcher)->loghelper);
    logHelper_destroy(&(*matcher)->loghelper);

    free(*matcher);

    return CELIX_SUCCESS;
}
celix_status_t remoteProxyFactory_destroy(remote_proxy_factory_pt *remote_proxy_factory_ptr) {
	celix_status_t status = CELIX_SUCCESS;

	if (!*remote_proxy_factory_ptr) {
		status = CELIX_ILLEGAL_ARGUMENT;
	}

	if (status == CELIX_SUCCESS) {
		if ((*remote_proxy_factory_ptr)->proxy_instances) {
			hashMap_destroy((*remote_proxy_factory_ptr)->proxy_instances, false, false);
			(*remote_proxy_factory_ptr)->proxy_instances = NULL;
		}
		if ((*remote_proxy_factory_ptr)->service) {
			free((*remote_proxy_factory_ptr)->service);
			(*remote_proxy_factory_ptr)->service = NULL;
		}
		free(*remote_proxy_factory_ptr);
		*remote_proxy_factory_ptr = NULL;
	}

	return status;
}
Пример #21
0
celix_status_t producer_destroy(producer_pt producer)
{
    celix_status_t status = CELIX_SUCCESS;

    pthread_rwlock_wrlock(&producer->queueLock);
    hashMap_destroy(producer->queueServices, false, true);
    pthread_rwlock_unlock(&producer->queueLock);

    pthread_rwlock_destroy(&producer->queueLock);

    if (producer->utilizationStatsName != NULL) {
        free(producer->utilizationStatsName);
    }

    if (producer->name != NULL) {
        free(producer->name);
    }

    free(producer);

    return status;
}
Пример #22
0
celix_status_t etcdWatcher_destroy(etcd_watcher_pt watcher) {
    celix_status_t status = CELIX_SUCCESS;
    char localNodePath[MAX_LOCALNODE_LENGTH];

    watcher->running = false;

    celixThread_join(watcher->watcherThread, NULL);

    // register own framework
    status = etcdWatcher_getLocalNodePath(watcher->discovery->context, &localNodePath[0]);

    if (status != CELIX_SUCCESS || etcd_del(localNodePath) == false)
    {
        logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, "Cannot remove local discovery registration.");
    }

    watcher->loghelper = NULL;

    hashMap_destroy(watcher->entries, true, true);

    free(watcher);

    return status;
}
Пример #23
0
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;
}