From c5b1977d42005914b32caba59feab1f0d7053d8b Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 11 Nov 2020 10:04:08 +0100 Subject: [PATCH 02/35] Add reference to pEpEngine project in Windows project (grafted from 31a4f245442863de0d687f749964362244e58b70) --- libpEpAdapter/libpEpAdapter.vcxproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libpEpAdapter/libpEpAdapter.vcxproj b/libpEpAdapter/libpEpAdapter.vcxproj index 1240878..b52c63b 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj +++ b/libpEpAdapter/libpEpAdapter.vcxproj @@ -119,6 +119,11 @@ XCOPY "$(SolutionDir)libpEpAdapter\*.hxx" "$(SolutionDir)pEp\" /I/F/Y + + + {146e69f8-e1da-456a-b048-6dd29d9acf6b} + + From 29de05185c4f3b6ec5a2a6a7c52c268c499a2882 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 11 Nov 2020 10:04:08 +0100 Subject: [PATCH 03/35] Add reference to pEpEngine project in Windows project --- libpEpAdapter/libpEpAdapter.vcxproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libpEpAdapter/libpEpAdapter.vcxproj b/libpEpAdapter/libpEpAdapter.vcxproj index 1240878..b52c63b 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj +++ b/libpEpAdapter/libpEpAdapter.vcxproj @@ -119,6 +119,11 @@ XCOPY "$(SolutionDir)libpEpAdapter\*.hxx" "$(SolutionDir)pEp\" /I/F/Y + + + {146e69f8-e1da-456a-b048-6dd29d9acf6b} + + From e9ff229630fcc2ec066b1acb51cc4c969c7abcf5 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Wed, 27 Jan 2021 01:31:15 +0100 Subject: [PATCH 05/35] ci: create initial gitlab-ci jobs Adds two simple jobs for building the library for Debian 10 and CentOS 8 They will pull down docker images containing the dependencies needed for libpEpAdapter, then proceed with the build. Upon successful compilation, an image containing the ouput (and dependencies) will be pushed to a docker registry on the CI infrastructure. Note about the docker images in use: Currently they pull the latest docker images containing pEpEngine, Sequoia, and other dependencies. We want to specify the exact required version in future updates to the jobs. --- .gitlab-ci-files/common-prepare.yml | 34 +++++++++++++++++++ .gitlab-ci.yml | 25 ++++++++++++++ scripts/centos8/Makefile | 15 ++++++++ scripts/centos8/build_libpEpAdapter.sh | 8 +++++ .../centos8/libpEpAdapter.centos8.Dockerfile | 23 +++++++++++++ scripts/debian10/Makefile | 15 ++++++++ scripts/debian10/build_libpEpAdapter.sh | 8 +++++ .../libpEpAdapter.debian10.Dockerfile | 23 +++++++++++++ 8 files changed, 151 insertions(+) create mode 100644 .gitlab-ci-files/common-prepare.yml create mode 100644 .gitlab-ci.yml create mode 100644 scripts/centos8/Makefile create mode 100755 scripts/centos8/build_libpEpAdapter.sh create mode 100644 scripts/centos8/libpEpAdapter.centos8.Dockerfile create mode 100644 scripts/debian10/Makefile create mode 100755 scripts/debian10/build_libpEpAdapter.sh create mode 100644 scripts/debian10/libpEpAdapter.debian10.Dockerfile diff --git a/.gitlab-ci-files/common-prepare.yml b/.gitlab-ci-files/common-prepare.yml new file mode 100644 index 0000000..14567f1 --- /dev/null +++ b/.gitlab-ci-files/common-prepare.yml @@ -0,0 +1,34 @@ +.ensure_docker: &ensure_docker + # Check for docker and install if missing + - 'which docker || ( sudo apt-get update -y && sudo apt-get install docker.io -y )' + +.ensure_rsync: &ensure_rsync + # Install rsync and deps if missing + - 'which ssh-agent || ( sudo apt-get update -y && sudo apt-get install openssh-client -y )' + - 'which rsync || ( sudo apt-get update -y && sudo apt-get install rsync -y )' + - 'which make || ( sudo apt-get update -y && sudo apt-get install make -y )' + +.enable_insecure_docker_registries: &enable_insecure_docker_registries + # Enable "insecure" docker registries + - | + cat < /tmp/docker-daemon.json + { + "insecure-registries" : ["${DOCKER_REGISTRY_HOST}"] + } + EOD + - sudo cp /tmp/docker-daemon.json /etc/docker/daemon.json + - sudo systemctl restart docker.service + +.standard_job: + tags: [kvm] + before_script: + - *ensure_docker + - *ensure_rsync + - *enable_insecure_docker_registries + +.make_in_docker: + extends: .standard_job + script: + - docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASS} ${DOCKER_REGISTRY_HOST} + - cd scripts/${CI_DISTRO_TARGET} + - make diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ea90745 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +include: + - '.gitlab-ci-files/common-prepare.yml' + +stages: + - build + + +# CentOS/RHEL + +centos8:build: + extends: .make_in_docker + stage: build + variables: + CI_MAKE_TARGET: libpepadapter + CI_DISTRO_TARGET: centos8 + +# Debian + +debian10:build: + extends: .make_in_docker + stage: build + variables: + CI_MAKE_TARGET: libpepadapter + CI_DISTRO_TARGET: debian10 + DEBIAN_FRONTEND: noninteractive diff --git a/scripts/centos8/Makefile b/scripts/centos8/Makefile new file mode 100644 index 0000000..8e10078 --- /dev/null +++ b/scripts/centos8/Makefile @@ -0,0 +1,15 @@ +CURRENT_DISTRO=$(shell basename $(shell pwd)) +LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD) +IMAGE_NAME=${DOCKER_REGISTRY_HOST}/pep-$(CURRENT_DISTRO)-libpepadapter +DOCKERFILE=libpEpAdapter.$(CURRENT_DISTRO).Dockerfile +all: + -docker pull $(IMAGE_NAME):latest + cd ../../ && docker build --build-arg CURRENT_DISTRO=$(CURRENT_DISTRO) \ + --build-arg DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST} \ + --build-arg LIBPEPADAPTER_VERSION=$(LIBPEPADAPTER_VERSION) \ + --cache-from $(IMAGE_NAME):latest \ + --tag=$(IMAGE_NAME):$(LIBPEPADAPTER_VERSION) \ + --tag=$(IMAGE_NAME):latest \ + -f scripts/${CURRENT_DISTRO}/$(DOCKERFILE) . + docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION} + docker push $(IMAGE_NAME):latest diff --git a/scripts/centos8/build_libpEpAdapter.sh b/scripts/centos8/build_libpEpAdapter.sh new file mode 100755 index 0000000..1f4a6c5 --- /dev/null +++ b/scripts/centos8/build_libpEpAdapter.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +set -exo + +echo "ENGINE_LIB_PATH=${INSTPREFIX}/lib" >> local.conf +echo "ENGINE_INC_PATH=${INSTPREFIX}/include" >> local.conf + +make +make install PREFIX="${INSTPREFIX}" diff --git a/scripts/centos8/libpEpAdapter.centos8.Dockerfile b/scripts/centos8/libpEpAdapter.centos8.Dockerfile new file mode 100644 index 0000000..a2fe8a3 --- /dev/null +++ b/scripts/centos8/libpEpAdapter.centos8.Dockerfile @@ -0,0 +1,23 @@ +ARG DOCKER_REGISTRY_HOST +ARG CURRENT_DISTRO +ARG PEPENGINE_VERSION=latest +FROM ${DOCKER_REGISTRY_HOST}/pep-${CURRENT_DISTRO}-engine:${PEPENGINE_VERSION} + +ENV BUILDROOT /build +ENV INSTPREFIX /install +ENV OUTDIR /out + +### Setup working directory +RUN mkdir ${BUILDROOT}/libpEpAdapter +COPY . ${BUILDROOT}/libpEpAdapter +USER root +RUN chown -R pep-builder:pep-builder ${BUILDROOT}/libpEpAdapter +USER pep-builder +WORKDIR ${BUILDROOT}/libpEpAdapter + +ARG LIBPEPADAPTER_VERSION +ARG CURRENT_DISTRO + +### Build libpEpAdapter +RUN sh ./scripts/${CURRENT_DISTRO}/build_libpEpAdapter.sh && \ + rm -rf ${BUILDROOT}/* diff --git a/scripts/debian10/Makefile b/scripts/debian10/Makefile new file mode 100644 index 0000000..8e10078 --- /dev/null +++ b/scripts/debian10/Makefile @@ -0,0 +1,15 @@ +CURRENT_DISTRO=$(shell basename $(shell pwd)) +LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD) +IMAGE_NAME=${DOCKER_REGISTRY_HOST}/pep-$(CURRENT_DISTRO)-libpepadapter +DOCKERFILE=libpEpAdapter.$(CURRENT_DISTRO).Dockerfile +all: + -docker pull $(IMAGE_NAME):latest + cd ../../ && docker build --build-arg CURRENT_DISTRO=$(CURRENT_DISTRO) \ + --build-arg DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST} \ + --build-arg LIBPEPADAPTER_VERSION=$(LIBPEPADAPTER_VERSION) \ + --cache-from $(IMAGE_NAME):latest \ + --tag=$(IMAGE_NAME):$(LIBPEPADAPTER_VERSION) \ + --tag=$(IMAGE_NAME):latest \ + -f scripts/${CURRENT_DISTRO}/$(DOCKERFILE) . + docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION} + docker push $(IMAGE_NAME):latest diff --git a/scripts/debian10/build_libpEpAdapter.sh b/scripts/debian10/build_libpEpAdapter.sh new file mode 100755 index 0000000..1f4a6c5 --- /dev/null +++ b/scripts/debian10/build_libpEpAdapter.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +set -exo + +echo "ENGINE_LIB_PATH=${INSTPREFIX}/lib" >> local.conf +echo "ENGINE_INC_PATH=${INSTPREFIX}/include" >> local.conf + +make +make install PREFIX="${INSTPREFIX}" diff --git a/scripts/debian10/libpEpAdapter.debian10.Dockerfile b/scripts/debian10/libpEpAdapter.debian10.Dockerfile new file mode 100644 index 0000000..a2fe8a3 --- /dev/null +++ b/scripts/debian10/libpEpAdapter.debian10.Dockerfile @@ -0,0 +1,23 @@ +ARG DOCKER_REGISTRY_HOST +ARG CURRENT_DISTRO +ARG PEPENGINE_VERSION=latest +FROM ${DOCKER_REGISTRY_HOST}/pep-${CURRENT_DISTRO}-engine:${PEPENGINE_VERSION} + +ENV BUILDROOT /build +ENV INSTPREFIX /install +ENV OUTDIR /out + +### Setup working directory +RUN mkdir ${BUILDROOT}/libpEpAdapter +COPY . ${BUILDROOT}/libpEpAdapter +USER root +RUN chown -R pep-builder:pep-builder ${BUILDROOT}/libpEpAdapter +USER pep-builder +WORKDIR ${BUILDROOT}/libpEpAdapter + +ARG LIBPEPADAPTER_VERSION +ARG CURRENT_DISTRO + +### Build libpEpAdapter +RUN sh ./scripts/${CURRENT_DISTRO}/build_libpEpAdapter.sh && \ + rm -rf ${BUILDROOT}/* From f50e785cd8c13f35bca34ffbe91633f7bdd0bd66 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 29 Jan 2021 14:29:56 +0100 Subject: [PATCH 06/35] convert .hgignore to .gitignore very small change to the contents of the file. primarily just a file rename. --- .hgignore => .gitignore | 1 - 1 file changed, 1 deletion(-) rename .hgignore => .gitignore (89%) diff --git a/.hgignore b/.gitignore similarity index 89% rename from .hgignore rename to .gitignore index e5cac49..72122ef 100644 --- a/.hgignore +++ b/.gitignore @@ -1,4 +1,3 @@ -syntax: glob *.o *.a *.d From e785f234f83c73a5c2e93ef64e1d69fe8a2dea8a Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 4 Dec 2020 23:20:11 +0100 Subject: [PATCH 07/35] Use compiler to generate .d files instead of using sed. --- Makefile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3c72e78..6eac3c6 100644 --- a/Makefile +++ b/Makefile @@ -13,15 +13,10 @@ SOURCE=$(wildcard *.cc) HEADERS=$(wildcard *.hh *.hxx) OBJECTS=$(subst .cc,.o,$(SOURCE)) DEPENDS=$(subst .cc,.d,$(SOURCE)) +CXXFLAGS+= -MMD -MP all: $(TARGET) -%.d: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - ifneq ($(MAKECMDGOALS),clean) -include $(DEPENDS) endif From a047b78518584db61231025efbde5ba4203e4632 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 29 Jan 2021 14:29:56 +0100 Subject: [PATCH 08/35] convert .hgignore to .gitignore very small change to the contents of the file. primarily just a file rename. (cherry picked from commit f50e785cd8c13f35bca34ffbe91633f7bdd0bd66) --- .hgignore => .gitignore | 1 - 1 file changed, 1 deletion(-) rename .hgignore => .gitignore (89%) diff --git a/.hgignore b/.gitignore similarity index 89% rename from .hgignore rename to .gitignore index e5cac49..72122ef 100644 --- a/.hgignore +++ b/.gitignore @@ -1,4 +1,3 @@ -syntax: glob *.o *.a *.d From 678eab6597584d57efa2092b1647c070781681ae Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 3 Feb 2021 07:32:08 +0100 Subject: [PATCH 09/35] Add Windows build directories to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 72122ef..999b25d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ local.conf build/ # Default ignored files .idea/workspace.xml +# Windows +libpEpAdapter/Debug/ +libpEpAdapter/Release/ \ No newline at end of file From 08bc62920477992c0c82f1c1379ac35d766f0a63 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 4 Feb 2021 08:47:37 +0100 Subject: [PATCH 10/35] Rename Windows build path --- .gitignore | 4 ++-- {libpEpAdapter => build-windows}/ReadMe.txt | 0 {libpEpAdapter => build-windows}/libpEpAdapter.vcxproj | 10 ---------- .../libpEpAdapter.vcxproj.filters | 0 4 files changed, 2 insertions(+), 12 deletions(-) rename {libpEpAdapter => build-windows}/ReadMe.txt (100%) rename {libpEpAdapter => build-windows}/libpEpAdapter.vcxproj (91%) rename {libpEpAdapter => build-windows}/libpEpAdapter.vcxproj.filters (100%) diff --git a/.gitignore b/.gitignore index 999b25d..e9f2fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,5 @@ build/ # Default ignored files .idea/workspace.xml # Windows -libpEpAdapter/Debug/ -libpEpAdapter/Release/ \ No newline at end of file +build-windows/Debug/ +build-windows/Release/ \ No newline at end of file diff --git a/libpEpAdapter/ReadMe.txt b/build-windows/ReadMe.txt similarity index 100% rename from libpEpAdapter/ReadMe.txt rename to build-windows/ReadMe.txt diff --git a/libpEpAdapter/libpEpAdapter.vcxproj b/build-windows/libpEpAdapter.vcxproj similarity index 91% rename from libpEpAdapter/libpEpAdapter.vcxproj rename to build-windows/libpEpAdapter.vcxproj index b52c63b..fdc2ca6 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj +++ b/build-windows/libpEpAdapter.vcxproj @@ -64,11 +64,6 @@ Windows - - XCOPY "$(SolutionDir)libpEpAdapter\*.hh" "$(SolutionDir)pEp\" /I/F/Y -XCOPY "$(SolutionDir)libpEpAdapter\*.hxx" "$(SolutionDir)pEp\" /I/F/Y - - @@ -86,11 +81,6 @@ XCOPY "$(SolutionDir)libpEpAdapter\*.hxx" "$(SolutionDir)pEp\" /I/F/Y true true - - XCOPY "$(SolutionDir)libpEpAdapter\*.hh" "$(SolutionDir)pEp\" /I/F/Y -XCOPY "$(SolutionDir)libpEpAdapter\*.hxx" "$(SolutionDir)pEp\" /I/F/Y - - diff --git a/libpEpAdapter/libpEpAdapter.vcxproj.filters b/build-windows/libpEpAdapter.vcxproj.filters similarity index 100% rename from libpEpAdapter/libpEpAdapter.vcxproj.filters rename to build-windows/libpEpAdapter.vcxproj.filters From 6cdfe86402ea5d14124140bb52c5cb057aed7bd2 Mon Sep 17 00:00:00 2001 From: heck Date: Mon, 15 Feb 2021 22:07:48 +0100 Subject: [PATCH 11/35] non-local single char named vars are not that handy. --- Adapter.cc | 12 ++++++------ Adapter.hxx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Adapter.cc b/Adapter.cc index f4a776d..47cfaae 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -42,7 +42,7 @@ namespace pEp { notifyHandshake_t _notifyHandshake = nullptr; std::thread _sync_thread; - ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > q; + ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > sync_evt_q; std::mutex m; std::thread::id sync_thread_id() @@ -54,11 +54,11 @@ namespace pEp { { try { if (ev == nullptr) { - q.clear(); - q.push_back(ev); + sync_evt_q.clear(); + sync_evt_q.push_back(ev); } else { - q.push_front(ev); + sync_evt_q.push_front(ev); } } catch (exception&) { @@ -76,7 +76,7 @@ namespace pEp { SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold) { SYNC_EVENT syncEvent = nullptr; - const bool success = q.try_pop_front(syncEvent, std::chrono::seconds(threshold)); + const bool success = sync_evt_q.try_pop_front(syncEvent, std::chrono::seconds(threshold)); if (!success) return new_sync_timeout_event(); @@ -138,7 +138,7 @@ namespace pEp { { SYNC_EVENT ev; try { - ev = q.back(); + ev = sync_evt_q.back(); } catch (std::underflow_error&) { return false; diff --git a/Adapter.hxx b/Adapter.hxx index 32af595..9718cde 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -16,7 +16,7 @@ namespace pEp { extern notifyHandshake_t _notifyHandshake; extern std::thread _sync_thread; - extern ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > q; + extern ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > sync_evt_q; extern std::mutex m; SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold); From b0a57da9fa8be282dcd42450fe060988c8241336 Mon Sep 17 00:00:00 2001 From: heck Date: Mon, 15 Feb 2021 22:20:48 +0100 Subject: [PATCH 12/35] just cosmetics (less error prone to read, makes you think about the missing else case) --- Adapter.cc | 11 +++++++---- Adapter.hxx | 18 ++++++++++++------ callback_dispatcher.cc | 34 +++++++++++++++++++++++----------- callback_dispatcher.hh | 26 ++++++++++++++++---------- 4 files changed, 58 insertions(+), 31 deletions(-) diff --git a/Adapter.cc b/Adapter.cc index 47cfaae..86ad5db 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -78,8 +78,9 @@ namespace pEp { SYNC_EVENT syncEvent = nullptr; const bool success = sync_evt_q.try_pop_front(syncEvent, std::chrono::seconds(threshold)); - if (!success) + if (!success) { return new_sync_timeout_event(); + } return syncEvent; } @@ -98,8 +99,9 @@ namespace pEp { switch (action) { case release: - if (_session.get()) + if (_session.get()) { _session = nullptr; + } break; case init: @@ -143,10 +145,11 @@ namespace pEp { catch (std::underflow_error&) { return false; } - if (ev) + if (ev) { return false; - else + } else { return true; + } } } } diff --git a/Adapter.hxx b/Adapter.hxx index 9718cde..4bd2544 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -30,8 +30,9 @@ namespace pEp { _ex = nullptr; assert(_messageToSend); assert(_notifyHandshake); - if (obj && _startup) + if (obj && _startup) { _startup(obj); + } session(); @@ -56,8 +57,9 @@ namespace pEp { session(release); - if (obj && _shutdown) + if (obj && _shutdown) { _shutdown(obj); + } } template< class T > @@ -68,22 +70,26 @@ namespace pEp { function< void(T *) > _startup, function< void(T *) > _shutdown) { - if (messageToSend) + if (messageToSend) { _messageToSend = messageToSend; + } - if (notifyHandshake) + if (notifyHandshake) { _notifyHandshake = notifyHandshake; + } session(); if (!_sync_thread.joinable()) { register_done = false; _sync_thread = std::thread(sync_thread, obj, _startup, _shutdown); - while (!register_done) + while (!register_done) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } - if (_ex) + if (_ex) { std::rethrow_exception(_ex); + } } } } diff --git a/callback_dispatcher.cc b/callback_dispatcher.cc index 08bf769..704017d 100644 --- a/callback_dispatcher.cc +++ b/callback_dispatcher.cc @@ -25,8 +25,9 @@ namespace pEp { ) { assert(messageToSend); - if (!messageToSend) + if (!messageToSend) { throw std::invalid_argument("messageToSend must be set"); + } targets.push_back({messageToSend, notifyHandshake, on_startup, shutdown}); } @@ -34,8 +35,9 @@ namespace pEp { void CallbackDispatcher::remove(::messageToSend_t messageToSend) { assert(messageToSend); - if (!messageToSend) + if (!messageToSend) { throw std::invalid_argument("messageToSend argument needed"); + } for (auto target = targets.begin(); target != targets.end(); ++target) { if (target->messageToSend == messageToSend) { @@ -43,23 +45,27 @@ namespace pEp { break; } } - if (targets.empty()) + + if (targets.empty()) { stop_sync(); + } } void CallbackDispatcher::on_startup() { for (auto target : targets) { - if (target.on_startup) + if (target.on_startup) { target.on_startup(); + } } } void CallbackDispatcher::on_shutdown() { for (auto target : targets) { - if (target.on_shutdown) + if (target.on_shutdown) { target.on_shutdown(); + } } } @@ -73,8 +79,9 @@ namespace pEp { &CallbackDispatcher::on_shutdown); for (auto target : callback_dispatcher.targets) { - if (target.notifyHandshake) + if (target.notifyHandshake) { target.notifyHandshake(nullptr, nullptr, SYNC_NOTIFY_START); + } } } @@ -85,8 +92,9 @@ namespace pEp { callback_dispatcher.semaphore.go(); for (auto target : callback_dispatcher.targets) { - if (target.notifyHandshake) + if (target.notifyHandshake) { target.notifyHandshake(nullptr, nullptr, SYNC_NOTIFY_STOP); + } } } @@ -95,14 +103,16 @@ namespace pEp { if (Adapter::on_sync_thread() && !msg) { semaphore.try_wait(); - if (Adapter::in_shutdown()) + if (Adapter::in_shutdown()) { return PEP_SYNC_NO_CHANNEL; + } PEP_STATUS status = PassphraseCache::config_next_passphrase(); // if the cache has no valid passphrase ask the app - if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) + if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) { semaphore.stop(); + } // the pEp engine must try again return status; @@ -117,8 +127,9 @@ namespace pEp { ::message *_msg = nullptr; if (msg) { _msg = ::message_dup(msg); - if (!_msg) + if (!_msg) { return PEP_OUT_OF_MEMORY; + } } assert(target.messageToSend); target.messageToSend(_msg); @@ -135,8 +146,9 @@ namespace pEp { ::pEp_identity *_me = nullptr; if (me) { _me = ::identity_dup(me); - if (!_me) + if (!_me) { return PEP_OUT_OF_MEMORY; + } } ::pEp_identity *_partner = nullptr; if (partner) { diff --git a/callback_dispatcher.hh b/callback_dispatcher.hh index 17f39e3..818f5ef 100644 --- a/callback_dispatcher.hh +++ b/callback_dispatcher.hh @@ -27,30 +27,36 @@ namespace pEp { public: void add( - ::messageToSend_t messageToSend, - ::notifyHandshake_t notifyHandshake, - proc on_startup = nullptr, - proc on_shutdown = nullptr - ); + ::messageToSend_t messageToSend, + ::notifyHandshake_t notifyHandshake, + proc on_startup = nullptr, + proc on_shutdown = nullptr + ); void remove(::messageToSend_t messageToSend); static void start_sync(); static void stop_sync(); static PEP_STATUS messageToSend(::message *msg); - static PEP_STATUS notifyHandshake(::pEp_identity *me, - ::pEp_identity *partner, ::sync_handshake_signal signal); + static PEP_STATUS notifyHandshake( + ::pEp_identity *me, + ::pEp_identity *partner, + ::sync_handshake_signal signal + ); protected: void on_startup(); void on_shutdown(); PEP_STATUS _messageToSend(::message *msg); - PEP_STATUS _notifyHandshake(::pEp_identity *me, - ::pEp_identity *partner, ::sync_handshake_signal signal); + PEP_STATUS _notifyHandshake( + ::pEp_identity *me, + ::pEp_identity *partner, + ::sync_handshake_signal signal + ); friend const char *PassphraseCache::add(const std::string& passphrase); }; extern CallbackDispatcher callback_dispatcher; -}; +} From 34cedaa8c6c98a561b583a84def7c2032615105e Mon Sep 17 00:00:00 2001 From: heck Date: Mon, 15 Feb 2021 22:22:14 +0100 Subject: [PATCH 13/35] .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e9f2fb2..ec3d93a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ lib local.conf build/ # Default ignored files -.idea/workspace.xml +?idea/ # Windows build-windows/Debug/ build-windows/Release/ \ No newline at end of file From 0de8502f8fa6a8df4f3a85a9bd85999d6528fa5f Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 00:47:46 +0100 Subject: [PATCH 14/35] local var never used --- Adapter.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/Adapter.cc b/Adapter.cc index 86ad5db..dfcaef9 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -93,7 +93,6 @@ namespace pEp { PEP_SESSION Session::operator()(session_action action) { std::lock_guard lock(m); - bool in_sync = on_sync_thread(); PEP_STATUS status = PEP_STATUS_OK; From 966b2967d47b2e73398e7ac60a036b53eaab7275 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 00:48:52 +0100 Subject: [PATCH 15/35] use std:: types for thread synchronization. (otherwise undef behaviour) --- Adapter.hxx | 18 ++++++++++++------ callback_dispatcher.cc | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Adapter.hxx b/Adapter.hxx index 4bd2544..a755075 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -22,11 +22,12 @@ namespace pEp { SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold); static std::exception_ptr _ex; - static bool register_done = false; + static std::atomic_bool register_done{false}; template< class T > void sync_thread(T *obj, function< void(T *) > _startup, function< void(T *) > _shutdown) { + pEpLog("called"); _ex = nullptr; assert(_messageToSend); assert(_notifyHandshake); @@ -41,11 +42,11 @@ namespace pEp { _notifyHandshake, _retrieve_next_sync_event); try { throw_status(status); - register_done = true; + register_done.store(true); } catch (...) { _ex = std::current_exception(); - register_done = true; + register_done.store(true); return; } } @@ -70,6 +71,7 @@ namespace pEp { function< void(T *) > _startup, function< void(T *) > _shutdown) { + pEpLog("called"); if (messageToSend) { _messageToSend = messageToSend; } @@ -77,17 +79,21 @@ namespace pEp { if (notifyHandshake) { _notifyHandshake = notifyHandshake; } - + pEpLog("creating session"); session(); if (!_sync_thread.joinable()) { - register_done = false; + register_done.store(false); + pEpLog("creating sync-thread"); + _sync_thread = std::thread(sync_thread, obj, _startup, _shutdown); - while (!register_done) { + while (register_done.load() == false) { + pEpLog("waiting for sync-thread to init..."); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } if (_ex) { + pEpLog("exception pending, rethrowing"); std::rethrow_exception(_ex); } } diff --git a/callback_dispatcher.cc b/callback_dispatcher.cc index 704017d..46d35dd 100644 --- a/callback_dispatcher.cc +++ b/callback_dispatcher.cc @@ -71,6 +71,7 @@ namespace pEp { void CallbackDispatcher::start_sync() { + pEpLog("called"); callback_dispatcher.semaphore.go(); pEp::Adapter::startup(CallbackDispatcher::messageToSend, @@ -78,6 +79,7 @@ namespace pEp { &CallbackDispatcher::on_startup, &CallbackDispatcher::on_shutdown); + pEpLog("all targets signal: SYNC_NOTIFY_START"); for (auto target : callback_dispatcher.targets) { if (target.notifyHandshake) { target.notifyHandshake(nullptr, nullptr, SYNC_NOTIFY_START); From 64b6857bd2c93536db316f7aeed83af89aab04ca Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 00:49:08 +0100 Subject: [PATCH 16/35] Semaphore - use std:: types for thread synchronization. (otherwise undef behaviour) --- Semaphore.hh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Semaphore.hh b/Semaphore.hh index e7d3f06..400e081 100644 --- a/Semaphore.hh +++ b/Semaphore.hh @@ -5,7 +5,11 @@ namespace pEp { class Semaphore { std::mutex mtx; std::condition_variable cv; - bool _stop; + // Atomic types are types that encapsulate a value whose access is guaranteed + // to not cause data races and can be used to synchronize memory accesses among + // different threads. + // To synchronize threads, ALWAYS use types + std::atomic_bool _stop; public: Semaphore() : _stop(false) { } @@ -13,23 +17,25 @@ namespace pEp { void stop() { std::unique_lock lock(mtx); - _stop = true; + _stop.store(true); } void try_wait() { std::unique_lock lock(mtx); - if (!_stop) + if (_stop.load() == false) { return; + } - while(_stop) + while(_stop.load() == true) { cv.wait(lock); + } } void go() { std::unique_lock lock(mtx); - _stop = false; + _stop.store(false); cv.notify_all(); } }; From 4f9ba2c1b764938a56d508f5f310ea3277bc34ed Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Sun, 14 Feb 2021 20:21:26 +0100 Subject: [PATCH 17/35] build-system: add 1st party dependencies file This commit adds a machine-readable file specifying the required versions of all 1st party dependencies. More info: https://dev.pep.foundation/CID/Processes --- DEPENDENCIES | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 DEPENDENCIES diff --git a/DEPENDENCIES b/DEPENDENCIES new file mode 100644 index 0000000..7ce15be --- /dev/null +++ b/DEPENDENCIES @@ -0,0 +1,5 @@ +# 1st Party Dependencies +## Prefer git tags instead of SHA hashes when possible. + +pEpEngine=Release_2.1.13 +sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59 From dd56c009e3534eaa9001c0b11ecb59d4b16f0b96 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Mon, 15 Feb 2021 02:23:09 +0100 Subject: [PATCH 18/35] CI: use specific project versions Make the CI jobs consume the DEPENDENCIES file. More info: https://dev.pep.foundation/CID/Processes --- .gitlab-ci.yml | 31 ++++++++++++++++++++++++++----- scripts/debian10/Makefile | 14 +++++++++++++- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea90745..d25b920 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,8 +11,18 @@ centos8:build: extends: .make_in_docker stage: build variables: - CI_MAKE_TARGET: libpepadapter - CI_DISTRO_TARGET: centos8 + CI_DISTRO_TARGET: "centos8" + rules: + - if: '$CI_COMMIT_TAG !~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' + +centos8:tagged-build: + extends: .make_in_docker + stage: build + variables: + CI_DISTRO_TARGET: "centos8" + TAGGED_BUILD: "true" + rules: + - if: '$CI_COMMIT_TAG =~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' # Debian @@ -20,6 +30,17 @@ debian10:build: extends: .make_in_docker stage: build variables: - CI_MAKE_TARGET: libpepadapter - CI_DISTRO_TARGET: debian10 - DEBIAN_FRONTEND: noninteractive + CI_DISTRO_TARGET: "debian10" + DEBIAN_FRONTEND: "noninteractive" + rules: + - if: '$CI_COMMIT_TAG !~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' + +debian10:tagged-build: + extends: .make_in_docker + stage: build + variables: + CI_DISTRO_TARGET: "debian10" + DEBIAN_FRONTEND: "noninteractive" + TAGGED_BUILD: "true" + rules: + - if: '$CI_COMMIT_TAG =~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' diff --git a/scripts/debian10/Makefile b/scripts/debian10/Makefile index 8e10078..6d59421 100644 --- a/scripts/debian10/Makefile +++ b/scripts/debian10/Makefile @@ -1,15 +1,27 @@ +include ../../DEPENDENCIES +export +PEPENGINE_VERSION=${pEpEngine} CURRENT_DISTRO=$(shell basename $(shell pwd)) -LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD) IMAGE_NAME=${DOCKER_REGISTRY_HOST}/pep-$(CURRENT_DISTRO)-libpepadapter DOCKERFILE=libpEpAdapter.$(CURRENT_DISTRO).Dockerfile +IS_TAGGED=${TAGGED_BUILD} +ifeq ($(IS_TAGGED), true) +# $CI_COMMIT_TAG is a predefined environment variable from Gitlab + LIBPEPADAPTER_VERSION=${CI_COMMIT_TAG} +else + LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD) +endif all: -docker pull $(IMAGE_NAME):latest cd ../../ && docker build --build-arg CURRENT_DISTRO=$(CURRENT_DISTRO) \ --build-arg DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST} \ + --build-arg PEPENGINE_VERSION=$(PEPENGINE_VERSION) \ --build-arg LIBPEPADAPTER_VERSION=$(LIBPEPADAPTER_VERSION) \ --cache-from $(IMAGE_NAME):latest \ --tag=$(IMAGE_NAME):$(LIBPEPADAPTER_VERSION) \ + --tag=$(IMAGE_NAME):${LIBPEPADAPTER_VERSION}_engine-${PEPENGINE_VERSION} \ --tag=$(IMAGE_NAME):latest \ -f scripts/${CURRENT_DISTRO}/$(DOCKERFILE) . docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION} + docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION}_engine-${PEPENGINE_VERSION} docker push $(IMAGE_NAME):latest From 1399afb4b21d5b938a54c7836f1d1adba2b14ae4 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Tue, 16 Feb 2021 12:53:03 +0100 Subject: [PATCH 19/35] CI: remove unfinished CentOS/RHEL jobs --- .gitlab-ci.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d25b920..4dc8459 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,25 +5,6 @@ stages: - build -# CentOS/RHEL - -centos8:build: - extends: .make_in_docker - stage: build - variables: - CI_DISTRO_TARGET: "centos8" - rules: - - if: '$CI_COMMIT_TAG !~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' - -centos8:tagged-build: - extends: .make_in_docker - stage: build - variables: - CI_DISTRO_TARGET: "centos8" - TAGGED_BUILD: "true" - rules: - - if: '$CI_COMMIT_TAG =~ /^Release_[0-9]+\.[0-9]+\.[0-9]+$/' - # Debian debian10:build: From 49c124c3dbdd7f0c0989a51522a0e1386419b5b1 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 21:10:36 +0100 Subject: [PATCH 20/35] simplify expressions --- Semaphore.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Semaphore.hh b/Semaphore.hh index 400e081..0643372 100644 --- a/Semaphore.hh +++ b/Semaphore.hh @@ -23,11 +23,11 @@ namespace pEp { void try_wait() { std::unique_lock lock(mtx); - if (_stop.load() == false) { + if (!_stop.load()) { return; } - while(_stop.load() == true) { + while(_stop.load()) { cv.wait(lock); } } From 277204c40d2ac44c655cacbdf8f4d121e6f9b675 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 21:26:48 +0100 Subject: [PATCH 21/35] pEpLog - added pEpEngine logging API support (providing platform abstractions and portability), runtime switching and thread-safety. (platforms --- pEpLog.cc | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ pEpLog.hh | 72 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 pEpLog.cc diff --git a/pEpLog.cc b/pEpLog.cc new file mode 100644 index 0000000..ec6f80d --- /dev/null +++ b/pEpLog.cc @@ -0,0 +1,86 @@ +#include "pEpLog.hh" +#include // cout and cerr +#include // for stringstream +#include // for log_event() +#include "Adapter.hh" // for session() + +namespace pEp { +namespace Adapter { +namespace pEpLog { + +std::mutex mtx; + +std::atomic_bool is_initialized{false}; +std::atomic_bool is_enabled{true}; +std::atomic_bool is_enabled_backend_pEpEngine{true}; +std::atomic_bool is_enabled_backend_cout{false}; +std::atomic_bool is_enabled_backend_cerr{false}; + + +void set_enabled(bool enabled) { + is_enabled.store(enabled); +} + +bool get_enabled() { + return is_enabled.load(); +} + +void set_enabled_cout(bool enabled){ + is_enabled_backend_cout.store(enabled); +} + +bool get_enabled_cout(){ + return is_enabled_backend_cout.load(); +} + +void set_enabled_cerr(bool enabled){ + is_enabled_backend_cerr.store(enabled); +} + +bool get_enabled_cerr(){ + return is_enabled_backend_cerr.load(); +} + +void set_enabled_pEpEngine(bool enabled){ + is_enabled_backend_pEpEngine.store(enabled); +} + +bool get_enabled_pEpEngine(){ + return is_enabled_backend_pEpEngine.load(); +} + +void log_pEpEngine(std::string &msg) { + if (!is_initialized.load()) { + ::config_service_log(pEp::Adapter::session(), true); + ::log_service(pEp::Adapter::session(), "pEpLog init", nullptr, nullptr, nullptr); + is_initialized.store(true); + } + ::log_service(pEp::Adapter::session(), msg.c_str(), nullptr, nullptr, nullptr); +} + +void log_cout(std::string &msg) { + std::cout << msg << std::endl; //std::endl also flushes +} + +void log_cerr(std::string &msg) { + std::cerr << msg << std::endl; //std::endl also flushes +} + +void log(std::string msg) { + std::lock_guard l(mtx); + if (is_enabled.load()) { + if (is_enabled_backend_cout.load()) { + log_cout(msg); + } + if (is_enabled_backend_cerr.load()) { + log_cerr(msg); + } + if (is_enabled_backend_pEpEngine.load()) { + log_pEpEngine(msg); + } + } +} + +} // pEpLog +} // Adapter +} // pEp diff --git a/pEpLog.hh b/pEpLog.hh index 12937e1..e515db7 100644 --- a/pEpLog.hh +++ b/pEpLog.hh @@ -1,7 +1,71 @@ -// TODO: put into not yet existing libpEpAdapter_utils.h, to be across whole libpEpAdapter +#ifndef LIBPEPADAPTER_PEPLOG_HH +#define LIBPEPADAPTER_PEPLOG_HH + +#include +#include + +// pEpLog +// ====== +// a "to be kept small and simple" logging unit. +// featuring: +// * pEpLog macro that will be eliminated in release-builds (-DNDEBUG=1) +// * all functions thread safe (no interleave when logging from diff threads) +// * logging backend: pEpEngine logging API (providing platform abstractions and portability) +// * logging backend: cout +// * logging backend: cerr +// * runtime enabled/disabled switch (global) +// * runtime enabled/disabled switch per backend +// +// You might want more and more features, but the feature-policy is very restrictive, and there is a +// primary design goal to keep it simple, maintainable and portable. +// +// How to use: +// include +// use the macro pEpLog(msg) to do logging +// use NDEBUG=1 to turn logging on/off at compile-time +// use set_enabled(bool) to turn logging on/off at runtime +// use set_enabled_(bool) to turn logging on/off per backend +// All these functions are thread-safe +// +// Thats all there is to it. + #ifdef NDEBUG #define pEpLog(msg) do{}while(0) #else - #include - #define pEpLog(msg) do{std::cerr << __FILE__ << "::" << __FUNCTION__ << " - " << msg << '\n';} while(0) -#endif \ No newline at end of file + #define pEpLog(msg) \ + do { \ + std::stringstream msg_ss; \ + msg_ss << std::this_thread::get_id() << " - " << __FILE__ << "::" << __FUNCTION__ << " - " << msg; \ + pEp::Adapter::pEpLog::log(msg_ss.str()); \ + } while(0) +#endif // NDEBUG + +namespace pEp { +namespace Adapter { +namespace pEpLog { + +void log(std::string msg); + +void set_enabled(bool is_enabled); + +bool get_enabled(); + +void set_enabled_cout(bool is_enabled); + +bool get_enabled_cout(); + +void set_enabled_cerr(bool is_enabled); + +bool get_enabled_cerr(); + +void set_enabled_pEpEngine(bool is_enabled); + +bool get_enabled_pEpEngine(); + +} // pEpLog +} // Adapter +} // pEp + + +#endif // LIBPEPADAPTER_PEPLOG_HH + From c732f24c48b66733aad0e5292deff87ba6229ee4 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 16 Feb 2021 22:08:43 +0100 Subject: [PATCH 22/35] ALL FILES - replace #pragma once with standard include guards (and make sure license header) --- Adapter.hh | 5 ++++- Adapter.hxx | 9 ++++++++- Semaphore.hh | 9 +++++++++ call_with_lock.cc | 3 ++- call_with_lock.hh | 9 +++++---- callback_dispatcher.cc | 3 +++ callback_dispatcher.hh | 7 ++++++- constant_time_algo.cc | 3 +++ constant_time_algo.hh | 8 +++++++- locked_queue.hh | 5 ++++- message_cache.cc | 3 +++ message_cache.hh | 7 ++++++- pEpLog.cc | 3 +++ pEpLog.hh | 3 +++ passphrase_cache.cc | 3 +++ passphrase_cache.hh | 7 ++++++- passphrase_cache.hxx | 7 +++++++ pc_container.hh | 6 ++++-- slurp.cc | 3 +++ slurp.hh | 9 ++++++--- status_to_string.cc | 3 +++ status_to_string.hh | 8 +++++++- test/framework.hh | 6 +++++- 23 files changed, 110 insertions(+), 19 deletions(-) diff --git a/Adapter.hh b/Adapter.hh index d136f25..43f0f0c 100644 --- a/Adapter.hh +++ b/Adapter.hh @@ -1,7 +1,8 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#pragma once +#ifndef LIBPEPADAPTER_ADAPTER_HH +#define LIBPEPADAPTER_ADAPTER_HH #include #include @@ -68,3 +69,5 @@ namespace pEp { } #include "Adapter.hxx" + +#endif //LIBPEPADAPTER_ADAPTER_HH \ No newline at end of file diff --git a/Adapter.hxx b/Adapter.hxx index a755075..2a2477f 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -1,7 +1,8 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#pragma once +#ifndef LIBPEPADAPTER_ADAPTER_HXX +#define LIBPEPADAPTER_ADAPTER_HXX #include #include "locked_queue.hh" @@ -35,11 +36,15 @@ namespace pEp { _startup(obj); } + pEpLog("creating session"); session(); { + //TODO: Do we need to use a passphraseWrap here??? + pEpLog("register_sync_callbacks()"); PEP_STATUS status = register_sync_callbacks(session(), nullptr, _notifyHandshake, _retrieve_next_sync_event); + pEpLog("register_sync_callbacks() return:" << status); try { throw_status(status); register_done.store(true); @@ -100,3 +105,5 @@ namespace pEp { } } } + +#endif //LIBPEPADAPTER_ADAPTER_HXX \ No newline at end of file diff --git a/Semaphore.hh b/Semaphore.hh index 0643372..268afa1 100644 --- a/Semaphore.hh +++ b/Semaphore.hh @@ -1,3 +1,9 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_SEMAPHORE_HH +#define LIBPEPADAPTER_SEMAPHORE_HH + #include #include @@ -41,3 +47,6 @@ namespace pEp { }; } +#endif // LIBPEPADAPTER_SEMAPHORE_HH + + diff --git a/call_with_lock.cc b/call_with_lock.cc index cd04003..83ba416 100644 --- a/call_with_lock.cc +++ b/call_with_lock.cc @@ -1,4 +1,5 @@ -// this file is under GNU GPL 3.0, see LICENSE.txt +// This file is under GNU General Public License 3.0 +// see LICENSE.txt #include "call_with_lock.hh" diff --git a/call_with_lock.hh b/call_with_lock.hh index 1877bcc..c8ebd73 100644 --- a/call_with_lock.hh +++ b/call_with_lock.hh @@ -1,7 +1,8 @@ -// this file is under GNU GPL 3.0, see LICENSE.txt +// This file is under GNU General Public License 3.0 +// see LICENSE.txt -#ifndef PEP_CALL_WITH_LOCK_HH -#define PEP_CALL_WITH_LOCK_HH +#ifndef LIBPEPADAPTER_CALL_WITH_LOCK_HH +#define LIBPEPADAPTER_CALL_WITH_LOCK_HH #include @@ -22,4 +23,4 @@ namespace pEp } -#endif // PEP_CALL_WITH_LOCK_HH +#endif // LIBPEPADAPTER_CALL_WITH_LOCK_HH diff --git a/callback_dispatcher.cc b/callback_dispatcher.cc index 46d35dd..42a743c 100644 --- a/callback_dispatcher.cc +++ b/callback_dispatcher.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "callback_dispatcher.hh" #include "passphrase_cache.hh" #include diff --git a/callback_dispatcher.hh b/callback_dispatcher.hh index 818f5ef..54248cf 100644 --- a/callback_dispatcher.hh +++ b/callback_dispatcher.hh @@ -1,4 +1,8 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_CALLBACK_DISPATCHER_HH +#define LIBPEPADAPTER_CALLBACK_DISPATCHER_HH #include #include @@ -60,3 +64,4 @@ namespace pEp { extern CallbackDispatcher callback_dispatcher; } +#endif // LIBPEPADAPTER_CALLBACK_DISPATCHER_HH diff --git a/constant_time_algo.cc b/constant_time_algo.cc index 6e4c2c4..8368b9e 100644 --- a/constant_time_algo.cc +++ b/constant_time_algo.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "constant_time_algo.hh" namespace pEp diff --git a/constant_time_algo.hh b/constant_time_algo.hh index d9b7ae2..59463ac 100644 --- a/constant_time_algo.hh +++ b/constant_time_algo.hh @@ -1,4 +1,8 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH +#define LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH #include @@ -12,3 +16,5 @@ namespace pEp bool constant_time_equal(const std::string& a, const std::string& b); } // end of namespace pEp + +#endif // LIBPEPADAPTER_CONSTANT_TIME_ALGO_HH diff --git a/locked_queue.hh b/locked_queue.hh index ccf45ea..e440704 100644 --- a/locked_queue.hh +++ b/locked_queue.hh @@ -1,7 +1,8 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#pragma once +#ifndef LIBPEPADAPTER_LOCKED_QUEUE_HH +#define LIBPEPADAPTER_LOCKED_QUEUE_HH #include #include @@ -182,3 +183,5 @@ namespace utility }; } // end of namespace utility + +#endif // LIBPEPADAPTER_LOCKED_QUEUE_HH diff --git a/message_cache.cc b/message_cache.cc index fd8a28c..f507253 100644 --- a/message_cache.cc +++ b/message_cache.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "message_cache.hh" #include #include diff --git a/message_cache.hh b/message_cache.hh index 7c3326d..b5c06be 100644 --- a/message_cache.hh +++ b/message_cache.hh @@ -1,4 +1,8 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_MESSAGE_CACHE_HH +#define LIBPEPADAPTER_MESSAGE_CACHE_HH #include #include @@ -128,3 +132,4 @@ namespace pEp { extern MessageCache message_cache; }; +#endif // LIBPEPADAPTER_MESSAGE_CACHE_HH diff --git a/pEpLog.cc b/pEpLog.cc index ec6f80d..006be68 100644 --- a/pEpLog.cc +++ b/pEpLog.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "pEpLog.hh" #include // cout and cerr #include // for stringstream diff --git a/pEpLog.hh b/pEpLog.hh index e515db7..9970384 100644 --- a/pEpLog.hh +++ b/pEpLog.hh @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #ifndef LIBPEPADAPTER_PEPLOG_HH #define LIBPEPADAPTER_PEPLOG_HH diff --git a/passphrase_cache.cc b/passphrase_cache.cc index c3b46e9..ee170f2 100644 --- a/passphrase_cache.cc +++ b/passphrase_cache.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include #include "Adapter.hh" #include "passphrase_cache.hh" diff --git a/passphrase_cache.hh b/passphrase_cache.hh index b857590..b514492 100644 --- a/passphrase_cache.hh +++ b/passphrase_cache.hh @@ -1,4 +1,8 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_PASSPHRASE_CACHE_HH +#define LIBPEPADAPTER_PASSPHRASE_CACHE_HH #include #include @@ -85,3 +89,4 @@ namespace pEp { #include "passphrase_cache.hxx" +#endif // LIBPEPADAPTER_PASSPHRASE_CACHE_HH diff --git a/passphrase_cache.hxx b/passphrase_cache.hxx index cb97d7a..ad5c616 100644 --- a/passphrase_cache.hxx +++ b/passphrase_cache.hxx @@ -1,3 +1,9 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_PASSPHRASE_CACHE_HXX +#define LIBPEPADAPTER_PASSPHRASE_CACHE_HXX + #include "passphrase_cache.hh" namespace pEp { @@ -20,3 +26,4 @@ namespace pEp { } }; +#endif // LIBPEPADAPTER_PASSPHRASE_CACHE_HXX diff --git a/pc_container.hh b/pc_container.hh index f470b92..d41e176 100644 --- a/pc_container.hh +++ b/pc_container.hh @@ -1,9 +1,10 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#pragma once +#ifndef LIBPEPADAPTER_PC_CONTAINER_HH +#define LIBPEPADAPTER_PC_CONTAINER_HH -// Conainer adapter that contains a container and a producer/consume queue +// Container adapter that contains a container and a producer/consume queue // that holds references to all changed elements #include @@ -82,4 +83,5 @@ private: }; } // end of namespace pEp +#endif // LIBPEPADAPTER_PC_CONTAINER_HH diff --git a/slurp.cc b/slurp.cc index 15519ab..a5cb3c5 100644 --- a/slurp.cc +++ b/slurp.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "slurp.hh" #include #include diff --git a/slurp.hh b/slurp.hh index e990a99..7e65eaf 100644 --- a/slurp.hh +++ b/slurp.hh @@ -1,5 +1,8 @@ -#ifndef PEP_LIB_SLURP_HH -#define PEP_LIB_SLURP_HH +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_LIB_SLURP_HH +#define LIBPEPADAPTER_LIB_SLURP_HH #include @@ -11,4 +14,4 @@ namespace pEp } // end of namespace pEp -#endif // PEP_LIB_SLURP_HH \ No newline at end of file +#endif // LIBPEPADAPTER_LIB_SLURP_HH \ No newline at end of file diff --git a/status_to_string.cc b/status_to_string.cc index 123ed9e..c95e36e 100644 --- a/status_to_string.cc +++ b/status_to_string.cc @@ -1,3 +1,6 @@ +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + #include "status_to_string.hh" #include diff --git a/status_to_string.hh b/status_to_string.hh index e9ae835..5078ef3 100644 --- a/status_to_string.hh +++ b/status_to_string.hh @@ -1,4 +1,8 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt + +#ifndef LIBPEPADAPTER_STATUS_TO_STRING_HH +#define LIBPEPADAPTER_STATUS_TO_STRING_HH #include #include @@ -11,3 +15,5 @@ namespace pEp std::string status_to_string(PEP_STATUS status); } // end of namespace pEp + +#endif // LIBPEPADAPTER_STATUS_TO_STRING_HH diff --git a/test/framework.hh b/test/framework.hh index f0b28f7..05c5711 100644 --- a/test/framework.hh +++ b/test/framework.hh @@ -1,4 +1,7 @@ -#pragma once +// This file is under GNU General Public License 3.0 +// see LICENSE.txt +#ifndef LIBPEPADAPTER_FRAMEWORK_HH +#define LIBPEPADAPTER_FRAMEWORK_HH #include #include @@ -57,3 +60,4 @@ namespace pEp { }; }; +#endif // LIBPEPADAPTER_FRAMEWORK_HH From 56009d14d5d46d57f00152217bfa0dedf6403ec8 Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 17 Feb 2021 01:10:31 +0100 Subject: [PATCH 23/35] pEpLog is "off" by default --- pEpLog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pEpLog.cc b/pEpLog.cc index 006be68..f7dfb2f 100644 --- a/pEpLog.cc +++ b/pEpLog.cc @@ -14,7 +14,7 @@ namespace pEpLog { std::mutex mtx; std::atomic_bool is_initialized{false}; -std::atomic_bool is_enabled{true}; +std::atomic_bool is_enabled{false}; std::atomic_bool is_enabled_backend_pEpEngine{true}; std::atomic_bool is_enabled_backend_cout{false}; std::atomic_bool is_enabled_backend_cerr{false}; From 038df251c92cd1b97739de4035a169745ba74cba Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 18 Feb 2021 16:14:17 +0100 Subject: [PATCH 24/35] Add pEpLog to Visual Studio project --- .gitignore | 3 ++- build-windows/libpEpAdapter.vcxproj | 2 ++ build-windows/libpEpAdapter.vcxproj.filters | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ec3d93a..cbe18a0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ build/ ?idea/ # Windows build-windows/Debug/ -build-windows/Release/ \ No newline at end of file +build-windows/Release/ +build-windows/libpEpAdapter.vcxproj.user \ No newline at end of file diff --git a/build-windows/libpEpAdapter.vcxproj b/build-windows/libpEpAdapter.vcxproj index fdc2ca6..eabd4a5 100644 --- a/build-windows/libpEpAdapter.vcxproj +++ b/build-windows/libpEpAdapter.vcxproj @@ -92,6 +92,7 @@ + @@ -105,6 +106,7 @@ + diff --git a/build-windows/libpEpAdapter.vcxproj.filters b/build-windows/libpEpAdapter.vcxproj.filters index 386d89f..ccbd6b4 100644 --- a/build-windows/libpEpAdapter.vcxproj.filters +++ b/build-windows/libpEpAdapter.vcxproj.filters @@ -42,6 +42,9 @@ Source Files + + Source Files + @@ -80,5 +83,8 @@ Header Files + + Header Files + \ No newline at end of file From d86ec580adef97e5cf0218fc5c739674ae34c2c7 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Tue, 23 Feb 2021 10:16:04 +0100 Subject: [PATCH 25/35] CID: don't use insecure docker registries anymore We now have a public registry, so we don't use registries on the LAN with only HTTP anymore. Let's remove the possiblity to use plain HTTP. --- .gitlab-ci-files/common-prepare.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.gitlab-ci-files/common-prepare.yml b/.gitlab-ci-files/common-prepare.yml index 14567f1..8053794 100644 --- a/.gitlab-ci-files/common-prepare.yml +++ b/.gitlab-ci-files/common-prepare.yml @@ -8,23 +8,11 @@ - 'which rsync || ( sudo apt-get update -y && sudo apt-get install rsync -y )' - 'which make || ( sudo apt-get update -y && sudo apt-get install make -y )' -.enable_insecure_docker_registries: &enable_insecure_docker_registries - # Enable "insecure" docker registries - - | - cat < /tmp/docker-daemon.json - { - "insecure-registries" : ["${DOCKER_REGISTRY_HOST}"] - } - EOD - - sudo cp /tmp/docker-daemon.json /etc/docker/daemon.json - - sudo systemctl restart docker.service - .standard_job: tags: [kvm] before_script: - *ensure_docker - *ensure_rsync - - *enable_insecure_docker_registries .make_in_docker: extends: .standard_job From 082aec794c9638e99b9d176ddc15a119c1bd4c9a Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 25 Feb 2021 01:04:38 +0100 Subject: [PATCH 26/35] pEpLog remove pEpEngine logging API / Add #ifdef and __android_log_print() --- pEpLog.cc | 69 ++++++++----------------------------------------------- pEpLog.hh | 26 ++++----------------- 2 files changed, 14 insertions(+), 81 deletions(-) diff --git a/pEpLog.cc b/pEpLog.cc index f7dfb2f..affd0e5 100644 --- a/pEpLog.cc +++ b/pEpLog.cc @@ -2,10 +2,9 @@ // see LICENSE.txt #include "pEpLog.hh" -#include // cout and cerr -#include // for stringstream -#include // for log_event() -#include "Adapter.hh" // for session() +#include +#include +#include namespace pEp { namespace Adapter { @@ -13,12 +12,7 @@ namespace pEpLog { std::mutex mtx; -std::atomic_bool is_initialized{false}; std::atomic_bool is_enabled{false}; -std::atomic_bool is_enabled_backend_pEpEngine{true}; -std::atomic_bool is_enabled_backend_cout{false}; -std::atomic_bool is_enabled_backend_cerr{false}; - void set_enabled(bool enabled) { is_enabled.store(enabled); @@ -28,59 +22,14 @@ bool get_enabled() { return is_enabled.load(); } -void set_enabled_cout(bool enabled){ - is_enabled_backend_cout.store(enabled); -} - -bool get_enabled_cout(){ - return is_enabled_backend_cout.load(); -} - -void set_enabled_cerr(bool enabled){ - is_enabled_backend_cerr.store(enabled); -} - -bool get_enabled_cerr(){ - return is_enabled_backend_cerr.load(); -} - -void set_enabled_pEpEngine(bool enabled){ - is_enabled_backend_pEpEngine.store(enabled); -} - -bool get_enabled_pEpEngine(){ - return is_enabled_backend_pEpEngine.load(); -} - -void log_pEpEngine(std::string &msg) { - if (!is_initialized.load()) { - ::config_service_log(pEp::Adapter::session(), true); - ::log_service(pEp::Adapter::session(), "pEpLog init", nullptr, nullptr, nullptr); - is_initialized.store(true); - } - ::log_service(pEp::Adapter::session(), msg.c_str(), nullptr, nullptr, nullptr); -} - -void log_cout(std::string &msg) { - std::cout << msg << std::endl; //std::endl also flushes -} - -void log_cerr(std::string &msg) { - std::cerr << msg << std::endl; //std::endl also flushes -} - void log(std::string msg) { - std::lock_guard l(mtx); if (is_enabled.load()) { - if (is_enabled_backend_cout.load()) { - log_cout(msg); - } - if (is_enabled_backend_cerr.load()) { - log_cerr(msg); - } - if (is_enabled_backend_pEpEngine.load()) { - log_pEpEngine(msg); - } + std::lock_guard l(mtx); + #if defined(ANDROID) && !defined(NDEBUG) + __android_log_print(ANDROID_LOG_DEBUG, "pEpDebugLog", "%s", msg.c_str()); + #else + std::cout << msg << std::endl; //std::endl also flushes + #endif } } diff --git a/pEpLog.hh b/pEpLog.hh index 9970384..dc5ef6c 100644 --- a/pEpLog.hh +++ b/pEpLog.hh @@ -9,15 +9,14 @@ // pEpLog // ====== -// a "to be kept small and simple" logging unit. +// a "to be kept ultra small and simple" logging unit. // featuring: // * pEpLog macro that will be eliminated in release-builds (-DNDEBUG=1) -// * all functions thread safe (no interleave when logging from diff threads) -// * logging backend: pEpEngine logging API (providing platform abstractions and portability) -// * logging backend: cout -// * logging backend: cerr +// * thread safe (no interleave when logging from diff threads) +// * OS dependent backend switches: +// * android: __android_log_print +// * all other OS: cout // * runtime enabled/disabled switch (global) -// * runtime enabled/disabled switch per backend // // You might want more and more features, but the feature-policy is very restrictive, and there is a // primary design goal to keep it simple, maintainable and portable. @@ -28,9 +27,6 @@ // use NDEBUG=1 to turn logging on/off at compile-time // use set_enabled(bool) to turn logging on/off at runtime // use set_enabled_(bool) to turn logging on/off per backend -// All these functions are thread-safe -// -// Thats all there is to it. #ifdef NDEBUG #define pEpLog(msg) do{}while(0) @@ -53,18 +49,6 @@ void set_enabled(bool is_enabled); bool get_enabled(); -void set_enabled_cout(bool is_enabled); - -bool get_enabled_cout(); - -void set_enabled_cerr(bool is_enabled); - -bool get_enabled_cerr(); - -void set_enabled_pEpEngine(bool is_enabled); - -bool get_enabled_pEpEngine(); - } // pEpLog } // Adapter } // pEp From cce6e5db3106784ad81af440fa5b109606affde7 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 25 Feb 2021 01:04:59 +0100 Subject: [PATCH 27/35] .gitignore --- .gitignore | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cbe18a0..2abfab1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,26 @@ build/ # Windows build-windows/Debug/ build-windows/Release/ -build-windows/libpEpAdapter.vcxproj.user \ No newline at end of file +build-windows/libpEpAdapter.vcxproj.user +/test/test_adapter.dSYM/Contents/Info.plist +/test/test_adapter_cxx.dSYM/Contents/Info.plist +/test/test_ensure_passphrase.dSYM/Contents/Info.plist +/test/test_leave_device_group.dSYM/Contents/Info.plist +/test/test_library.dSYM/Contents/Info.plist +/test/test_message_cache.dSYM/Contents/Info.plist +/test/test_passphrase_cache.dSYM/Contents/Info.plist +/test/test_semaphore.dSYM/Contents/Info.plist +/test/test_adapter_cxx.dSYM/Contents/Resources/DWARF/test_adapter_cxx +/test/test_adapter_cxx +/test/test_ensure_passphrase.dSYM/Contents/Resources/DWARF/test_ensure_passphrase +/test/test_ensure_passphrase +/test/test_leave_device_group.dSYM/Contents/Resources/DWARF/test_leave_device_group +/test/test_leave_device_group +/test/test_library.dSYM/Contents/Resources/DWARF/test_library +/test/test_library +/test/test_message_cache.dSYM/Contents/Resources/DWARF/test_message_cache +/test/test_message_cache +/test/test_passphrase_cache.dSYM/Contents/Resources/DWARF/test_passphrase_cache +/test/test_passphrase_cache +/test/test_semaphore.dSYM/Contents/Resources/DWARF/test_semaphore +/test/test_semaphore From bfc7b88a6f01aafef3d440705352b1348017f69b Mon Sep 17 00:00:00 2001 From: Hussein Kasem Date: Mon, 22 Feb 2021 10:47:16 +0100 Subject: [PATCH 28/35] Android Build: Add all *.cc source files instead of one by one (cherry picked from commit 4e9b5192cc1e49324db476c8bbbbbaec39c3a054) --- build-android/jni/Android.mk | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk index 2594a0b..9664823 100644 --- a/build-android/jni/Android.mk +++ b/build-android/jni/Android.mk @@ -25,12 +25,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../pEpEngine/build-android/include \ LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)../include -LOCAL_SRC_FILES += $(LOCAL_PATH)/../../Adapter.cc \ - $(LOCAL_PATH)/../../slurp.cc \ - $(LOCAL_PATH)/../../call_with_lock.cc \ - $(LOCAL_PATH)/../../passphrase_cache.cc \ - $(LOCAL_PATH)/../../callback_dispatcher.cc \ - $(LOCAL_PATH)/../../status_to_string.cc +LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../*.cc) include $(BUILD_STATIC_LIBRARY) From 30e7668d5156176adf8ea622c03e02d31542177d Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 27 Feb 2021 19:02:59 +0100 Subject: [PATCH 29/35] add includes for linux gcc --- Adapter.hxx | 1 + Semaphore.hh | 1 + pEpLog.cc | 2 ++ 3 files changed, 4 insertions(+) diff --git a/Adapter.hxx b/Adapter.hxx index 2a2477f..2b8b054 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -8,6 +8,7 @@ #include "locked_queue.hh" #include #include "pEpLog.hh" +#include namespace pEp { namespace Adapter { diff --git a/Semaphore.hh b/Semaphore.hh index 268afa1..a9c0593 100644 --- a/Semaphore.hh +++ b/Semaphore.hh @@ -6,6 +6,7 @@ #include #include +#include namespace pEp { class Semaphore { diff --git a/pEpLog.cc b/pEpLog.cc index affd0e5..cfaa083 100644 --- a/pEpLog.cc +++ b/pEpLog.cc @@ -4,8 +4,10 @@ #include "pEpLog.hh" #include #include +#include #include + namespace pEp { namespace Adapter { namespace pEpLog { From e0122ea82f6f9bdb0d901fa5da0cc803eb0fafa1 Mon Sep 17 00:00:00 2001 From: Hussein Kasem Date: Wed, 3 Mar 2021 22:24:05 +0100 Subject: [PATCH 30/35] Android Build: Add android/log.h include --- pEpLog.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pEpLog.hh b/pEpLog.hh index dc5ef6c..16854bf 100644 --- a/pEpLog.hh +++ b/pEpLog.hh @@ -31,6 +31,10 @@ #ifdef NDEBUG #define pEpLog(msg) do{}while(0) #else + #ifdef ANDROID + #include + #endif + #define pEpLog(msg) \ do { \ std::stringstream msg_ss; \ From ff0b8afbb83dbfa5707d21a06a110102358414d6 Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 3 Mar 2021 22:35:34 +0100 Subject: [PATCH 31/35] replace C99 style #if defined() with C++ --- pEpLog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pEpLog.cc b/pEpLog.cc index cfaa083..08af695 100644 --- a/pEpLog.cc +++ b/pEpLog.cc @@ -27,7 +27,7 @@ bool get_enabled() { void log(std::string msg) { if (is_enabled.load()) { std::lock_guard l(mtx); - #if defined(ANDROID) && !defined(NDEBUG) + #ifdef ANDROID __android_log_print(ANDROID_LOG_DEBUG, "pEpDebugLog", "%s", msg.c_str()); #else std::cout << msg << std::endl; //std::endl also flushes From bcd05ee2040260b9f2c2bc4a1f78c04cdd90accb Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 10 Mar 2021 18:01:11 +0100 Subject: [PATCH 32/35] BUILD: use pEpEngine=Release_2.1.14 --- DEPENDENCIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 7ce15be..e5496f5 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,5 +1,5 @@ # 1st Party Dependencies ## Prefer git tags instead of SHA hashes when possible. -pEpEngine=Release_2.1.13 +pEpEngine=Release_2.1.14 sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59 From d9049651855d7315a2b258f52b72f99cf783a09a Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 10 Mar 2021 18:02:41 +0100 Subject: [PATCH 33/35] BUILD: use pEpEngine=Release_2.1.15 --- DEPENDENCIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index e5496f5..a79ebd3 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,5 +1,5 @@ # 1st Party Dependencies ## Prefer git tags instead of SHA hashes when possible. -pEpEngine=Release_2.1.14 +pEpEngine=Release_2.1.15 sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59 From 5cca0658b7bde24aa7707cd07c6ec6af10d28ade Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 10 Mar 2021 18:03:19 +0100 Subject: [PATCH 34/35] BUILD: use pEpEngine=Release_2.1.16 --- DEPENDENCIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index a79ebd3..2dd65a7 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,5 +1,5 @@ # 1st Party Dependencies ## Prefer git tags instead of SHA hashes when possible. -pEpEngine=Release_2.1.15 +pEpEngine=Release_2.1.16 sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59 From 513dd36e1b9923a9215df8941cfc54ff2a747330 Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 12 Mar 2021 17:26:24 +0100 Subject: [PATCH 35/35] BUILD: use pEpEngine=Release_2.1.18 --- DEPENDENCIES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 2dd65a7..37f0507 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,5 +1,5 @@ # 1st Party Dependencies ## Prefer git tags instead of SHA hashes when possible. -pEpEngine=Release_2.1.16 +pEpEngine=Release_2.1.18 sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59