celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From griccia...@apache.org
Subject celix git commit: Fixed some Coverity issues
Date Tue, 03 Oct 2017 14:19:50 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 33644af89 -> 64491416f


Fixed some Coverity issues


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/64491416
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/64491416
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/64491416

Branch: refs/heads/develop
Commit: 64491416f2b9ea92fb22115aaae31a6649f7f61c
Parents: 33644af
Author: gricciardi <gricciardi@apache.org>
Authored: Tue Oct 3 16:19:29 2017 +0200
Committer: gricciardi <gricciardi@apache.org>
Committed: Tue Oct 3 16:19:29 2017 +0200

----------------------------------------------------------------------
 .../private/src/pubsub_admin_impl.c                    | 11 +++++------
 .../pubsub_admin_zmq/private/src/pubsub_admin_impl.c   | 13 ++++++-------
 2 files changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/64491416/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c b/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
index a582c22..1fbdb08 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/pubsub_admin_impl.c
@@ -386,6 +386,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	}
 
 	/* Check if we already know some publisher about this topic, otherwise let's put the subscription
in the pending hashmap */
+	celixThreadMutex_lock(&admin->pendingSubscriptionsLock);
 	celixThreadMutex_lock(&admin->subscriptionsLock);
 	celixThreadMutex_lock(&admin->localPublicationsLock);
 	celixThreadMutex_lock(&admin->externalPublicationsLock);
