[celix] branch master updated (d8d5adaa -> cfb684e4)

2022-09-21 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git


from d8d5adaa Merge pull request #444 from 
apache/hotfix/service_tracker_guard_condition
 add bc2e8d2a Fix gcc-12 compiler errors
 new cfb684e4 Merge pull request #445 from apache/bugfix/fix_gcc12_errors

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libs/dfi/src/dyn_avpr_type.c| 6 +++---
 libs/framework/src/bundle_archive.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)



[celix] 01/01: Merge pull request #445 from apache/bugfix/fix_gcc12_errors

2022-09-21 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git

commit cfb684e44ff9fad6003c2cb03a951f78f42d4262
Merge: d8d5adaa bc2e8d2a
Author: Erjan Altena 
AuthorDate: Wed Sep 21 20:42:13 2022 +0200

Merge pull request #445 from apache/bugfix/fix_gcc12_errors

Fix gcc-12 compiler errors

 libs/dfi/src/dyn_avpr_type.c| 6 +++---
 libs/framework/src/bundle_archive.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)



[celix] branch bugfix/fix_gcc12_errors updated: Fix gcc-12 compiler errors

2022-09-19 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch bugfix/fix_gcc12_errors
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/bugfix/fix_gcc12_errors by 
this push:
 new bc2e8d2a Fix gcc-12 compiler errors
bc2e8d2a is described below

commit bc2e8d2ae1d8b976168e114d9146be91fd746048
Author: Erjan Altena 
AuthorDate: Mon Sep 19 20:32:30 2022 +0200

Fix gcc-12 compiler errors
---
 libs/dfi/src/dyn_avpr_type.c| 6 +++---
 libs/framework/src/bundle_archive.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libs/dfi/src/dyn_avpr_type.c b/libs/dfi/src/dyn_avpr_type.c
