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 <[email protected]>
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 <sstream>
#include "log_helper.h"
-
+#include <mutex>
namespace celix {
namespace pubsub {
namespace nanomsg {
-
-// template<typename... Args>
-// 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<typename... Args>
-// 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<typename... Args>
-// 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<typename... Args>
-// 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<typename... Args>
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<typename... Args>
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<typename... Args>
- void INFO(Args... args) {
+ void INFO(Args... args) {
auto ss = LOG_STREAM(args...);
- logHelper_log(_logHelper, OSGI_LOGSERVICE_INFO,
ss.str().c_str());
+ log_string(OSGI_LOGSERVICE_INFO, ss.str());
}
template<typename... Args>
- void DBG(Args... args) {
+ void DBG(Args... args) {
auto ss = LOG_STREAM(args...);
- logHelper_log(_logHelper, OSGI_LOGSERVICE_DEBUG,
ss.str().c_str());
+ log_string(OSGI_LOGSERVICE_DEBUG, ss.str());
}
private:
+ bundle_context_t *ctx;
bool helperCreated{false};
log_helper_t *_logHelper{};
-
+ std::string componentName{};
template<typename T>
- std::stringstream LOG_STREAM(T first) {
+ std::stringstream LOG_STREAM(T first) const {
std::stringstream ss;
ss << first;
return ss;
}
template<typename T, typename... Args>
- std::stringstream LOG_STREAM(T first, Args... args) {
+ std::stringstream LOG_STREAM(T first, Args... args) const {
std::stringstream ss;
- ss << first << LOG_STREAM(args...).str();
+ ss << "[" << componentName << "] " << first <<
LOG_STREAM(args...).str();
return ss;
}
+ void log_string(log_level_t level, const std::string& msg) {
+ if (_logHelper == nullptr) {
+ helperCreated = true;
+ logHelper_create(ctx, &_logHelper);
+ logHelper_start(_logHelper);
+ }
+ logHelper_log(_logHelper, level, msg.c_str());
+ }
};
}
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 f249a06..5e79a43 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/psa_nanomsg_activator.cc
@@ -26,39 +26,41 @@
#include "LogHelper.h"
#include "pubsub_admin.h"
#include "pubsub_nanomsg_admin.h"
+namespace celix { namespace pubsub { namespace nanomsg {
+ class Activator {
+ public:
+ Activator(celix_bundle_context_t *ctx) :
+ context{ctx},
+ L{context, std::string("PSA_NANOMSG_ACIVATOR")},
+ admin(context)
+ {
+ }
+ Activator(const Activator&) = delete;
+ Activator& operator=(const Activator&) = delete;
+ ~Activator() = default;
-class psa_nanomsg_activator {
-public:
- psa_nanomsg_activator(celix_bundle_context_t *ctx) : context{ctx},
L{context}, admin(context, L) {
- }
- psa_nanomsg_activator(const psa_nanomsg_activator&) = delete;
- psa_nanomsg_activator& operator=(const psa_nanomsg_activator&) = delete;
-
- ~psa_nanomsg_activator() {
+ celix_status_t start() {
+ admin.start();
+ return CELIX_SUCCESS;
+ }
- }
+ celix_status_t stop() {
+ admin.stop();
+ return CELIX_SUCCESS;
+ };
- celix_status_t start() {
- admin.start();
- return CELIX_SUCCESS;
- }
+ private:
+ celix_bundle_context_t *context{};
+ celix::pubsub::nanomsg::LogHelper L;
+ pubsub_nanomsg_admin admin;
- celix_status_t stop() {
- admin.stop();
- return CELIX_SUCCESS;
};
-
-private:
- celix_bundle_context_t *context{};
- celix::pubsub::nanomsg::LogHelper L;
- pubsub_nanomsg_admin admin;
-
-};
+}}}
celix_status_t celix_bundleActivator_create(celix_bundle_context_t *ctx ,
void **userData) {
celix_status_t status = CELIX_SUCCESS;
- auto data = new (std::nothrow) psa_nanomsg_activator{ctx};
+ auto data = new (std::nothrow) celix::pubsub::nanomsg::Activator{ctx};
if (data != NULL) {
*userData = data;
} else {
@@ -68,18 +70,18 @@ celix_status_t
celix_bundleActivator_create(celix_bundle_context_t *ctx , void
}
celix_status_t celix_bundleActivator_start(void *userData,
celix_bundle_context_t *) {
- auto act = static_cast<psa_nanomsg_activator*>(userData);
+ auto act = static_cast<celix::pubsub::nanomsg::Activator*>(userData);
return act->start();
}
celix_status_t celix_bundleActivator_stop(void *userData,
celix_bundle_context_t *) {
- auto act = static_cast<psa_nanomsg_activator*>(userData);
+ auto act = static_cast<celix::pubsub::nanomsg::Activator*>(userData);
return act->stop();
}
celix_status_t celix_bundleActivator_destroy(void *userData,
celix_bundle_context_t *) {
- auto act = static_cast<psa_nanomsg_activator*>(userData);
+ auto act = static_cast<celix::pubsub::nanomsg::Activator*>(userData);
delete act;
return CELIX_SUCCESS;
}
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 1a01ebf..6d4454e 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.cc
@@ -37,9 +37,9 @@
static celix_status_t nanoMsg_getIpAddress(const char *interface, char **ip);
-pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx,
celix::pubsub::nanomsg::LogHelper& logHelper):
+pubsub_nanomsg_admin::pubsub_nanomsg_admin(celix_bundle_context_t *_ctx):
ctx{_ctx},
- L{logHelper} {
+ L{ctx, "pubsub_nanomsg_admin"} {
verbose = celix_bundleContext_getPropertyAsBool(ctx,
PUBSUB_NANOMSG_VERBOSE_KEY, PUBSUB_NANOMSG_VERBOSE_DEFAULT);
fwUUID = celix_bundleContext_getProperty(ctx,
OSGI_FRAMEWORK_FRAMEWORK_UUID, nullptr);
@@ -315,7 +315,7 @@ celix_status_t pubsub_nanomsg_admin::setupTopicSender(const
char *scope, const c
auto &serEntry = kv->second;
auto e = topicSenders.map.emplace(std::piecewise_construct,
std::forward_as_tuple(key),
- std::forward_as_tuple(ctx, L, scope, topic,
serializerSvcId, serEntry.svc, ipAddress,
+ std::forward_as_tuple(ctx, scope, topic, serializerSvcId,
serEntry.svc, ipAddress,
basePort, maxPort));
celix_properties_t *newEndpoint = pubsubEndpoint_create(fwUUID,
scope, topic, PUBSUB_PUBLISHER_ENDPOINT_TYPE,
PUBSUB_NANOMSG_ADMIN_TYPE, serEntry.serType, nullptr);
@@ -373,7 +373,7 @@ celix_status_t
pubsub_nanomsg_admin::setupTopicReceiver(const std::string &scope
auto kvs = serializers.map.find(serializerSvcId);
if (kvs != serializers.map.end()) {
auto serEntry = kvs->second;
- receiver = new pubsub::nanomsg::topic_receiver(ctx, L, scope,
topic, serializerSvcId, serEntry.svc);
+ receiver = new pubsub::nanomsg::topic_receiver(ctx, scope,
topic, serializerSvcId, serEntry.svc);
} else {
L.ERROR("[PSA_NANOMSG] Cannot find serializer for TopicSender
", scope, "/", topic);
}
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 1ac7fea..768accc 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_admin.h
@@ -50,7 +50,7 @@ struct ProtectedMap {
class pubsub_nanomsg_admin {
public:
- pubsub_nanomsg_admin(celix_bundle_context_t *ctx,
celix::pubsub::nanomsg::LogHelper& logHelper);
+ pubsub_nanomsg_admin(celix_bundle_context_t *ctx);
pubsub_nanomsg_admin(const pubsub_nanomsg_admin&) = delete;
pubsub_nanomsg_admin& operator=(const pubsub_nanomsg_admin&) = delete;
~pubsub_nanomsg_admin();
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 333cb2d..a0e68a0 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.cc
@@ -26,7 +26,7 @@ int psa_nanoMsg_localMsgTypeIdForMsgType(void *handle
__attribute__((unused)), c
return 0;
}
-bool psa_nanomsg_checkVersion(version_pt msgVersion, const
pubsub_nanmosg_msg_header_t *hdr) {
+bool psa_nanomsg_checkVersion(version_pt msgVersion, const
celix::pubsub::nanomsg::msg_header *hdr) {
bool check=false;
int major=0,minor=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 b3c8d25..a792521 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_common.h
@@ -38,21 +38,21 @@
* 3) The actual payload
*/
-
-struct pubsub_nanomsg_msg_header {
+namespace celix { namespace pubsub { namespace nanomsg {
+struct msg_header {
//header
unsigned int type;
unsigned char major;
unsigned char minor;
};
-typedef struct pubsub_nanomsg_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);
std::string psa_nanomsg_setScopeAndTopicFilter(const std::string &scope, const
std::string &topic);
-bool psa_nanomsg_checkVersion(version_pt msgVersion, const
pubsub_nanmosg_msg_header_t *hdr);
+bool psa_nanomsg_checkVersion(version_pt msgVersion, const
celix::pubsub::nanomsg::msg_header *hdr);
#endif //CELIX_PUBSUB_ZMQ_COMMON_H
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 4df5aae..3b056ed 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
@@ -64,11 +64,10 @@
pubsub::nanomsg::topic_receiver::topic_receiver(celix_bundle_context_t *_ctx,
- celix::pubsub::nanomsg::LogHelper& _logHelper,
const std::string &_scope,
const std::string &_topic,
long _serializerSvcId,
- pubsub_serializer_service_t *_serializer) : L{_logHelper},
m_serializerSvcId{_serializerSvcId}, m_scope{_scope}, m_topic{_topic} {
+ pubsub_serializer_service_t *_serializer) : L{_ctx,
"NANOMSG_topic_receiver"}, m_serializerSvcId{_serializerSvcId},
m_scope{_scope}, m_topic{_topic} {
ctx = _ctx;
serializer = _serializer;
@@ -249,7 +248,7 @@ void pubsub::nanomsg::topic_receiver::removeSubscriber(void
*/*svc*/,
}
}
-void
pubsub::nanomsg::topic_receiver::processMsgForSubscriberEntry(psa_nanomsg_subscriber_entry*
entry, const pubsub_nanmosg_msg_header_t *hdr, const char* payload, size_t
payloadSize) {
+void
pubsub::nanomsg::topic_receiver::processMsgForSubscriberEntry(psa_nanomsg_subscriber_entry*
entry, const celix::pubsub::nanomsg::msg_header *hdr, const char* payload,
size_t payloadSize) {
pubsub_msg_serializer_t* msgSer =
static_cast<pubsub_msg_serializer_t*>(hashMap_get(entry->msgTypes,
(void*)(uintptr_t)(hdr->type)));
pubsub_subscriber_t *svc = entry->svc;
@@ -273,7 +272,7 @@ void
pubsub::nanomsg::topic_receiver::processMsgForSubscriberEntry(psa_nanomsg_s
}
}
-void pubsub::nanomsg::topic_receiver::processMsg(const
pubsub_nanmosg_msg_header_t *hdr, const char *payload, size_t payloadSize) {
+void pubsub::nanomsg::topic_receiver::processMsg(const
celix::pubsub::nanomsg::msg_header *hdr, const char *payload, size_t
payloadSize) {
std::lock_guard<std::mutex> _lock(subscribers.mutex);
for (auto entry : subscribers.map) {
processMsgForSubscriberEntry(&entry.second, hdr, payload, payloadSize);
@@ -281,7 +280,7 @@ void pubsub::nanomsg::topic_receiver::processMsg(const
pubsub_nanmosg_msg_header
}
struct Message {
- pubsub_nanmosg_msg_header_t header;
+ celix::pubsub::nanomsg::msg_header header;
char payload[];
};
@@ -303,7 +302,7 @@ void pubsub::nanomsg::topic_receiver::recvThread_exec() {
errno = 0;
int recvBytes = nn_recvmsg(m_nanoMsgSocket, &msgHdr, 0);
- if (msg && static_cast<unsigned long>(recvBytes) >=
sizeof(pubsub_nanmosg_msg_header_t)) {
+ if (msg && static_cast<unsigned long>(recvBytes) >=
sizeof(celix::pubsub::nanomsg::msg_header)) {
processMsg(&msg->header, msg->payload,
recvBytes-sizeof(msg->header));
nn_freemsg(msg);
} else if (recvBytes >= 0) {
diff --git
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.h
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.h
index b1ac457..1b5f264 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_receiver.h
@@ -72,7 +72,6 @@ namespace pubsub {
public:
topic_receiver(celix_bundle_context_t
*ctx,
- celix::pubsub::nanomsg::LogHelper& logHelper,
const std::string &scope,
const std::string &topic,
long serializerSvcId, pubsub_serializer_service_t
@@ -88,8 +87,8 @@ namespace pubsub {
void connectTo(const char *url);
void disconnectFrom(const char *url);
void recvThread_exec();
- void processMsg(const pubsub_nanmosg_msg_header_t *hdr, const char
*payload, size_t payloadSize);
- void processMsgForSubscriberEntry(psa_nanomsg_subscriber_entry*
entry, const pubsub_nanmosg_msg_header_t *hdr, const char* payload, size_t
payloadSize);
+ void processMsg(const celix::pubsub::nanomsg::msg_header *hdr,
const char *payload, size_t payloadSize);
+ void processMsgForSubscriberEntry(psa_nanomsg_subscriber_entry*
entry, const celix::pubsub::nanomsg::msg_header *hdr, const char* payload,
size_t payloadSize);
void addSubscriber(void *svc, const celix_properties_t *props,
const celix_bundle_t *bnd);
void removeSubscriber(void */*svc*/, const celix_properties_t
*/*props*/, const celix_bundle_t *bnd);
celix_service_tracking_options_t createOptions();
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
index b03881a..8173198 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc
@@ -42,7 +42,6 @@ static unsigned int rand_range(unsigned int min, unsigned int
max);
static void
delay_first_send_for_late_joiners(celix::pubsub::nanomsg::LogHelper& logHelper);
pubsub::nanomsg::pubsub_nanomsg_topic_sender::pubsub_nanomsg_topic_sender(celix_bundle_context_t
*_ctx,
-
celix::pubsub::nanomsg::LogHelper& _logHelper,
const char *_scope,
const char *_topic,
long _serializerSvcId,
@@ -51,7 +50,7 @@
pubsub::nanomsg::pubsub_nanomsg_topic_sender::pubsub_nanomsg_topic_sender(celix_
unsigned int
_basePort,
unsigned int
_maxPort) :
ctx{_ctx},
- L{_logHelper},
+ L{ctx, "PSA_ZMQ_TS"},
serializerSvcId {_serializerSvcId},
serializer{_ser},
scope{_scope},
@@ -156,7 +155,7 @@ void*
pubsub::nanomsg::pubsub_nanomsg_topic_sender::getPublisherService(const ce
} else {
auto entry = boundedServices.map.emplace(std::piecewise_construct,
std::forward_as_tuple(bndId),
- std::forward_as_tuple(scope, topic, bndId,
nanomsg.socket, L));
+ std::forward_as_tuple(scope, topic, bndId,
nanomsg.socket, ctx));
int rc = serializer->createSerializerMap(serializer->handle,
(celix_bundle_t*)requestingBundle, &entry.first->second.msgTypes);
if (rc == 0) {
@@ -203,7 +202,7 @@ int
pubsub::nanomsg::bounded_service_entry::topicPublicationSend(unsigned int ms
int major = 0, minor = 0;
- pubsub_nanmosg_msg_header_t msg_hdr{};// = calloc(1, sizeof(*msg_hdr));
+ celix::pubsub::nanomsg::msg_header msg_hdr{};
msg_hdr.type = msgTypeId;
if (msgSer->msgVersion != nullptr) {
diff --git
a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.h
b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.h
index 6fd2bb8..f23a63d 100644
--- a/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.h
+++ b/bundles/pubsub/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.h
@@ -35,7 +35,7 @@ namespace pubsub {
std::string &_topic,
long _bndId,
int _nanoMsgSocket,
- celix::pubsub::nanomsg::LogHelper& _logHelper) :
scope{_scope}, topic{_topic}, bndId{_bndId}, nanoMsgSocket{_nanoMsgSocket},
L{_logHelper} {
+ celix_bundle_context_t *_context) : scope{_scope},
topic{_topic}, bndId{_bndId}, nanoMsgSocket{_nanoMsgSocket}, L{_context,
"nanomsg_bounded_service_entry"} {
}
bounded_service_entry(const bounded_service_entry&) = delete;
@@ -56,7 +56,7 @@ namespace pubsub {
class pubsub_nanomsg_topic_sender {
public:
pubsub_nanomsg_topic_sender(celix_bundle_context_t *_ctx,
- celix::pubsub::nanomsg::LogHelper&
_logHelper, const char *_scope,
+ const char *_scope,
const char *_topic, long
_serializerSvcId, pubsub_serializer_service_t *_ser,
const char *_bindIp, unsigned int
_basePort, unsigned int _maxPort);
diff --git a/libs/framework/src/service_registry.c
b/libs/framework/src/service_registry.c
index 62c0d2f..7a79e93 100644
--- a/libs/framework/src/service_registry.c
+++ b/libs/framework/src/service_registry.c
@@ -304,11 +304,14 @@ static void
serviceRegistry_logWarningServiceRegistration(service_registry_pt re
celix_status_t serviceRegistry_getServiceReference(service_registry_pt
registry, bundle_pt owner,
service_registration_pt
registration, service_reference_pt *out) {
celix_status_t status = CELIX_SUCCESS;
-
+ printf("serviceRegistry_getServiceReference1\n");
if(celixThreadRwlock_writeLock(®istry->lock) == CELIX_SUCCESS) {
+ printf("serviceRegistry_getServiceReference2\n");
status = serviceRegistry_getServiceReference_internal(registry,
owner, registration, out);
+ printf("serviceRegistry_getServiceReference3\n");
celixThreadRwlock_unlock(®istry->lock);
}
+ printf("serviceRegistry_getServiceReference4\n");
return status;
}
@@ -364,7 +367,10 @@ celix_status_t
serviceRegistry_getServiceReferences(service_registry_pt registry
celixThreadRwlock_readLock(®istry->lock);
iterator = hashMapIterator_create(registry->serviceRegistrations);
+ int loopCnt = 0;
+ printf("### while iterator loop\n");
while (status == CELIX_SUCCESS && hashMapIterator_hasNext(iterator)) {
+ printf("### loopCnt %d\n", loopCnt++);
array_list_pt regs = (array_list_pt)
hashMapIterator_nextValue(iterator);
unsigned int regIdx;
for (regIdx = 0; (regs != NULL) && regIdx <
arrayList_size(regs); regIdx++) {
@@ -400,13 +406,15 @@ celix_status_t
serviceRegistry_getServiceReferences(service_registry_pt registry
}
}
}
+ printf("### end iterator loop\n");
celixThreadRwlock_unlock(®istry->lock);
hashMapIterator_destroy(iterator);
+ printf("### for loop\n");
if (status == CELIX_SUCCESS) {
unsigned int i;
unsigned int size = arrayList_size(matchingRegistrations);
-
+ printf("### array size: &%d\n", size);
for (i = 0; i < size; i += 1) {
service_registration_pt reg = arrayList_get(matchingRegistrations,
i);
service_reference_pt reference = NULL;
@@ -431,6 +439,7 @@ celix_status_t
serviceRegistry_getServiceReferences(service_registry_pt registry
arrayList_destroy(references);
framework_logIfError(logger, status, NULL, "Cannot get service
references");
}
+ printf("### finished\n");
return status;
}
@@ -756,11 +765,12 @@ static celix_status_t
serviceRegistry_removeHook(service_registry_pt registry, s
celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry,
bundle_pt owner, array_list_pt *out) {
celix_status_t status;
array_list_pt result;
-
+ printf("### serviceRegistry_getListenerHooks1\n");
status = arrayList_create(&result);
if (status == CELIX_SUCCESS) {
unsigned int i;
unsigned size = arrayList_size(registry->listenerHooks);
+ printf("### serviceRegistry_getListenerHooks2\n");
for (i = 0; i < size; i += 1) {
celixThreadRwlock_readLock(®istry->lock);
@@ -769,15 +779,21 @@ celix_status_t
serviceRegistry_getListenerHooks(service_registry_pt registry, bu
serviceRegistration_retain(registration);
}
celixThreadRwlock_unlock(®istry->lock);
+ printf("### serviceRegistry_getListenerHooks3 %d/%d\n", i, size);
if (registration != NULL) {
service_reference_pt reference = NULL;
+ printf("### serviceRegistry_getListenerHooks3.1 %d/%d\n", i,
size);
+
serviceRegistry_getServiceReference(registry, owner,
registration, &reference);
+ printf("### serviceRegistry_getListenerHooks3.2 %d/%d\n", i,
size);
arrayList_add(result, reference);
serviceRegistration_release(registration);
+ printf("### serviceRegistry_getListenerHooks3.3 %d/%d\n", i,
size);
}
}
}
+ printf("### serviceRegistry_getListenerHooks4\n");
if (status == CELIX_SUCCESS) {
*out = result;
@@ -787,6 +803,7 @@ celix_status_t
serviceRegistry_getListenerHooks(service_registry_pt registry, bu
}
framework_logIfError(logger, status, NULL, "Cannot get listener
hooks");
}
+ printf("### serviceRegistry_getListenerHooks5\n");
return status;
}
diff --git a/libs/framework/src/service_tracker.c
b/libs/framework/src/service_tracker.c
index 1bc26e1..6a88743 100644
--- a/libs/framework/src/service_tracker.c
+++ b/libs/framework/src/service_tracker.c
@@ -188,19 +188,21 @@ celix_status_t serviceTracker_open(service_tracker_pt
tracker) {
instance->remove = tracker->remove;
instance->removeWithProperties = tracker->removeWithProperties;
instance->removeWithOwner = tracker->removeWithOwner;
-
+ printf("### serviceTracker_open pre\n");
status = bundleContext_getServiceReferences(tracker->context, NULL,
tracker->filter, &initial); //REF COUNT to 1
+ printf("### serviceTracker_open post\n");
tracker->instance = instance;
} else {
//already open
}
celixThreadRwlock_unlock(&tracker->instanceLock);
-
+ printf("### serviceTracker_open 2\n");
//TODO add fw call which adds a service listener and return the then valid
service references.
if (status == CELIX_SUCCESS && listener != NULL) { //register service
listener
status = bundleContext_addServiceListener(tracker->context, listener,
tracker->filter);
}
+ printf("### serviceTracker_open 3\n");
if (status == CELIX_SUCCESS && initial != NULL) {
service_reference_pt initial_reference;
unsigned int i;
@@ -211,12 +213,14 @@ celix_status_t serviceTracker_open(service_tracker_pt
tracker) {
}
arrayList_destroy(initial);
}
+ printf("### serviceTracker_open 4\n");
if (status != CELIX_SUCCESS && listener != NULL){
free(listener);
}
framework_logIfError(logger, status, NULL, "Cannot open tracker");
+ printf("### serviceTracker_open 5\n");
return status;
}