@@ -396,9 +397,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	array_list_pt ext_pub_list = (array_list_pt)hashMap_get(admin->externalPublications,scope_topic);
 
 	if(factory==NULL && ext_pub_list==NULL){ //No (local or external) publishers yet
for this topic
-		celixThreadMutex_lock(&admin->pendingSubscriptionsLock);
 		pubsubAdmin_addSubscriptionToPendingList(admin,subEP);
-		celixThreadMutex_unlock(&admin->pendingSubscriptionsLock);
 	}
 	else{
 		int i;
@@ -468,6 +467,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	celixThreadMutex_unlock(&admin->externalPublicationsLock);
 	celixThreadMutex_unlock(&admin->localPublicationsLock);
 	celixThreadMutex_unlock(&admin->subscriptionsLock);
+	celixThreadMutex_unlock(&admin->pendingSubscriptionsLock);
 
 	return status;
 
@@ -871,9 +871,11 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 	celixThreadMutex_unlock(&admin->serializerListLock);
 
 	celixThreadMutex_lock(&admin->usedSerializersLock);
+	array_list_pt topicPubList = (array_list_pt)hashMap_remove(admin->topicPublicationsPerSerializer,
service);
+	array_list_pt topicSubList = (array_list_pt)hashMap_remove(admin->topicSubscriptionsPerSerializer,
service);
+	celixThreadMutex_unlock(&admin->usedSerializersLock);
 
 	/* Now destroy the topicPublications, but first put back the pubsub_endpoints back to the
noSerializer pending list */
-	array_list_pt topicPubList = (array_list_pt)hashMap_remove(admin->topicPublicationsPerSerializer,
service);
 	if(topicPubList!=NULL){
 		for(i=0;i<arrayList_size(topicPubList);i++){
 			topic_publication_pt topicPub = (topic_publication_pt)arrayList_get(topicPubList,i);
@@ -926,7 +928,6 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 	}
 
 	/* Now destroy the topicSubscriptions, but first put back the pubsub_endpoints back to the
noSerializer pending list */
-	array_list_pt topicSubList = (array_list_pt)hashMap_remove(admin->topicSubscriptionsPerSerializer,
service);
 	if(topicSubList!=NULL){
 		for(i=0;i<arrayList_size(topicSubList);i++){
 			topic_subscription_pt topicSub = (topic_subscription_pt)arrayList_get(topicSubList,i);
@@ -974,8 +975,6 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 		arrayList_destroy(topicSubList);
 	}
 
-	celixThreadMutex_unlock(&admin->usedSerializersLock);
-
 	printf("PSA_UDP_MC: %s serializer removed\n",serType);
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/64491416/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c b/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
index db3b762..29ead0c 100644
--- a/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
+++ b/pubsub/pubsub_admin_zmq/private/src/pubsub_admin_impl.c
@@ -387,6 +387,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	}
 
 	/* Check if we already know some publisher about this topic, otherwise let's put the subscription
in the pending hashmap */
+	celixThreadMutex_lock(&admin->pendingSubscriptionsLock);
 	celixThreadMutex_lock(&admin->subscriptionsLock);
 	celixThreadMutex_lock(&admin->localPublicationsLock);
 	celixThreadMutex_lock(&admin->externalPublicationsLock);
@@ -397,9 +398,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	array_list_pt ext_pub_list = (array_list_pt)hashMap_get(admin->externalPublications,scope_topic);
 
 	if(factory==NULL && ext_pub_list==NULL){ //No (local or external) publishers yet
for this topic
-		celixThreadMutex_lock(&admin->pendingSubscriptionsLock);
 		pubsubAdmin_addSubscriptionToPendingList(admin,subEP);
-		celixThreadMutex_unlock(&admin->pendingSubscriptionsLock);
 	}
 	else{
 		int i;
@@ -469,6 +468,7 @@ celix_status_t pubsubAdmin_addSubscription(pubsub_admin_pt admin,pubsub_endpoint
 	celixThreadMutex_unlock(&admin->externalPublicationsLock);
 	celixThreadMutex_unlock(&admin->localPublicationsLock);
 	celixThreadMutex_unlock(&admin->subscriptionsLock);
+	celixThreadMutex_unlock(&admin->pendingSubscriptionsLock);
 
 	return status;
 
@@ -648,8 +648,6 @@ celix_status_t pubsubAdmin_removePublication(pubsub_admin_pt admin,pubsub_endpoi
 			}
 			celixThreadMutex_unlock(&admin->noSerializerPendingsLock);
 		}
-
-
 	}
 	else{
 
@@ -872,9 +870,11 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 
 
 	celixThreadMutex_lock(&admin->usedSerializersLock);
+	array_list_pt topicPubList = (array_list_pt)hashMap_remove(admin->topicPublicationsPerSerializer,
service);
+	array_list_pt topicSubList = (array_list_pt)hashMap_remove(admin->topicSubscriptionsPerSerializer,
service);
+	celixThreadMutex_unlock(&admin->usedSerializersLock);
 
 	/* Now destroy the topicPublications, but first put back the pubsub_endpoints back to the
noSerializer pending list */
-	array_list_pt topicPubList = (array_list_pt)hashMap_remove(admin->topicPublicationsPerSerializer,
service);
 	if(topicPubList!=NULL){
 		for(i=0;i<arrayList_size(topicPubList);i++){
 			topic_publication_pt topicPub = (topic_publication_pt)arrayList_get(topicPubList,i);
@@ -927,7 +927,6 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 	}
 
 	/* Now destroy the topicSubscriptions, but first put back the pubsub_endpoints back to the
noSerializer pending list */
-	array_list_pt topicSubList = (array_list_pt)hashMap_remove(admin->topicSubscriptionsPerSerializer,
service);
 	if(topicSubList!=NULL){
 		for(i=0;i<arrayList_size(topicSubList);i++){
 			topic_subscription_pt topicSub = (topic_subscription_pt)arrayList_get(topicSubList,i);
@@ -975,7 +974,7 @@ celix_status_t pubsubAdmin_serializerRemoved(void * handle, service_reference_pt
 		arrayList_destroy(topicSubList);
 	}
 
-	celixThreadMutex_unlock(&admin->usedSerializersLock);
+
 
 	printf("PSA_ZMQ: %s serializer removed\n",serType);
 


Mime
View raw message