index 64121a31..c485b590 100644
--- a/libs/dfi/src/dyn_avpr_type.c
+++ b/libs/dfi/src/dyn_avpr_type.c
@@ -348,7 +348,7 @@ static dyn_type * dynAvprType_parseRecord(dyn_type * root, 
dyn_type * parent, js
 // Create namespace + name for storage in type->name (to preserve 
namespacing)
 char fqn_buffer[FQN_SIZE];
 snprintf(fqn_buffer, FQN_SIZE, "%s.%s", record_ns, 
json_string_value(json_object_get(record_obj, "name")));
-type->name = strndup(fqn_buffer, STR_LENGTH);
+type->name = strndup(fqn_buffer, FQN_SIZE);
 if (!type->name) {
 LOG_ERROR("Record: failed to allocate memory for type->name");
 dynType_destroy(type);
@@ -1010,13 +1010,13 @@ static inline void 
dynAvprType_createVersionMetaEntry(dyn_type * type, json_t co
 version_destroy(v);
 }
 else {
-m_entry->value = strndup("0.0.0", STR_LENGTH);
+m_entry->value = strdup("0.0.0");
 LOG_WARNING("parseAvpr: Did not find valid version, set version to 
0.0.0");
 }
 }
 else {
 // If no version or an invalid version is available, default to 0.0.0
-m_entry->value = strndup("0.0.0", STR_LENGTH);
+m_entry->value = strdup("0.0.0");
 LOG_WARNING("parseAvpr: Did not find version entry, set version to 
0.0.0");
 }
 
diff --git a/libs/framework/src/bundle_archive.c 
b/libs/framework/src/bundle_archive.c
index 80d53607..e4448c7b 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -73,7 +73,7 @@ celix_status_t 
bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle
status = linkedList_create(&archive->revisions);
if (status == CELIX_SUCCESS) {
archive->id = CELIX_FRAMEWORK_BUNDLE_ID;
-   archive->location = strndup("System Bundle", 
1024);
+   archive->location = strdup("System Bundle");
archive->archiveRoot = NULL;
archive->archiveRootDir = NULL;
archive->refreshCount = -1;



[celix] branch bugfix/fix_gcc12_errors created (now d8d5adaa)

2022-09-19 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch bugfix/fix_gcc12_errors
in repository https://gitbox.apache.org/repos/asf/celix.git


  at d8d5adaa Merge pull request #444 from 
apache/hotfix/service_tracker_guard_condition

No new revisions were added by this update.



[celix] branch dm_cmd_with_plantuml_output updated (9b812c0 -> 372e30f)

2021-11-25 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch dm_cmd_with_plantuml_output
in repository https://gitbox.apache.org/repos/asf/celix.git.


from 9b812c0  Added an extra output to the DM shell command which generates 
plantuml output to quickly see the resolved and not-resolved dependencies
 add 372e30f  Fix introduced mem leak

No new revisions were added by this update.

Summary of changes:
 bundles/shell/shell/src/dm_shell_list_command.c | 3 +++
 1 file changed, 3 insertions(+)


[celix] branch dm_cmd_with_plantuml_output created (now 9b812c0)

2021-11-25 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch dm_cmd_with_plantuml_output
in repository https://gitbox.apache.org/repos/asf/celix.git.


  at 9b812c0  Added an extra output to the DM shell command which generates 
plantuml output to quickly see the resolved and not-resolved dependencies

This branch includes the following new commits:

 new 9b812c0  Added an extra output to the DM shell command which generates 
plantuml output to quickly see the resolved and not-resolved dependencies

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[celix] 01/01: Added an extra output to the DM shell command which generates plantuml output to quickly see the resolved and not-resolved dependencies

2021-11-25 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch dm_cmd_with_plantuml_output
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 9b812c08e0f8f8b46292992f41d7d28ff6b5d1d5
Author: Erjan Altena 
AuthorDate: Thu Nov 25 21:18:24 2021 +0100

Added an extra output to the DM shell command which generates plantuml 
output to quickly see the resolved and not-resolved dependencies
---
 bundles/shell/shell/src/dm_shell_list_command.c| 174 -
 .../dm_example_cxx/api/include/IPhase1.h   |   1 +
 2 files changed, 140 insertions(+), 35 deletions(-)

diff --git a/bundles/shell/shell/src/dm_shell_list_command.c 
b/bundles/shell/shell/src/dm_shell_list_command.c
index df1fdca..ce8b722 100644
--- a/bundles/shell/shell/src/dm_shell_list_command.c
+++ b/bundles/shell/shell/src/dm_shell_list_command.c
@@ -30,7 +30,20 @@ static const char * const WARNING_COLOR = "\033[93m";
 static const char * const NOK_COLOR = "\033[91m";
 static const char * const END_COLOR = "\033[m";
 
-static void parseCommandLine(const char*line, celix_array_list_t 
**requestedBundleIds, bool *fullInfo, bool *wtf, FILE *err) {
+void printInactiveBundles(FILE *out, celix_dependency_manager_t *mng, bool 
useColors);
+
+void printSpecifiedBundles(FILE *out, celix_dependency_manager_t *mng, bool 
useColors, bool fullInfo, bool plantUmlInfo);
+
+void printAllBundles(FILE *out, celix_dependency_manager_t *mng, bool 
useColors, const celix_array_list_t *bundleIds,
+ bool fullInfo, bool plantUmlInfo);
+
+static void printPlantUmlInfo(FILE *out, celix_dependency_manager_t *mng);
+static void printUmlComponents(FILE *out, const celix_array_list_t *infos);
+
+static void printUmlDependencies(FILE *out, const celix_array_list_t *infos);
+
+
+static void parseCommandLine(const char*line, celix_array_list_t 
**requestedBundleIds, bool *fullInfo, bool *plantUmlInfo, bool *wtf, FILE *err) 
{
 *fullInfo = false;
 *wtf = false;
 char *str = strdup(line);
@@ -43,6 +56,8 @@ static void parseCommandLine(const char*line, 
celix_array_list_t **requestedBund
 *wtf = true;
 } else if (tok[0] == 'f') { // f or full argument => show full info
 *fullInfo = true;
+} else if (tok[0] == 'u') { // u or full plant UML syntax output 
=>copy paste in a file java -jar plantuml.jar  gives a nice dependency 
graph
+*plantUmlInfo = true;
 } else if ( (tok[0] >= '0') && (tok[0] <= '9')) { // bundle id
 long id = strtol(tok, NULL, 10);
 celix_arrayList_addLong(*requestedBundleIds, id);
@@ -102,6 +117,74 @@ static void printFullInfo(FILE *out, bool colors, long 
bundleId, const char* bnd
 fprintf(out, "\n");
 
 }
+static void printPlantUmlInfo(FILE *out, celix_dependency_manager_t *mng) {
+
+celix_array_list_t *infos = celix_dependencyManager_createInfos(mng);
+
+fprintf(out, "@startuml\n");
+
+printUmlComponents(out, infos);
+printUmlDependencies(out, infos);
+
+fprintf(out, "@enduml\n");
+}
+
+static void printUmlComponents(FILE *out, const celix_array_list_t *infos) {
+unsigned int nof_bundles = celix_arrayList_size(infos);
+for (int bnd = 0; bnd < nof_bundles; ++bnd) {
+celix_dependency_manager_info_t *info = celix_arrayList_get(infos, 
bnd);
+for (int cmpCnt = 0; cmpCnt < celix_arrayList_size(info->components); 
++cmpCnt) {
+celix_dm_component_info_t *compInfo = 
celix_arrayList_get(info->components, cmpCnt);
+fprintf(out, "class %s\n", compInfo->name);
+for (int interfCnt = 0; interfCnt < 
celix_arrayList_size(compInfo->interfaces); interfCnt++) {
+dm_interface_info_pt intfInfo = 
celix_arrayList_get(compInfo->interfaces, interfCnt);
+fprintf(out, "interface %s\n", intfInfo->name);
+}
+}
+}
+// depdencies at last, since the type overwrites the interface for a nice 
graph
+for (int bnd = 0; bnd < nof_bundles; ++bnd) {
+celix_dependency_manager_info_t *info = celix_arrayList_get(infos, 
bnd);
+for (int cmpCnt = 0; cmpCnt < celix_arrayList_size(info->components); 
++cmpCnt) {
+celix_dm_component_info_t *compInfo = 
celix_arrayList_get(info->components, cmpCnt);
+for (int depCnt = 0; depCnt < 
celix_arrayList_size(compInfo->dependency_list); ++depCnt) {
+dm_service_dependency_info_pt dependency;
+dependency = celix_arrayList_get(compInfo->dependency_list, 
depCnt);
+fprintf(out, "interface %s\n", dependency->serviceName);
+}
+}
+}
+fprintf(out, "\n");
+}
+
+
+static void pr

[celix] 01/01: Merge pull request #361 from apache/PR358_match_admin_name_fix

2021-09-13 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git

commit f029b2a48aea46246527f480e5f9dccf01222a1f
Merge: 214e831 34b580e
Author: Erjan Altena 
AuthorDate: Mon Sep 13 21:04:58 2021 +0200

Merge pull request #361 from apache/PR358_match_admin_name_fix

#358 Fix for comparing with same string with extension

 bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)


[celix] branch master updated (214e831 -> f029b2a)

2021-09-13 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git.


from 214e831  Merge pull request #362 from 
stegemr/feature/bugfix_ExceptionSlice
 add 34b580e  #358 Fix for comparing with same string with extension
 new f029b2a  Merge pull request #361 from apache/PR358_match_admin_name_fix

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)


[celix] branch PR358_match_admin_name_fix created (now 34b580e)

2021-09-09 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch PR358_match_admin_name_fix
in repository https://gitbox.apache.org/repos/asf/celix.git.


  at 34b580e  #358 Fix for comparing with same string with extension

This branch includes the following new commits:

 new 34b580e  #358 Fix for comparing with same string with extension

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[celix] 01/01: #358 Fix for comparing with same string with extension

2021-09-09 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch PR358_match_admin_name_fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 34b580e4943b6309b23a249d069e948e47fe8d16
Author: Erjan Altena 
AuthorDate: Mon Sep 6 20:01:35 2021 +0200

#358 Fix for comparing with same string with extension
---
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c 
b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
index 89173b1..7514800 100644
--- a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
+++ b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
@@ -33,17 +33,17 @@
 
 static double getPSAScore(const char *requested_admin, const char 
*request_qos, const char *adminType, double sampleScore, double controlScore, 
double defaultScore) {
 double score;
-if (requested_admin != NULL && strncmp(requested_admin, adminType, 
strlen(adminType)) == 0) {
+if (requested_admin != NULL && strncmp(requested_admin, adminType, 
strlen(adminType) + 1) == 0) {
 /* We got precise specification on the pubsub_admin we want */
 //Full match
 score = PUBSUB_ADMIN_FULL_MATCH_SCORE;
 } else if (requested_admin != NULL) {
 //admin type requested, but no match -> do not select this psa
 score = PUBSUB_ADMIN_NO_MATCH_SCORE;
-} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_SAMPLE, strlen(PUBSUB_UTILS_QOS_TYPE_SAMPLE)) == 0) {
+} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_SAMPLE, strlen(PUBSUB_UTILS_QOS_TYPE_SAMPLE) + 1) == 0) {
 //qos match
 score = sampleScore;
-} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_CONTROL, strlen(PUBSUB_UTILS_QOS_TYPE_CONTROL)) == 0) {
+} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_CONTROL, strlen(PUBSUB_UTILS_QOS_TYPE_CONTROL) + 1) == 0) 
{
 //qos match
 score = controlScore;
 } else if (request_qos != NULL) {
@@ -273,7 +273,7 @@ bool pubsubEndpoint_match(
 bool psaMatch = false;
 const char *configured_admin = celix_properties_get(ep, 
PUBSUB_ENDPOINT_ADMIN_TYPE, NULL);
 if (configured_admin != NULL) {
-psaMatch = strncmp(configured_admin, adminType, strlen(adminType)) == 
0;
+psaMatch = strncmp(configured_admin, adminType, strlen(adminType) + 1) 
== 0;
 }
 
 bool serMatch = false;


[celix] branch PR358_matching_admin_name_fix updated: #358 Fix for comparing with same string with extension

2021-09-06 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch PR358_matching_admin_name_fix
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/PR358_matching_admin_name_fix 
by this push:
 new a607810  #358 Fix for comparing with same string with extension
a607810 is described below

commit a607810e29c2e22d32fdcfbec5ae84a2d6512b96
Author: Erjan Altena 
AuthorDate: Mon Sep 6 20:01:35 2021 +0200

#358 Fix for comparing with same string with extension
---
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c 
b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
index 659ad5d..693c401 100644
--- a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
+++ b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
@@ -32,17 +32,17 @@
 
 static double getPSAScore(const char *requested_admin, const char 
*request_qos, const char *adminType, double sampleScore, double controlScore, 
double defaultScore) {
 double score;
-if (requested_admin != NULL && strncmp(requested_admin, adminType, 
strlen(adminType)) == 0) {
+if (requested_admin != NULL && strncmp(requested_admin, adminType, 
strlen(adminType) + 1) == 0) {
 /* We got precise specification on the pubsub_admin we want */
 //Full match
 score = PUBSUB_ADMIN_FULL_MATCH_SCORE;
 } else if (requested_admin != NULL) {
 //admin type requested, but no match -> do not select this psa
 score = PUBSUB_ADMIN_NO_MATCH_SCORE;
-} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_SAMPLE, strlen(PUBSUB_UTILS_QOS_TYPE_SAMPLE)) == 0) {
+} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_SAMPLE, strlen(PUBSUB_UTILS_QOS_TYPE_SAMPLE) + 1) == 0) {
 //qos match
 score = sampleScore;
-} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_CONTROL, strlen(PUBSUB_UTILS_QOS_TYPE_CONTROL)) == 0) {
+} else if (request_qos != NULL && strncmp(request_qos, 
PUBSUB_UTILS_QOS_TYPE_CONTROL, strlen(PUBSUB_UTILS_QOS_TYPE_CONTROL) + 1) == 0) 
{
 //qos match
 score = controlScore;
 } else if (request_qos != NULL) {
@@ -288,7 +288,7 @@ bool pubsubEndpoint_match(
 bool psaMatch = false;
 const char *configured_admin = celix_properties_get(ep, 
PUBSUB_ENDPOINT_ADMIN_TYPE, NULL);
 if (configured_admin != NULL) {
-psaMatch = strncmp(configured_admin, adminType, strlen(adminType)) == 
0;
+psaMatch = strncmp(configured_admin, adminType, strlen(adminType) + 1) 
== 0;
 }
 
 bool serMatch = false;


[celix] branch PR358_matching_admin_name_fix created (now 1833814)

2021-09-06 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch PR358_matching_admin_name_fix
in repository https://gitbox.apache.org/repos/asf/celix.git.


  at 1833814  Merge pull request #213 from 
apache/bugfix/fix_tcp_admin_using_ip_with_postfix

No new revisions were added by this update.


[celix] branch develop updated: Added missing findpackage/include dirs. Include directories on host system where used iso those found with find package

2019-05-06 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena 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 db4bd65  Added missing findpackage/include dirs. Include directories 
on host system where used iso those found with find package
db4bd65 is described below

commit db4bd656e44756609b1e59644f5a57ca4e55cf88
Author: Erjan Altena 
AuthorDate: Mon May 6 10:35:34 2019 +0200

Added missing findpackage/include dirs. Include directories on host system 
where used iso those found with find package
---
 bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt  | 2 ++
 bundles/pubsub/pubsub_topology_manager/CMakeLists.txt   | 4 
 bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt | 2 +-
 libs/framework/CMakeLists.txt   | 2 +-
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt 
b/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt
index b960615..f7bac88 100644
--- a/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt
@@ -20,6 +20,7 @@ if (BUILD_PUBSUB_PSA_ZMQ)
find_package(ZMQ REQUIRED)
find_package(CZMQ REQUIRED)
find_package(Jansson REQUIRED)
+   find_package(UUID REQUIRED)
 
if (BUILD_ZMQ_SECURITY)
add_definitions(-DBUILD_WITH_ZMQ_SECURITY=1)
@@ -53,6 +54,7 @@ if (BUILD_PUBSUB_PSA_ZMQ)
${ZMQ_INCLUDE_DIR}
${CZMQ_INCLUDE_DIR}
${JANSSON_INCLUDE_DIR}
+   ${UUID_INCLUDE_DIRS}
src
)
 
diff --git a/bundles/pubsub/pubsub_topology_manager/CMakeLists.txt 
b/bundles/pubsub/pubsub_topology_manager/CMakeLists.txt
index ae18912..2ff659c 100644
--- a/bundles/pubsub/pubsub_topology_manager/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_topology_manager/CMakeLists.txt
@@ -15,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+find_package(UUID REQUIRED)
+
 add_celix_bundle(celix_pubsub_topology_manager
 BUNDLE_SYMBOLICNAME "apache_celix_pubsub_topology_manager"
 VERSION "1.0.0"
@@ -25,6 +27,8 @@ add_celix_bundle(celix_pubsub_topology_manager
src/pubsub_topology_manager.h
 )
 target_link_libraries(celix_pubsub_topology_manager PRIVATE Celix::framework 
Celix::log_helper Celix::pubsub_spi Celix::shell_api)
+target_include_directories(celix_pubsub_topology_manager PRIVATE 
${UUID_INCLUDE_DIRS})
+
 get_target_property(DESC Celix::pubsub_spi TOPIC_INFO_DESCRIPTOR)
 celix_bundle_files(celix_pubsub_topology_manager
${DESC}
diff --git a/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt 
b/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
index d241d7b..91037a4 100644
--- a/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
+++ b/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
@@ -40,7 +40,7 @@ if (RSA_REMOTE_SERVICE_ADMIN_DFI)
 celix_bundle_private_libs(rsa_dfi Celix::dfi)
 target_include_directories(rsa_dfi PRIVATE 
$)
 #target_include_directories(rsa_dfi SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} 
${JANSSON_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS})
-target_include_directories(rsa_dfi PRIVATE ${JANSSON_INCLUDE_DIRS})
+target_include_directories(rsa_dfi PRIVATE ${JANSSON_INCLUDE_DIRS} 
${UUID_INCLUDE_DIRS})
 target_link_libraries(rsa_dfi PRIVATE
 Celix::dfi
 Celix::log_helper
diff --git a/libs/framework/CMakeLists.txt b/libs/framework/CMakeLists.txt
index 29181e2..a404f2a 100644
--- a/libs/framework/CMakeLists.txt
+++ b/libs/framework/CMakeLists.txt
@@ -47,7 +47,7 @@ target_compile_options(framework PRIVATE -DUSE_FILE32API)
 set_target_properties(framework PROPERTIES "SOVERSION" 2)
 target_link_libraries(framework PUBLIC Celix::utils)
 target_link_libraries(framework PRIVATE ${UUID_LIBRARY} ${ZLIB_LIBRARY} 
${CURL_LIBRARIES})
-
+target_include_directories(framework PRIVATE ${CURL_INCLUDE_DIR} 
${UUID_INCLUDE_DIRS})
 install(TARGETS framework EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} 
COMPONENT framework)
 install(DIRECTORY include/ DESTINATION include/celix COMPONENT framework)
 



[celix] branch develop updated: Fixed typo in zmq-admin shed->sched

2019-04-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena 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 1ba7643  Fixed typo in zmq-admin shed->sched
1ba7643 is described below

commit 1ba764335a7e810ac2d9e05a2f18db21f1bae989
Author: Erjan Altena 
AuthorDate: Thu Apr 11 10:28:29 2019 +0200

Fixed typo in zmq-admin shed->sched
---
 bundles/pubsub/pubsub_admin_zmq/src/pubsub_psa_zmq_constants.h  | 2 +-
 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_psa_zmq_constants.h 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_psa_zmq_constants.h
index bdff810..ef8361e 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_psa_zmq_constants.h
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_psa_zmq_constants.h
@@ -91,7 +91,7 @@
  * Can be set in the topic properties.
  */
 #define PUBSUB_ZMQ_THREAD_REALTIME_PRIO"thread.realtime.prio"
-#define PUBSUB_ZMQ_THREAD_REALTIME_SHED"thread.realtime.shed"
+#define PUBSUB_ZMQ_THREAD_REALTIME_SCHED   "thread.realtime.sched"
 
 /**
  * High Water Mark option. See ZMQ doc for more information
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
index 7799f4c..f8950e4 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
@@ -758,7 +758,7 @@ static void 
psa_zmq_setupZmqContext(pubsub_zmq_topic_receiver_t *receiver, const
 }
 }
 
-const char *sched = celix_properties_get(topicProperties, 
PUBSUB_ZMQ_THREAD_REALTIME_SHED, NULL);
+const char *sched = celix_properties_get(topicProperties, 
PUBSUB_ZMQ_THREAD_REALTIME_SCHED, NULL);
 if (sched != NULL) {
 int policy = ZMQ_THREAD_SCHED_POLICY_DFLT;
 if (strncmp("SCHED_OTHER", sched, 16) == 0) {
@@ -806,4 +806,4 @@ static void 
psa_zmq_setupZmqSocket(pubsub_zmq_topic_receiver_t *receiver, const
 ts->zmq_cert = sub_cert;
 ts->zmq_pub_cert = pub_cert;
 #endif
-}
\ No newline at end of file
+}



[celix] branch feature/CELIX-459-pubsub-hums updated: CELIX-460: aligned signed/unsigned in metrics type

2019-02-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch feature/CELIX-459-pubsub-hums
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/CELIX-459-pubsub-hums 
by this push:
 new fcde889  CELIX-460: aligned signed/unsigned in metrics type
fcde889 is described below

commit fcde889c2ec136de6259c436d0c3ae8677b5c97f
Author: Erjan Altena 
AuthorDate: Mon Feb 11 14:34:13 2019 +0100

CELIX-460: aligned signed/unsigned in metrics type
---
 .../pubsub_spi/include/pubsub_admin_metrics.h  | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h 
b/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
index 8bb7c2a..2f351a1 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_admin_metrics.h
@@ -31,10 +31,10 @@
 typedef struct pubsub_admin_sender_msg_type_metrics {
long bndId;
char typeFqn[PUBSUB_AMDIN_METRICS_NAME_MAX];
-   int typeId;
-   long nrOfMessagesSend;
-   long nrOfMessagesSendFailed;
-   long nrOfSerializationErrors;
+   unsigned int typeId;
+   unsigned long nrOfMessagesSend;
+   unsigned long nrOfMessagesSendFailed;
+   unsigned long nrOfSerializationErrors;
struct timespec lastMessageSend;
double averageTimeBetweenMessagesInSeconds;
double averageSerializationTimeInSeconds;
@@ -43,24 +43,24 @@ typedef struct pubsub_admin_sender_msg_type_metrics {
 typedef struct pubsub_admin_sender_metrics {
char scope[PUBSUB_AMDIN_METRICS_NAME_MAX];
char topic[PUBSUB_AMDIN_METRICS_NAME_MAX];
-   long nrOfUnknownMessagesRetrieved;
-   int nrOfmsgMetrics;
+   unsigned long nrOfUnknownMessagesRetrieved;
+   unsigned int nrOfmsgMetrics;
pubsub_admin_sender_msg_type_metrics_t *msgMetrics; //size = 
nrOfMessageTypes
 } pubsub_admin_sender_metrics_t;
 
 typedef struct pubsub_admin_receiver_metrics {
char scope[PUBSUB_AMDIN_METRICS_NAME_MAX];
char topic[PUBSUB_AMDIN_METRICS_NAME_MAX];
-   long nrOfMsgTypes;
+   unsigned long nrOfMsgTypes;
struct {
-   int typeId;
+   unsigned int typeId;
char typeFqn[PUBSUB_AMDIN_METRICS_NAME_MAX];
int nrOfOrigins;
struct {
uuid_t originUUID;
-   long nrOfMessagesReceived;
-   long nrOfSerializationErrors;
-   long nrOfMissingSeqNumbers;
+   unsigned long nrOfMessagesReceived;
+   unsigned long nrOfSerializationErrors;
+   unsigned long nrOfMissingSeqNumbers;
struct timespec lastMessageReceived;
double averageTimeBetweenMessagesInSeconds;
double averageSerializationTimeInSeconds;



[celix] branch feature/CELIX-459-pubsub-hums updated: CELIX-460: Report msg id as hexadecimal

2019-02-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch feature/CELIX-459-pubsub-hums
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/CELIX-459-pubsub-hums 
by this push:
 new 340e87a  CELIX-460: Report msg id as hexadecimal
340e87a is described below

commit 340e87af8cb4dc2de78aaf64e421170fe48d4ada
Author: Erjan Altena 
AuthorDate: Mon Feb 11 14:10:34 2019 +0100

CELIX-460: Report msg id as hexadecimal
---
 bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c 
b/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
index be18131..3ca41f5 100644
--- a/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
+++ b/bundles/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
@@ -1146,7 +1146,7 @@ static celix_status_t 
pubsub_topologyManager_metrics(pubsub_topology_manager_t *
 char uuidStr[UUID_STR_LEN+1];
 uuid_unparse(rm->msgTypes[j].origins[m].originUUID, 
uuidStr);
 fprintf(os, "   |- Message '%s' from framework UUID 
%s:\n", rm->msgTypes[j].typeFqn, uuidStr);
-fprintf(os, "  |- msg type = %i\n", 
rm->msgTypes[j].typeId);
+fprintf(os, "  |- msg type = 0x%X\n", 
rm->msgTypes[j].typeId);
 fprintf(os, "  |- receive count = %li\n", 
rm->msgTypes[j].origins[m].nrOfMessagesReceived);
 fprintf(os, "  |- serialization error = %li\n", 
rm->msgTypes[j].origins[m].nrOfSerializationErrors);
 fprintf(os, "  |- missing seq numbers = %li\n", 
rm->msgTypes[j].origins[m].nrOfMissingSeqNumbers);



[celix] branch hotfix/CELIX_460_msgid deleted (was dc4efa3)

2019-02-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch hotfix/CELIX_460_msgid
in repository https://gitbox.apache.org/repos/asf/celix.git.


 was dc4efa3  Fixes an issue in the FindUUID.cmake

The revisions that were on this branch are still contained in
other references; therefore, this change does not discard any commits
from the repository.



[celix] branch feature/CELIX-459-pubsub-hums updated: CELIX-460: Fixed signed/unsigned mismatch in pubsub which caused missing messages

2019-02-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch feature/CELIX-459-pubsub-hums
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/CELIX-459-pubsub-hums 
by this push:
 new 855c5e4  CELIX-460: Fixed signed/unsigned mismatch in pubsub which 
caused missing messages
855c5e4 is described below

commit 855c5e4e7232e86544d43a05d6c9de5de9dc37b4
Author: Erjan Altena 
AuthorDate: Mon Feb 11 13:41:57 2019 +0100

CELIX-460: Fixed signed/unsigned mismatch in pubsub which caused missing 
messages
---
 .../pubsub_admin_zmq/src/pubsub_zmq_common.c   |  6 +--
 .../pubsub_admin_zmq/src/pubsub_zmq_common.h   | 12 +++---
 .../src/pubsub_zmq_topic_receiver.c| 44 --
 .../src/pubsub_topology_manager.c  |  4 +-
 4 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.c 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.c
index e77398c..0854a93 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.c
@@ -60,12 +60,12 @@ void psa_zmq_setScopeAndTopicFilter(const char* scope, 
const char *topic, char *
 }
 }
 
-static int readInt(const unsigned char *data, int offset, int32_t *val) {
+static int readInt(const unsigned char *data, int offset, uint32_t *val) {
 *val = ((data[offset+0] << 24) | (data[offset+1] << 16) | (data[offset+2] 
<< 8) | (data[offset+3] << 0));
 return offset + 4;
 }
 
-static int readLong(const unsigned char *data, int offset, int64_t *val) {
+static int readLong(const unsigned char *data, int offset, uint64_t *val) {
 *val = (
 ((int64_t)data[offset+0] << 56) |
 ((int64_t)data[offset+1] << 48) |
@@ -134,4 +134,4 @@ void psa_zmq_encodeHeader(const pubsub_zmq_msg_header_t 
*msgHeader, unsigned cha
 index += 16;
 index = writeLong(data, index, msgHeader->sendtimeSeconds);
 writeLong(data, index, msgHeader->sendTimeNanoseconds);
-}
\ No newline at end of file
+}
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.h 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.h
index 8a4c7ff..3e0e52f 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.h
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.h
@@ -38,13 +38,13 @@
 
 
 struct pubsub_zmq_msg_header {
-int32_t type; //msg type id (hash of fqn)
-int8_t major;
-int8_t minor;
-int32_t seqNr;
+uint32_t type; //msg type id (hash of fqn)
+uint8_t major;
+uint8_t minor;
+uint32_t seqNr;
 unsigned char originUUID[16];
-int64_t sendtimeSeconds; //seconds since epoch
-int64_t sendTimeNanoseconds; //ns since epoch
+uint64_t sendtimeSeconds; //seconds since epoch
+uint64_t sendTimeNanoseconds; //ns since epoch
 };
 
 typedef struct pubsub_zmq_msg_header pubsub_zmq_msg_header_t;
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
index 3790bdb..b8a5cc7 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
@@ -90,19 +90,19 @@ typedef struct psa_zmq_requested_connection_entry {
 } psa_zmq_requested_connection_entry_t;
 
 typedef struct psa_zmq_subscriber_metrics_entry_t {
-int msgTypeId;
+unsigned int msgTypeId;
 uuid_t origin;
 
-long nrOfMessagesReceived;
-long nrOfSerializationErrors;
+unsigned long nrOfMessagesReceived;
+unsigned long nrOfSerializationErrors;
 struct timespec lastMessageReceived;
 double averageTimeBetweenMessagesInSeconds;
 double averageSerializationTimeInSeconds;
 double averageDelayInSeconds;
 double maxDelayInSeconds;
 double minDelayInSeconds;
-int lastSeqNr;
-long nrOfMissingSeqNumbers;
+unsigned int lastSeqNr;
+unsigned long nrOfMissingSeqNumbers;
 } psa_zmq_subscriber_metrics_entry_t;
 
 typedef struct psa_zmq_subscriber_entry {
@@ -495,7 +495,7 @@ static inline void 
processMsgForSubscriberEntry(pubsub_zmq_topic_receiver_t *rec
 }
 }
 } else {
-L_WARN("[PSA_ZMQ_TR] Cannot find serializer for type id %i", 
hdr->type);
+L_WARN("[PSA_ZMQ_TR] Cannot find serializer for type id 0x%X", 
hdr->type);
 }
 
 if (msgSer != NULL && monitor) {
@@ -673,19 +673,23 @@ pubsub_admin_receiver_metrics_t* 
pubsub_zmqTopicReceiver_metrics(pubsub_zmq_topi
 psa_zmq_subscriber_metrics_entry_t *metrics = 
hashMapIterator_nextValue(&iter3);
 result->msgTypes[i].typeId = metrics->msgTypeId;
 pubsub_msg_serializer_t *msgSer = hashMap_get(entry->msgTypes, 
(vo

[celix] branch hotfix/CELIX_460_msgid created (now dc4efa3)

2019-02-11 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch hotfix/CELIX_460_msgid
in repository https://gitbox.apache.org/repos/asf/celix.git.


  at dc4efa3  Fixes an issue in the FindUUID.cmake

No new revisions were added by this update.



[celix] branch nanomsg deleted (was f8a7dd1)

2019-01-03 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch nanomsg
in repository https://gitbox.apache.org/repos/asf/celix.git.


 was f8a7dd1  Nanomsg removed debug prints

The revisions that were on this branch are still contained in
other references; therefore, this change does not discard any commits
from the repository.



[celix] 01/01: Merge remote-tracking branch 'remotes/origin/develop' into nanomsg

2018-12-28 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 7f67b07cf27bfca062388f261643f4e418d89a19
Merge: f8a7dd1 52ca1dd
Author: Erjan Altena 
AuthorDate: Fri Dec 28 12:42:53 2018 +0100

Merge remote-tracking branch 'remotes/origin/develop' into nanomsg

 bundles/log_service/loghelper_include/log_helper.h |   2 +-
 .../log_writer/log_writer_syslog/CMakeLists.txt|   2 +-
 .../pubsub_discovery/src/pubsub_discovery_impl.c   |  31 +-
 .../pubsub/pubsub_spi/include/pubsub_constants.h   |  15 +
 .../pubsub/pubsub_spi/include/pubsub_endpoint.h|   6 +-
 .../src/pubsub_topology_manager.c  | 103 ++--
 .../src/pubsub_topology_manager.h  |   3 +-
 .../discovery_common/src/discovery_activator.c |   2 +-
 .../discovery_etcd/src/etcd_watcher.c  |   4 +-
 bundles/shell/shell/include/shell.h|   2 +-
 bundles/shell/shell/src/dm_shell_list_command.c| 115 ++---
 cmake/cmake_celix/ContainerPackaging.cmake | 151 +++---
 cmake/cmake_celix/DockerPackaging.cmake|   2 +-
 cmake/cmake_celix/runtime_common.sh.in |   4 +-
 doap/doap_Celix.rdf|   2 +-
 documents/cmake_commands/readme.md |  10 +-
 examples/celix-examples/CMakeLists.txt |   2 +
 .../bar/private/src/bar_activator.c|  13 +-
 .../foo1/private/src/foo1_activator.c  |  28 +-
 .../foo2/private/src/foo2.c|   2 +-
 .../foo2/private/src/foo2_activator.c  |  30 +-
 .../celix-examples/civetweb/src/bundle_activator.c |   2 +-
 examples/celix-examples/dm_example/CMakeLists.txt  |   5 +-
 .../dm_example/phase1/CMakeLists.txt   |  11 -
 .../dm_example/phase1/src/phase1_activator.c   |  47 +-
 .../dm_example/phase1/src/phase1_cmp.c |   6 +-
 .../dm_example/phase1/src/phase1_cmp.h |   2 +-
 .../dm_example/phase2a/CMakeLists.txt  |  11 -
 .../dm_example/phase2a/src/phase2a_activator.c |  59 +--
 .../dm_example/phase2b/CMakeLists.txt  |  11 -
 .../dm_example/phase2b/src/phase2b_activator.c |  60 +--
 .../dm_example/phase3/CMakeLists.txt   |  11 -
 .../dm_example/phase3/src/phase3_activator.c   |  62 ++-
 .../dm_example/phase3/src/phase3_cmp.c |   2 +-
 .../celix-examples/dm_example_cxx/CMakeLists.txt   |   1 +
 .../dm_example_cxx/phase1/src/Phase1Activator.cc   |   8 +-
 .../dm_example_cxx/phase1/src/Phase1Activator.h|   1 -
 .../celix-examples/embedding/private/src/main.c|   8 +-
 .../hello_world/private/src/activator.c|   8 +-
 .../hello_world_test/private/src/activator.c   |   8 +-
 .../log_service_example/src/activator.c|   8 +-
 .../service_hook_example/src/activator.c   |  12 +-
 .../src/dynamic_provider_example.c |   2 +-
 libs/dependency_manager/src/dm_activator.c |  10 +-
 libs/dependency_manager_cxx/src/dm_activator.cc|  18 +-
 libs/framework/include/bundle.h|  76 +--
 libs/framework/include/bundle_activator.h  |  16 +-
 libs/framework/include/bundle_context.h|  54 +-
 libs/framework/include/bundle_revision.h   |   4 +-
 libs/framework/include/celix/dm/Component.h|  26 +-
 libs/framework/include/celix/dm/Component_Impl.h   |  37 +-
 .../framework/include/celix/dm/DependencyManager.h |  18 +-
 libs/framework/include/celix/dm/DmActivator.h  |  14 +-
 .../framework/include/celix/dm/ServiceDependency.h |  16 +-
 .../include/celix/dm/ServiceDependency_Impl.h  |  88 ++--
 libs/framework/include/celix_api.h |   3 +-
 libs/framework/include/celix_bundle_context.h  |   2 +-
 libs/framework/include/celix_dependency_manager.h  |  86 
 .../{dm_component.h => celix_dm_component.h}   |  63 +--
 libs/framework/include/celix_dm_info.h |  76 +++
 .../include/celix_dm_service_dependency.h  | 169 +++
 libs/framework/include/celix_framework.h   |   2 -
 libs/framework/include/celix_framework_factory.h   |   2 +-
 libs/framework/include/celix_launcher.h|  14 +-
 libs/framework/include/celix_types.h   |  50 +-
 libs/framework/include/constants.h |   3 +
 libs/framework/include/dm_activator.h  |  12 +-
 libs/framework/include/dm_component.h  |  52 +-
 libs/framework/include/dm_dependency_manager.h |  18 +-
 libs/framework/include/dm_info.h   |  76 ---
 libs/framework/include/dm_service_dependency.h |  36 +-
 libs/framework/include/framework.h |  17 +-
 libs/framework/include/listener_hook_service.h |   6 +-
 libs/framework/include/manifest.h  |   4 +-
 libs/framework/include/module.h|  12 +-
 libs/fram

[celix] branch develop updated (52ca1dd -> 7f67b07)

2018-12-28 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git.


from 52ca1dd  Fixed link in Doap file to new GitBox url
 add 4fc1f3d  NanoMsgAdmin: first version
 add cb740b0  Updates to nanomsg admin
 add 95892a8  admin mutexes replaced by std::mutex and lock_guard
 add 3009e64  Replaced celix-map with std::map
 add 95633eb  Removed celix-maps from nanomsg admin
 add c19a5bd  nanomsg topicreceiver changed to class
 add 0abbf43  nanomsg Topic receiver to class
 add 8658738  nanomsg celix-map replaced by std::map
 add 120895d  subscriber.map now std::map
 add 883abee  Nanomsg: moved charptr to std::string
 add cdefb0d  Nanomsg
 add 7c14142  NanoMsg
 add 15f268d  Nanomsg
 add b6a0337  NanoMsg
 add 707b8e5  Nanomsg
 add b53498a  Nanomsg: added LogHelper class
 add a54c3c5  NanoMsg, fixed deadlock
 add f8a7dd1  Nanomsg removed debug prints
 new 7f67b07  Merge remote-tracking branch 'remotes/origin/develop' into 
nanomsg

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../device_access/device_access/src/activator.c|   0
 bundles/log_service/loghelper_include/log_helper.h |   9 +-
 bundles/log_service/src/log_helper.c   |   2 +-
 bundles/pubsub/CMakeLists.txt  |   2 +
 bundles/pubsub/examples/CMakeLists.txt |  88 ++-
 bundles/pubsub/pubsub_admin_nanomsg/CMakeLists.txt |  51 ++
 .../pubsub/pubsub_admin_nanomsg/src/LogHelper.h|  98 
 .../src/psa_nanomsg_activator.cc   |  87 +++
 .../src/pubsub_nanomsg_admin.cc| 609 +
 .../src/pubsub_nanomsg_admin.h | 136 +
 .../src/pubsub_nanomsg_common.cc}  |  26 +-
 .../src/pubsub_nanomsg_common.h}   |  27 +-
 .../src/pubsub_nanomsg_topic_receiver.cc   | 319 +++
 .../src/pubsub_nanomsg_topic_receiver.h| 125 +
 .../src/pubsub_nanomsg_topic_sender.cc | 267 +
 .../src/pubsub_nanomsg_topic_sender.h  | 111 
 .../src/pubsub_psa_nanomsg_constants.h |  35 +-
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c   |   2 +-
 .../pubsub/pubsub_spi/include/pubsub_endpoint.h|  23 +-
 bundles/pubsub/pubsub_spi/include/pubsub_utils.h   |  50 +-
 cmake/Modules/{FindZMQ.cmake => FindNanoMsg.cmake} |  14 +-
 doap/doap_Celix.rdf|   0
 libs/framework/include/celix_bundle_activator.h|   2 +-
 23 files changed, 1987 insertions(+), 96 deletions(-)
 mode change 100755 => 100644 
bundles/device_access/device_access/src/activator.c
 create mode 100644 bundles/pubsub/pubsub_admin_nanomsg/CMakeLists.txt
 create mode 100644 bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
 copy bundles/pubsub/{pubsub_admin_zmq/src/pubsub_zmq_common.c => 
pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc} (66%)
 copy bundles/pubsub/{pubsub_admin_zmq/src/pubsub_zmq_common.h => 
pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h} (70%)
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.h
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
 create mode 100644 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.h
 copy libs/utils/include/filter.h => 
bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_psa_nanomsg_constants.h (51%)
 copy cmake/Modules/{FindZMQ.cmake => FindNanoMsg.cmake} (78%)
 mode change 100755 => 100644 doap/doap_Celix.rdf



[celix] branch nanomsg updated: Nanomsg removed debug prints

2018-12-28 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch nanomsg
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/nanomsg by this push:
 new f8a7dd1  Nanomsg removed debug prints
f8a7dd1 is described below

commit f8a7dd194d6afcc7f86911f08d76ab815f31b9d0
Author: Erjan Altena 
AuthorDate: Fri Dec 28 12:41:10 2018 +0100

Nanomsg removed debug prints
---
 .../src/pubsub_nanomsg_admin.cc| 10 +
 .../src/pubsub_nanomsg_common.cc   |  6 +++---
 .../src/pubsub_nanomsg_common.h| 21 +--
 .../src/pubsub_nanomsg_topic_receiver.cc   |  8 
 .../src/pubsub_nanomsg_topic_sender.cc |  4 ++--
 .../src/pubsub_psa_nanomsg_constants.h | 24 --
 libs/framework/src/service_registry.c  | 23 +++--
 libs/framework/src/service_tracker.c   |  8 ++--
 8 files changed, 38 insertions(+), 66 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 6d4454e..8f3c229 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -248,12 +248,14 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 
 {
 std::lock_guard receiverLock(topicReceivers.mutex);
-for (auto &kv : topicReceivers.map){
-auto *receiver = kv.second;
+for (auto iter = topicReceivers.map.begin(); iter != 
topicReceivers.map.end();) {
+auto *receiver = iter->second;
 if (receiver != nullptr && entry.svcId == 
receiver->serializerSvcId()) {
-auto key = kv.first;
-topicReceivers.map.erase(key);
+auto key = iter->first;
+topicReceivers.map.erase(iter++);
 delete receiver;
+} else {
+++iter;
 }
 }
 }
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
index a0e68a0..520c22e 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
@@ -20,13 +20,13 @@
 #include 
 #include "pubsub_nanomsg_common.h"
 
-int psa_nanoMsg_localMsgTypeIdForMsgType(void *handle __attribute__((unused)), 
const char *msgType,
+int celix::pubsub::nanomsg::localMsgTypeIdForMsgType(void *handle 
__attribute__((unused)), const char *msgType,
  unsigned int *msgTypeId) {
 *msgTypeId = utils_stringHash(msgType);
 return 0;
 }
 
-bool psa_nanomsg_checkVersion(version_pt msgVersion, const 
celix::pubsub::nanomsg::msg_header *hdr) {
+bool celix::pubsub::nanomsg::checkVersion(version_pt msgVersion, const 
celix::pubsub::nanomsg::msg_header *hdr) {
 bool check=false;
 int major=0,minor=0;
 
@@ -41,7 +41,7 @@ bool psa_nanomsg_checkVersion(version_pt msgVersion, const 
celix::pubsub::nanoms
 return check;
 }
 
-std::string psa_nanomsg_setScopeAndTopicFilter(const std::string &scope, const 
std::string &topic) {
+std::string celix::pubsub::nanomsg::setScopeAndTopicFilter(const std::string 
&scope, const std::string &topic) {
 std::string result("");
 if (scope.size() >= 2)  { //3 ??
 result += scope[0];
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
index a792521..e22b4df 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
@@ -39,20 +39,19 @@
  */
 
 namespace celix { namespace pubsub { namespace nanomsg {
-struct msg_header {
-//header
-unsigned int type;
-unsigned char major;
-unsigned char minor;
-};
+struct msg_header {
+//header
+unsigned int type;
+unsigned char major;
+unsigned char minor;
+};
+int localMsgTypeIdForMsgType(void *handle, const char *msgType, unsigned 
int *msgTypeId);
+std::string setScopeAndTopicFilter(const std::string &scope, const 
std::string &topic);
 
-//typedef struct pubsub_nanomsg_msg_header pubsub_nanmosg_msg_header_t;
-}}}
+bool checkVersion(version_pt msgVersion, const 
celix::pubsub::nanomsg::msg_header *hdr);
 
-int psa_nanoMsg_localMsgTypeIdForMsgType(void *handle, const char *msgType, 
unsigned int *msgTypeId);
-std::string psa_nanomsg_setScopeAndTopicFilter(const std::string &scope, const 
std::string &am

[celix] branch nanomsg updated: NanoMsg, fixed deadlock

2018-12-28 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch nanomsg
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/nanomsg by this push:
 new a54c3c5  NanoMsg, fixed deadlock
a54c3c5 is described below

commit a54c3c544817c034a4145c557984ea87efbd8fe4
Author: Erjan Altena 
AuthorDate: Fri Dec 28 12:02:50 2018 +0100

NanoMsg, fixed deadlock
---
 .../pubsub/pubsub_admin_nanomsg/src/LogHelper.h| 74 +-
 .../src/psa_nanomsg_activator.cc   | 56 
 .../src/pubsub_nanomsg_admin.cc|  8 +--
 .../src/pubsub_nanomsg_admin.h |  2 +-
 .../src/pubsub_nanomsg_common.cc   |  2 +-
 .../src/pubsub_nanomsg_common.h| 10 +--
 .../src/pubsub_nanomsg_topic_receiver.cc   | 11 ++--
 .../src/pubsub_nanomsg_topic_receiver.h|  5 +-
 .../src/pubsub_nanomsg_topic_sender.cc |  7 +-
 .../src/pubsub_nanomsg_topic_sender.h  |  4 +-
 libs/framework/src/service_registry.c  | 23 ++-
 libs/framework/src/service_tracker.c   |  8 ++-
 12 files changed, 108 insertions(+), 102 deletions(-)

diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h 
b/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
index d14ebc3..6369051 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
@@ -15,96 +15,82 @@ limitations under the License.
 #pragma once
 #include 
 #include "log_helper.h"
-
+#include 
 namespace celix {
 namespace pubsub {
 namespace nanomsg {
-
-//template
-//void L_DEBUG(log_helper_t *logHelper, Args... args) {
-//std::stringstream ss = LOG_STREAM(args...);
-//logHelper_log(logHelper, OSGI_LOGSERVICE_DEBUG, 
ss.str().c_str());
-//}
-//
-//template
-//void L_INFO(log_helper_t *logHelper, Args... args) {
-//auto ss = LOG_STREAM(args...);
-//logHelper_log(logHelper, OSGI_LOGSERVICE_INFO, 
ss.str().c_str());
-//}
-//
-//template
-//void L_WARN(log_helper_t *logHelper, Args... args) {
-//auto ss = LOG_STREAM(args...);
-//logHelper_log(logHelper, OSGI_LOGSERVICE_WARNING, 
ss.str().c_str());
-//}
-//
-//template
-//void L_ERROR(log_helper_t *logHelper, Args... args) {
-//auto ss = LOG_STREAM(args...);
-//logHelper_log((log_helper_pt) logHelper, 
OSGI_LOGSERVICE_ERROR, ss.str().c_str());
-//}
-
+/*
+ * Not that the loghelper is created in the firs log-call. This is 
because when a log-helper is started
+ * during registration of a service with a service-factory a 
dead-lock can occur
+ * This prevents it.
+ */
 class LogHelper {
 public:
-LogHelper(log_helper_t *lh) : _logHelper{lh} {
+LogHelper(bundle_context_t *_ctx, const std::string& 
_componentName ) :  ctx{_ctx}, helperCreated{true}, 
componentName{_componentName}{
 }
 
-LogHelper(const LogHelper& ) = default;
-LogHelper& operator=(const LogHelper&) = default;
+LogHelper(const LogHelper& ) = delete;
+LogHelper& operator=(const LogHelper&) = delete;
 
-LogHelper(bundle_context_pt ctx) :  helperCreated{true} {
-logHelper_create(ctx, &_logHelper);
-logHelper_start(_logHelper);
-}
 
 ~LogHelper() {
-if (helperCreated) {
+if (helperCreated && _logHelper) {
 logHelper_stop(_logHelper);
 logHelper_destroy(&_logHelper);
 }
+std::cerr << "Destroyed loghelper for " << componentName 
<< std::endl;
 }
 template
 void ERROR(Args... args) {
 auto ss = LOG_STREAM(args...);
-logHelper_log(_logHelper, OSGI_LOGSERVICE_ERROR, 
ss.str().c_str());
+log_string(OSGI_LOGSERVICE_ERROR, ss.str());
 }
 
 template
 void WARN(Args... args) {
 auto ss = LOG_STREAM(args...);
-logHelper_log(_logHelper, OSGI_LOGSERVICE_WARNING, 
ss.str().c_str());
+log_string(OSGI_LOGSERVICE_WARNING, ss.str());
 }
 
 template
-void INFO(Args... args) {
+void INFO(Args... args)  {
   

[celix] branch nanomsg updated: Nanomsg: added LogHelper class

2018-12-23 Thread erjanaltena
This is an automated email from the ASF dual-hosted git repository.

erjanaltena pushed a commit to branch nanomsg
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/nanomsg by this push:
 new b53498a  Nanomsg: added LogHelper class
b53498a is described below

commit b53498a8c632d0857da1ab059fe4bfc87f26e9ba
Author: erjan altena 
AuthorDate: Sun Dec 23 11:23:46 2018 +0100

Nanomsg: added LogHelper class
---
 .../device_access/device_access/src/activator.c|   0
 .../pubsub/pubsub_admin_nanomsg/src/LogHelper.h| 112 +
 .../src/psa_nanomsg_activator.cc   |  43 +---
 .../src/pubsub_nanomsg_admin.cc|  75 ++
 .../src/pubsub_nanomsg_admin.h |  16 +--
 .../src/pubsub_nanomsg_common.h|   3 +-
 .../src/pubsub_nanomsg_topic_receiver.cc   |  62 +---
 .../src/pubsub_nanomsg_topic_receiver.h|   6 +-
 .../src/pubsub_nanomsg_topic_sender.cc |  73 +++---
 .../src/pubsub_nanomsg_topic_sender.h  |   9 +-
 doap/doap_Celix.rdf|   0
 11 files changed, 204 insertions(+), 195 deletions(-)

diff --git a/bundles/device_access/device_access/src/activator.c 
b/bundles/device_access/device_access/src/activator.c
old mode 100755
new mode 100644
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h 
b/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
new file mode 100644
index 000..d14ebc3
--- /dev/null
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/LogHelper.h
@@ -0,0 +1,112 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+#pragma once
+#include 
+#include "log_helper.h"
+
+namespace celix {
+namespace pubsub {
+namespace nanomsg {
+
+//template
+//void L_DEBUG(log_helper_t *logHelper, Args... args) {
+//std::stringstream ss = LOG_STREAM(args...);
+//logHelper_log(logHelper, OSGI_LOGSERVICE_DEBUG, 
ss.str().c_str());
+//}
+//
+//template
+//void L_INFO(log_helper_t *logHelper, Args... args) {
+//auto ss = LOG_STREAM(args...);
+//logHelper_log(logHelper, OSGI_LOGSERVICE_INFO, 
ss.str().c_str());
+//}
+//
+//template
+//void L_WARN(log_helper_t *logHelper, Args... args) {
+//auto ss = LOG_STREAM(args...);
+//logHelper_log(logHelper, OSGI_LOGSERVICE_WARNING, 
ss.str().c_str());
+//}
+//
+//template
+//void L_ERROR(log_helper_t *logHelper, Args... args) {
+//auto ss = LOG_STREAM(args...);
+//logHelper_log((log_helper_pt) logHelper, 
OSGI_LOGSERVICE_ERROR, ss.str().c_str());
+//}
+
+class LogHelper {
+public:
+LogHelper(log_helper_t *lh) : _logHelper{lh} {
+}
+
+LogHelper(const LogHelper& ) = default;
+LogHelper& operator=(const LogHelper&) = default;
+
+LogHelper(bundle_context_pt ctx) :  helperCreated{true} {
+logHelper_create(ctx, &_logHelper);
+logHelper_start(_logHelper);
+}
+
+~LogHelper() {
+if (helperCreated) {
+logHelper_stop(_logHelper);
+logHelper_destroy(&_logHelper);
+}
+}
+template
+void ERROR(Args... args) {
+auto ss = LOG_STREAM(args...);
+logHelper_log(_logHelper, OSGI_LOGSERVICE_ERROR, 
ss.str().c_str());
+}
+
+template
+void WARN(Args... args) {
+auto ss = LOG_STREAM(args...);
+logHelper_log(_logHelper, OSGI_LOGSERVICE_WARNING, 
ss.str().c_str());
+}
+
+template
+void INFO(Args... args) {
+auto ss = LOG_STREAM(args...);
+logHelper_log(_logHelper, OSGI_LOGSERVICE_INFO, 
ss.str().c_str());
+}
+
+template
+void DBG(Args... args) {
+auto ss = LOG_STREAM(args...);
+logHelper_log(

celix git commit: Fix in RSA discovery-etcd: remote services where not published in etcd

2018-12-04 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 79852c59a -> f7779cc84


Fix in RSA discovery-etcd: remote services where not published in etcd


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

Branch: refs/heads/develop
Commit: f7779cc84bf0aadc0c5602a70b622161485d1467
Parents: 79852c5
Author: Erjan Altena 
Authored: Tue Dec 4 19:03:36 2018 +0100
Committer: Erjan Altena 
Committed: Tue Dec 4 19:03:36 2018 +0100

--
 bundles/remote_services/discovery_etcd/src/etcd_watcher.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/f7779cc8/bundles/remote_services/discovery_etcd/src/etcd_watcher.c
--
diff --git a/bundles/remote_services/discovery_etcd/src/etcd_watcher.c 
b/bundles/remote_services/discovery_etcd/src/etcd_watcher.c
index ebeac4f..faded7b 100644
--- a/bundles/remote_services/discovery_etcd/src/etcd_watcher.c
+++ b/bundles/remote_services/discovery_etcd/src/etcd_watcher.c
@@ -174,10 +174,10 @@ static celix_status_t 
etcdWatcher_addOwnFramework(etcd_watcher_pt watcher)
 }
 }
 
-   if (etcd_get(localNodePath, &value, &modIndex) != true) {
+   if (etcd_get(localNodePath, &value, &modIndex) != ETCDLIB_RC_OK) {
etcd_set(localNodePath, endpoints, ttl, false);
}
-   else if (etcd_set(localNodePath, endpoints, ttl, true) == false)  {
+   else if (etcd_set(localNodePath, endpoints, ttl, true) != 
ETCDLIB_RC_OK)  {
logHelper_log(*watcher->loghelper, OSGI_LOGSERVICE_WARNING, 
"Cannot register local discovery");
 }
 else {



[2/3] celix git commit: NanoMsg

2018-12-01 Thread erjanaltena
NanoMsg


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

Branch: refs/heads/nanomsg
Commit: b6a0337233c48c48bf48a86274682ba8329f91f3
Parents: 15f268d
Author: Erjan Altena 
Authored: Thu Nov 29 20:39:40 2018 +0100
Committer: Erjan Altena 
Committed: Thu Nov 29 20:39:40 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc |   7 +-
 .../src/pubsub_nanomsg_admin.h  |   2 +-
 .../src/pubsub_nanomsg_topic_receiver.cc|  34 +++---
 .../src/pubsub_nanomsg_topic_receiver.h |   4 +-
 .../src/pubsub_nanomsg_topic_sender.cc  | 119 ---
 .../src/pubsub_nanomsg_topic_sender.h   |  14 ++-
 6 files changed, 106 insertions(+), 74 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/b6a03372/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 9fdf2a3..cc17ebb 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -250,13 +250,11 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 auto &entry = kvsm->second;
 {
 std::lock_guard senderLock(topicSenders.mutex);
-for (auto kv: topicSenders.map) {
+for (auto &kv: topicSenders.map) {
 auto *sender = kv.second;
 if (sender != nullptr && entry.svcId == 
sender->getSerializerSvcId()) {
-char *key = kv.first;
 topicSenders.map.erase(kv.first);
 delete (sender);
-free(key);
 }
 }
 }
@@ -377,9 +375,7 @@ celix_status_t 
pubsub_nanomsg_admin::teardownTopicSender(const char *scope, cons
 std::lock_guard topicSenderLock(topicSenders.mutex);
 auto kv = topicSenders.map.find(key);
 if (kv != topicSenders.map.end()) {
-char *mapKey = kv->first;
 pubsub::nanomsg::pubsub_nanomsg_topic_sender *sender = kv->second;
-free(mapKey);
 //TODO disconnect endpoints to sender. note is this needed for a 
nanomsg topic sender?
 delete (sender);
 } else {
@@ -557,7 +553,6 @@ celix_status_t pubsub_nanomsg_admin::removeEndpoint(const 
celix_properties_t *en
 celix_status_t pubsub_nanomsg_admin::executeCommand(char *commandLine 
__attribute__((unused)), FILE *out,
   FILE *errStream 
__attribute__((unused))) {
 celix_status_t  status = CELIX_SUCCESS;
-
 fprintf(out, "\n");
 fprintf(out, "Topic Senders:\n");
 {

http://git-wip-us.apache.org/repos/asf/celix/blob/b6a03372/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
index 7c2e9a0..8ec35e5 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
@@ -119,7 +119,7 @@ private:
 pubsub_serializer_service_t *svc;
 } psa_nanomsg_serializer_entry_t;
 ProtectedMap serializers{};
-ProtectedMap 
topicSenders{};
+ProtectedMap 
topicSenders{};
 ProtectedMap 
topicReceivers{};
 ProtectedMap discoveredEndpoints{};
 };

http://git-wip-us.apache.org/repos/asf/celix/blob/b6a03372/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
--
diff --git 
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
index 30c2af7..83d1caf 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
@@ -72,7 +72,6 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 ctx = _ctx;
 logHelper = _logHelper;
 serializer = _serializer;
-m_scopeAndTopicFilter = psa_nanomsg_setScopeAndTopicFilter(m_scope, 
m_topic);
 
 m_nanoMsgSocket = nn_socket(AF_SP, NN_BUS);
 if (m_nanoMsgSocket < 0) {
@@ -88,20 +87,7 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 
 auto subscriberFilter = psa_na

[1/3] celix git commit: Nanomsg

2018-12-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/nanomsg 7c141424d -> 707b8e54a


Nanomsg


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

Branch: refs/heads/nanomsg
Commit: 15f268d131370e55dc2dd4c5b6c247baa522fc58
Parents: 7c14142
Author: Erjan Altena 
Authored: Wed Nov 28 21:07:00 2018 +0100
Committer: Erjan Altena 
Committed: Wed Nov 28 21:37:36 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc |  12 +-
 .../src/pubsub_nanomsg_common.cc|  15 +-
 .../src/pubsub_nanomsg_common.h |   2 +-
 .../src/pubsub_nanomsg_topic_receiver.cc|   5 +-
 .../src/pubsub_nanomsg_topic_receiver.h |   2 +-
 .../src/pubsub_nanomsg_topic_sender.cc  | 211 +++
 .../src/pubsub_nanomsg_topic_sender.h   |  54 +++--
 7 files changed, 138 insertions(+), 163 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/15f268d1/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 42ed632..9fdf2a3 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -341,7 +341,7 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const 
char *scope, const c
 const char *serType = serEntry->serType;
 newEndpoint = pubsubEndpoint_create(fwUUID, scope, topic, 
PUBSUB_PUBLISHER_ENDPOINT_TYPE, psaType, serType,
 nullptr);
-celix_properties_set(newEndpoint, PUBSUB_NANOMSG_URL_KEY, 
sender->getUrl());
+celix_properties_set(newEndpoint, PUBSUB_NANOMSG_URL_KEY, 
sender->getUrl().c_str());
 //if available also set container name
 const char *cn = celix_bundleContext_getProperty(ctx, 
"CELIX_CONTAINER_NAME", nullptr);
 if (cn != nullptr) {
@@ -568,12 +568,12 @@ celix_status_t pubsub_nanomsg_admin::executeCommand(char 
*commandLine __attribut
 long serSvcId = sender->getSerializerSvcId();
 auto kvs = serializers.map.find(serSvcId);
 const char* serType = ( kvs == serializers.map.end() ? "!Error" :  
kvs->second.serType);
-const char *scope = sender->getScope();
-const char *topic = sender->getTopic();
-const char *url = sender->getUrl();
-fprintf(out, "|- Topic Sender %s/%s\n", scope, topic);
+const auto scope = sender->getScope();
+const auto topic = sender->getTopic();
+const auto url = sender->getUrl();
+fprintf(out, "|- Topic Sender %s/%s\n", scope.c_str(), 
topic.c_str());
 fprintf(out, "   |- serializer type = %s\n", serType);
-fprintf(out, "   |- url = %s\n", url);
+fprintf(out, "   |- url = %s\n", url.c_str());
 }
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/15f268d1/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
index 3ecd19c..333cb2d 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
@@ -41,16 +41,15 @@ bool psa_nanomsg_checkVersion(version_pt msgVersion, const 
pubsub_nanmosg_msg_he
 return check;
 }
 
-void psa_nanomsg_setScopeAndTopicFilter(const std::string &scope, const 
std::string &topic, char *filter) {
-for (int i = 0; i < 5; ++i) { // 5 ??
-filter[i] = '\0';
-}
+std::string psa_nanomsg_setScopeAndTopicFilter(const std::string &scope, const 
std::string &topic) {
+std::string result("");
 if (scope.size() >= 2)  { //3 ??
-filter[0] = scope[0];
-filter[1] = scope[1];
+result += scope[0];
+result += scope[1];
 }
 if (topic.size() >= 2)  { //3 ??
-filter[2] = topic[0];
-filter[3] = topic[1];
+result += topic[0];
+result += topic[1];
 }
+return result;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/15f268d1/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
--
diff --git a/bundles/pubsub/pubsub_a

[3/3] celix git commit: Nanomsg

2018-12-01 Thread erjanaltena
Nanomsg


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

Branch: refs/heads/nanomsg
Commit: 707b8e54aeda61c5eba4b8a3fa65059ec0f5821a
Parents: b6a0337
Author: Erjan Altena 
Authored: Sat Dec 1 09:26:44 2018 +0100
Committer: Erjan Altena 
Committed: Sat Dec 1 09:26:44 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc | 66 
 .../src/pubsub_nanomsg_admin.h  |  4 +-
 2 files changed, 29 insertions(+), 41 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/707b8e54/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index cc17ebb..ba47723 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pubsub_utils.h"
 #include "pubsub_nanomsg_admin.h"
@@ -96,11 +97,11 @@ 
pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx, log_hel
 pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 //note assuming al psa register services and service tracker are removed.
 {
-std::lock_guard lock(topicSenders.mutex);
-for (auto kv : topicSenders.map) {
-auto *sender = kv.second;
-delete (sender);
-}
+//std::lock_guard lock(topicSenders.mutex);
+//for (auto &kv : topicSenders.map) {
+//auto &sender = kv.second;
+//delete (sender);
+//}
 }
 
 {
@@ -224,11 +225,6 @@ void pubsub_nanomsg_admin::addSerializerSvc(void *svc, 
const celix_properties_t
 serializers.map.emplace(std::piecewise_construct,
 std::forward_as_tuple(svcId),
 std::forward_as_tuple(serType, svcId, 
static_cast(svc)));
-//auto entry = 
static_cast(calloc(1, 
sizeof(psa_nanomsg_serializer_entry_t)));
-//entry->serType = serType;
-//entry->svcId = svcId;
-//entry->svc = static_cast(svc);
-//serializers.map[svcId] = entry;
 }
 }
 }
@@ -250,11 +246,12 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 auto &entry = kvsm->second;
 {
 std::lock_guard senderLock(topicSenders.mutex);
-for (auto &kv: topicSenders.map) {
-auto *sender = kv.second;
-if (sender != nullptr && entry.svcId == 
sender->getSerializerSvcId()) {
-topicSenders.map.erase(kv.first);
-delete (sender);
+for(auto it = topicSenders.map.begin(); it != 
topicSenders.map.end(); /*nothing*/) {
+auto &sender = it->second;
+if (entry.svcId == sender.getSerializerSvcId()) {
+it = topicSenders.map.erase(it);
+} else {
+++it;
 }
 }
 }
@@ -320,32 +317,30 @@ celix_status_t 
pubsub_nanomsg_admin::setupTopicSender(const char *scope, const c
 celix_properties_t *newEndpoint = nullptr;
 
 char *key = pubsubEndpoint_createScopeTopicKey(scope, topic);
-pubsub::nanomsg::pubsub_nanomsg_topic_sender *sender = nullptr;
 std::lock_guard serializerLock(serializers.mutex);
 std::lock_guard topicSenderLock(topicSenders.mutex);
-sender = topicSenders.map.find(key)->second;
-if (sender == nullptr) {
+auto sender = topicSenders.map.find(key);
+if (sender == topicSenders.map.end()) {
 psa_nanomsg_serializer_entry_t *serEntry = nullptr;
 auto kv = serializers.map.find(serializerSvcId);
 if (kv != serializers.map.end()) {
 serEntry = &kv->second;
 }
 if (serEntry != nullptr) {
-sender = new pubsub::nanomsg::pubsub_nanomsg_topic_sender(ctx, 
log, scope, topic, serializerSvcId, serEntry->svc, ipAddress,
-  basePort, maxPort);
-}
-if (sender != nullptr) {
+auto e = topicSenders.map.emplace(std::piecewise_construct,
+std::forward_as_tuple(key),
+std::forward_as_tuple(ctx, log, scope, topic, 
serializerSvcId, serEntry->svc, ipAddress,
+  basePort, maxPort));
 const char *psaType = PUBSUB_NANOMSG_ADMIN_TYPE;
 const char *serType = serEntry->serType;
  

[3/8] celix git commit: nanomsg Topic receiver to class

2018-11-27 Thread erjanaltena
nanomsg Topic receiver to class


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

Branch: refs/heads/nanomsg
Commit: 0abbf4323838b5823b6f275ab418438727dfe289
Parents: c19a5bd
Author: Erjan Altena 
Authored: Wed Nov 21 20:34:12 2018 +0100
Committer: Erjan Altena 
Committed: Wed Nov 21 21:10:41 2018 +0100

--
 .../src/pubsub_nanomsg_common.h |  4 +-
 .../src/pubsub_nanomsg_topic_receiver.cc| 90 ++--
 .../src/pubsub_nanomsg_topic_receiver.h | 42 +
 3 files changed, 47 insertions(+), 89 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/0abbf432/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
index 28293a8..3d5d48d 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
@@ -37,14 +37,14 @@
  */
 
 
-struct pubsub_zmq_msg_header {
+struct pubsub_nanomsg_msg_header {
 //header
 unsigned int type;
 unsigned char major;
 unsigned char minor;
 };
 
-typedef struct pubsub_zmq_msg_header pubsub_nanmosg_msg_header_t;
+typedef struct pubsub_nanomsg_msg_header pubsub_nanmosg_msg_header_t;
 
 
 int psa_nanoMsg_localMsgTypeIdForMsgType(void *handle, const char *msgType, 
unsigned int *msgTypeId);

http://git-wip-us.apache.org/repos/asf/celix/blob/0abbf432/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
--
diff --git 
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
index 889d79d..6c6 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
@@ -17,6 +17,7 @@
  *under the License.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -61,34 +62,6 @@
 #define L_WARN printf
 #define L_ERROR printf
 
-struct pubsub_nanomsg_topic_receiver {
-celix_bundle_context_t *ctx;
-log_helper_t *logHelper;
-long serializerSvcId;
-pubsub_serializer_service_t *serializer;
-char *scope;
-char *topic;
-char scopeAndTopicFilter[5];
-
-int nanoMsgSocket;
-
-struct {
-celix_thread_t thread;
-std::mutex mutex;
-bool running;
-} recvThread;
-
-struct {
-std::mutex mutex;
-hash_map_t *map; //key = zmq url, value = 
psa_zmq_requested_connection_entry_t*
-} requestedConnections;
-
-long subscriberTrackerId;
-struct {
-std::mutex mutex;
-hash_map_t *map; //key = bnd id, value = psa_zmq_subscriber_entry_t
-} subscribers;
-};
 
 typedef struct psa_zmq_requested_connection_entry {
 char *url;
@@ -96,23 +69,14 @@ typedef struct psa_zmq_requested_connection_entry {
 int id;
 } psa_nanomsg_requested_connection_entry_t;
 
-typedef struct psa_zmq_subscriber_entry {
-int usageCount;
-hash_map_t *msgTypes; //map from serializer svc
-pubsub_subscriber_t *svc;
-} psa_nanomsg_subscriber_entry_t;
 
 
-static void pubsub_zmqTopicReceiver_addSubscriber(void *handle, void *svc, 
const celix_properties_t *props, const celix_bundle_t *owner);
+static void pubsub_nanomsgTopicReceiver_addSubscriber(void *handle, void *svc, 
const celix_properties_t *props,
+  const celix_bundle_t 
*owner);
 static void pubsub_nanoMsgTopicReceiver_removeSubscriber(void *handle, void 
*svc, const celix_properties_t *props,
  const celix_bundle_t 
*owner);
-static void* psa_nanomsg_recvThread(void *data);
 
 
-//pubsub_nanomsg_topic_receiver_t* 
pubsub_nanoMsgTopicReceiver_create(celix_bundle_context_t *ctx,
-//
log_helper_t *logHelper, const char *scope,
-//const 
char *topic, long serializerSvcId,
-//
pubsub_serializer_service_t *serializer) {
 pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 log_helper_t *_logHelper,
 const char *_scope,
@@ -149,6 +113,7 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 m_topic = strndu

[5/8] celix git commit: subscriber.map now std::map

2018-11-27 Thread erjanaltena
subscriber.map now std::map


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

Branch: refs/heads/nanomsg
Commit: 120895dd93c2c995d98327925fe88f939d345d12
Parents: 8658738
Author: Erjan Altena 
Authored: Fri Nov 23 21:53:50 2018 +0100
Committer: Erjan Altena 
Committed: Fri Nov 23 21:53:50 2018 +0100

--
 .../src/pubsub_nanomsg_topic_receiver.cc| 100 +++
 .../src/pubsub_nanomsg_topic_receiver.h |  12 ++-
 2 files changed, 45 insertions(+), 67 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/120895dd/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
--
diff --git 
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
index 8acf6b1..2205ed2 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
@@ -63,13 +63,6 @@
 #define L_ERROR printf
 
 
-
-
-
-//static void pubsub_nanoMsgTopicReceiver_removeSubscriber(void *handle, void 
*svc, const celix_properties_t *props,
-// const 
celix_bundle_t *owner);
-
-
 pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 log_helper_t *_logHelper,
 const char *_scope,
@@ -103,8 +96,8 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 m_scope = strndup(m_scope, 1024 * 1024);
 m_topic = strndup(m_topic, 1024 * 1024);
 
-subscribers.map = hashMap_create(NULL, NULL, NULL, NULL);
-std::cout << " Creating subscirbers.map!! " << subscribers.map << 
"\n";
+//subscribers.map = hashMap_create(NULL, NULL, NULL, NULL);
+//std::cout << " Creating subscirbers.map!! " << subscribers.map 
<< "\n";
 //requestedConnections.map = hashMap_create(utils_stringHash, NULL, 
utils_stringEquals, NULL);
 
 int size = snprintf(NULL, 0, "(%s=%s)", PUBSUB_SUBSCRIBER_TOPIC, 
m_topic);
@@ -139,38 +132,13 @@ pubsub::nanomsg::topic_receiver::~topic_receiver() {
 
 celix_bundleContext_stopTracker(ctx, subscriberTrackerId);
 
-hash_map_iterator_t iter=hash_map_iterator_t();
 {
 std::lock_guard _lock(subscribers.mutex);
-iter = hashMapIterator_construct(subscribers.map);
-while (hashMapIterator_hasNext(&iter)) {
-psa_nanomsg_subscriber_entry_t *entry = 
static_cast(hashMapIterator_nextValue(&iter));
-if (entry != NULL)  {
-serializer->destroySerializerMap(serializer->handle, 
entry->msgTypes);
-free(entry);
-}
+for(auto elem : subscribers.map) {
+serializer->destroySerializerMap(serializer->handle, 
elem.second.msgTypes);
 }
-hashMap_destroy(subscribers.map, false, false);
+subscribers.map.clear();
 }
-
-
-//{
-//std::lock_guard _lock(requestedConnections.mutex);
-//iter = hashMapIterator_construct(requestedConnections.map);
-//while (hashMapIterator_hasNext(&iter)) {
-//psa_nanomsg_requested_connection_entry_t *entry = 
static_cast(hashMapIterator_nextValue(&iter));
-//if (entry != NULL) {
-//free(entry->url);
-//free(entry);
-//}
-//}
-//hashMap_destroy(requestedConnections.map, false, false);
-//}
-
-//celixThreadMutex_destroy(&receiver->subscribers.mutex);
-//celixThreadMutex_destroy(&receiver->requestedConnections.mutex);
-//celixThreadMutex_destroy(&receiver->recvThread.mutex);
-
 nn_close(m_nanoMsgSocket);
 
 free((void*)m_scope);
@@ -211,6 +179,7 @@ void pubsub::nanomsg::topic_receiver::connectTo(const char 
*url) {
 std::piecewise_construct,
 std::forward_as_tuple(std::string(url)),
 std::forward_as_tuple(url, -1));
+entry = requestedConnections.map.find(url);
 }
 if (!entry->second.isConnected()) {
 int connection_id = nn_connect(m_nanoMsgSocket, url);
@@ -254,21 +223,26 @@ void pubsub::nanomsg::topic_receiver::addSubscriber(void 
*svc, const celix_prope
 }
 
 std::lock_guard _lock(subscribers.mutex);
-psa_nanomsg_subscriber_entry_t *entry = 
static_cast(hashMap_get(subscribers.map, 
(void*)bndId));
-if (entry != NULL) {

[7/8] celix git commit: Nanomsg

2018-11-27 Thread erjanaltena
Nanomsg


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

Branch: refs/heads/nanomsg
Commit: cdefb0d665b27a41f360599598ff489b322b4405
Parents: 883abee
Author: Erjan Altena 
Authored: Mon Nov 26 20:23:11 2018 +0100
Committer: Erjan Altena 
Committed: Mon Nov 26 20:23:11 2018 +0100

--
 .../log_service/loghelper_include/log_helper.h  |  2 +-
 bundles/log_service/src/log_helper.c|  2 +-
 .../src/pubsub_nanomsg_admin.cc | 62 
 .../src/pubsub_nanomsg_admin.h  | 10 ++--
 .../src/pubsub_nanomsg_topic_receiver.cc| 10 ++--
 .../src/pubsub_nanomsg_topic_sender.cc  | 11 +---
 6 files changed, 42 insertions(+), 55 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/cdefb0d6/bundles/log_service/loghelper_include/log_helper.h
--
diff --git a/bundles/log_service/loghelper_include/log_helper.h 
b/bundles/log_service/loghelper_include/log_helper.h
index 28e6877..af058eb 100644
--- a/bundles/log_service/loghelper_include/log_helper.h
+++ b/bundles/log_service/loghelper_include/log_helper.h
@@ -33,7 +33,7 @@ celix_status_t logHelper_create(bundle_context_pt context, 
log_helper_pt* log_he
 celix_status_t logHelper_start(log_helper_pt loghelper);
 celix_status_t logHelper_stop(log_helper_pt loghelper);
 celix_status_t logHelper_destroy(log_helper_pt* loghelper);
-celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* 
message, ... );
+celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, const 
char* message, ... );
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/celix/blob/cdefb0d6/bundles/log_service/src/log_helper.c
--
diff --git a/bundles/log_service/src/log_helper.c 
b/bundles/log_service/src/log_helper.c
index 6570357..e9939ed 100644
--- a/bundles/log_service/src/log_helper.c
+++ b/bundles/log_service/src/log_helper.c
@@ -156,7 +156,7 @@ celix_status_t logHelper_destroy(log_helper_pt* loghelper) {
 
 
 
-celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* 
message, ... )
+celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, const 
char* message, ... )
 {
 celix_status_t status = CELIX_SUCCESS;
va_list listPointer;

http://git-wip-us.apache.org/repos/asf/celix/blob/cdefb0d6/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 030441d..cf516ee 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -32,20 +32,15 @@
 #include "pubsub_utils.h"
 #include "pubsub_nanomsg_admin.h"
 #include "pubsub_psa_nanomsg_constants.h"
-/*
-//#define L_DEBUG(...) \
-//logHelper_log(psa->log, OSGI_LOGSERVICE_DEBUG, __VA_ARGS__)
-//#define L_INFO(...) \
-//logHelper_log(psa->log, OSGI_LOGSERVICE_INFO, __VA_ARGS__)
-//#define L_WARN(...) \
-//logHelper_log(psa->log, OSGI_LOGSERVICE_WARNING, __VA_ARGS__)
-//#define L_ERROR(...) \
-//logHelper_log(psa->log, OSGI_LOGSERVICE_ERROR, __VA_ARGS__)
-*/
-#define L_DEBUG printf
-#define L_INFO printf
-#define L_WARN printf
-#define L_ERROR printf
+
+#define L_DEBUG(...) \
+logHelper_log(log, OSGI_LOGSERVICE_DEBUG, __VA_ARGS__)
+#define L_INFO(...) \
+logHelper_log(log, OSGI_LOGSERVICE_INFO, __VA_ARGS__)
+#define L_WARN(...) \
+logHelper_log(log, OSGI_LOGSERVICE_WARNING, __VA_ARGS__)
+#define L_ERROR(...) \
+logHelper_log(log, OSGI_LOGSERVICE_ERROR, __VA_ARGS__)
 
 
 
@@ -125,10 +120,7 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 
 {
 std::lock_guard lock(serializers.mutex);
-// todo: do not use pointer but type in map
-for(auto kv: serializers.map) {
-free(kv.second);
-}
+serializers.map.clear();
 }
 
 free(ipAddress);
@@ -229,11 +221,14 @@ void pubsub_nanomsg_admin::addSerializerSvc(void *svc, 
const celix_properties_t
 std::lock_guard lock(serializers.mutex);
 auto it = serializers.map.find(svcId);
 if (it == serializers.map.end()) {
-auto entry = 
static_cast(calloc(1, 
sizeof(psa_nanomsg_serializer_entry_t)));
-entry->serType = serType;
-entry->svcId = svcId;
-entry->svc = static_cast(svc);
-serializers.m

[4/8] celix git commit: nanomsg celix-map replaced by std::map

2018-11-27 Thread erjanaltena
nanomsg celix-map replaced by std::map


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

Branch: refs/heads/nanomsg
Commit: 8658738d5e9a905eb0642ea605d36e50dc24730a
Parents: 0abbf43
Author: Erjan Altena 
Authored: Wed Nov 21 21:28:32 2018 +0100
Committer: Erjan Altena 
Committed: Wed Nov 21 21:28:32 2018 +0100

--
 .../src/pubsub_nanomsg_topic_receiver.cc| 128 +--
 .../src/pubsub_nanomsg_topic_receiver.h |  37 +-
 2 files changed, 95 insertions(+), 70 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/8658738d/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
--
diff --git 
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
index 6c6..8acf6b1 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.cc
@@ -63,18 +63,11 @@
 #define L_ERROR printf
 
 
-typedef struct psa_zmq_requested_connection_entry {
-char *url;
-bool connected;
-int id;
-} psa_nanomsg_requested_connection_entry_t;
 
 
 
-static void pubsub_nanomsgTopicReceiver_addSubscriber(void *handle, void *svc, 
const celix_properties_t *props,
-  const celix_bundle_t 
*owner);
-static void pubsub_nanoMsgTopicReceiver_removeSubscriber(void *handle, void 
*svc, const celix_properties_t *props,
- const celix_bundle_t 
*owner);
+//static void pubsub_nanoMsgTopicReceiver_removeSubscriber(void *handle, void 
*svc, const celix_properties_t *props,
+// const 
celix_bundle_t *owner);
 
 
 pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
@@ -83,7 +76,6 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 const char *_topic,
 long _serializerSvcId,
 pubsub_serializer_service_t *_serializer) : 
m_serializerSvcId{_serializerSvcId}, m_scope{_scope}, m_topic{_topic} {
-//pubsub_nanomsg_topic_receiver_t *receiver = 
static_cast(calloc(1, sizeof(*receiver)));
 ctx = _ctx;
 logHelper = _logHelper;
 serializer = _serializer;
@@ -107,14 +99,13 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 
 char subscribeFilter[5];
 psa_nanomsg_setScopeAndTopicFilter(m_scope, m_topic, subscribeFilter);
-//zsock_set_subscribe(receiver->nanoMsgSocket, subscribeFilter);
 
 m_scope = strndup(m_scope, 1024 * 1024);
 m_topic = strndup(m_topic, 1024 * 1024);
 
 subscribers.map = hashMap_create(NULL, NULL, NULL, NULL);
 std::cout << " Creating subscirbers.map!! " << subscribers.map << 
"\n";
-requestedConnections.map = hashMap_create(utils_stringHash, NULL, 
utils_stringEquals, NULL);
+//requestedConnections.map = hashMap_create(utils_stringHash, NULL, 
utils_stringEquals, NULL);
 
 int size = snprintf(NULL, 0, "(%s=%s)", PUBSUB_SUBSCRIBER_TOPIC, 
m_topic);
 char buf[size + 1];
@@ -124,8 +115,12 @@ 
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
 opts.filter.serviceName = PUBSUB_SUBSCRIBER_SERVICE_NAME;
 opts.filter.filter = buf;
 opts.callbackHandle = this;
-opts.addWithOwner = pubsub_nanomsgTopicReceiver_addSubscriber;
-opts.removeWithOwner = pubsub_nanoMsgTopicReceiver_removeSubscriber;
+opts.addWithOwner = [](void *handle, void *svc, const 
celix_properties_t *props, const celix_bundle_t *svcOwner) {
+static_cast(handle)->addSubscriber(svc, props, 
svcOwner);
+};
+opts.removeWithOwner = [](void *handle, void *svc, const 
celix_properties_t *props, const celix_bundle_t *svcOwner) {
+static_cast(handle)->removeSubscriber(svc, props, 
svcOwner);
+};
 
 subscriberTrackerId = 
celix_bundleContext_trackServicesWithOptions(ctx, &opts);
 recvThread.running = true;
@@ -159,18 +154,18 @@ pubsub::nanomsg::topic_receiver::~topic_receiver() {
 }
 
 
-{
-std::lock_guard _lock(requestedConnections.mutex);
-iter = hashMapIterator_construct(requestedConnections.map);
-while (hashMapIterator_hasNext(&iter)) {
-psa_nanomsg_requested_connection_entry_t *entry = 
static_cast(hashMapIterator_nextValue(&iter));
-   

[2/8] celix git commit: nanomsg topicreceiver changed to class

2018-11-27 Thread erjanaltena
nanomsg topicreceiver changed to class


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

Branch: refs/heads/nanomsg
Commit: c19a5bd85b5c514794c6b38a1080b5382b8ca1ad
Parents: 95633eb
Author: Erjan Altena 
Authored: Mon Nov 19 20:10:50 2018 +0100
Committer: Erjan Altena 
Committed: Mon Nov 19 20:10:50 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc |  44 ++---
 .../src/pubsub_nanomsg_admin.h  |   6 +-
 .../src/pubsub_nanomsg_topic_receiver.cc| 162 +--
 .../src/pubsub_nanomsg_topic_receiver.h |  77 +++--
 4 files changed, 169 insertions(+), 120 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/c19a5bd8/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 6c15ec8..3e788ae 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -111,7 +111,7 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 {
 std::lock_guard lock(topicReceivers.mutex);
 for (auto kv: topicReceivers.map) {
-pubsub_nanoMsgTopicReceiver_destroy(kv.second);
+delete kv.second;
 }
 }
 
@@ -274,10 +274,10 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 std::lock_guard receiverLock(topicReceivers.mutex);
 for (auto kv : topicReceivers.map){
 auto *receiver = kv.second;
-if (receiver != nullptr && entry->svcId == 
pubsub_nanoMsgTopicReceiver_serializerSvcId(receiver)) {
+if (receiver != nullptr && entry->svcId == 
receiver->serializerSvcId()) {
 char *key = kv.first;
 topicReceivers.map.erase(key);
-pubsub_nanoMsgTopicReceiver_destroy(receiver);
+delete receiver;
 free(key);
 }
 }
@@ -409,7 +409,7 @@ celix_status_t 
pubsub_nanomsg_admin::setupTopicReceiver(const char *scope, const
 celix_properties_t *newEndpoint = nullptr;
 
 char *key = pubsubEndpoint_createScopeTopicKey(scope, topic);
-pubsub_nanomsg_topic_receiver_t * receiver = nullptr;
+pubsub::nanomsg::topic_receiver * receiver = nullptr;
 {
 std::lock_guard serializerLock(serializers.mutex);
 std::lock_guard topicReceiverLock(topicReceivers.mutex);
@@ -421,7 +421,7 @@ celix_status_t 
pubsub_nanomsg_admin::setupTopicReceiver(const char *scope, const
 auto kvs = serializers.map.find(serializerSvcId);
 if (kvs != serializers.map.end()) {
 auto serEntry = kvs->second;
-receiver = pubsub_nanoMsgTopicReceiver_create(ctx, log, scope, 
topic, serializerSvcId, serEntry->svc);
+receiver = new pubsub::nanomsg::topic_receiver(ctx, log, 
scope, topic, serializerSvcId, serEntry->svc);
 } else {
 L_ERROR("[PSA_NANOMSG] Cannot find serializer for TopicSender 
%s/%s", scope, topic);
 }
@@ -471,24 +471,24 @@ celix_status_t 
pubsub_nanomsg_admin::teardownTopicReceiver(const char *scope, co
 free(key);
 if (entry != topicReceivers.map.end()) {
 char *receiverKey = entry->first;
-pubsub_nanomsg_topic_receiver_t *receiver = entry->second;
+pubsub::nanomsg::topic_receiver *receiver = entry->second;
 topicReceivers.map.erase(receiverKey);
 
 free(receiverKey);
-pubsub_nanoMsgTopicReceiver_destroy(receiver);
+delete receiver;
 }
 
 celix_status_t  status = CELIX_SUCCESS;
 return status;
 }
 
-celix_status_t 
pubsub_nanomsg_admin::connectEndpointToReceiver(pubsub_nanomsg_topic_receiver_t 
*receiver,
+celix_status_t 
pubsub_nanomsg_admin::connectEndpointToReceiver(pubsub::nanomsg::topic_receiver 
*receiver,
 const 
celix_properties_t *endpoint) {
 //note can be called with discoveredEndpoint.mutex lock
 celix_status_t status = CELIX_SUCCESS;
 
-const char *scope = pubsub_nanoMsgTopicReceiver_scope(receiver);
-const char *topic = pubsub_nanoMsgTopicReceiver_topic(receiver);
+const char *scope = receiver->scope();
+const char *topic = receiver->topic();
 
 const char *eScope = celix_properties_get(endpoint, 
PUBSUB_ENDPOINT_TOPIC_SCOPE, nullptr);
 const char *eTopic = ce

[6/8] celix git commit: Nanomsg: moved charptr to std::string

2018-11-27 Thread erjanaltena
Nanomsg: moved charptr to std::string


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

Branch: refs/heads/nanomsg
Commit: 883abeed00cfa3c1509b026fea888550b863defc
Parents: 120895d
Author: Erjan Altena 
Authored: Fri Nov 23 22:35:30 2018 +0100
Committer: Erjan Altena 
Committed: Fri Nov 23 22:35:30 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc | 56 +++---
 .../src/pubsub_nanomsg_admin.h  |  4 +-
 .../src/pubsub_nanomsg_common.cc|  8 +--
 .../src/pubsub_nanomsg_common.h |  3 +-
 .../src/pubsub_nanomsg_topic_receiver.cc| 60 +++-
 .../src/pubsub_nanomsg_topic_receiver.h | 26 -
 6 files changed, 63 insertions(+), 94 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/883abeed/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 3e788ae..030441d 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -159,7 +159,7 @@ void pubsub_nanomsg_admin::start() {
 };
 adminService.setupTopicReceiver = [](void *handle, const char *scope, 
const char *topic, long serializerSvcId, celix_properties_t 
**subscriberEndpoint) {
 auto me = static_cast(handle);
-return me->setupTopicReceiver(scope, topic,serializerSvcId, 
subscriberEndpoint);
+return me->setupTopicReceiver(std::string(scope), 
std::string(topic),serializerSvcId, subscriberEndpoint);
 };
 
 adminService.teardownTopicReceiver = [] (void *handle, const char *scope, 
const char *topic) {
@@ -205,7 +205,7 @@ void pubsub_nanomsg_admin::start() {
 celix_properties_t* shellProps = celix_properties_create();
 celix_properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, "psa_nanomsg");
 celix_properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, "psa_nanomsg");
-celix_properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, "Print 
the information about the TopicSender and TopicReceivers for the ZMQ PSA");
+celix_properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, "Print 
the information about the TopicSender and TopicReceivers for the nanomsg PSA");
 cmdSvcId = celix_bundleContext_registerService(ctx, &cmdSvc, 
OSGI_SHELL_COMMAND_SERVICE_NAME, shellProps);
 
 }
@@ -275,10 +275,9 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 for (auto kv : topicReceivers.map){
 auto *receiver = kv.second;
 if (receiver != nullptr && entry->svcId == 
receiver->serializerSvcId()) {
-char *key = kv.first;
+auto key = kv.first;
 topicReceivers.map.erase(key);
 delete receiver;
-free(key);
 }
 }
 }
@@ -338,8 +337,6 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const 
char *scope, const c
 std::lock_guard topicSenderLock(topicSenders.mutex);
 sender = topicSenders.map.find(key)->second;
 if (sender == nullptr) {
-//auto *serEntry = static_cast(hashMap_get(serializers.map,
-// 
  (void *) serializerSvcId));
 psa_nanomsg_serializer_entry_t *serEntry = nullptr;
 auto kv = serializers.map.find(serializerSvcId);
 if (kv != serializers.map.end()) {
@@ -403,12 +400,12 @@ celix_status_t 
pubsub_nanomsg_admin::teardownTopicSender(const char *scope, cons
 return status;
 }
 
-celix_status_t pubsub_nanomsg_admin::setupTopicReceiver(const char *scope, 
const char *topic,
+celix_status_t pubsub_nanomsg_admin::setupTopicReceiver(const std::string 
&scope, const std::string &topic,
   long serializerSvcId, 
celix_properties_t **outSubscriberEndpoint) {
 
 celix_properties_t *newEndpoint = nullptr;
 
-char *key = pubsubEndpoint_createScopeTopicKey(scope, topic);
+std::string key = pubsubEndpoint_createScopeTopicKey(scope.c_str(), 
topic.c_str());
 pubsub::nanomsg::topic_receiver * receiver = nullptr;
 {
 std::lock_guard serializerLock(serializers.mutex);
@@ -423,12 +420,12 @@ celix_status_t 
pubsub_nanomsg_admin::setupTopicReceiver(const char *scope, const
 auto serEntry = kvs->second;
 rec

[8/8] celix git commit: NanoMsg

2018-11-27 Thread erjanaltena
NanoMsg


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

Branch: refs/heads/nanomsg
Commit: 7c141424d925afa98a83bc693649dc3500354965
Parents: cdefb0d
Author: Erjan Altena 
Authored: Tue Nov 27 21:02:18 2018 +0100
Committer: Erjan Altena 
Committed: Tue Nov 27 21:02:18 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc |  42 ++--
 .../src/pubsub_nanomsg_admin.h  |   2 +-
 .../src/pubsub_nanomsg_topic_sender.cc  | 240 ---
 .../src/pubsub_nanomsg_topic_sender.h   |  66 -
 4 files changed, 178 insertions(+), 172 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/7c141424/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index cf516ee..42ed632 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -99,20 +99,20 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 std::lock_guard lock(topicSenders.mutex);
 for (auto kv : topicSenders.map) {
 auto *sender = kv.second;
-pubsub_nanoMsgTopicSender_destroy(sender);
+delete (sender);
 }
 }
 
 {
 std::lock_guard lock(topicReceivers.mutex);
-for (auto kv: topicReceivers.map) {
+for (auto &kv: topicReceivers.map) {
 delete kv.second;
 }
 }
 
 {
 std::lock_guard lock(discoveredEndpoints.mutex);
-for (auto entry : discoveredEndpoints.map) {
+for (auto &entry : discoveredEndpoints.map) {
 auto *ep = entry.second;
 celix_properties_destroy(ep);
 }
@@ -252,10 +252,10 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 std::lock_guard senderLock(topicSenders.mutex);
 for (auto kv: topicSenders.map) {
 auto *sender = kv.second;
-if (sender != nullptr && entry.svcId == 
pubsub_nanoMsgTopicSender_serializerSvcId(sender)) {
+if (sender != nullptr && entry.svcId == 
sender->getSerializerSvcId()) {
 char *key = kv.first;
 topicSenders.map.erase(kv.first);
-pubsub_nanoMsgTopicSender_destroy(sender);
+delete (sender);
 free(key);
 }
 }
@@ -263,7 +263,7 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 
 {
 std::lock_guard receiverLock(topicReceivers.mutex);
-for (auto kv : topicReceivers.map){
+for (auto &kv : topicReceivers.map){
 auto *receiver = kv.second;
 if (receiver != nullptr && entry.svcId == 
receiver->serializerSvcId()) {
 auto key = kv.first;
@@ -322,7 +322,7 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const 
char *scope, const c
 celix_properties_t *newEndpoint = nullptr;
 
 char *key = pubsubEndpoint_createScopeTopicKey(scope, topic);
-pubsub_nanomsg_topic_sender_t *sender = nullptr;
+pubsub::nanomsg::pubsub_nanomsg_topic_sender *sender = nullptr;
 std::lock_guard serializerLock(serializers.mutex);
 std::lock_guard topicSenderLock(topicSenders.mutex);
 sender = topicSenders.map.find(key)->second;
@@ -333,7 +333,7 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const 
char *scope, const c
 serEntry = &kv->second;
 }
 if (serEntry != nullptr) {
-sender = pubsub_nanoMsgTopicSender_create(ctx, log, scope, topic, 
serializerSvcId, serEntry->svc, ipAddress,
+sender = new pubsub::nanomsg::pubsub_nanomsg_topic_sender(ctx, 
log, scope, topic, serializerSvcId, serEntry->svc, ipAddress,
   basePort, maxPort);
 }
 if (sender != nullptr) {
@@ -341,7 +341,7 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const 
char *scope, const c
 const char *serType = serEntry->serType;
 newEndpoint = pubsubEndpoint_create(fwUUID, scope, topic, 
PUBSUB_PUBLISHER_ENDPOINT_TYPE, psaType, serType,
 nullptr);
-celix_properties_set(newEndpoint, PUBSUB_NANOMSG_URL_KEY, 
pubsub_nanoMsgTopicSender_url(sender));
+celix_properties_set(newEndpoint, PUBSUB_NANOMSG_UR

[1/8] celix git commit: Removed celix-maps from nanomsg admin

2018-11-27 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/nanomsg 3009e6470 -> 7c141424d


Removed celix-maps from nanomsg admin


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

Branch: refs/heads/nanomsg
Commit: 95633eb954a09232867277d7cd0d71c30d49a012
Parents: 3009e64
Author: Erjan Altena 
Authored: Sat Nov 3 19:40:27 2018 +0100
Committer: Erjan Altena 
Committed: Sat Nov 3 19:40:27 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc | 148 +++
 .../src/pubsub_nanomsg_admin.h  |  34 ++---
 2 files changed, 67 insertions(+), 115 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/95633eb9/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index 9fe91d9..6c15ec8 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -32,8 +32,6 @@
 #include "pubsub_utils.h"
 #include "pubsub_nanomsg_admin.h"
 #include "pubsub_psa_nanomsg_constants.h"
-#include "pubsub_nanomsg_topic_sender.h"
-#include "pubsub_nanomsg_topic_receiver.h"
 /*
 //#define L_DEBUG(...) \
 //logHelper_log(psa->log, OSGI_LOGSERVICE_DEBUG, __VA_ARGS__)
@@ -50,11 +48,6 @@
 #define L_ERROR printf
 
 
-typedef struct psa_nanomsg_serializer_entry {
-const char *serType;
-long svcId;
-pubsub_serializer_service_t *svc;
-} psa_nanomsg_serializer_entry_t;
 
 static celix_status_t nanoMsg_getIpAddress(const char *interface, char **ip);
 
@@ -103,41 +96,29 @@ 
pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx, log_hel
 defaultScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_DEFAULT_SCORE_KEY, PSA_NANOMSG_DEFAULT_SCORE);
 qosSampleScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_SAMPLE_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_SAMPLE_SCORE);
 qosControlScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_CONTROL_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_CONTROL_SCORE);
-
-//serializers.map = hashMap_create(nullptr, nullptr, nullptr, nullptr);
-
-topicSenders.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
-
-topicReceivers.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
-
-discoveredEndpoints.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
 }
 
 pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 //note assuming al psa register services and service tracker are removed.
 {
 std::lock_guard lock(topicSenders.mutex);
-hash_map_iterator_t iter = hashMapIterator_construct(topicSenders.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *sender = static_cast(hashMapIterator_nextValue(&iter));
+for (auto kv : topicSenders.map) {
+auto *sender = kv.second;
 pubsub_nanoMsgTopicSender_destroy(sender);
 }
 }
 
 {
 std::lock_guard lock(topicReceivers.mutex);
-hash_map_iterator_t iter = 
hashMapIterator_construct(topicReceivers.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *recv = 
static_cast(hashMapIterator_nextValue(&iter));
-pubsub_nanoMsgTopicReceiver_destroy(recv);
+for (auto kv: topicReceivers.map) {
+pubsub_nanoMsgTopicReceiver_destroy(kv.second);
 }
 }
 
 {
 std::lock_guard lock(discoveredEndpoints.mutex);
-hash_map_iterator_t iter = 
hashMapIterator_construct(discoveredEndpoints.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *ep = 
static_cast(hashMapIterator_nextValue(&iter));
+for (auto entry : discoveredEndpoints.map) {
+auto *ep = entry.second;
 celix_properties_destroy(ep);
 }
 }
@@ -150,12 +131,6 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 }
 }
 
-hashMap_destroy(topicSenders.map, true, false);
-
-hashMap_destroy(topicReceivers.map, true, false);
-
-hashMap_destroy(discoveredEndpoints.map, false, false);
-
 free(ipAddress);
 
 }
@@ -276,21 +251,19 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 std::lock_guard lock(serializers.mutex);
 
 psa_nanomsg_serializer_entry_t* entry = nullptr;
-auto kv = serializers.map.find(svcId);
-if (kv != serializers.map.end()) {
-entry = kv->second;
+auto kv

celix git commit: Added DM-Cxx fucntion to remove previously registered component callbacks

2018-11-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop bd38363ab -> 6f9b23dcb


Added DM-Cxx fucntion to remove previously registered component callbacks


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

Branch: refs/heads/develop
Commit: 6f9b23dcbc9b1057d76d344633ed0811d2e53e7f
Parents: bd38363
Author: Erjan Altena 
Authored: Thu Nov 8 12:30:42 2018 +0100
Committer: Erjan Altena 
Committed: Thu Nov 8 12:30:42 2018 +0100

--
 .../dm_example_cxx/phase1/src/Phase1Activator.cc| 2 +-
 libs/framework/include/celix/dm/Component.h | 6 ++
 libs/framework/include/celix/dm/Component_Impl.h| 9 +
 3 files changed, 16 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/6f9b23dc/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
--
diff --git 
a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc 
b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
index 2dd5ed2..61443dd 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@ -99,5 +99,5 @@ void Phase1Activator::init() {
 }
 
 void Phase1Activator::deinit() {
-//nothing to do
+phase1cmp->removeCallbacks();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/6f9b23dc/libs/framework/include/celix/dm/Component.h
--
diff --git a/libs/framework/include/celix/dm/Component.h 
b/libs/framework/include/celix/dm/Component.h
index 076700e..85723f9 100644
--- a/libs/framework/include/celix/dm/Component.h
+++ b/libs/framework/include/celix/dm/Component.h
@@ -237,6 +237,12 @@ namespace celix { namespace dm {
 int (T::*stop)(),
 int (T::*deinit)()
 );
+/**
+ * Remove the previously registered callbacks for the component life 
cycle control
+ *
+ * @return the DM Component reference for chaining (fluent API)
+ */
+Component& removeCallbacks();
 };
 }}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/6f9b23dc/libs/framework/include/celix/dm/Component_Impl.h
--
diff --git a/libs/framework/include/celix/dm/Component_Impl.h 
b/libs/framework/include/celix/dm/Component_Impl.h
index f20cf09..7848c6a 100644
--- a/libs/framework/include/celix/dm/Component_Impl.h
+++ b/libs/framework/include/celix/dm/Component_Impl.h
@@ -326,3 +326,12 @@ Component& Component::setCallbacks(
 
 return *this;
 }
+
+template
+Component& Component::removeCallbacks() {
+
+component_setCallbacks(this->cComponent(), nullptr, nullptr, nullptr, 
nullptr);
+
+return *this;
+}
+



celix git commit: Removed potential null-dereference when retrieving hook services

2018-11-06 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 68f69f893 -> bd38363ab


Removed potential null-dereference when retrieving hook services


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

Branch: refs/heads/develop
Commit: bd38363ab1fff2fe817a31d31ec476cc21c6b8c3
Parents: 68f69f8
Author: Erjan Altena 
Authored: Tue Nov 6 16:14:51 2018 +0100
Committer: Erjan Altena 
Committed: Tue Nov 6 16:14:51 2018 +0100

--
 libs/framework/src/framework.c | 506 ++--
 1 file changed, 256 insertions(+), 250 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/bd38363a/libs/framework/src/framework.c
--
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 2de670c..4ed4187 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -1674,39 +1674,45 @@ void fw_addServiceListener(framework_pt framework, 
bundle_pt bundle, celix_servi
 celixThreadMutex_unlock(&framework->serviceListenersLock);
 
 //TODO lock listeners hooks?
-   serviceRegistry_getListenerHooks(framework->registry, 
framework->bundle, &listenerHooks);
+   celix_status_t  status = 
serviceRegistry_getListenerHooks(framework->registry, framework->bundle, 
&listenerHooks);
 
-struct listener_hook_info info;
+   if (status == CELIX_SUCCESS) {
+struct listener_hook_info info;
 
-   bundle_getContext(bundle, &context);
-   info.context = context;
-   info.removed = false;
-   info.filter = sfilter;
+bundle_getContext(bundle, &context);
+info.context = context;
+info.removed = false;
+info.filter = sfilter;
 
-   for (i = 0; i < arrayList_size(listenerHooks); i++) {
-   service_reference_pt ref = (service_reference_pt) 
arrayList_get(listenerHooks, i);
-   listener_hook_service_pt hook = NULL;
-   array_list_pt infos = NULL;
-   bool ungetResult = false;
+for (i = 0; i < arrayList_size(listenerHooks); i++) {
+service_reference_pt ref = (service_reference_pt) 
arrayList_get(listenerHooks, i);
+listener_hook_service_pt hook = NULL;
+array_list_pt infos = NULL;
+bool ungetResult = false;
 
-   fw_getService(framework, framework->bundle, ref, (const void 
**) &hook);
+status = fw_getService(framework, framework->bundle, ref, (const 
void **) &hook);
 
-   arrayList_create(&infos);
-   arrayList_add(infos, &info);
-   hook->added(hook->handle, infos);
-   serviceRegistry_ungetService(framework->registry, 
framework->bundle, ref, &ungetResult);
-   serviceRegistry_ungetServiceReference(framework->registry, 
framework->bundle, ref);
-   arrayList_destroy(infos);
-   }
+if (status == CELIX_SUCCESS && hook != NULL) {
+arrayList_create(&infos);
+arrayList_add(infos, &info);
+hook->added(hook->handle, infos);
+serviceRegistry_ungetService(framework->registry, 
framework->bundle, ref, &ungetResult);
+serviceRegistry_ungetServiceReference(framework->registry, 
framework->bundle, ref);
+arrayList_destroy(infos);
+} else {
+fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, 
status, "Could not retrieve hook service.");
+}
+}
 
-   arrayList_destroy(listenerHooks);
+arrayList_destroy(listenerHooks);
+}
 }
 
 void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, 
celix_service_listener_t *listener) {
 celix_fw_service_listener_entry_t *match = NULL;
 
-   bundle_context_t *context;
-   bundle_getContext(bundle, &context);
+bundle_context_t *context;
+bundle_getContext(bundle, &context);
 
 int i;
 celixThreadMutex_lock(&framework->serviceListenersLock);
@@ -1757,109 +1763,109 @@ void fw_removeServiceListener(framework_pt framework, 
bundle_pt bundle, celix_se
 if (match != NULL) {
 listener_release(match);
 listener_waitAndDestroy(framework, match);
-   }
+}
 }
 
 celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, 
bundle_listener_pt listener) {
-   celix_status_t status = CELIX_SUCCESS;
-   fw_bundle_listener_pt bundleListener = NULL;
+celix_status_t status = CELIX_SUCCESS;
+fw_bundle_listener_pt bundleListener = NULL;
 
-   bundleListener = (fw_bundle_listener_pt) 
malloc(sizeof(*bundleListene

[1/2] celix git commit: admin mutexes replaced by std::mutex and lock_guard

2018-11-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/nanomsg cb740b0d4 -> 3009e6470


admin mutexes replaced by std::mutex and lock_guard


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

Branch: refs/heads/nanomsg
Commit: 95892a8577107eb4fa93410ae08913d51407763b
Parents: cb740b0
Author: Erjan Altena 
Authored: Thu Nov 1 21:17:02 2018 +0100
Committer: Erjan Altena 
Committed: Thu Nov 1 21:17:02 2018 +0100

--
 .../src/psa_nanomsg_activator.cc|   4 -
 .../src/pubsub_nanomsg_admin.cc | 329 +--
 .../src/pubsub_nanomsg_admin.h  |  10 +-
 3 files changed, 166 insertions(+), 177 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/95892a85/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
index ec3ee7d..e599f01 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
@@ -87,10 +87,6 @@ private:
 LogHelper logHelper;
pubsub_nanomsg_admin admin;
 
-
-//command_service_t cmdSvc{};
-
-// long cmdSvcId = -1L;
 };
 
 celix_status_t  celix_bundleActivator_create(celix_bundle_context_t *ctx , 
void **userData) {

http://git-wip-us.apache.org/repos/asf/celix/blob/95892a85/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index bd1d0a5..c10431f 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -105,64 +105,59 @@ 
pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx, log_hel
 qosSampleScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_SAMPLE_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_SAMPLE_SCORE);
 qosControlScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_CONTROL_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_CONTROL_SCORE);
 
-celixThreadMutex_create(&serializers.mutex, nullptr);
 serializers.map = hashMap_create(nullptr, nullptr, nullptr, nullptr);
 
-celixThreadMutex_create(&topicSenders.mutex, nullptr);
 topicSenders.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
 
-celixThreadMutex_create(&topicReceivers.mutex, nullptr);
 topicReceivers.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
 
-celixThreadMutex_create(&discoveredEndpoints.mutex, nullptr);
 discoveredEndpoints.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
 }
 
 pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 //note assuming al psa register services and service tracker are removed.
-
-celixThreadMutex_lock(&topicSenders.mutex);
-hash_map_iterator_t iter = hashMapIterator_construct(topicSenders.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *sender = 
static_cast(hashMapIterator_nextValue(&iter));
-pubsub_nanoMsgTopicSender_destroy(sender);
+{
+std::lock_guard lock(topicSenders.mutex);
+hash_map_iterator_t iter = hashMapIterator_construct(topicSenders.map);
+while (hashMapIterator_hasNext(&iter)) {
+auto *sender = static_cast(hashMapIterator_nextValue(&iter));
+pubsub_nanoMsgTopicSender_destroy(sender);
+}
 }
-celixThreadMutex_unlock(&topicSenders.mutex);
 
-celixThreadMutex_lock(&topicReceivers.mutex);
-iter = hashMapIterator_construct(topicReceivers.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *recv = 
static_cast(hashMapIterator_nextValue(&iter));
-pubsub_nanoMsgTopicReceiver_destroy(recv);
+{
+std::lock_guard lock(topicReceivers.mutex);
+hash_map_iterator_t iter = 
hashMapIterator_construct(topicReceivers.map);
+while (hashMapIterator_hasNext(&iter)) {
+auto *recv = 
static_cast(hashMapIterator_nextValue(&iter));
+pubsub_nanoMsgTopicReceiver_destroy(recv);
+}
 }
-celixThreadMutex_unlock(&topicReceivers.mutex);
 
-celixThreadMutex_lock(&discoveredEndpoints.mutex);
-iter = hashMapIterator_construct(discoveredEndpoints.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *ep = 
static

[2/2] celix git commit: Replaced celix-map with std::map

2018-11-01 Thread erjanaltena
Replaced celix-map with std::map


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

Branch: refs/heads/nanomsg
Commit: 3009e64705e1be606ca308ffc7ec7c0633dfde77
Parents: 95892a8
Author: Erjan Altena 
Authored: Thu Nov 1 21:40:24 2018 +0100
Committer: Erjan Altena 
Committed: Thu Nov 1 21:40:24 2018 +0100

--
 .../src/pubsub_nanomsg_admin.cc | 57 +++-
 .../src/pubsub_nanomsg_admin.h  | 11 +++-
 .../src/pubsub_nanomsg_topic_receiver.h |  3 +-
 3 files changed, 44 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/3009e647/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
index c10431f..9fe91d9 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "pubsub_utils.h"
 #include "pubsub_nanomsg_admin.h"
@@ -105,7 +104,7 @@ 
pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx, log_hel
 qosSampleScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_SAMPLE_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_SAMPLE_SCORE);
 qosControlScore = celix_bundleContext_getPropertyAsDouble(ctx, 
PSA_NANOMSG_QOS_CONTROL_SCORE_KEY, PSA_NANOMSG_DEFAULT_QOS_CONTROL_SCORE);
 
-serializers.map = hashMap_create(nullptr, nullptr, nullptr, nullptr);
+//serializers.map = hashMap_create(nullptr, nullptr, nullptr, nullptr);
 
 topicSenders.map = hashMap_create(utils_stringHash, nullptr, 
utils_stringEquals, nullptr);
 
@@ -145,10 +144,9 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 
 {
 std::lock_guard lock(serializers.mutex);
-hash_map_iterator_t iter = hashMapIterator_construct(serializers.map);
-while (hashMapIterator_hasNext(&iter)) {
-auto *entry = 
static_cast(hashMapIterator_nextValue(&iter));
-free(entry);
+// todo: do not use pointer but type in map
+for(auto kv: serializers.map) {
+free(kv.second);
 }
 }
 
@@ -158,8 +156,6 @@ pubsub_nanomsg_admin::~pubsub_nanomsg_admin() {
 
 hashMap_destroy(discoveredEndpoints.map, false, false);
 
-hashMap_destroy(serializers.map, false, false);
-
 free(ipAddress);
 
 }
@@ -256,13 +252,13 @@ void pubsub_nanomsg_admin::addSerializerSvc(void *svc, 
const celix_properties_t
 
 {
 std::lock_guard lock(serializers.mutex);
-auto *entry = 
static_cast(hashMap_get(serializers.map, 
(void*)svcId));
-if (entry == nullptr) {
-entry = static_cast(calloc(1, 
sizeof(*entry)));
+auto it = serializers.map.find(svcId);
+if (it == serializers.map.end()) {
+auto entry = 
static_cast(calloc(1, 
sizeof(psa_nanomsg_serializer_entry_t)));
 entry->serType = serType;
 entry->svcId = svcId;
 entry->svc = static_cast(svc);
-hashMap_put(serializers.map, (void*)svcId, entry);
+serializers.map[svcId] = entry;
 }
 }
 }
@@ -278,7 +274,13 @@ void pubsub_nanomsg_admin::removeSerializerSvc(void 
*/*svc*/, const celix_proper
 // Note that it is the responsibility of the topology manager to create 
new topic senders/receivers
 
 std::lock_guard lock(serializers.mutex);
-auto *entry = 
static_cast(hashMap_remove(serializers.map, 
(void*)svcId));
+
+psa_nanomsg_serializer_entry_t* entry = nullptr;
+auto kv = serializers.map.find(svcId);
+if (kv != serializers.map.end()) {
+entry = kv->second;
+}
+serializers.map.erase(svcId);
 if (entry != nullptr) {
 {
 std::lock_guard senderLock(topicSenders.mutex);
@@ -365,8 +367,13 @@ celix_status_t 
pubsub_nanomsg_admin::setupTopicSender(const char *scope, const c
 std::lock_guard topicSenderLock(topicSenders.mutex);
 sender = static_cast(hashMap_get(topicSenders.map, key));
 if (sender == nullptr) {
-auto *serEntry = static_cast(hashMap_get(serializers.map,
-   
(void *) serializerSvcId));
+//auto *serEntry = static_cast(hashMap_get(serializers.map,
+// 
  (void *) serializerSvcId));
+psa_nanomsg_serializer_entry_t *serEntry = nullptr;
+ 

celix git commit: Updates to nanomsg admin

2018-11-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/nanomsg 4fc1f3d3f -> cb740b0d4


Updates to nanomsg admin


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

Branch: refs/heads/nanomsg
Commit: cb740b0d41df786fead29ab1d9f3930187a7fe82
Parents: 4fc1f3d
Author: Erjan Altena 
Authored: Thu Nov 1 20:43:05 2018 +0100
Committer: Erjan Altena 
Committed: Thu Nov 1 20:43:05 2018 +0100

--
 .../pubsub_admin_nanomsg/src/nanomsg_crypto.cc  | 281 -
 .../pubsub_admin_nanomsg/src/nanomsg_crypto.h   |  41 --
 .../src/psa_nanomsg_activator.cc| 171 +++---
 .../src/pubsub_nanomsg_admin.cc | 573 ++-
 .../src/pubsub_nanomsg_admin.h  | 110 +++-
 .../src/pubsub_nanomsg_topic_receiver.cc|  21 +-
 .../src/pubsub_nanomsg_topic_sender.cc  |   2 -
 libs/framework/include/celix_bundle_activator.h |   2 +-
 8 files changed, 476 insertions(+), 725 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/cb740b0d/bundles/pubsub/pubsub_admin_nanomsg/src/nanomsg_crypto.cc
--
diff --git a/bundles/pubsub/pubsub_admin_nanomsg/src/nanomsg_crypto.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/nanomsg_crypto.cc
deleted file mode 100644
index d7d88bb..000
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/nanomsg_crypto.cc
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * zmq_crypto.c
- *
- *  \date   Dec 2, 2016
- *  \authormailto:d...@celix.apache.org";>Apache Celix 
Project Team
- *  \copyright Apache License, Version 2.0
- */
-
-#include "nanomsg_crypto.h"
-
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#define MAX_FILE_PATH_LENGTH 512
-#define ZMQ_KEY_LENGTH 40
-#define AES_KEY_LENGTH 32
-#define AES_IV_LENGTH 16
-
-#define KEY_TO_GET "aes_key"
-#define IV_TO_GET "aes_iv"
-
-static char* read_file_content(char* filePath, char* fileName);
-static void parse_key_lines(char *keysBuffer, char **key, char **iv);
-static void parse_key_line(char *line, char **key, char **iv);
-static void extract_keys_from_buffer(unsigned char *input, int inputlen, char 
**publicKey, char **secretKey);
-
-/**
- * Return a valid zcert_t from an encoded file
- * Caller is responsible for freeing by calling zcert_destroy(zcert** cert);
- */
-zcert_t* get_zcert_from_encoded_file(char* keysFilePath, char* keysFileName, 
char* file_path)
-{
-
-   if (keysFilePath == NULL){
-   keysFilePath = DEFAULT_KEYS_FILE_PATH;
-   }
-
-   if (keysFileName == NULL){
-   keysFileName = DEFAULT_KEYS_FILE_NAME;
-   }
-
-   char* keys_data = read_file_content(keysFilePath, keysFileName);
-   if (keys_data == NULL){
-   return NULL;
-   }
-
-   char *key = NULL;
-   char *iv = NULL;
-   parse_key_lines(keys_data, &key, &iv);
-   free(keys_data);
-
-   if (key == NULL || iv == NULL){
-   free(key);
-   free(iv);
-
-   printf("CRYPTO: Loading AES key and/or AES iv failed!\n");
-   return NULL;
-   }
-
-   //At this point, we know an aes key and iv are stored and loaded
-
-   // generate sha256 hashes
-   unsigned char key_digest[EVP_MAX_MD_SIZE];
-   unsigned char iv_digest[EVP_MAX_MD_SIZE];
-   generate_sha256_hash((char*) key, key_digest);
-   generate_sha256_hash((char*) iv, iv_digest);
-
-   zchunk_t* encoded_secret = zchunk_slurp (file_path, 0);
-   if (encoded_secret == NULL){
-   free(key);
-   free(iv);
-
-   return NULL;
-   }
-
-   int encoded_secret_size = (int) zchunk_size (encoded_secret);
-   char* encoded_secret_data = zchunk_strdup(encoded_secret);
-   zchunk_destroy (&encoded_secret);
-
-   // Decryption of data
-   int decryptedt

[2/2] celix git commit: NanoMsgAdmin: first version

2018-10-24 Thread erjanaltena
NanoMsgAdmin: first version


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

Branch: refs/heads/nanomsg
Commit: 4fc1f3d3f7398a4b1f0e3993ed889b811f653d95
Parents: 1ffdd94
Author: Erjan Altena 
Authored: Wed Oct 24 14:15:02 2018 +0200
Committer: Erjan Altena 
Committed: Wed Oct 24 14:30:16 2018 +0200

--
 .../log_service/loghelper_include/log_helper.h  |   7 +-
 bundles/pubsub/CMakeLists.txt   |   2 +
 bundles/pubsub/examples/CMakeLists.txt  |  88 ++-
 .../pubsub/pubsub_admin_nanomsg/CMakeLists.txt  |  51 ++
 .../pubsub_admin_nanomsg/src/nanomsg_crypto.cc  | 281 
 .../pubsub_admin_nanomsg/src/nanomsg_crypto.h   |  41 ++
 .../src/psa_nanomsg_activator.cc| 113 +++
 .../src/pubsub_nanomsg_admin.cc | 698 +++
 .../src/pubsub_nanomsg_admin.h  |  73 ++
 .../src/pubsub_nanomsg_common.cc|  56 ++
 .../src/pubsub_nanomsg_common.h |  56 ++
 .../src/pubsub_nanomsg_topic_receiver.cc| 420 +++
 .../src/pubsub_nanomsg_topic_receiver.h |  45 ++
 .../src/pubsub_nanomsg_topic_sender.cc  | 368 ++
 .../src/pubsub_nanomsg_topic_sender.h   |  42 ++
 .../src/pubsub_psa_nanomsg_constants.h  |  50 ++
 .../src/pubsub_udpmc_admin.c|   2 +-
 .../pubsub/pubsub_spi/include/pubsub_endpoint.h |  23 +-
 .../pubsub/pubsub_spi/include/pubsub_utils.h|  50 +-
 cmake/Modules/FindNanoMsg.cmake |  42 ++
 libs/framework/include/celix_bundle_activator.h |   2 +-
 21 files changed, 2471 insertions(+), 39 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/4fc1f3d3/bundles/log_service/loghelper_include/log_helper.h
--
diff --git a/bundles/log_service/loghelper_include/log_helper.h 
b/bundles/log_service/loghelper_include/log_helper.h
index 2ae9d83..28e6877 100644
--- a/bundles/log_service/loghelper_include/log_helper.h
+++ b/bundles/log_service/loghelper_include/log_helper.h
@@ -23,7 +23,9 @@
 
 #include "bundle_context.h"
 #include "log_service.h"
-
+#ifdef __cplusplus
+extern "C" {
+#endif
 typedef struct log_helper log_helper_t;
 typedef struct log_helper* log_helper_pt;
 
@@ -32,5 +34,8 @@ celix_status_t logHelper_start(log_helper_pt loghelper);
 celix_status_t logHelper_stop(log_helper_pt loghelper);
 celix_status_t logHelper_destroy(log_helper_pt* loghelper);
 celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* 
message, ... );
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* LOGHELPER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/4fc1f3d3/bundles/pubsub/CMakeLists.txt
--
diff --git a/bundles/pubsub/CMakeLists.txt b/bundles/pubsub/CMakeLists.txt
index e3db995..05e6ee1 100644
--- a/bundles/pubsub/CMakeLists.txt
+++ b/bundles/pubsub/CMakeLists.txt
@@ -24,12 +24,14 @@ if (PUBSUB)
option(BUILD_ZMQ_SECURITY "Build with security for ZeroMQ." OFF)
 endif (BUILD_PUBSUB_PSA_ZMQ)
 
+   option(BUILD_PUBSUB_PSA_NANOMSG "Build NanoMsg PubSub Admin - 
Experimental" OFF)
add_subdirectory(pubsub_api)
add_subdirectory(pubsub_spi)
add_subdirectory(pubsub_topology_manager)
add_subdirectory(pubsub_discovery)
add_subdirectory(pubsub_serializer_json)
add_subdirectory(pubsub_admin_zmq)
+   add_subdirectory(pubsub_admin_nanomsg)
add_subdirectory(pubsub_admin_udp_mc)
add_subdirectory(keygen)
add_subdirectory(mock)

http://git-wip-us.apache.org/repos/asf/celix/blob/4fc1f3d3/bundles/pubsub/examples/CMakeLists.txt
--
diff --git a/bundles/pubsub/examples/CMakeLists.txt 
b/bundles/pubsub/examples/CMakeLists.txt
index e8113b9..126db2d 100644
--- a/bundles/pubsub/examples/CMakeLists.txt
+++ b/bundles/pubsub/examples/CMakeLists.txt
@@ -25,7 +25,7 @@ find_package(ZMQ REQUIRED)
 find_package(CZMQ REQUIRED)
 find_package(Jansson REQUIRED)
 
-set(PUBSUB_CONTAINER_LIBS ${JANSSON_LIBRARY} ${ZMQ_LIBRARIES} 
${CZMQ_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} Celix::dfi)
+set(PUBSUB_CONTAINER_LIBS ${JANSSON_LIBRARY} ${ZMQ_LIBRARIES} 
${CZMQ_LIBRARIES} ${NANOMSG_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} Celix::dfi)
 
 # UDP Multicast
 add_celix_container(pubsub_publisher_udp_mc
@@ -264,5 +264,91 @@ if (BUILD_PUBSUB_PSA_ZMQ)
 USE_TERM
 )
 endif ()
+endif()
+if (BUILD_PUBSUB_PSA_NANOMSG)
+add_celix_container("pubsub_publisher1_nanomsg"
+GROUP "pubsub"
+

[1/2] celix git commit: NanoMsgAdmin: first version

2018-10-24 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/nanomsg [created] 4fc1f3d3f


http://git-wip-us.apache.org/repos/asf/celix/blob/4fc1f3d3/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
--
diff --git 
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc 
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
new file mode 100644
index 000..feead76
--- /dev/null
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
@@ -0,0 +1,368 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "pubsub_nanomsg_topic_sender.h"
+#include "pubsub_psa_nanomsg_constants.h"
+#include "pubsub_nanomsg_common.h"
+
+#define FIRST_SEND_DELAY_IN_SECONDS 2
+#define NANOMSG_BIND_MAX_RETRY  10
+/*
+#define L_DEBUG(...) \
+logHelper_log(sender->logHelper, OSGI_LOGSERVICE_DEBUG, __VA_ARGS__)
+#define L_INFO(...) \
+logHelper_log(sender->logHelper, OSGI_LOGSERVICE_INFO, __VA_ARGS__)
+#define L_WARN(...) \
+logHelper_log(sender->logHelper, OSGI_LOGSERVICE_WARNING, __VA_ARGS__)
+#define L_ERROR(...) \
+logHelper_log(sender->logHelper, OSGI_LOGSERVICE_ERROR, __VA_ARGS__)
+*/
+#define L_DEBUG printf
+#define L_INFO printf
+#define L_WARN printf
+#define L_ERROR printf
+
+struct pubsub_nanomsg_topic_sender {
+celix_bundle_context_t *ctx;
+log_helper_t *logHelper;
+long serializerSvcId;
+pubsub_serializer_service_t *serializer;
+
+char *scope;
+char *topic;
+char scopeAndTopicFilter[5];
+char *url;
+
+struct {
+celix_thread_mutex_t mutex;
+int socket;
+} nanomsg;
+
+struct {
+long svcId;
+celix_service_factory_t factory;
+} publisher;
+
+struct {
+celix_thread_mutex_t mutex;
+hash_map_t *map;  //key = bndId, value = 
psa_nanomsg_bounded_service_entry_t
+} boundedServices;
+};
+
+typedef struct psa_nanomsg_bounded_service_entry {
+pubsub_nanomsg_topic_sender_t *parent;
+pubsub_publisher_t service;
+long bndId;
+hash_map_t *msgTypes;
+int getCount;
+} psa_nanomsg_bounded_service_entry_t;
+
+static void* psa_nanomsg_getPublisherService(void *handle, const 
celix_bundle_t *requestingBundle,
+ const celix_properties_t 
*svcProperties);
+static void psa_nanomsg_ungetPublisherService(void *handle, const 
celix_bundle_t *requestingBundle,
+  const celix_properties_t 
*svcProperties);
+static unsigned int rand_range(unsigned int min, unsigned int max);
+static void delay_first_send_for_late_joiners(pubsub_nanomsg_topic_sender_t 
*sender);
+
+static int psa_nanomsg_topicPublicationSend(void *handle, unsigned int 
msgTypeId, const void *msg);
+
+pubsub_nanomsg_topic_sender_t* 
pubsub_nanoMsgTopicSender_create(celix_bundle_context_t *ctx, log_helper_t 
*logHelper,
+const char 
*scope, const char *topic,
+long 
serializerSvcId, pubsub_serializer_service_t *ser,
+const char 
*bindIP, unsigned int basePort,
+unsigned int 
maxPort) {
+pubsub_nanomsg_topic_sender_t *sender = 
static_cast(calloc(1, sizeof(*sender)));
+sender->ctx = ctx;
+sender->logHelper = logHelper;
+sender->serializerSvcId = serializerSvcId;
+sender->serializer = ser;
+psa_nanomsg_setScopeAndTopicFilter(scope, topic, 
sender->scopeAndTopicFilter);
+
+//setting up nanomsg socket for nanomsg TopicSender
+{
+
+int socket = nn_socket(AF_SP, NN_BUS);
+if (socket == -1) {
+perror("Error for nanomsg_socket");
+}
+
+int rv = -1, retry=0;
+while(rv == -1 && retry < NANOMSG_BIND_MAX_RETRY ) {
+/* Randomized part due to same bundle publishing on diffe

celix git commit: Removed sleep in zmqadmin read-thread and fixed doublke destroy of property

2018-10-16 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 3b56bcebc -> 24def6839


Removed sleep in zmqadmin read-thread and fixed doublke destroy of property


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

Branch: refs/heads/develop
Commit: 24def683920dfd4145178130a7f96fa923a13676
Parents: 3b56bce
Author: Erjan Altena 
Authored: Tue Oct 16 14:23:02 2018 +0200
Committer: Erjan Altena 
Committed: Tue Oct 16 14:30:40 2018 +0200

--
 .../pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c | 11 +--
 bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c   |  5 ++---
 2 files changed, 11 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/24def683/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
--
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
index 7a07827..1633058 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
@@ -165,7 +165,14 @@ pubsub_zmq_topic_receiver_t* 
pubsub_zmqTopicReceiver_create(celix_bundle_context
 }
 
 if (receiver->zmqSocket != NULL) {
+int timeout = PSA_ZMQ_RECV_TIMEOUT;
+void *zmqSocket =  zsock_resolve(receiver->zmqSocket);
+int res = zmq_setsockopt(zmqSocket, ZMQ_RCVTIMEO, &timeout, 
sizeof(timeout));
+if (res) {
+L_ERROR("[PSA_ZMQ] Cannot set ZMQ socket option ZMQ_RCVTIMEO 
errno=%d", errno);
+}
 #ifdef BUILD_WITH_ZMQ_SECURITY
+
 zcert_apply (sub_cert, zmq_s);
 zsock_set_curve_serverkey (zmq_s, pub_key); //apply key of publisher 
to socket of subscriber
 #endif
@@ -397,10 +404,10 @@ static void* psa_zmq_recvThread(void * data) {
 celixThreadMutex_unlock(&receiver->recvThread.mutex);
 
 while (running) {
-zframe_t* headerMsg = zframe_recv_nowait(receiver->zmqSocket);
+zframe_t* headerMsg = zframe_recv(receiver->zmqSocket);
 if (headerMsg == NULL) {
 if(errno == EAGAIN) {
-usleep(PSA_ZMQ_RECV_TIMEOUT);
+// Do nothing
 } else if (errno == EINTR) {
 //It means we got a signal and we have to exit...
 L_INFO("PSA_ZMQ_TS: header_recv thread for topic got a signal 
and will exit.\n");

http://git-wip-us.apache.org/repos/asf/celix/blob/24def683/bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c
--
diff --git a/bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c 
b/bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c
index bbe4fe7..1542e4f 100644
--- a/bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c
+++ b/bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c
@@ -176,6 +176,7 @@ double pubsub_utils_matchSubscriber(
requested_qos = celix_properties_get(ep, 
PUBSUB_UTILS_QOS_ATTRIBUTE_KEY, NULL);
requested_serializer = celix_properties_get(ep, 
PUBSUB_ENDPOINT_SERIALIZER, NULL);
celix_properties_destroy(ep);
+   data.outEndpoint = NULL;
}
 
double score = getPSAScore(requested_admin, requested_qos, adminType, 
sampleScore, controlScore, defaultScore);
@@ -185,8 +186,6 @@ double pubsub_utils_matchSubscriber(
score = PUBSUB_ADMIN_NO_MATCH_SCORE; //no serializer, no match
}
 
-// printf("Score subscriber service match for psa type %s is %f\n", 
adminType, score);
-
if (outSerializerSvcId != NULL) {
*outSerializerSvcId = serializerSvcId;
}
@@ -222,4 +221,4 @@ bool pubsub_utils_matchEndpoint(
}
 
return match;
-}
\ No newline at end of file
+}



celix git commit: Report error to user if serializaton fails

2018-10-12 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop ca2d0901c -> 7b4433ba9


Report error to user if serializaton fails


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

Branch: refs/heads/develop
Commit: 7b4433ba9e8503076f32f9e8e42510441d77c2cb
Parents: ca2d090
Author: Erjan Altena 
Authored: Fri Oct 12 19:07:43 2018 +0200
Committer: Erjan Altena 
Committed: Fri Oct 12 19:09:39 2018 +0200

--
 .../src/pubsub_udpmc_topic_sender.c | 48 +-
 .../src/pubsub_zmq_topic_sender.c   | 97 +++-
 2 files changed, 78 insertions(+), 67 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/7b4433ba/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c
--
diff --git a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c 
b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c
index 64d3d59..59c809c 100644
--- a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c
+++ b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c
@@ -254,35 +254,39 @@ static int psa_udpmc_topicPublicationSend(void* handle, 
unsigned int msgTypeId,
 if (msgSer != NULL) {
 int major=0, minor=0;
 
-pubsub_msg_header_t *msg_hdr = calloc(1,sizeof(struct 
pubsub_msg_header));
-strncpy(msg_hdr->topic,entry->parent->topic,MAX_TOPIC_LEN-1);
-msg_hdr->type = msgTypeId;
+void* serializedOutput = NULL;
+size_t serializedOutputLen = 0;
+if (msgSer->serialize(msgSer,inMsg,&serializedOutput, 
&serializedOutputLen) == CELIX_SUCCESS) {
 
+pubsub_msg_header_t *msg_hdr = calloc(1,sizeof(struct 
pubsub_msg_header));
+strncpy(msg_hdr->topic,entry->parent->topic,MAX_TOPIC_LEN-1);
+msg_hdr->type = msgTypeId;
 
-if (msgSer->msgVersion != NULL){
-version_getMajor(msgSer->msgVersion, &major);
-version_getMinor(msgSer->msgVersion, &minor);
-msg_hdr->major = major;
-msg_hdr->minor = minor;
-}
 
-void* serializedOutput = NULL;
-size_t serializedOutputLen = 0;
-msgSer->serialize(msgSer,inMsg,&serializedOutput, 
&serializedOutputLen);
+if (msgSer->msgVersion != NULL){
+version_getMajor(msgSer->msgVersion, &major);
+version_getMinor(msgSer->msgVersion, &minor);
+msg_hdr->major = major;
+msg_hdr->minor = minor;
+}
 
-pubsub_msg_t *msg = calloc(1,sizeof(pubsub_msg_t));
-msg->header = msg_hdr;
-msg->payload = (char*)serializedOutput;
-msg->payloadSize = serializedOutputLen;
 
+pubsub_msg_t *msg = calloc(1, sizeof(pubsub_msg_t));
+msg->header = msg_hdr;
+msg->payload = (char *) serializedOutput;
+msg->payloadSize = serializedOutputLen;
 
-if(psa_udpmc_sendMsg(entry, msg,true, NULL) == false) {
-status = -1;
-}
-free(msg_hdr);
-free(msg);
-free(serializedOutput);
 
+if (psa_udpmc_sendMsg(entry, msg, true, NULL) == false) {
+status = -1;
+}
+free(msg);
+free(msg_hdr);
+free(serializedOutput);
+} else {
+printf("[PSA_UDPMC/TopicSender] Serialization of msg type id %d 
failed\n", msgTypeId);
+status=-1;
+}
 
 } else {
 printf("[PSA_UDPMC/TopicSender] No msg serializer available for msg 
type id %d\n", msgTypeId);

http://git-wip-us.apache.org/repos/asf/celix/blob/7b4433ba/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c
--
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c 
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c
index dc735c2..ad36820 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c
@@ -443,55 +443,62 @@ static int psa_zmq_topicPublicationSendMultipart(void 
*handle, unsigned int msgT
 
 void *serializedOutput = NULL;
 size_t serializedOutputLen = 0;
-msgSer->serialize(msgSer,inMsg,&serializedOutput, 
&serializedOutputLen);
-
-pubsub_msg_t *msg = calloc(1,sizeof(struct pubsub_msg));
-msg->header = msg_hdr;
-msg->payload = (char*)serializedOutput;
-msg->payloadSize = (int)serializedOutputLen;
-bool snd = true;
-
-switch(flags) {
-  

celix git commit: CELIX-448: Added component_removeInterface / C++ Component::removeCInterface

2018-06-28 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop a5192fc6a -> 788577859


CELIX-448: Added component_removeInterface / C++ Component::removeCInterface


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

Branch: refs/heads/develop
Commit: 788577859c99196b7f34f062616ab19199a9696f
Parents: a5192fc
Author: Erjan Altena 
Authored: Thu Jun 28 20:39:27 2018 +0200
Committer: Erjan Altena 
Committed: Thu Jun 28 20:39:49 2018 +0200

--
 .../phase1/src/Phase1Activator.cc   | 33 ++--
 .../dm_example_cxx/phase1/src/Phase1Activator.h | 11 ++-
 libs/framework/include/celix/dm/Component.h | 11 +++
 .../framework/include/celix/dm/Component_Impl.h |  8 +
 libs/framework/include/dm_component.h   |  7 +
 libs/framework/src/dm_component_impl.c  | 23 ++
 6 files changed, 90 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/78857785/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
--
diff --git 
a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc 
b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
index 4bee1df..2dd5ed2 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@ -55,18 +55,47 @@ void Phase1Activator::init() {
 return cmp->infoCmd(line, out, err);
 };
 
+Properties addProps;
+addProps[OSGI_SHELL_COMMAND_NAME] = "add";
+addProps[OSGI_SHELL_COMMAND_USAGE] = "add";
+addProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "add dummy service";
+
+
+addCmd.handle = this;
+addCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, FILE 
*/*err*/) {
+Phase1Activator* act = (Phase1Activator*)handle;
+fprintf(out, "Adding dummy interface");
+act->phase1cmp->addCInterface(act->dummySvc, "DUMMY_SERVICE");
+return 0;
+};
+
+Properties removeProps;
+removeProps[OSGI_SHELL_COMMAND_NAME] = "remove";
+removeProps[OSGI_SHELL_COMMAND_USAGE] = "remove";
+removeProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "remove dummy service";
+
+
+removeCmd.handle = this;
+removeCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, 
FILE */*err*/) {
+Phase1Activator* act = (Phase1Activator*)handle;
+fprintf(out, "Removing dummy interface");
+act->phase1cmp->removeCInterface(act->dummySvc);
+return 0;
+};
+
 auto tst = std::unique_ptr(new InvalidCServ{});
 tst->handle = cmp.get();
 
 
-mng.createComponent(std::move(cmp))  //using a pointer a instance. Also 
supported is lazy initialization (default constructor needed) or a rvalue 
reference (move)
+phase1cmp = &mng.createComponent(std::move(cmp))  //using a pointer a 
instance. Also supported is lazy initialization (default constructor needed) or 
a rvalue reference (move)
 .addInterface(IPHASE1_VERSION)
 //.addInterface() -> Compile error (static assert), because 
Phase1Cmp does not implement IPhase2
 .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
+.addCInterface(&addCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", addProps)
+.addCInterface(&removeCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", 
removeProps)
 //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static 
assert), because InvalidCServ is not a pod
 .addInterface(INAME_VERSION)
 .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, 
&Phase1Cmp::deinit);
-
 }
 
 void Phase1Activator::deinit() {

http://git-wip-us.apache.org/repos/asf/celix/blob/78857785/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
--
diff --git 
a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h 
b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
index 37b25e3..a3b062b 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
@@ -24,11 +24,20 @@
 #include "command.h"
 
 using namespace celix::dm;
+struct DummyService {
+void *handle;
+};
 
 class Phase1Activator : public DmActivator {
 command_service_t cmd {nullptr, nullptr};
-public:
+command_service_t addCmd {nullptr, nullptr};
+command_service_t removeCmd {nullptr, nullptr};
+Component *phase1cmp{nullptr};
+DummyService *dummySvc{new DummyService};
+p

celix git commit: Fixed memory leak in DM shell command

2018-06-26 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 4fb26cf10 -> a5192fc6a


Fixed memory leak in DM shell command


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

Branch: refs/heads/develop
Commit: a5192fc6a0b7a302b106dacd7d023f55d48b241b
Parents: 4fb26cf
Author: Erjan Altena 
Authored: Tue Jun 26 11:12:08 2018 +0200
Committer: Erjan Altena 
Committed: Tue Jun 26 11:12:08 2018 +0200

--
 bundles/shell/shell/src/dm_shell_list_command.c | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/a5192fc6/bundles/shell/shell/src/dm_shell_list_command.c
--
diff --git a/bundles/shell/shell/src/dm_shell_list_command.c 
b/bundles/shell/shell/src/dm_shell_list_command.c
index 6b92c17..aeb7afd 100644
--- a/bundles/shell/shell/src/dm_shell_list_command.c
+++ b/bundles/shell/shell/src/dm_shell_list_command.c
@@ -184,6 +184,7 @@ celix_status_t dmListCommand_execute(void* handle, char * 
line, FILE *out, FILE
 
 }
 }
+arrayList_destroy(bundles);
 }
 
 destroyBundleIdList(bundleIds);



celix git commit: Added dependencyManager_remove(C) /DependencyManager::destroyComponent (C++) function to be able to remove a component from a started Dependency manager.

2018-04-18 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 78460c7a7 -> 83cf4c964


Added dependencyManager_remove(C) /DependencyManager::destroyComponent (C++) 
function to be able to remove a component from a started Dependency manager.


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

Branch: refs/heads/develop
Commit: 83cf4c9643005f4b7df8edc9b2498d2159608830
Parents: 78460c7
Author: Erjan Altena 
Authored: Wed Apr 18 10:23:24 2018 +0200
Committer: Erjan Altena 
Committed: Thu Apr 19 08:37:55 2018 +0200

--
 dependency_manager/api/dm_dependency_manager.h|  5 +
 dependency_manager/src/dm_dependency_manager_impl.c   | 14 --
 .../include/celix/dm/DependencyManager.h  |  8 
 3 files changed, 25 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager/api/dm_dependency_manager.h
--
diff --git a/dependency_manager/api/dm_dependency_manager.h 
b/dependency_manager/api/dm_dependency_manager.h
index 89fe51d..8e01302 100644
--- a/dependency_manager/api/dm_dependency_manager.h
+++ b/dependency_manager/api/dm_dependency_manager.h
@@ -57,6 +57,11 @@ void dependencyManager_destroy(dm_dependency_manager_pt 
manager);
 celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, 
dm_component_pt component);
 
 /**
+ * Removes a DM component from the dependency manager and destroys it
+ */
+celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, 
dm_component_pt component);
+
+/**
  * Removes all DM components from the dependency manager
  */
 celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt 
manager);

http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager/src/dm_dependency_manager_impl.c
--
diff --git a/dependency_manager/src/dm_dependency_manager_impl.c 
b/dependency_manager/src/dm_dependency_manager_impl.c
index 4864be1..14c02f6 100644
--- a/dependency_manager/src/dm_dependency_manager_impl.c
+++ b/dependency_manager/src/dm_dependency_manager_impl.c
@@ -66,6 +66,16 @@ celix_status_t 
dependencyManager_add(dm_dependency_manager_pt manager, dm_compon
return status;
 }
 
+celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, 
dm_component_pt component) {
+celix_status_t status;
+
+   arrayList_removeElement(manager->components, component);
+status = component_stop(component);
+component_destroy(component);
+
+return status;
+}
+
 celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt 
manager) {
celix_status_t status = CELIX_SUCCESS;
 
@@ -89,7 +99,7 @@ celix_status_t 
dependencyManager_removeAllComponents(dm_dependency_manager_pt ma
 
 celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, 
dm_dependency_manager_info_pt *out) {
celix_status_t status = CELIX_SUCCESS;
-   int i;
+   unsigned int i;
int size;
dm_component_info_pt cmpInfo = NULL;
dm_dependency_manager_info_pt info = calloc(1, sizeof(*info));
@@ -118,7 +128,7 @@ celix_status_t 
dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_de
return status;
 }
 
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, 
dm_dependency_manager_info_pt info) {
+void dependencyManager_destroyInfo(dm_dependency_manager_pt 
__attribute__((__unused__)) manager, dm_dependency_manager_info_pt info) {
 unsigned int i = 0;
 for (; i < arrayList_size(info->components); i += 1) {
 dm_component_info_pt cmpinfo = 
(dm_component_info_pt)arrayList_get(info->components, i);

http://git-wip-us.apache.org/repos/asf/celix/blob/83cf4c96/dependency_manager_cxx/include/celix/dm/DependencyManager.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h 
b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
index afafacc..8648bc9 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -121,6 +121,14 @@ namespace celix { namespace dm {
 }
 
 /**
+ * Removes a component from the  Dependency Manager and destroys it
+ */
+template
+void destroyComponent(Component &component) {
+dependencyManager_remove(cDepMan, component.cComponent());
+}
+
+/**
  * Stops the Dependency Manager
  */
 void

celix git commit: Fixed possible deadlock

2018-04-17 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 184497c35 -> 2eeadb4cc


Fixed possible deadlock


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

Branch: refs/heads/develop
Commit: 2eeadb4cc61362b7daba407d1947247e7ddb80c8
Parents: 184497c
Author: Erjan Altena 
Authored: Tue Apr 17 15:48:18 2018 +0200
Committer: Erjan Altena 
Committed: Tue Apr 17 15:48:18 2018 +0200

--
 .../include/celix/dm/DependencyManager.h| 34 +---
 .../include/celix/dm/DependencyManager_Impl.h   |  2 +-
 2 files changed, 23 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/2eeadb4c/dependency_manager_cxx/include/celix/dm/DependencyManager.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h 
b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
index e51a4d7..afafacc 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -46,13 +46,13 @@ namespace celix { namespace dm {
 }
 
 DependencyManager(DependencyManager&& mgr) : componentsMutex{} {
-std::lock_guard lock(componentsMutex);
-mgr.context = context;
-mgr.queuedComponents = std::move(queuedComponents);
-mgr.startedComponents = std::move(startedComponents);
-mgr.cDepMan = cDepMan;
-cDepMan = nullptr;
-context = nullptr;
+std::lock_guard 
lock(this->componentsMutex);
+mgr.context = this->context;
+mgr.queuedComponents = std::move(this->queuedComponents);
+mgr.startedComponents = std::move(this->startedComponents);
+mgr.cDepMan = this->cDepMan;
+this->cDepMan = nullptr;
+this->context = nullptr;
 }
 DependencyManager& operator=(DependencyManager&&) = default;
 
@@ -102,12 +102,22 @@ namespace celix { namespace dm {
  * Starts the Dependency Manager
  */
 void start() {
-std::lock_guard lock(componentsMutex);
-for (auto it = queuedComponents.begin(); it != 
queuedComponents.end(); ++it) {
+std::vector> 
toBeStartedComponents {};
+{
+std::lock_guard 
lock(componentsMutex);
+for (auto it = queuedComponents.begin(); it != 
queuedComponents.end(); ++it) {
+
toBeStartedComponents.push_back(std::move(*it));
+}
+queuedComponents.clear();
+}
+for (auto it = toBeStartedComponents.begin(); it != 
toBeStartedComponents.end(); ++it) {
+
 dependencyManager_add(cDepMan, (*it)->cComponent());
-startedComponents.push_back(std::move(*it));
+{
+std::lock_guard 
lock(componentsMutex);
+startedComponents.push_back(std::move(*it));
+}
 }
-queuedComponents.clear();
 }
 
 /**
@@ -123,7 +133,7 @@ namespace celix { namespace dm {
 std::vector> queuedComponents {};
 std::vector> startedComponents {};
 dm_dependency_manager_pt cDepMan {nullptr};
-std::mutex componentsMutex{};
+std::recursive_mutex componentsMutex{};
 };
 
 }}

http://git-wip-us.apache.org/repos/asf/celix/blob/2eeadb4c/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h 
b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
index 5714ef0..82e0802 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
@@ -25,7 +25,7 @@ Component& DependencyManager::createComponent(std::string 
name) {
 Component::create(this->context) :
 Component::create(this->context, name);
 if (cmp->isValid()) {
-std::lock_guard lock(componentsMutex);
+std::lock_guard lock(componentsMutex);
 this->queuedComponents.push_back(std::unique_ptr {cmp});
 }
 return *cmp;



celix git commit: DepMgr-C++: DependencyManager::start starts now only not started components, this makes it possible to add and start components when the DependencyManager is already started.

2018-04-17 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 000259361 -> 184497c35


DepMgr-C++: DependencyManager::start starts now only not started components, 
this makes it possible to add and start components when the DependencyManager 
is already started.


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

Branch: refs/heads/develop
Commit: 184497c35658294748e1a230718834f5b2019947
Parents: 0002593
Author: Erjan Altena 
Authored: Tue Apr 17 11:26:34 2018 +0200
Committer: Erjan Altena 
Committed: Tue Apr 17 11:26:34 2018 +0200

--
 .../include/celix/dm/DependencyManager.h| 25 
 .../include/celix/dm/DependencyManager_Impl.h   |  3 ++-
 2 files changed, 22 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/184497c3/dependency_manager_cxx/include/celix/dm/DependencyManager.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager.h 
b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
index f079b35..e51a4d7 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager.h
@@ -29,6 +29,7 @@
 #include "dm_dependency_manager.h"
 
 #include 
+#include 
 
 namespace celix { namespace dm {
 
@@ -44,7 +45,15 @@ namespace celix { namespace dm {
 this->cDepMan = nullptr;
 }
 
-DependencyManager(DependencyManager&&) = default;
+DependencyManager(DependencyManager&& mgr) : componentsMutex{} {
+std::lock_guard lock(componentsMutex);
+mgr.context = context;
+mgr.queuedComponents = std::move(queuedComponents);
+mgr.startedComponents = std::move(startedComponents);
+mgr.cDepMan = cDepMan;
+cDepMan = nullptr;
+context = nullptr;
+}
 DependencyManager& operator=(DependencyManager&&) = default;
 
 DependencyManager(const DependencyManager&) = delete;
@@ -93,9 +102,12 @@ namespace celix { namespace dm {
  * Starts the Dependency Manager
  */
 void start() {
-for(std::unique_ptr& cmp : components)  {
-dependencyManager_add(cDepMan, cmp->cComponent());
+std::lock_guard lock(componentsMutex);
+for (auto it = queuedComponents.begin(); it != 
queuedComponents.end(); ++it) {
+dependencyManager_add(cDepMan, (*it)->cComponent());
+startedComponents.push_back(std::move(*it));
 }
+queuedComponents.clear();
 }
 
 /**
@@ -103,12 +115,15 @@ namespace celix { namespace dm {
  */
 void stop() {
 dependencyManager_removeAllComponents(cDepMan);
-components.clear();
+queuedComponents.clear();
+startedComponents.clear();
 }
 private:
 bundle_context_pt context {nullptr};
-std::vector> components {};
+std::vector> queuedComponents {};
+std::vector> startedComponents {};
 dm_dependency_manager_pt cDepMan {nullptr};
+std::mutex componentsMutex{};
 };
 
 }}

http://git-wip-us.apache.org/repos/asf/celix/blob/184497c3/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h 
b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
index 70cbcca..5714ef0 100644
--- a/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/DependencyManager_Impl.h
@@ -25,7 +25,8 @@ Component& DependencyManager::createComponent(std::string 
name) {
 Component::create(this->context) :
 Component::create(this->context, name);
 if (cmp->isValid()) {
-this->components.push_back(std::unique_ptr {cmp});
+std::lock_guard lock(componentsMutex);
+this->queuedComponents.push_back(std::unique_ptr {cmp});
 }
 return *cmp;
 }



celix git commit: Fixed messed-up terminal by shell when celix does not exit normally.

2018-03-28 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 2a50dd28c -> 000259361


Fixed messed-up terminal by shell when celix does not exit normally.


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

Branch: refs/heads/develop
Commit: 000259361ec8a67a811da181763ecb9b562e5386
Parents: 2a50dd2
Author: Erjan Altena 
Authored: Wed Mar 28 20:14:38 2018 +0200
Committer: Erjan Altena 
Committed: Wed Mar 28 20:14:38 2018 +0200

--
 shell_tui/private/src/shell_tui.c | 54 ++
 1 file changed, 48 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/00025936/shell_tui/private/src/shell_tui.c
--
diff --git a/shell_tui/private/src/shell_tui.c 
b/shell_tui/private/src/shell_tui.c
index 28bedaa..2ceb21a 100644
--- a/shell_tui/private/src/shell_tui.c
+++ b/shell_tui/private/src/shell_tui.c
@@ -73,17 +73,30 @@ typedef struct shell_context {
 history_t* hist;
 } shell_context_t;
 
+struct OriginalSettings {
+struct termios term_org;
+struct sigaction oldSigIntAction;
+struct sigaction oldSigSegvAction;
+struct sigaction oldSigAbrtAction;
+struct sigaction oldSigQuitAction;
+
+};
+
 // static function declarations
 static void remove_newlines(char* line);
 static void clearLine();
 static void cursorLeft(int n);
 static void writeLine(const char*line, int pos);
 static int autoComplete(shell_service_pt shellSvc, char *in, int cursorPos, 
size_t maxLen);
+static void shellSigHandler(int sig, siginfo_t *info, void* ptr);
 static void* shellTui_runnable(void *data);
 static void shellTui_parseInputForControl(shell_tui_t* shellTui, 
shell_context_t* ctx);
 static void shellTui_parseInput(shell_tui_t* shellTui, shell_context_t* ctx);
 static void writePrompt(void);
 
+// Unfortunately has to be static, it is not possible to pass user defined 
data to the handler
+static struct OriginalSettings originalSettings;
+
 shell_tui_t* shellTui_create(bool useAnsiControlSequences) {
 shell_tui_t* result = calloc(1, sizeof(*result));
 if (result != NULL) {
@@ -139,6 +152,19 @@ celix_status_t shellTui_setShell(shell_tui_t* shellTui, 
shell_service_t* svc) {
 return CELIX_SUCCESS;
 }
 
+static void shellSigHandler(int sig, siginfo_t *info, void* ptr) {
+tcsetattr(STDIN_FILENO, TCSANOW, &originalSettings.term_org);
+if (sig == SIGINT) {
+originalSettings.oldSigIntAction.sa_sigaction(sig, info, ptr);
+} else if (sig == SIGSEGV){
+originalSettings.oldSigSegvAction.sa_sigaction(sig, info, ptr);
+} else if (sig == SIGABRT){
+originalSettings.oldSigAbrtAction.sa_sigaction(sig, info, ptr);
+} else if (sig == SIGQUIT){
+originalSettings.oldSigQuitAction.sa_sigaction(sig, info, ptr);
+}
+}
+
 static void* shellTui_runnable(void *data) {
 shell_tui_t* shellTui = (shell_tui_t*) data;
 
@@ -147,12 +173,24 @@ static void* shellTui_runnable(void *data) {
 memset(&ctx, 0, sizeof(ctx));
 ctx.hist = historyCreate();
 
-struct termios term_org, term_new;
+struct termios term_new;
 if (shellTui->useAnsiControlSequences) {
-tcgetattr(STDIN_FILENO, &term_org);
-
-
-term_new = term_org;
+sigaction(SIGINT, NULL, &originalSettings.oldSigIntAction);
+sigaction(SIGSEGV, NULL, &originalSettings.oldSigSegvAction);
+sigaction(SIGABRT, NULL, &originalSettings.oldSigAbrtAction);
+sigaction(SIGQUIT, NULL, &originalSettings.oldSigQuitAction);
+struct sigaction newAction;
+memset(&newAction, 0, sizeof(newAction));
+newAction.sa_flags = SA_SIGINFO;
+newAction.sa_sigaction = shellSigHandler;
+sigaction(SIGINT, &newAction, NULL);
+sigaction(SIGSEGV, &newAction, NULL);
+sigaction(SIGABRT, &newAction, NULL);
+sigaction(SIGQUIT, &newAction, NULL);
+tcgetattr(STDIN_FILENO, &originalSettings.term_org);
+
+
+term_new = originalSettings.term_org;
 term_new.c_lflag &= ~(ICANON | ECHO);
 tcsetattr(STDIN_FILENO, TCSANOW, &term_new);
 }
@@ -186,7 +224,11 @@ static void* shellTui_runnable(void *data) {
 
 historyDestroy(ctx.hist);
 if (shellTui->useAnsiControlSequences) {
-tcsetattr(STDIN_FILENO, TCSANOW, &term_org);
+tcsetattr(STDIN_FILENO, TCSANOW, &originalSettings.term_org);
+sigaction(SIGINT, &originalSettings.oldSigIntAction, NULL);
+sigaction(SIGSEGV, &originalSettings.oldSigSegvAction, NULL);
+sigaction(SIGABRT, &originalSettings.oldSigAbrtAction, NULL);
+sigaction(SIGQUIT, &originalSettings.oldSigQ

celix git commit: Extended dm command: limit scope of functions

2018-03-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop f1dec56a6 -> 2e20c6d5c


Extended dm command: limit scope of functions


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

Branch: refs/heads/develop
Commit: 2e20c6d5cd211c03daa805683609279dc9b53f4a
Parents: f1dec56
Author: Erjan Altena 
Authored: Thu Mar 8 21:32:33 2018 +0100
Committer: Erjan Altena 
Committed: Thu Mar 8 21:32:33 2018 +0100

--
 dependency_manager/src/dm_shell_list_command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/2e20c6d5/dependency_manager/src/dm_shell_list_command.c
--
diff --git a/dependency_manager/src/dm_shell_list_command.c 
b/dependency_manager/src/dm_shell_list_command.c
index 33e9b49..8eb989c 100644
--- a/dependency_manager/src/dm_shell_list_command.c
+++ b/dependency_manager/src/dm_shell_list_command.c
@@ -84,7 +84,7 @@ static bool is_bundleId_in_list(array_list_pt ids, long id) {
 }
 
 
-void printFullInfo(FILE *out, bool colors, dm_component_info_pt compInfo) {
+static void printFullInfo(FILE *out, bool colors, dm_component_info_pt 
compInfo) {
 const char *startColors = "";
 const char *endColors = "";
 if (colors) {
@@ -128,7 +128,7 @@ void printFullInfo(FILE *out, bool colors, 
dm_component_info_pt compInfo) {
 
 }
 
-void printBasicInfo(FILE *out, bool colors, dm_component_info_pt compInfo) {
+static void printBasicInfo(FILE *out, bool colors, dm_component_info_pt 
compInfo) {
 const char *startColors = "";
 const char *endColors = "";
 if (colors) {



celix git commit: Extended dm command: show all info or info per bundle and basic/full info

2018-03-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 04671006c -> f1dec56a6


Extended dm command: show all info or info per bundle and basic/full info


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

Branch: refs/heads/develop
Commit: f1dec56a6ec26611efbe2335a620e095f9694974
Parents: 0467100
Author: Erjan Altena 
Authored: Thu Mar 8 21:25:05 2018 +0100
Committer: Erjan Altena 
Committed: Thu Mar 8 21:25:05 2018 +0100

--
 dependency_manager/src/dm_shell_activator.c|   4 +-
 dependency_manager/src/dm_shell_list_command.c | 199 +---
 2 files changed, 134 insertions(+), 69 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/f1dec56a/dependency_manager/src/dm_shell_activator.c
--
diff --git a/dependency_manager/src/dm_shell_activator.c 
b/dependency_manager/src/dm_shell_activator.c
index 4d6f507..661ffae 100644
--- a/dependency_manager/src/dm_shell_activator.c
+++ b/dependency_manager/src/dm_shell_activator.c
@@ -71,9 +71,9 @@ celix_status_t bundleActivator_start(void * userData, 
bundle_context_pt context)
 properties_pt props = properties_create();
 properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, 
CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
 properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
-properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm");
+properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm [f|full] [ 
[ [...]]]");
 properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
-   "Gives an overview of the component managemend by a 
dependency manager.");
+   "Gives an overview of the component managemed by a 
dependency manager.");
 
 status = bundleContext_registerService(context, 
OSGI_SHELL_COMMAND_SERVICE_NAME, &bi->dmCommand, props, &bi->reg);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/f1dec56a/dependency_manager/src/dm_shell_list_command.c
--
diff --git a/dependency_manager/src/dm_shell_list_command.c 
b/dependency_manager/src/dm_shell_list_command.c
index 1600710..33e9b49 100644
--- a/dependency_manager/src/dm_shell_list_command.c
+++ b/dependency_manager/src/dm_shell_list_command.c
@@ -27,23 +27,124 @@
 #include 
 #include 
 #include 
-#include "dm_info.h"
-#include "service_reference.h"
-#include "array_list.h"
-#include "bundle_context.h"
-#include "bundle.h"
-#include "shell.h"
-
 
 static const char * const OK_COLOR = "\033[92m";
 static const char * const WARNING_COLOR = "\033[93m";
 static const char * const NOK_COLOR = "\033[91m";
 static const char * const END_COLOR = "\033[m";
 
+static void parseCommandLine(const char*line, array_list_pt 
*requestedBundleIds, bool *fullInfo, FILE *err) {
+*fullInfo = false;
+char *str = strdup(line);
+// skip first argument since this is the command
+strtok(str," ");
+char* tok = strtok(NULL," ");
+*requestedBundleIds = NULL;
+arrayList_create(requestedBundleIds);
+while (tok) {
+if (tok[0] == 'f') { // f or full argument => show full info
+*fullInfo = true;
+} else if ( (tok[0] >= '0') && (tok[0] <= '9')) { // bundle id
+long *id = malloc(sizeof(*id));
+*id = strtol(tok, NULL, 10);
+arrayList_add(*requestedBundleIds, id);
+} else {
+fprintf (err, "DM: Skipping unknown argument: %s", tok );
+}
+tok = strtok(NULL," ");
+}
+free (str);
+}
+
+static void destroyBundleIdList(array_list_pt ids) {
+unsigned int size = arrayList_size(ids);
+for (unsigned int i = 0; i < size; i++) {
+free(arrayList_get(ids, i));
+}
+arrayList_destroy(ids);
+}
+
+/*
+ * Check if the ID is in the array list. If  arrayist is empty also true is 
returned so that all
+ * bundles are shown
+ */
+static bool is_bundleId_in_list(array_list_pt ids, long id) {
+unsigned int size = arrayList_size(ids);
+bool result = false;
+if (size == 0) {
+result = true;
+}
+for(unsigned int i = 0; i < size; ++i) {
+if (*((long*)arrayList_get(ids, i))  == id) {
+result = true;
+break;
+}
+}
+return result;
+}
+
+
+void printFullInfo(FILE *out, bool colors, dm_component_info_pt compInfo) {
+const char *startColors = "";
+const char *endColors = "";
+if (colors) {
+startColors = compInfo->active ? OK_COLOR : NOK_COLOR;
+endColors = END_COLOR;
+}
+fprintf(out, "Component: Name=%s\n|- ID=%s, %sActive=%s%s, State=%s\n", 
compInfo->name, compInfo->id,
+

celix git commit: pubsubEndpoint_equals returned wrong value -> reconnections failed

2018-03-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 058d79918 -> 04671006c


pubsubEndpoint_equals returned wrong value -> reconnections failed


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

Branch: refs/heads/develop
Commit: 04671006cae1b0e5d55147fe3426bce130a52545
Parents: 058d799
Author: Erjan Altena 
Authored: Thu Mar 1 21:06:54 2018 +0100
Committer: Erjan Altena 
Committed: Thu Mar 1 21:06:54 2018 +0100

--
 pubsub/pubsub_spi/src/pubsub_endpoint.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/04671006/pubsub/pubsub_spi/src/pubsub_endpoint.c
--
diff --git a/pubsub/pubsub_spi/src/pubsub_endpoint.c 
b/pubsub/pubsub_spi/src/pubsub_endpoint.c
index 24123b7..2f480a8 100644
--- a/pubsub/pubsub_spi/src/pubsub_endpoint.c
+++ b/pubsub/pubsub_spi/src/pubsub_endpoint.c
@@ -314,7 +314,12 @@ void pubsubEndpoint_destroy(pubsub_endpoint_pt psEp){
 
 bool pubsubEndpoint_equals(pubsub_endpoint_pt psEp1,pubsub_endpoint_pt psEp2){
 
-   return strcmp(properties_get(psEp1->endpoint_props, 
PUBSUB_ENDPOINT_UUID),properties_get(psEp2->endpoint_props, 
PUBSUB_ENDPOINT_UUID));
+   if (psEp1->endpoint_props && psEp2->endpoint_props) {
+   return !strcmp(properties_get(psEp1->endpoint_props, 
PUBSUB_ENDPOINT_UUID),
+ properties_get(psEp2->endpoint_props, 
PUBSUB_ENDPOINT_UUID));
+   }else {
+   return false;
+   }
 }
 
 char * pubsubEndpoint_createScopeTopicKey(const char* scope, const char* 
topic) {



celix git commit: Changed ZMQ blocking read to non-blocking read to prevent lock up when all publishers are removed

2018-02-09 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop cf294f3c0 -> b0477babb


Changed ZMQ blocking read to non-blocking read to prevent lock up when all 
publishers are removed


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

Branch: refs/heads/develop
Commit: b0477babb58a5c12aee2385eb7c465e653a08921
Parents: cf294f3
Author: Erjan Altena 
Authored: Fri Feb 9 10:30:35 2018 +0100
Committer: Erjan Altena 
Committed: Fri Feb 9 10:30:35 2018 +0100

--
 pubsub/README.md|  9 ++
 .../pubsub_admin_zmq/src/topic_subscription.c   | 32 ++--
 2 files changed, 38 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/b0477bab/pubsub/README.md
--
diff --git a/pubsub/README.md b/pubsub/README.md
index 1b533be..ff33690 100644
--- a/pubsub/README.md
+++ b/pubsub/README.md
@@ -82,3 +82,12 @@ For ZeroMQ without encryption, start here
 1. Run `cd deploy/pubsub/pubsub_subscriber_zmq`
 1. Run `cat ~/pubsub.conf >> config.properties` (only for ZeroMQ with 
encryption)
 1. Run `sh run.sh`
+
+### Properties PSA ZMQ
+
+Some properties can be set to configure the PSA-ZMQ. If not configured 
defaults will be used. These
+properties can be set in the config.properties file (= format)
+
+1. PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC : Set the polling interval of the ZMQ 
receive thread. Default 1ms
+1. PSA_IP : The local IP address to be used by the ZMQ admin to publish its 
data. Default te first IP not on localhost
+1. PSA_INTERFACE : The local ethernet interface to be used by the ZMQ admin to 
publish its data (ie eth0). Default the first non localhost interface
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/b0477bab/pubsub/pubsub_admin_zmq/src/topic_subscription.c
--
diff --git a/pubsub/pubsub_admin_zmq/src/topic_subscription.c 
b/pubsub/pubsub_admin_zmq/src/topic_subscription.c
index 9728865..8ff94d0 100644
--- a/pubsub/pubsub_admin_zmq/src/topic_subscription.c
+++ b/pubsub/pubsub_admin_zmq/src/topic_subscription.c
@@ -57,6 +57,11 @@
 #define POLL_TIMEOUT   250
 #define ZMQ_POLL_TIMEOUT_MS_ENV"ZMQ_POLL_TIMEOUT_MS"
 
+#define PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC "PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC"
+#define PSA_ZMQ_RECV_DEFAULT_TIMEOUT_STR "1000"
+#define PSA_ZMQ_RECV_DEFAULT_TIMEOUT 1000
+
+
 struct topic_subscription{
 
zsock_t* zmq_socket;
@@ -81,6 +86,7 @@ struct topic_subscription{
celix_thread_mutex_t pendingDisconnections_lock;
 
unsigned int nrSubscribers;
+   int zmqReceiveTimeout;
 };
 
 typedef struct complete_zmq_msg{
@@ -109,6 +115,24 @@ static mp_handle_pt create_mp_handle(hash_map_pt 
svc_msg_db,array_list_pt rcv_ms
 static void destroy_mp_handle(mp_handle_pt mp_handle);
 static void connectPendingPublishers(topic_subscription_pt sub);
 static void disconnectPendingPublishers(topic_subscription_pt sub);
+static unsigned int get_zmq_receive_timeout(bundle_context_pt context);
+
+
+static unsigned int get_zmq_receive_timeout(bundle_context_pt context) {
+   unsigned int timeout;
+   const char* timeout_str = NULL;
+   bundleContext_getPropertyWithDefault(context,
+   
 PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC,
+   
 PSA_ZMQ_RECV_DEFAULT_TIMEOUT_STR,
+   
 &timeout_str);
+   timeout = strtoul(timeout_str, NULL, 10);
+   if (timeout == 0) {
+   // on errror strtol returns 0
+   timeout = PSA_ZMQ_RECV_DEFAULT_TIMEOUT;
+   }
+
+   return timeout;
+}
 
 celix_status_t pubsub_topicSubscriptionCreate(bundle_context_pt 
bundle_context, char* scope, char* topic, pubsub_serializer_service_t 
*best_serializer, topic_subscription_pt* out){
celix_status_t status = CELIX_SUCCESS;
@@ -179,7 +203,7 @@ celix_status_t 
pubsub_topicSubscriptionCreate(bundle_context_pt bundle_context,
ts->running = false;
ts->nrSubscribers = 0;
ts->serializer = best_serializer;
-
+   ts->zmqReceiveTimeout = get_zmq_receive_timeout(bundle_context);
 #ifdef BUILD_WITH_ZMQ_SECURITY
ts->zmq_cert = sub_cert;
ts->zmq_pub_cert = pub_cert;
@@ -508,9 +532,11 @@ static void* zmq_recv_thread_func(void * arg) {
 
celixThreadMutex_lock(&sub->socket_lock);
 
-   zframe_t* headerMsg = zframe_recv(sub->zmq_socket);
+

celix git commit: Fixed cleanup admin

2018-02-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop af26af6b7 -> cf294f3c0


Fixed cleanup admin


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

Branch: refs/heads/develop
Commit: cf294f3c0a57a667fe7d71b83f7141149e4c5029
Parents: af26af6
Author: Erjan Altena 
Authored: Thu Feb 8 19:11:49 2018 +0100
Committer: Erjan Altena 
Committed: Thu Feb 8 19:11:49 2018 +0100

--
 pubsub/pubsub_admin_zmq/src/psa_activator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/cf294f3c/pubsub/pubsub_admin_zmq/src/psa_activator.c
--
diff --git a/pubsub/pubsub_admin_zmq/src/psa_activator.c 
b/pubsub/pubsub_admin_zmq/src/psa_activator.c
index 687e909..008dff5 100644
--- a/pubsub/pubsub_admin_zmq/src/psa_activator.c
+++ b/pubsub/pubsub_admin_zmq/src/psa_activator.c
@@ -159,6 +159,8 @@ celix_status_t bundleActivator_stop(void * userData, 
bundle_context_pt context)
struct activator *activator = userData;
 
status += serviceTracker_close(activator->serializerTracker);
+   serviceRegistration_unregister(activator->admin->shellCmdReg);
+   activator->admin->shellCmdReg = NULL;
status += serviceRegistration_unregister(activator->registration);
 
activator->registration = NULL;
@@ -176,7 +178,6 @@ celix_status_t bundleActivator_destroy(void * userData, 
bundle_context_pt contex
serviceTracker_destroy(activator->serializerTracker);
pubsubAdmin_destroy(activator->admin);
activator->admin = NULL;
-serviceRegistration_unregister(activator->admin->shellCmdReg);
free(activator);
 
return status;



celix git commit: Fixed memory leaks reported by coverity

2018-02-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 7b3d1a8e5 -> af26af6b7


Fixed memory leaks reported by coverity


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

Branch: refs/heads/develop
Commit: af26af6b71513a1d808b88e617beced679ddad81
Parents: 7b3d1a8
Author: Erjan Altena 
Authored: Thu Feb 8 19:05:30 2018 +0100
Committer: Erjan Altena 
Committed: Thu Feb 8 19:05:30 2018 +0100

--
 etcdlib/src/etcd.c  |  8 +---
 etcdlib/test/etcdlib_test.c |  7 +++
 pubsub/pubsub_admin_zmq/src/psa_activator.c | 17 +
 3 files changed, 17 insertions(+), 15 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/af26af6b/etcdlib/src/etcd.c
--
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
index 861b07a..0c9d615 100644
--- a/etcdlib/src/etcd.c
+++ b/etcdlib/src/etcd.c
@@ -374,9 +374,6 @@ int etcd_watch(const char* key, long long index, char** 
action, char** prevValue
 reply.header = NULL; /* will be grown as needed by the realloc above */
 reply.headerSize = 0; /* no data at this point */
 
-reply.header = malloc(1); /* will be grown as needed by the realloc above 
*/
-reply.headerSize = 0; /* no data at this point */
-
if (index != 0)
asprintf(&url, 
"http://%s:%d/v2/keys/%s?wait=true&recursive=true&waitIndex=%lld";, etcd_server, 
etcd_port, key, index);
else
@@ -431,9 +428,7 @@ int etcd_watch(const char* key, long long index, char** 
action, char** prevValue
 
}
 
-   if (reply.memory) {
-   free(reply.memory);
-   }
+   free(reply.memory);
 
return retVal;
 }
@@ -475,7 +470,6 @@ int etcd_del(const char* key) {
}
 
free(reply.memory);
-   free(reply.header);
 
return retVal;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/af26af6b/etcdlib/test/etcdlib_test.c
--
diff --git a/etcdlib/test/etcdlib_test.c b/etcdlib/test/etcdlib_test.c
index 7c2d573..afd0e74 100644
--- a/etcdlib/test/etcdlib_test.c
+++ b/etcdlib/test/etcdlib_test.c
@@ -40,6 +40,7 @@ int simplewritetest() {
 printf("etcdlib test error: expected testvalue got %s\n", value);
 res = -1;
 }
+free(value);
 return res;
 }
 
@@ -53,6 +54,10 @@ void* waitForChange(void*arg) {
 printf("Watching for index %d\n", *idx);
 etcd_watch("hier/ar", *idx, &action, &prevValue, &value, &rkey, 
&modifiedIndex);
 printf(" New value from watch : [%s]%s => %s\n", rkey, prevValue, value);
+free (action);
+free(prevValue);
+free(rkey);
+free(value);
 *idx = modifiedIndex+1;
 etcd_watch("hier/ar", *idx, &action, &prevValue, &value, &rkey, 
&modifiedIndex);
 printf(" New value from watch : [%s]%s => %s\n", rkey, prevValue, value);
@@ -70,6 +75,7 @@ int waitforchangetest() {
 
 int index;
 etcd_get("hier/ar/chi/cal", &value, &index);
+free(value);
 pthread_t waitThread;
 index++;
 pthread_create(&waitThread, NULL, waitForChange, &index);
@@ -83,6 +89,7 @@ int waitforchangetest() {
 printf("etcdtest::waitforchange1 expected testvalue3, got %s\n", 
(char*)resVal);
 res = -1;
 }
+free(resVal);
 return res;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/af26af6b/pubsub/pubsub_admin_zmq/src/psa_activator.c
--
diff --git a/pubsub/pubsub_admin_zmq/src/psa_activator.c 
b/pubsub/pubsub_admin_zmq/src/psa_activator.c
index f754cd1..687e909 100644
--- a/pubsub/pubsub_admin_zmq/src/psa_activator.c
+++ b/pubsub/pubsub_admin_zmq/src/psa_activator.c
@@ -99,7 +99,15 @@ celix_status_t bundleActivator_create(bundle_context_pt 
context, void **userData
&customizer);
if(status == CELIX_SUCCESS){
status = serviceTracker_create(context, 
PUBSUB_SERIALIZER_SERVICE, customizer, &(activator->serializerTracker));
-   if(status != CELIX_SUCCESS){
+if (status == CELIX_SUCCESS) {
+properties_pt shellProps = properties_create();
+properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, 
"psa_zmq_info");
+properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, 
"psa_zmq_info");
+properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, 
"psa_zmq_info: Overview of PubSub ZMQ Admin");
+activator->admin->shellCmdServi

celix git commit: etcd_get_directory retrieves the index from the HTTP header instead of the last modified index in the content

2018-02-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 490811d2c -> 7b3d1a8e5


etcd_get_directory retrieves the index from the HTTP header instead of the last 
modified index in the content


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

Branch: refs/heads/develop
Commit: 7b3d1a8e5ddca7b4f72897c2be8ff26e55e50a5d
Parents: 490811d
Author: Erjan Altena 
Authored: Thu Feb 8 14:20:54 2018 +0100
Committer: Erjan Altena 
Committed: Thu Feb 8 14:20:54 2018 +0100

--
 etcdlib/src/etcd.c | 102 
 1 file changed, 78 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/7b3d1a8e/etcdlib/src/etcd.c
--
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
index cb5c0ff..861b07a 100644
--- a/etcdlib/src/etcd.c
+++ b/etcdlib/src/etcd.c
@@ -35,6 +35,8 @@
 #define ETCD_JSON_MODIFIEDINDEX "modifiedIndex"
 #define ETCD_JSON_INDEX "index"
 
+#define ETCD_HEADER_INDEX   "X-Etcd-Index: "
+
 #define MAX_OVERHEAD_LENGTH   64
 #define DEFAULT_CURL_TIMEOUT  10
 #define DEFAULT_CURL_CONECTTIMEOUT10
@@ -48,14 +50,16 @@ static int etcd_port = 0;
 
 struct MemoryStruct {
char *memory;
-   size_t size;
+   char *header;
+   size_t memorySize;
+size_t headerSize;
 };
 
 
 /**
  * Static function declarations
  */
-static int performRequest(char* url, request_t request, void* callback, void* 
reqData, void* repData);
+static int performRequest(char* url, request_t request, void* reqData, void* 
repData);
 static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, 
void *userp);
 /**
  * External function definition
@@ -92,12 +96,14 @@ int etcd_get(const char* key, char** value, int* 
modifiedIndex) {
struct MemoryStruct reply;
 
reply.memory = malloc(1); /* will be grown as needed by the realloc 
above */
-   reply.size = 0; /* no data at this point */
+   reply.memorySize = 0; /* no data at this point */
+reply.header = NULL; /* will be grown as needed by the realloc above */
+reply.headerSize = 0; /* no data at this point */
 
int retVal = -1;
char *url;
asprintf(&url, "http://%s:%d/v2/keys/%s";, etcd_server, etcd_port, key);
-   res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) 
&reply);
+   res = performRequest(url, GET, NULL, (void*) &reply);
free(url);
 
if (res == CURLE_OK) {
@@ -178,6 +184,17 @@ static int etcd_get_recursive_values(json_t* js_root, 
etcd_key_value_callback ca
return (*mod_index > 0 ? 0 : 1);
 }
 
+static long long etcd_get_current_index(const char* headerData) {
+long long index = -1;
+char * indexStr = strstr(headerData, ETCD_HEADER_INDEX);
+indexStr += strlen(ETCD_HEADER_INDEX);
+
+if (sscanf(indexStr, "%lld\n",&index) == 1) {
+} else {
+index = -1;
+}
+return index;
+}
 /**
  * etcd_get_directory
  */
@@ -190,14 +207,16 @@ int etcd_get_directory(const char* directory, 
etcd_key_value_callback callback,
struct MemoryStruct reply;
 
reply.memory = malloc(1); /* will be grown as needed by the realloc 
above */
-   reply.size = 0; /* no data at this point */
+   reply.memorySize = 0; /* no data at this point */
+reply.header = malloc(1); /* will be grown as needed by the realloc above 
*/
+reply.headerSize = 0; /* no data at this point */
 
int retVal = 0;
char *url;
 
asprintf(&url, "http://%s:%d/v2/keys/%s?recursive=true";, etcd_server, 
etcd_port, directory);
 
-   res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) 
&reply);
+   res = performRequest(url, GET, NULL, (void*) &reply);
free(url);
if (res == CURLE_OK) {
js_root = json_loads(reply.memory, 0, &error);
@@ -210,6 +229,10 @@ int etcd_get_directory(const char* directory, 
etcd_key_value_callback callback,
if (js_rootnode != NULL) {
*modifiedIndex = 0;
retVal = etcd_get_recursive_values(js_rootnode, 
callback, arg, (json_int_t*)modifiedIndex);
+long long indexFromHeader = etcd_get_current_index(reply.header);
+if (indexFromHeader > *modifiedIndex) {
+  *modifiedIndex = indexFromHeader;
+}
} else {
// Error occured, retrieve the index of ETCD from the 
error code
js_rootnode = json_object_get(js_root, ETCD_JSON_INDEX);
@@ -228,9 +251,8 @@ int etcd_get_dire

[1/2] celix git commit: Discovery subscriber failed reading ETCD when started without existing publisher

2018-02-08 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 24bad0e41 -> 490811d2c


Discovery subscriber failed reading ETCD when started without existing publisher


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

Branch: refs/heads/develop
Commit: a0d4621d9056d208695cb5d97788153ddfa1b3bc
Parents: f988011
Author: Erjan Altena 
Authored: Thu Feb 8 11:32:28 2018 +0100
Committer: Erjan Altena 
Committed: Thu Feb 8 11:32:28 2018 +0100

--
 etcdlib/src/etcd.c  | 14 +-
 pubsub/pubsub_admin_zmq/src/psa_activator.c | 14 +++---
 2 files changed, 20 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/a0d4621d/etcdlib/src/etcd.c
--
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
index f75fa03..cb5c0ff 100644
--- a/etcdlib/src/etcd.c
+++ b/etcdlib/src/etcd.c
@@ -33,6 +33,7 @@
 #define ETCD_JSON_VALUE "value"
 #define ETCD_JSON_DIR   "dir"
 #define ETCD_JSON_MODIFIEDINDEX "modifiedIndex"
+#define ETCD_JSON_INDEX "index"
 
 #define MAX_OVERHEAD_LENGTH   64
 #define DEFAULT_CURL_TIMEOUT  10
@@ -198,7 +199,6 @@ int etcd_get_directory(const char* directory, 
etcd_key_value_callback callback,
 
res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) 
&reply);
free(url);
-
if (res == CURLE_OK) {
js_root = json_loads(reply.memory, 0, &error);
if (js_root != NULL) {
@@ -210,6 +210,18 @@ int etcd_get_directory(const char* directory, 
etcd_key_value_callback callback,
if (js_rootnode != NULL) {
*modifiedIndex = 0;
retVal = etcd_get_recursive_values(js_rootnode, 
callback, arg, (json_int_t*)modifiedIndex);
+   } else {
+   // Error occured, retrieve the index of ETCD from the 
error code
+   js_rootnode = json_object_get(js_root, ETCD_JSON_INDEX);
+   if(js_rootnode) {
+   json_int_t index = 
json_integer_value(js_rootnode);
+   *modifiedIndex = index;
+
+   } else {
+   fprintf(stderr, "[ETCDLIB] Error: index not 
found in error %s\n", reply.memory);
+
+   }
+
}
if (js_root != NULL) {
json_decref(js_root);

http://git-wip-us.apache.org/repos/asf/celix/blob/a0d4621d/pubsub/pubsub_admin_zmq/src/psa_activator.c
--
diff --git a/pubsub/pubsub_admin_zmq/src/psa_activator.c 
b/pubsub/pubsub_admin_zmq/src/psa_activator.c
index 73c45fa..f754cd1 100644
--- a/pubsub/pubsub_admin_zmq/src/psa_activator.c
+++ b/pubsub/pubsub_admin_zmq/src/psa_activator.c
@@ -108,14 +108,14 @@ celix_status_t bundleActivator_create(bundle_context_pt 
context, void **userData
pubsubAdmin_destroy(activator->admin);
}
}
+   properties_pt shellProps = properties_create();
+   properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, 
"psa_zmq_info");
+   properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, 
"psa_zmq_info");
+   properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, 
"psa_zmq_info: Overview of PubSub ZMQ Admin");
+   activator->admin->shellCmdService.handle = activator;
+   activator->admin->shellCmdService.executeCommand = shellCommand;
+   bundleContext_registerService(context, 
OSGI_SHELL_COMMAND_SERVICE_NAME, &activator->admin->shellCmdService, 
shellProps, &activator->admin->shellCmdReg);
}
-properties_pt shellProps = properties_create();
-properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, "psa_zmq_info");
-properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, "psa_zmq_info");
-properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, "psa_zmq_info: 
Overview of PubSub ZMQ Admin");
-activator->admin->shellCmdService.handle = activator;
-activator->admin->shellCmdService.executeCommand = shellCommand;
-bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, 
&activator->admin->shellCmdService, shellProps, &activator->admin->shellCmdReg);
return status;
 }
 



[2/2] celix git commit: Merge branch 'develop' of https://github.com/apache/celix into develop

2018-02-08 Thread erjanaltena
Merge branch 'develop' of https://github.com/apache/celix into develop


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

Branch: refs/heads/develop
Commit: 490811d2c41cd5c375e25dc58dcf2f4ef67e7d7a
Parents: a0d4621 24bad0e
Author: Erjan Altena 
Authored: Thu Feb 8 11:36:22 2018 +0100
Committer: Erjan Altena 
Committed: Thu Feb 8 11:36:22 2018 +0100

--
 pubsub/pubsub_admin_udp_mc/src/topic_publication.c | 2 ++
 remote_services/remote_services_api/CMakeLists.txt | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
--




celix git commit: Added shell command to inspect internal state of ZMQ PS-admin

2018-02-06 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 008b4f103 -> ea782bd38


Added shell command to inspect internal state of ZMQ PS-admin


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

Branch: refs/heads/develop
Commit: ea782bd38a5a009c8e07a5f97ac6d841d7dac8ae
Parents: 008b4f1
Author: Erjan Altena 
Authored: Tue Feb 6 21:53:48 2018 +0100
Committer: Erjan Altena 
Committed: Tue Feb 6 21:53:48 2018 +0100

--
 pubsub/pubsub_admin_zmq/CMakeLists.txt  |  4 +-
 pubsub/pubsub_admin_zmq/src/psa_activator.c | 48 ++--
 pubsub/pubsub_admin_zmq/src/pubsub_admin_impl.h |  4 ++
 3 files changed, 51 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/ea782bd3/pubsub/pubsub_admin_zmq/CMakeLists.txt
--
diff --git a/pubsub/pubsub_admin_zmq/CMakeLists.txt 
b/pubsub/pubsub_admin_zmq/CMakeLists.txt
index 6b3ecfd..ddc17eb 100644
--- a/pubsub/pubsub_admin_zmq/CMakeLists.txt
+++ b/pubsub/pubsub_admin_zmq/CMakeLists.txt
@@ -54,7 +54,7 @@ if (BUILD_PUBSUB_PSA_ZMQ)
src
)
 
-install_celix_bundle(celix_pubsub_admin_zmq EXPORT celix COMPONENT 
pubsub)
-
+   install_celix_bundle(celix_pubsub_admin_zmq EXPORT celix COMPONENT 
pubsub)
+   target_link_libraries(celix_pubsub_admin_zmq PRIVATE Celix::shell_api)
add_library(Celix::pubsub_admin_zmq ALIAS celix_pubsub_admin_zmq)
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/ea782bd3/pubsub/pubsub_admin_zmq/src/psa_activator.c
--
diff --git a/pubsub/pubsub_admin_zmq/src/psa_activator.c 
b/pubsub/pubsub_admin_zmq/src/psa_activator.c
index fd07310..73c45fa 100644
--- a/pubsub/pubsub_admin_zmq/src/psa_activator.c
+++ b/pubsub/pubsub_admin_zmq/src/psa_activator.c
@@ -27,7 +27,6 @@
 #include 
 
 #include "bundle_activator.h"
-#include "service_registration.h"
 #include "service_tracker.h"
 
 #include "pubsub_admin_impl.h"
@@ -40,6 +39,43 @@ struct activator {
service_tracker_pt serializerTracker;
 };
 
+
+static celix_status_t shellCommand(void *handle, char * commandLine, FILE 
*outStream, FILE *errorStream) {
+struct activator *act= (struct activator*)handle;
+if (act->admin->externalPublications && 
!hashMap_isEmpty(act->admin->externalPublications)) {
+fprintf(outStream, "External Publications:\n");
+for(hash_map_iterator_t iter = 
hashMapIterator_construct(act->admin->externalPublications); 
hashMapIterator_hasNext(&iter);) {
+const char* key = (const char*)hashMapIterator_nextKey(&iter);
+fprintf(outStream, "%s\n", key);
+}
+}
+if (act->admin->localPublications && 
!hashMap_isEmpty(act->admin->localPublications)) {
+fprintf(outStream, "Local Publications:\n");
+for (hash_map_iterator_t iter = hashMapIterator_construct(
+act->admin->localPublications); 
hashMapIterator_hasNext(&iter);) {
+const char *key = (const char *) hashMapIterator_nextKey(&iter);
+fprintf(outStream, "%s\n", key);
+}
+}
+if (act->admin->subscriptions && 
!hashMap_isEmpty(act->admin->subscriptions)) {
+fprintf(outStream, "Active Subscriptions:\n");
+for (hash_map_iterator_t iter = hashMapIterator_construct(
+act->admin->subscriptions); hashMapIterator_hasNext(&iter);) {
+const char *key = (const char *) hashMapIterator_nextKey(&iter);
+fprintf(outStream, "%s\n", key);
+}
+}
+if (act->admin->pendingSubscriptions && 
!hashMap_isEmpty(act->admin->pendingSubscriptions)) {
+fprintf(outStream, "Pending Subscriptions:\n");
+for (hash_map_iterator_t iter = hashMapIterator_construct(
+act->admin->pendingSubscriptions); 
hashMapIterator_hasNext(&iter);) {
+const char *key = (const char *) hashMapIterator_nextKey(&iter);
+fprintf(outStream, "%s\n", key);
+}
+}
+return CELIX_SUCCESS;
+}
+
 celix_status_t bundleActivator_create(bundle_context_pt context, void 
**userData) {
celix_status_t status = CELIX_SUCCESS;
struct activator *activator;
@@ -73,7 +109,13 @@ celix_status_t bundleActivator_create(bundle_context_pt 
context, void **userData
}
}
}
-
+properties_pt shellProps = properties_create();
+properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, "psa_zmq_info");
+properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, "psa_zmq_info");
+properties_set(shellPr

celix git commit: PubSub serializer selection: if only one is available, use this one

2018-02-06 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 4b8222dc1 -> 008b4f103


PubSub serializer selection: if only one is available, use this one


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

Branch: refs/heads/develop
Commit: 008b4f103162ccca75bf585735f4feb855a64cc2
Parents: 4b8222d
Author: Erjan Altena 
Authored: Tue Feb 6 21:24:38 2018 +0100
Committer: Erjan Altena 
Committed: Tue Feb 6 21:24:38 2018 +0100

--
 pubsub/pubsub_spi/src/pubsub_admin_match.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/008b4f10/pubsub/pubsub_spi/src/pubsub_admin_match.c
--
diff --git a/pubsub/pubsub_spi/src/pubsub_admin_match.c 
b/pubsub/pubsub_spi/src/pubsub_admin_match.c
index 2a695c1..cfe1dad 100644
--- a/pubsub/pubsub_spi/src/pubsub_admin_match.c
+++ b/pubsub/pubsub_spi/src/pubsub_admin_match.c
@@ -189,7 +189,17 @@ celix_status_t 
pubsub_admin_get_best_serializer(properties_pt endpoint_props, ar
void *svc = NULL;
 
/* Analyze the serializers */
-   if(requested_serializer_type != NULL){ /* We got precise specification 
on the serializer we want */
+   if (arrayList_size(serializerList) == 1) {
+   // Only one serializer, use this one
+   svcRef = (service_reference_pt)arrayList_get(serializerList,0);
+   manage_service_from_reference(svcRef, &svc, true);
+   *serSvc = svc;
+   char *serializer_type = NULL;
+   get_serializer_type(svcRef, &serializer_type);
+   printf("Selected the only serializer available. Type = %s\n", 
serializer_type);
+
+   }
+   else if(requested_serializer_type != NULL){ /* We got precise 
specification on the serializer we want */
for(i=0;i

celix git commit: Added shell command to pubsub to get overview of pubs and subs, fixed some code warnings

2018-02-06 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 6cd9df7ec -> 4b8222dc1


Added shell command to pubsub to get overview of pubs and subs, fixed some code 
warnings


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

Branch: refs/heads/develop
Commit: 4b8222dc11e7ae6aa75d5648bfd940e72518f755
Parents: 6cd9df7
Author: Erjan Altena 
Authored: Tue Feb 6 21:11:07 2018 +0100
Committer: Erjan Altena 
Committed: Tue Feb 6 21:11:50 2018 +0100

--
 pubsub/pubsub_topology_manager/CMakeLists.txt   |  2 +-
 .../src/pubsub_topology_manager.c   | 96 ++--
 .../src/pubsub_topology_manager.h   |  5 +
 3 files changed, 72 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/4b8222dc/pubsub/pubsub_topology_manager/CMakeLists.txt
--
diff --git a/pubsub/pubsub_topology_manager/CMakeLists.txt 
b/pubsub/pubsub_topology_manager/CMakeLists.txt
index 7ae00f6..9cb452b 100644
--- a/pubsub/pubsub_topology_manager/CMakeLists.txt
+++ b/pubsub/pubsub_topology_manager/CMakeLists.txt
@@ -23,7 +23,7 @@ add_celix_bundle(celix_pubsub_topology_manager
src/pubsub_topology_manager.c
src/pubsub_topology_manager.h
 )
-target_link_libraries(celix_pubsub_topology_manager PRIVATE Celix::framework 
Celix::log_helper Celix::pubsub_spi)
+target_link_libraries(celix_pubsub_topology_manager PRIVATE Celix::framework 
Celix::log_helper Celix::pubsub_spi Celix::shell_api)
 get_target_property(DESC Celix::pubsub_spi TOPIC_INFO_DESCRIPTOR)
 celix_bundle_files(celix_pubsub_topology_manager
${DESC}

http://git-wip-us.apache.org/repos/asf/celix/blob/4b8222dc/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
--
diff --git a/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c 
b/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
index a63b275..71a9ad9 100644
--- a/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
+++ b/pubsub/pubsub_topology_manager/src/pubsub_topology_manager.c
@@ -32,22 +32,53 @@
 #include "array_list.h"
 #include "bundle_context.h"
 #include "constants.h"
-#include "module.h"
-#include "bundle.h"
-#include "filter.h"
 #include "listener_hook_service.h"
 #include "utils.h"
-#include "service_reference.h"
-#include "service_registration.h"
 #include "log_service.h"
 #include "log_helper.h"
 
 #include "publisher_endpoint_announce.h"
 #include "pubsub_topology_manager.h"
-#include "pubsub_endpoint.h"
 #include "pubsub_admin.h"
-#include "pubsub_utils.h"
 
+static void print_endpoint_info(hash_map_pt endpoints, FILE *outStream) {
+   for(hash_map_iterator_t iter = hashMapIterator_construct(endpoints); 
hashMapIterator_hasNext(&iter);) {
+   const char* key = (const char*)hashMapIterator_nextKey(&iter);
+   fprintf(outStream, "Topic=%s\n", key);
+   array_list_pt ep_list = hashMap_get(endpoints, key);
+   for(unsigned int i = 0; i < arrayList_size(ep_list); ++i) {
+   pubsub_endpoint_pt ep = arrayList_get(ep_list, i);
+   fprintf(outStream, "Endpoint %d\n", i);
+   fprintf(outStream, "Endpoint properties\n");
+   const char *propKey;
+   if(ep->endpoint_props) {
+   PROPERTIES_FOR_EACH(ep->endpoint_props, 
propKey) {
+   fprintf(outStream, "%s 
=> %s\n", propKey, properties_get(ep->endpoint_props, propKey));
+   }
+   }
+   if(ep->topic_props) {
+   fprintf(outStream, "Topic 
properties\n");
+   PROPERTIES_FOR_EACH(ep->topic_props, propKey) {
+   fprintf(outStream, "%s 
=> %s\n", propKey, properties_get(ep->topic_props, propKey));
+   }
+   }
+   }
+   }
+
+}
+
+static celix_status_t shellCommand(void *handle, char * commandLine, FILE 
*outStream, FILE *errorStream) {
+   pubsub_topology_manager_pt manager = (pubsub_topology_manager_pt) 
handle;
+   if (manager->publications && !hashMap_isEmpty(manager->publications)) {
+   fprintf(outStream, "Publications:\n");
+   print_endpoint_info(manager->publications, outStream);
+   }
+   if (manager->subscriptions && !hashMap_isEmpty(manager->subscriptions))

celix git commit: Added test for etcdlib

2018-02-06 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 0a5ef69a6 -> ac36f55a0


Added test for etcdlib


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

Branch: refs/heads/develop
Commit: ac36f55a0d3d084aa15818a21273c85484623e56
Parents: 0a5ef69
Author: Erjan Altena 
Authored: Tue Feb 6 16:38:35 2018 +0100
Committer: Erjan Altena 
Committed: Tue Feb 6 16:38:35 2018 +0100

--
 etcdlib/CMakeLists.txt  |  4 ++
 etcdlib/src/etcd.c  |  1 -
 etcdlib/test/etcdlib_test.c | 98 
 3 files changed, 102 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/ac36f55a/etcdlib/CMakeLists.txt
--
diff --git a/etcdlib/CMakeLists.txt b/etcdlib/CMakeLists.txt
index d9909dc..8c64858 100644
--- a/etcdlib/CMakeLists.txt
+++ b/etcdlib/CMakeLists.txt
@@ -61,6 +61,7 @@ target_link_libraries(etcdlib ${CURL_LIBRARIES} 
${JANSSON_LIBRARIES})
 add_library(etcdlib_static STATIC
 src/etcd.c
 )
+
 target_include_directories(etcdlib_static PUBLIC 
 $
 $
@@ -73,6 +74,9 @@ target_include_directories(etcdlib_static PRIVATE
 set_target_properties(etcdlib_static PROPERTIES "SOVERSION" 1)
 target_link_libraries(etcdlib_static ${CURL_LIBRARIES} ${JANSSON_LIBRARY})
 
+add_executable(etcdlib_test ${CMAKE_CURRENT_SOURCE_DIR}/test/etcdlib_test.c)
+target_link_libraries(etcdlib_test etcdlib_static)
+
 install(DIRECTORY api/ DESTINATION include/etcdlib COMPONENT ${ETCDLIB_CMP})
 if (NOT COMMAND celix_subproject) 
 install(TARGETS etcdlib etcdlib_static DESTINATION ${CMAKE_INSTALL_LIBDIR} 
COMPONENT ${ETCDLIB_CMP})

http://git-wip-us.apache.org/repos/asf/celix/blob/ac36f55a/etcdlib/src/etcd.c
--
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
index ff9f827..f75fa03 100644
--- a/etcdlib/src/etcd.c
+++ b/etcdlib/src/etcd.c
@@ -259,7 +259,6 @@ int etcd_set(const char* key, const char* value, int ttl, 
bool prevExist) {
}
 
res = performRequest(url, PUT, WriteMemoryCallback, request, (void*) 
&reply);
-
if(url) {
free(url);
}

http://git-wip-us.apache.org/repos/asf/celix/blob/ac36f55a/etcdlib/test/etcdlib_test.c
--
diff --git a/etcdlib/test/etcdlib_test.c b/etcdlib/test/etcdlib_test.c
new file mode 100644
index 000..200b1a2
--- /dev/null
+++ b/etcdlib/test/etcdlib_test.c
@@ -0,0 +1,98 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+/**
+ * Test program for testing the etcdlib.
+ * Prerequisite is that etcdlib is started on localhost on default port (2379)
+ * tested with etcd 2.3.7
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "etcd.h"
+
+#include 
+
+int simplewritetest() {
+int res = 0;
+char*value = NULL;
+etcd_set("simplekey", "testvalue", 5, false);
+etcd_get("simplekey", &value, NULL);
+if (value && strcmp(value, "testvalue")) {
+printf("etcdlib test error: expected testvalue got %s\n", value);
+res = -1;
+}
+return res;
+}
+
+void* waitForChange(void*arg) {
+int *idx = (int*)arg;
+char *action = NULL;
+char *prevValue;
+char *value;
+char *rkey;
+long long modifiedIndex;
+printf("Watching for index %d\n", *idx);
+etcd_watch("hier/ar", *idx, &action, &prevValue, &value, &rkey, 
&modifiedIndex);
+printf(" New value from watch : [%s]%s => %s\n", rkey, prevValue, value);
+*idx = modifiedIndex+1;
+etcd_watch("hier/ar", *idx, &action, &prevValue, &value, &rkey, 
&modifiedIndex);
+printf(" New value from watch : [%s]%s => %s\n", rkey, prevValue, value);
+free (action);
+free(prevValue);
+free(rkey);
+return value;
+}
+
+int waitforchangetest() {
+int res = 0;
+char*val

celix git commit: Added functionality to add new interfaces to a DM-component when it is active

2018-01-09 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 6f78b6701 -> efed212cb


Added functionality to add new interfaces to a DM-component when it is active


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

Branch: refs/heads/develop
Commit: efed212cbd189666558e2388dbc9bfd4dc276f79
Parents: 6f78b67
Author: Erjan Altena 
Authored: Tue Jan 9 14:15:43 2018 +0100
Committer: Erjan Altena 
Committed: Tue Jan 9 14:15:43 2018 +0100

--
 .../private/src/dm_component_impl.c | 67 +++-
 .../phase1/private/include/phase1_cmp.h |  3 +-
 .../phase1/private/src/phase1_activator.c   |  1 +
 .../dm_example/phase1/private/src/phase1_cmp.c  | 11 
 4 files changed, 52 insertions(+), 30 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/efed212c/dependency_manager/private/src/dm_component_impl.c
--
diff --git a/dependency_manager/private/src/dm_component_impl.c 
b/dependency_manager/private/src/dm_component_impl.c
index 13a2ee0..e0d9f52 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -39,7 +39,7 @@ struct dm_component_struct {
 char id[DM_COMPONENT_MAX_ID_LENGTH];
 char name[DM_COMPONENT_MAX_NAME_LENGTH];
 bundle_context_pt context;
-array_list_pt dm_interfaces;
+array_list_pt dm_interfaces;  //protected by mutex
 
 void* implementation;
 
@@ -338,40 +338,42 @@ celix_status_t 
component_setCLanguageProperty(dm_component_pt component, bool se
 celix_status_t component_addInterface(dm_component_pt component, const char* 
serviceName, const char* serviceVersion, const void* service, properties_pt 
properties) {
 celix_status_t status = CELIX_SUCCESS;
 
-if (component->active) {
-return CELIX_ILLEGAL_STATE;
-} else {
-dm_interface_t *interface = (dm_interface_t *) calloc(1, 
sizeof(*interface));
-char *name = strdup(serviceName);
+dm_interface_t *interface = (dm_interface_t *) calloc(1, 
sizeof(*interface));
+char *name = strdup(serviceName);
 
-if (properties == NULL) {
-properties = properties_create();
-}
+if (properties == NULL) {
+properties = properties_create();
+}
 
-if ((properties_get(properties, CELIX_FRAMEWORK_SERVICE_VERSION) == 
NULL) && (serviceVersion != NULL)) {
-properties_set(properties, CELIX_FRAMEWORK_SERVICE_VERSION, 
serviceVersion);
-}
+if ((properties_get(properties, CELIX_FRAMEWORK_SERVICE_VERSION) == NULL) 
&& (serviceVersion != NULL)) {
+properties_set(properties, CELIX_FRAMEWORK_SERVICE_VERSION, 
serviceVersion);
+}
 
-if (component->setCLanguageProperty && properties_get(properties, 
CELIX_FRAMEWORK_SERVICE_LANGUAGE) == NULL) { //always set default lang to C
-properties_set(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, 
CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-}
+if (component->setCLanguageProperty && properties_get(properties, 
CELIX_FRAMEWORK_SERVICE_LANGUAGE) == NULL) { //always set default lang to C
+properties_set(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, 
CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
+}
 
-if (interface && name) {
-interface->serviceName = name;
-interface->service = service;
-interface->properties = properties;
-interface->registration = NULL;
-arrayList_add(component->dm_interfaces, interface);
-} else {
-free(interface);
-free(name);
-status = CELIX_ENOMEM;
+if (interface && name) {
+interface->serviceName = name;
+interface->service = service;
+interface->properties = properties;
+interface->registration = NULL;
+celixThreadMutex_lock(&component->mutex);
+arrayList_add(component->dm_interfaces, interface);
+celixThreadMutex_unlock(&component->mutex);
+if (component->state == DM_CMP_STATE_TRACKING_OPTIONAL) {
+component_registerServices(component);
 }
+} else {
+free(interface);
+free(name);
+status = CELIX_ENOMEM;
 }
 
 return status;
 }
 
+
 celix_status_t component_getInterfaces(dm_component_pt component, 
array_list_pt *out) {
 celix_status_t status = CELIX_SUCCESS;
 array_list_pt names = NULL;
@@ -1179,12 +1181,17 @@ celix_status_t 
component_registerServices(dm_component_pt component) {
 
 if (component->context != NULL) {
unsigned int i;
+celixThreadMutex_lock(&component->mu

celix git commit: Added log service example

2017-09-11 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 0d5e9c814 -> c9779f9ea


Added log service example


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

Branch: refs/heads/develop
Commit: c9779f9ea2c9db7b21a8e2138788259d597c78c4
Parents: 0d5e9c8
Author: Erjan Altena 
Authored: Mon Sep 11 22:22:47 2017 +0200
Committer: Erjan Altena 
Committed: Mon Sep 11 22:23:01 2017 +0200

--
 examples/CMakeLists.txt |  1 +
 examples/log_service_example/CMakeLists.txt | 34 
 .../log_service_example/private/src/activator.c | 85 
 log_service/public/src/log_helper.c |  1 +
 4 files changed, 121 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/c9779f9e/examples/CMakeLists.txt
--
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 122f87c..164500d 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -31,5 +31,6 @@ if (EXAMPLES)
 add_subdirectory(whiteboard)
 add_subdirectory(embedding)
 add_subdirectory(service_hook_example)
+add_subdirectory(log_service_example)
 
 endif(EXAMPLES)

http://git-wip-us.apache.org/repos/asf/celix/blob/c9779f9e/examples/log_service_example/CMakeLists.txt
--
diff --git a/examples/log_service_example/CMakeLists.txt 
b/examples/log_service_example/CMakeLists.txt
new file mode 100644
index 000..fbfc291
--- /dev/null
+++ b/examples/log_service_example/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#Importing and exporting libraries not (yet) work under OSX.
+
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("public/include")
+include_directories("${CMAKE_SOURCE_DIR}/log_service/public/include")
+
+add_bundle(log_service_example
+VERSION "1.0"
+SOURCES
+private/src/activator.c
+${CMAKE_SOURCE_DIR}/log_service/public/src/log_helper.c
+)
+
+add_deploy(log_example
+GROUP log_service
+BUNDLES log_service_example log_service shell shell_tui
+)

http://git-wip-us.apache.org/repos/asf/celix/blob/c9779f9e/examples/log_service_example/private/src/activator.c
--
diff --git a/examples/log_service_example/private/src/activator.c 
b/examples/log_service_example/private/src/activator.c
new file mode 100644
index 000..75eaf59
--- /dev/null
+++ b/examples/log_service_example/private/src/activator.c
@@ -0,0 +1,85 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * activator.c
+ *
+ *  \date   Sep 11, 2017
+ *  \authormailto:d...@celix.apache.org";>Apache Celix 
Project Team
+ *  \copyright Apache License, Version 2.0
+ */
+#include 
+#include 
+#include 
+#include "bundle_activator.h"
+#include "log_helper.h"
+
+struct userData {
+   pthread_t logger_thread;
+   bool running;
+   log_helper_pt log_helper;
+};
+
+static void *loggerThread(void *userData);
+
+celix_status_t bundleActivator_create(bundl

celix git commit: Fixed not existing usage of std::vector.remove

2017-07-24 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop a09848351 -> 4ed36cc18


Fixed not existing usage of std::vector.remove


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

Branch: refs/heads/develop
Commit: 4ed36cc18d6c37bcd4554402ae9228cfc90fce46
Parents: a098483
Author: Erjan Altena 
Authored: Mon Jul 24 21:22:32 2017 +0200
Committer: Erjan Altena 
Committed: Mon Jul 24 21:22:32 2017 +0200

--
 dependency_manager_cxx/include/celix/dm/Component.h  | 2 +-
 dependency_manager_cxx/include/celix/dm/Component_Impl.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/4ed36cc1/dependency_manager_cxx/include/celix/dm/Component.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/Component.h 
b/dependency_manager_cxx/include/celix/dm/Component.h
index 3064155..9e79d0f 100644
--- a/dependency_manager_cxx/include/celix/dm/Component.h
+++ b/dependency_manager_cxx/include/celix/dm/Component.h
@@ -169,7 +169,7 @@ namespace celix { namespace dm {
 ServiceDependency& createServiceDependency(const std::string name 
= std::string{});
 
 /**
- Creates and adds a C++ service dependency to the component
+ Removes a C++ service dependency from the component
  *
  * @return the DM Component reference for chaining (fluent API)
  */

http://git-wip-us.apache.org/repos/asf/celix/blob/4ed36cc1/dependency_manager_cxx/include/celix/dm/Component_Impl.h
--
diff --git a/dependency_manager_cxx/include/celix/dm/Component_Impl.h 
b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
index 81b3903..d1b1ebe 100644
--- a/dependency_manager_cxx/include/celix/dm/Component_Impl.h
+++ b/dependency_manager_cxx/include/celix/dm/Component_Impl.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace celix::dm;
 
@@ -111,7 +112,7 @@ template
 template
 Component& Component::remove(ServiceDependency& dep) {
 component_removeServiceDependency(cComponent(), dep.cServiceDependency());
-this->dependencies.remove(dep);
+this->dependencies.erase(std::remove(this->dependencies.begin(), 
this->dependencies.end(), dep));
 return *this;
 }
 
@@ -137,7 +138,7 @@ template
 template
 Component& Component::remove(CServiceDependency& dep) {
 component_removeServiceDependency(cComponent(), dep.cServiceDependency());
-this->dependencies.remove(dep);
+ this->dependencies.erase(std::remove(this->dependencies.begin(), 
this->dependencies.end(), dep));
 return *this;
 }
 



celix git commit: Added etcdlib's include dir to CELIX_INCLUDE_DIRS

2017-07-22 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop d1f0e1d33 -> a09848351


Added etcdlib's include dir to CELIX_INCLUDE_DIRS


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

Branch: refs/heads/develop
Commit: a098483519013914279823aa9ff3c5c2e5267b7e
Parents: d1f0e1d
Author: Erjan Altena 
Authored: Sat Jul 22 12:24:38 2017 +0200
Committer: Erjan Altena 
Committed: Sat Jul 22 12:24:38 2017 +0200

--
 cmake/FindCELIX.cmake | 19 +++
 etcdlib/public/include/etcd.h |  7 +++
 2 files changed, 22 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/a0984835/cmake/FindCELIX.cmake
--
diff --git a/cmake/FindCELIX.cmake b/cmake/FindCELIX.cmake
index 84642d2..9d76996 100644
--- a/cmake/FindCELIX.cmake
+++ b/cmake/FindCELIX.cmake
@@ -33,11 +33,16 @@
 set(CELIX_DIR_FROM_FINDCELIX "${CMAKE_CURRENT_LIST_DIR}/../../../..")
 
 
-find_path(CELIX_INCLUDE_DIR celix_errno.h
+find_path(CELIX_INCLUDE_DIR NAMES celix_errno.h
PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} 
/usr /usr/local
PATH_SUFFIXES include include/celix
 )
 
+find_path(CELIX_ETCD_INCLUDE_DIR NAMES etcd.h
+   PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} 
/usr /usr/local
+   PATH_SUFFIXES include include/etcdlib
+   )
+
 find_library(CELIX_FRAMEWORK_LIBRARY NAMES celix_framework
PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} 
/usr /usr/local
PATH_SUFFIXES lib lib64
@@ -58,7 +63,7 @@ find_program(CELIX_LAUNCHER NAMES celix
PATH_SUFFIXES bin
 )
 
-find_file(CELIX_CMAKECELIX_FILE CMakeCelix.cmake
+find_file(CELIX_CMAKECELIX_FILE NAMES CMakeCelix.cmake
PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} 
/usr /usr/local
PATH_SUFFIXES share/celix/cmake/modules
 )
@@ -84,6 +89,11 @@ find_library(CELIX_DM_STATIC_CXX_LIB NAMES 
dependency_manager_cxx_static
PATH_SUFFIXES lib lib64
 )
 
+find_library(CELIX_ETCD_LIB NAMES etcdlib
+   PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} 
/usr /usr/local
+   PATH_SUFFIXES lib lib64
+   )
+
 if (CELIX_DM_STATIC_LIB)
 set(CELIX_DM_INCLUDE_DIR ${CELIX_INCLUDE_DIR}/dependency_manager)
 endif()
@@ -99,10 +109,11 @@ include(FindPackageHandleStandardArgs)
 # if all listed variables are TRUE
 find_package_handle_standard_args(CELIX  DEFAULT_MSG
CELIX_FRAMEWORK_LIBRARY CELIX_UTILS_LIBRARY CELIX_DFI_LIBRARY 
CELIX_DM_LIB CELIX_DM_STATIC_LIB CELIX_DM_STATIC_CXX_LIB CELIX_INCLUDE_DIR 
CELIX_LAUNCHER CELIX_CMAKECELIX_FILE)
-mark_as_advanced(CELIX_INCLUDE_DIR CELIX_FRAMEWORK_LIBRARY CELIX_UTILS_LIBRARY 
CELIX_LAUNCHER CELIX_CMAKECELIX_FILE)
+mark_as_advanced(CELIX_INCLUDE_DIR CELIX_ETCD_INCLUDE_DIR 
CELIX_FRAMEWORK_LIBRARY CELIX_UTILS_LIBRARY CELIX_LAUNCHER 
CELIX_CMAKECELIX_FILE)
 
 if(CELIX_FOUND)
set(CELIX_LIBRARIES ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY} 
${CELIX_DFI_LIBRARY})
-   set(CELIX_INCLUDE_DIRS ${CELIX_INCLUDE_DIR} ${CELIX_DM_INCLUDE_DIR} 
${CELIX_DM_CXX_INCLUDE_DIR})
+   set(CELIX_INCLUDE_DIRS ${CELIX_INCLUDE_DIR} ${CELIX_ETCD_INCLUDE_DIR} 
${CELIX_DM_INCLUDE_DIR} ${CELIX_DM_CXX_INCLUDE_DIR})
include(${CELIX_CMAKECELIX_FILE})
+   include_directories(${CELIX_INCLUDE_DIRS})
 endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/a0984835/etcdlib/public/include/etcd.h
--
diff --git a/etcdlib/public/include/etcd.h b/etcdlib/public/include/etcd.h
index 0fdb99a..7980700 100644
--- a/etcdlib/public/include/etcd.h
+++ b/etcdlib/public/include/etcd.h
@@ -30,6 +30,13 @@
  */
 #define ETCDLIB_NO_CURL_INITIALIZATION (1)
 
+#define ETCDLIB_ACTION_CREATE   "create"
+#define ETCDLIB_ACTION_GET  "get"
+#define ETCDLIB_ACTION_SET  "set"
+#define ETCDLIB_ACTION_UPDATE   "update"
+#define ETCDLIB_ACTION_DELETE   "delete"
+#define ETCDLIB_ACTION_EXPIRE   "expire"
+
 typedef void (*etcd_key_value_callback) (const char *key, const char *value, 
void* arg);
 
 /**



celix git commit: CELIX-404: Fix for crash with inspect command

2017-02-24 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 6785a38c4 -> b6c369907


CELIX-404: Fix for crash with inspect command


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

Branch: refs/heads/develop
Commit: b6c36990718c8f46e61150aee79fe189a7803731
Parents: 6785a38
Author: Erjan Altena 
Authored: Fri Feb 24 23:49:15 2017 +0100
Committer: Erjan Altena 
Committed: Fri Feb 24 23:49:15 2017 +0100

--
 framework/private/src/service_registry.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/b6c36990/framework/private/src/service_registry.c
--
diff --git a/framework/private/src/service_registry.c 
b/framework/private/src/service_registry.c
index 8df355f..d27cc32 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -607,12 +607,14 @@ celix_status_t 
serviceRegistry_getServicesInUse(service_registry_pt registry, bu
 
 hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
 
-hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
-while (hashMapIterator_hasNext(iter)) {
-service_reference_pt ref = hashMapIterator_nextValue(iter);
-arrayList_add(result, ref);
+if(refsMap) {
+hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
+while (hashMapIterator_hasNext(iter)) {
+service_reference_pt ref = hashMapIterator_nextValue(iter);
+arrayList_add(result, ref);
+}
+hashMapIterator_destroy(iter);
 }
-hashMapIterator_destroy(iter);
 
 //UNLOCK
 celixThreadRwlock_unlock(®istry->lock);



celix git commit: Adding history and autocompletion to shell_tui

2017-02-24 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 3b802c90f -> 6785a38c4


Adding history and autocompletion to shell_tui


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

Branch: refs/heads/develop
Commit: 6785a38c4a1dbdb20a93b94b33a3fec120d91933
Parents: 3b802c9
Author: Erjan Altena 
Authored: Wed Feb 22 22:28:29 2017 +0100
Committer: Erjan Altena 
Committed: Fri Feb 24 22:27:12 2017 +0100

--
 shell_tui/CMakeLists.txt|   1 +
 shell_tui/private/include/history.h |  39 +
 shell_tui/private/src/history.c |  87 ++
 shell_tui/private/src/shell_tui.c   | 263 ++-
 4 files changed, 354 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/6785a38c/shell_tui/CMakeLists.txt
--
diff --git a/shell_tui/CMakeLists.txt b/shell_tui/CMakeLists.txt
index fdc9e7c..0216261 100644
--- a/shell_tui/CMakeLists.txt
+++ b/shell_tui/CMakeLists.txt
@@ -24,6 +24,7 @@ if (SHELL_TUI)
SOURCES 
private/src/activator 
private/src/shell_tui
+   private/src/history
)

install_bundle(shell_tui)

http://git-wip-us.apache.org/repos/asf/celix/blob/6785a38c/shell_tui/private/include/history.h
--
diff --git a/shell_tui/private/include/history.h 
b/shell_tui/private/include/history.h
new file mode 100644
index 000..b5e6320
--- /dev/null
+++ b/shell_tui/private/include/history.h
@@ -0,0 +1,39 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * history.h
+ *
+ *  \date   Jan 16, 2016
+ *  \authormailto:d...@celix.apache.org";>Apache Celix 
Project Team
+ *  \copyright Apache License, Version 2.0
+ */
+#ifndef SHELL_TUI_HISTORY
+#define SHELL_TUI_HISTORY
+
+typedef struct history history_t;
+
+history_t *historyCreate();
+void historyDestroy(history_t *hist);
+void history_addLine(history_t *hist, const char *line);
+char *historyGetPrevLine(history_t *hist);
+char *historyGetNextLine(history_t *hist);
+void historyLineReset(history_t *hist);
+unsigned int historySize(history_t *hist);
+
+#endif // SHELL_TUI_HISTORY

http://git-wip-us.apache.org/repos/asf/celix/blob/6785a38c/shell_tui/private/src/history.c
--
diff --git a/shell_tui/private/src/history.c b/shell_tui/private/src/history.c
new file mode 100644
index 000..ee77f2e
--- /dev/null
+++ b/shell_tui/private/src/history.c
@@ -0,0 +1,87 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * activator.c
+ *
+ *  \date   Jan 15, 2016
+ *  \authormailto:d...@celix.apache.org";>Apache Celix 
Project Team
+ *  \copyright Apache License, Version 2.0
+ */
+
+#include "history.h"
+#include 
+#include 
+#include "linked_list.h"
+
+#define HIST_SIZE 32
+
+struct history {
+   linked_list_pt history_lines;
+   int currentLine;
+};
+
+history_t *historyCreate() {
+   history_t* hist = calloc(1, sizeof(*hist));
+linkedList_create(&

celix git commit: CELIX-403: Free service-listener memory if tracker is closed to fix memory leak.

2017-02-23 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop 8670cae69 -> 3b802c90f


CELIX-403: Free service-listener memory if tracker is closed to fix memory leak.


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

Branch: refs/heads/develop
Commit: 3b802c90f1fc720b42ee28b052128724108d37d0
Parents: 8670cae
Author: Erjan Altena 
Authored: Thu Feb 23 14:56:01 2017 +0100
Committer: Erjan Altena 
Committed: Thu Feb 23 14:58:36 2017 +0100

--
 .../private/src/activator.c | 21 
 framework/private/src/service_tracker.c |  5 -
 2 files changed, 25 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/3b802c90/examples/service_hook_example/private/src/activator.c
--
diff --git a/examples/service_hook_example/private/src/activator.c 
b/examples/service_hook_example/private/src/activator.c
index 77238aa..f2d2a15 100644
--- a/examples/service_hook_example/private/src/activator.c
+++ b/examples/service_hook_example/private/src/activator.c
@@ -24,6 +24,7 @@
  *  \copyright Apache License, Version 2.0
  */
 #include 
+#include 
 #include 
 
 #include "bundle_activator.h"
@@ -86,12 +87,32 @@ celix_status_t bundleActivator_start(void * handle, 
bundle_context_pt context) {
 userData->hookService = hookService;
 userData->hookReg = NULL;
 
+printf("Registering hook service\n");
+bundleContext_registerService(context, 
OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, 
&userData->hookReg);
+
+printf("Unregistering hook service\n");
+serviceRegistration_unregister(userData->hookReg);
+
+printf("Re-Registering hook service\n");
+userData->hookReg = NULL;
 bundleContext_registerService(context, 
OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, 
&userData->hookReg);
 
 userData->trackerAfter = 0;
 serviceTracker_create(context, "MY_SERVICE_AFTER_REGISTERING_HOOK", NULL, 
&userData->trackerAfter);
 serviceTracker_open(userData->trackerAfter);
   
+sleep(1);
+printf("Closing tracker\n");
+serviceTracker_close(userData->trackerAfter);
+printf("Reopening tracker\n");
+serviceTracker_open(userData->trackerAfter);
+
+sleep(1);
+printf("Closing tracker\n");
+serviceTracker_close(userData->trackerAfter);
+printf("Reopening tracker\n");
+serviceTracker_open(userData->trackerAfter);
+
return CELIX_SUCCESS;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3b802c90/framework/private/src/service_tracker.c
--
diff --git a/framework/private/src/service_tracker.c 
b/framework/private/src/service_tracker.c
index d43b362..2631058 100644
--- a/framework/private/src/service_tracker.c
+++ b/framework/private/src/service_tracker.c
@@ -166,8 +166,11 @@ celix_status_t serviceTracker_close(service_tracker_pt 
tracker) {
}
 if (status == CELIX_SUCCESS) {
 status = bundleContext_removeServiceListener(tracker->context, 
tracker->listener);
+if(status == CELIX_SUCCESS) {
+free(tracker->listener);
+tracker->listener = NULL;
+}
 }
-
framework_logIfError(logger, status, NULL, "Cannot close tracker");
 
return status;



celix git commit: Added service-listener-hook example

2017-02-22 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/develop cd0164c72 -> ef3ef52a8


Added service-listener-hook example


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

Branch: refs/heads/develop
Commit: ef3ef52a88d860b03db5d517b99cd0f80b111ba3
Parents: cd0164c
Author: Erjan Altena 
Authored: Wed Feb 22 14:49:37 2017 +0100
Committer: Erjan Altena 
Committed: Wed Feb 22 14:49:37 2017 +0100

--
 examples/CMakeLists.txt |   1 +
 examples/service_hook_example/CMakeLists.txt|  37 ++
 .../private/src/activator.c | 116 +++
 3 files changed, 154 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/celix/blob/ef3ef52a/examples/CMakeLists.txt
--
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 5192ee3..122f87c 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -30,5 +30,6 @@ if (EXAMPLES)
 endif()
 add_subdirectory(whiteboard)
 add_subdirectory(embedding)
+add_subdirectory(service_hook_example)
 
 endif(EXAMPLES)

http://git-wip-us.apache.org/repos/asf/celix/blob/ef3ef52a/examples/service_hook_example/CMakeLists.txt
--
diff --git a/examples/service_hook_example/CMakeLists.txt 
b/examples/service_hook_example/CMakeLists.txt
new file mode 100644
index 000..8835a85
--- /dev/null
+++ b/examples/service_hook_example/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+if(NOT APPLE)
+#Importing and exporting libraries not (yet) work under OSX.
+
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("public/include")
+
+add_bundle(hook_example
+   BUNDLE_SYMBOLICNAME "Hook_Example"
+   VERSION "1.0.0"
+   SOURCES
+private/src/activator
+)
+
+add_deploy("hook_service_example"
+BUNDLES
+shell
+shell_tui
+hook_example
+)
+endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/ef3ef52a/examples/service_hook_example/private/src/activator.c
--
diff --git a/examples/service_hook_example/private/src/activator.c 
b/examples/service_hook_example/private/src/activator.c
new file mode 100644
index 000..77238aa
--- /dev/null
+++ b/examples/service_hook_example/private/src/activator.c
@@ -0,0 +1,116 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * activator.c
+ *
+ *  \date   Aug 20, 2010
+ *  \authormailto:d...@celix.apache.org";>Apache Celix 
Project Team
+ *  \copyright Apache License, Version 2.0
+ */
+#include 
+#include 
+
+#include "bundle_activator.h"
+#include "service_tracker_customizer.h"
+#include "service_tracker.h"
+#include "bundle_context.h"
+#include "listener_hook_service.h"
+#include "service_registry.h"
+
+struct userData {
+service_registration_pt hookReg;
+service_tracker_pt trackerBefore;
+service_tracker_pt trackerAfter;
+listener_hook_service

[celix] Git Push Summary

2017-02-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/commit_check [deleted] 3e678523e


[celix] Git Push Summary

2017-02-01 Thread erjanaltena
Repository: celix
Updated Branches:
  refs/heads/commit_check [created] 3e678523e