You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/10/14 10:32:08 UTC
[celix] branch develop updated: #101: Fixes double lock in psa tcp,
udpmc, zmq and websocket.
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/develop by this push:
new 8c7e48b #101: Fixes double lock in psa tcp,udpmc,zmq and websocket.
8c7e48b is described below
commit 8c7e48b3ce783ac7b6cb29d6bc2df93b5fe7f4e1
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Mon Oct 14 12:31:46 2019 +0200
#101: Fixes double lock in psa tcp,udpmc,zmq and websocket.
Also adds some doxygen to pubsub utils
---
.../pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c | 2 +-
.../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c | 2 +-
.../src/pubsub_websocket_admin.c | 2 +-
.../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c | 2 +-
bundles/pubsub/pubsub_spi/include/pubsub_admin.h | 2 +-
.../pubsub_spi/include/pubsub_admin_metrics.h | 2 +-
.../pubsub/pubsub_spi/include/pubsub_endpoint.h | 2 +-
.../pubsub/pubsub_spi/include/pubsub_listeners.h | 4 +-
.../include/pubsub_topic_info.descriptor | 10 ---
bundles/pubsub/pubsub_spi/include/pubsub_utils.h | 95 +++++++++++++++++++++-
10 files changed, 102 insertions(+), 21 deletions(-)
diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
index 47cd2b4..d49c5eb 100644
--- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
+++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
@@ -507,7 +507,7 @@ celix_status_t pubsub_tcpAdmin_teardownTopicReceiver(void *handle, const char *s
free(receiverKey);
pubsub_tcpTopicReceiver_destroy(receiver);
}
- celixThreadMutex_lock(&psa->topicReceivers.mutex);
+ celixThreadMutex_unlock(&psa->topicReceivers.mutex);
celix_status_t status = CELIX_SUCCESS;
return status;
diff --git a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
index 57d9430..86fe3c2 100644
--- a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
+++ b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
@@ -440,7 +440,7 @@ celix_status_t pubsub_udpmcAdmin_teardownTopicReceiver(void *handle, const char
free(receiverKey);
pubsub_udpmcTopicReceiver_destroy(receiver);
}
- celixThreadMutex_lock(&psa->topicReceivers.mutex);
+ celixThreadMutex_unlock(&psa->topicReceivers.mutex);
celix_status_t status = CELIX_SUCCESS;
return status;
diff --git a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
index f116b27..0a34dc1 100644
--- a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
+++ b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
@@ -423,7 +423,7 @@ celix_status_t pubsub_websocketAdmin_teardownTopicReceiver(void *handle, const c
free(receiverKey);
pubsub_websocketTopicReceiver_destroy(receiver);
}
- celixThreadMutex_lock(&psa->topicReceivers.mutex);
+ celixThreadMutex_unlock(&psa->topicReceivers.mutex);
celix_status_t status = CELIX_SUCCESS;
return status;
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
index ed37e1b..83e38ea 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
@@ -525,7 +525,7 @@ celix_status_t pubsub_zmqAdmin_teardownTopicReceiver(void *handle, const char *s
free(receiverKey);
pubsub_zmqTopicReceiver_destroy(receiver);
}
- celixThreadMutex_lock(&psa->topicReceivers.mutex);
+ celixThreadMutex_unlock(&psa->topicReceivers.mutex);
celix_status_t status = CELIX_SUCCESS;
return status;
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_admin.h b/bundles/pubsub/pubsub_spi/include/pubsub_admin.h
index aa51ff3..cd172cc 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_admin.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_admin.h
@@ -44,7 +44,7 @@
struct pubsub_admin_service {
void *handle;
- celix_status_t (*matchPublisher)(void *handle, long svcRequesterBndId, const celix_filter_t *svcFilter, celix_properties_t **outTopicProperties, double *outScopre, long *outSerializerSvcId);
+ celix_status_t (*matchPublisher)(void *handle, long svcRequesterBndId, const celix_filter_t *svcFilter, celix_properties_t **outTopicProperties, double *outScore, long *outSerializerSvcId);
celix_status_t (*matchSubscriber)(void *handle, long svcProviderBndId, const celix_properties_t *svcProperties, celix_properties_t **outTopicProperties, double *outScore, long *outSerializerSvcId);
celix_status_t (*matchDiscoveredEndpoint)(void *handle, const celix_properties_t *endpoint, bool *match);
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h b/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
index e71661d..449ec63 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
@@ -24,7 +24,7 @@
#include <sys/time.h>
#include "celix_array_list.h"
-#define PUBSUB_ADMIN_METRICS_SERVICE_NAME "pubsub_admin_metrics [version 1.0]"
+#define PUBSUB_ADMIN_METRICS_SERVICE_NAME "pubsub_admin_metrics"
#define PUBSUB_AMDIN_METRICS_NAME_MAX 1024
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h b/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
index 875e351..8e51474 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
@@ -38,7 +38,7 @@ extern "C" {
#define PUBSUB_ENDPOINT_UUID "pubsub.endpoint.uuid" //required
#define PUBSUB_ENDPOINT_FRAMEWORK_UUID "pubsub.framework.uuid" //required
#define PUBSUB_ENDPOINT_TYPE "pubsub.endpoint.type" //PUBSUB_PUBLISHER_ENDPOINT_TYPE or PUBSUB_SUBSCRIBER_ENDPOINT_TYPE
-#define PUBSUB_ENDPOINT_VISIBILITY "pubsub.endpoint.visiblity" //local, host or system. e.g. for IPC host
+#define PUBSUB_ENDPOINT_VISIBILITY "pubsub.endpoint.visibility" //local, host or system. e.g. for IPC host
#define PUBSUB_ENDPOINT_ADMIN_TYPE PUBSUB_ADMIN_TYPE_KEY
#define PUBSUB_ENDPOINT_SERIALIZER PUBSUB_SERIALIZER_TYPE_KEY
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_listeners.h b/bundles/pubsub/pubsub_spi/include/pubsub_listeners.h
index 3bd1eb0..0982a0f 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_listeners.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_listeners.h
@@ -23,7 +23,7 @@
#include "celix_properties.h"
-#define PUBSUB_DISCOVERED_ENDPOINT_LISTENER_SERVICE "pubsub_discovered_endpoint_listener [version 1.0]"
+#define PUBSUB_DISCOVERED_ENDPOINT_LISTENER_SERVICE "pubsub_discovered_endpoint_listener"
//Informs the topology manager that pub/sub endpoints are discovered in the network
struct pubsub_discovered_endpoint_listener {
@@ -36,7 +36,7 @@ typedef struct pubsub_discovered_endpoint_listener pubsub_discovered_endpoint_li
-#define PUBSUB_ANNOUNCE_ENDPOINT_LISTENER_SERVICE "pubsub_announce_endpoint_listener [version 1.0]"
+#define PUBSUB_ANNOUNCE_ENDPOINT_LISTENER_SERVICE "pubsub_announce_endpoint_listener"
//Informs the pubsub discoveries to announce/revoke endpoint
struct pubsub_announce_endpoint_listener {
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_topic_info.descriptor b/bundles/pubsub/pubsub_spi/include/pubsub_topic_info.descriptor
deleted file mode 100644
index c01a2fd..0000000
--- a/bundles/pubsub/pubsub_spi/include/pubsub_topic_info.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=interface
-name=pubsub_topic_info
-version=1.0.0
-:annotations
-:types
-:methods
-getParticipantsNumber(t)i=getParticipantsNumber(#am=handle;Pt#am=pre;*i)N
-getSubscribersNumber(t)i=getSubscribersNumber(#am=handle;Pt#am=pre;*i)N
-getPublishersNumber(t)i=getPublishersNumber(#am=handle;Pt#am=pre;*i)N
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_utils.h b/bundles/pubsub/pubsub_spi/include/pubsub_utils.h
index b7137ec..557014c 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_utils.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_utils.h
@@ -34,14 +34,50 @@ extern "C" {
/**
* Returns the pubsub info from the provided filter. A pubsub filter should have a topic and can
* have a scope. If no topic is present the topic and scope output will be NULL.
- * If a topic is present the topic output will contain a allocated topic string and if a scope was
- * present a allocated scope string.
+ * If a topic is present the topic output will contain an allocated topic string and if a scope was
+ * present an allocated scope string.
* The caller is owner of the topic and scope output string.
*/
celix_status_t pubsub_getPubSubInfoFromFilter(const char* filterstr, char **topic, char **scope);
+/**
+ * Loop through all bundles and look for the bundle with the keys inside.
+ * If no key bundle found, return NULL
+ *
+ * Caller is responsible for freeing the object
+ */
char* pubsub_getKeysBundleDir(celix_bundle_context_t *ctx);
+/**
+ * Match a publisher for a provided bnd (using the bundleId) and service filter.
+ *
+ * The match function will try to find a topic properties for the requesting bundle (bundleId) using the topic
+ * from the filter at META-INF/topics/pub/<topic>.properties
+ *
+ * If the topic properties is configured for the provided adminType (i.e. pubsub.config=ZMQ) a full match will
+ * be returned. If no specific admin is configured in the topic properties the sampleScore will be returned if sample
+ * qos is configured (i.e. qos=sample), the controlScore will be returned if control qos is configured
+ * (i.e. qos=control) and otherwise the defaultScore will be returned.
+ *
+ * The match function will also search for a valid serializer. If a serializer is configured in the topic properties
+ * (i.e. pubsub.serializer=json) that specific serializer will be searched. If no serializer is configured the
+ * highest ranking serializer service will be returned. If no serializer can be found, the outSerializerSvcId will
+ * be -1.
+ *
+ * The function will also returned the found topic properties and the matching serialized.
+ * The caller is owner of the outTopicProperties.
+ *
+ * @param ctx The bundle context.
+ * @param bundleId The requesting bundle id.
+ * @param filter The filter of the publisher (i.e. "(&(topic=example)(scope=subsystem))")
+ * @param adminType The admin type used for the match.
+ * @param sampleScore The sample score used for the match.
+ * @param controlScore The control score used for the match.
+ * @param defaultScore The default score used for the match.
+ * @param outTopicProperties Output pointer for the read topic properties. Return can be NULL.
+ * @param outSerializerSvcId Output svc id for the matching serializer. If not found will be -1L.
+ * @return The matching score.
+ */
double pubsub_utils_matchPublisher(
celix_bundle_context_t *ctx,
long bundleId,
@@ -53,6 +89,36 @@ double pubsub_utils_matchPublisher(
celix_properties_t **outTopicProperties,
long *outSerializerSvcId);
+/**
+ * Match a subscriber for a provided bnd (using the bundleId) and provided service properties.
+ *
+ * The match function will try to find a topic properties for the requesting bundle (bundleId) - using topic in the
+ * provided service properties - at META-INF/topics/sub/<topic>.properties
+ *
+ * If the topic properties is configured for the provided adminType (i.e. pubsub.config=ZMQ) a full match will
+ * be returned. If no specific admin is configured in the topic properties the sampleScore will be returned if sample
+ * qos is configured (i.e. qos=sample), the controlScore will be returned if control qos is configured
+ * (i.e. qos=control) and otherwise the defaultScore will be returned.
+ *
+ * The match function will also search for a valid serializer. If a serializer is configured in the topic properties
+ * (i.e. pubsub.serializer=json) that specific serializer will be searched. If no serializer is configured the
+ * highest ranking serializer service will be returned. If no serializer can be found, the outSerializerSvcId will
+ * be -1.
+ *
+ * The function will also returned the found topic properties and the matching serialized.
+ * The caller is owner of the outTopicProperties.
+ *
+ * @param ctx The bundle context.
+ * @param bundleId The requesting bundle id.
+ * @param svcProperties The service properties of the registered subscriber service.
+ * @param adminType The admin type used for the match.
+ * @param sampleScore The sample score used for the match.
+ * @param controlScore The control score used for the match.
+ * @param defaultScore The default score used for the match.
+ * @param outTopicProperties Output pointer for the read topic properties. Return can be NULL.
+ * @param outSerializerSvcId Output svc id for the matching serializer. If not found will be -1L.
+ * @return The matching score.
+ */
double pubsub_utils_matchSubscriber(
celix_bundle_context_t *ctx,
long svcProviderBundleId,
@@ -64,6 +130,18 @@ double pubsub_utils_matchSubscriber(
celix_properties_t **outTopicProperties,
long *outSerializerSvcId);
+/**
+ * Match an endpoint (subscriber or publisher endpoint) for the provided admin type.
+ *
+ * Also tries to found the matching serializer configured in the endpoint.
+ *
+ * @param ctx The bundle context.
+ * @param endpoint The endpoint to match.
+ * @param adminType The admin type (i.e. UDPMC)
+ * @param outSerializerSvcId The found serialized svc id based on the endpoint or -1 if no serializer is
+ * configured/found.
+ * @return true if there is a match.
+ */
bool pubsub_utils_matchEndpoint(
celix_bundle_context_t *ctx,
const celix_properties_t *endpoint,
@@ -71,6 +149,19 @@ bool pubsub_utils_matchEndpoint(
long *outSerializerSvcId);
+/**
+ * Tries to find and read the topic properties for the provided bundle.
+ *
+ * Will look at META-INF/topics/pub/<topic>.properties for publisher and
+ * META-INF/topics/sub/<topic>.properties for subscribers.
+ *
+ * The caller is owner of the returned topic properties.
+ *
+ * @param bundle The bundle where the properties reside.
+ * @param topic The topic name.
+ * @param isPublisher true if the topic properties for a publisher should be found.
+ * @return The topic properties if found or NULL.
+ */
celix_properties_t* pubsub_utils_getTopicProperties(const celix_bundle_t *bundle, const char *topic, bool isPublisher);
#ifdef __cplusplus