Merge lp:~marcustomlinson/unity-scopes-api/scope_debug_mode into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 469
Merged at revision: 446
Proposed branch: lp:~marcustomlinson/unity-scopes-api/scope_debug_mode
Merge into: lp:unity-scopes-api/devel
Diff against target: 1538 lines (+636/-107)
48 files modified
HACKING (+1/-1)
debian/libunity-scopes3.symbols (+17/-14)
include/unity/scopes/internal/ActivationReplyObject.h (+2/-1)
include/unity/scopes/internal/DfltConfig.h.in (+3/-3)
include/unity/scopes/internal/MWRegistry.h (+1/-0)
include/unity/scopes/internal/MWScope.h (+1/-0)
include/unity/scopes/internal/PreviewReplyObject.h (+2/-1)
include/unity/scopes/internal/ReplyObject.h (+2/-1)
include/unity/scopes/internal/ResultReplyObject.h (+2/-4)
include/unity/scopes/internal/ScopeConfig.h (+2/-0)
include/unity/scopes/internal/ScopeObject.h (+4/-1)
include/unity/scopes/internal/ScopeObjectBase.h (+2/-0)
include/unity/scopes/internal/smartscopes/SSScopeObject.h (+2/-0)
include/unity/scopes/internal/zmq_middleware/ScopeI.h (+5/-2)
include/unity/scopes/internal/zmq_middleware/ZmqObjectProxy.h (+1/-1)
include/unity/scopes/internal/zmq_middleware/ZmqRegistry.h (+1/-0)
include/unity/scopes/internal/zmq_middleware/ZmqScope.h (+7/-0)
scoperegistry/scoperegistry.cpp (+9/-1)
src/scopes/internal/ActivationReplyObject.cpp (+3/-2)
src/scopes/internal/PreviewReplyObject.cpp (+3/-2)
src/scopes/internal/RegistryObject.cpp (+11/-3)
src/scopes/internal/ReplyObject.cpp (+22/-8)
src/scopes/internal/ResultReplyObject.cpp (+3/-5)
src/scopes/internal/RuntimeImpl.cpp (+5/-2)
src/scopes/internal/ScopeConfig.cpp (+49/-33)
src/scopes/internal/ScopeImpl.cpp (+4/-4)
src/scopes/internal/ScopeObject.cpp (+8/-2)
src/scopes/internal/smartscopes/SSScopeObject.cpp (+5/-0)
src/scopes/internal/zmq_middleware/ScopeI.cpp (+19/-5)
src/scopes/internal/zmq_middleware/ZmqObject.cpp (+11/-3)
src/scopes/internal/zmq_middleware/ZmqRegistry.cpp (+6/-2)
src/scopes/internal/zmq_middleware/ZmqScope.cpp (+40/-4)
src/scopes/internal/zmq_middleware/capnproto/Scope.capnp (+5/-0)
test/gtest/scopes/Invocation/CMakeLists.txt (+2/-1)
test/gtest/scopes/Invocation/DebugTestScope.cpp (+59/-0)
test/gtest/scopes/Invocation/DebugTestScope.h (+33/-0)
test/gtest/scopes/Invocation/DebugTestScope.ini.in (+5/-0)
test/gtest/scopes/Invocation/Invocation_test.cpp (+34/-0)
test/gtest/scopes/Registry/Registry_test.cpp (+58/-0)
test/gtest/scopes/Registry/other_scopes/testscopeC/CMakeLists.txt (+2/-0)
test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.cpp (+99/-0)
test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.ini.in (+2/-0)
test/gtest/scopes/ReplyReaper/CMakeLists.txt (+1/-0)
test/gtest/scopes/ReplyReaper/DebugScope.ini.in (+5/-0)
test/gtest/scopes/ReplyReaper/ReplyReaper_test.cpp (+70/-1)
test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp (+2/-0)
test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in (+1/-0)
test/gtest/scopes/internal/zmq_middleware/ZmqMiddleware/ZmqMiddleware_test.cpp (+5/-0)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/scope_debug_mode
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Review via email: mp+230577@code.launchpad.net

Commit message

Added "DebugMode" parameter to scope config in order to enable more lenient operation timeouts when debugging that particular scope.

Description of the change

If a scope config file contains the line "DebugMode = true" the following debug timeouts are applied (only) to comms with that particular scope:

* Registry process timeout upped to 15s
* Scope idle timeout disabled
* Runtime reply reaper disabled
* Middleware two-way invocation timeout disabled
* Middleware locate() timeout upped to 15s

*** Summary of changes: ***

* Added "DebugMode" parameter to ScopeConfig (not to ScopeMetadata).

* A new debug_mode() method on ScopeObject (propagated through middleware to MWScope but not expose to the public ScopeProxy).

* An additional "dont_reap" boolean argument for ReplyObject constructor (provided via ScopeImpl from the result of fwd()->debug_mode()).

* An additional "locate_timeout" argument for ZmqObjectProxy::invoke_twoway_() allowing for both two-way and locate timeouts to be overridden from ZmqScope invocations ("locate_timeout" argument also made available on MWRegistry interface).

* Updated RuntimeImpl::run_scope() to use scope_config.debug_mode() to set idle timeout and construct ScopeObject accordingly.

* Updated scoperegistry to use scope_config.debug_mode() to set process timeout accordingly.

* Added tests.

*** Other changes: ***

* Fixed remove_local_scope() to kill scope if currently running before removing it from the list.

* Some cleaning up of API code in general.

* Invocation.shutdown_with_outstanding_async test was missing "run_test_registry();"

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

940 +bool ZmqScope::debug_mode()
941 +{
942 + // We only need to retrieve the debug mode state once, so we cache it in debug_mode_
943 + if (!debug_mode_)

This looks racy to me. The thread that calls debug_mode() isn't the necessarily the same one each time, is it?

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> 940 +bool ZmqScope::debug_mode()
> 941 +{
> 942 + // We only need to retrieve the debug mode state once, so we
> cache it in debug_mode_
> 943 + if (!debug_mode_)
>
> This looks racy to me. The thread that calls debug_mode() isn't the
> necessarily the same one each time, is it?

Right, I'll add an interlock

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> 940 +bool ZmqScope::debug_mode()
> 941 +{
> 942 + // We only need to retrieve the debug mode state once, so we
> cache it in debug_mode_
> 943 + if (!debug_mode_)
>
> This looks racy to me. The thread that calls debug_mode() isn't the
> necessarily the same one each time, is it?

K, fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

LGTM, thank you!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
469. By Marcus Tomlinson

Hopefully fixes "terminate called without an active exception"

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING'
2--- HACKING 2014-07-22 08:57:07 +0000
3+++ HACKING 2014-08-13 14:26:04 +0000
4@@ -151,7 +151,7 @@
5 $ bzr bd
6 $ # this will exit with an error if symbols file isn't up-to-date
7 $ cd ../build-area/unity-scopes-api-[version]
8- $ cat ./debian/libunity-scopes2/DEBIAN/symbols | c++filt | sed 's/^ \(.*@Base\)/ (c++)"\1"/' | uniq | diff -u debian/libunity-scopes2.symbols - | sed 's/^+ \(.*@Base"\)\( .*\)/+ \1 0replaceme/' > /tmp/symbols.diff
9+ $ cat ./debian/libunity-scopes3/DEBIAN/symbols | c++filt | sed 's/^ \(.*@Base\)/ (c++)"\1"/' | uniq | diff -u debian/libunity-scopes3.symbols - | sed 's/^+ \(.*@Base"\)\( .*\)/+ \1 0replaceme/' > /tmp/symbols.diff
10 $ cd -
11 $ # review the symbol differences and if everything is ok, apply the diff
12 $ patch -p0 < /tmp/symbols.diff
13
14=== modified file 'debian/libunity-scopes3.symbols'
15--- debian/libunity-scopes3.symbols 2014-08-04 20:26:59 +0000
16+++ debian/libunity-scopes3.symbols 2014-08-13 14:26:04 +0000
17@@ -410,12 +410,12 @@
18 (c++)"unity::scopes::testing::ScopeMetadataBuilder::invisible(unity::scopes::testing::ScopeMetadataBuilder::Optional<bool> const&)@Base" 0.5.0+14.10.20140619
19 (c++)"unity::scopes::testing::ScopeMetadataBuilder::ScopeMetadataBuilder()@Base" 0.4.0+14.04.20140312.1
20 (c++)"unity::scopes::testing::ScopeMetadataBuilder::~ScopeMetadataBuilder()@Base" 0.4.0+14.04.20140312.1
21- (c++)"unity::scopes::testing::TypedScopeFixtureHelper::set_registry(std::shared_ptr<unity::scopes::ScopeBase> const&, std::shared_ptr<unity::scopes::Registry> const&)@Base" 0.6.0+14.10.20140804.1
22 (c++)"unity::scopes::testing::OutOfProcessBenchmark::for_action(std::shared_ptr<unity::scopes::ScopeBase> const&, unity::scopes::testing::Benchmark::ActionConfiguration)@Base" 0.4.0+14.04.20140312.1
23 (c++)"unity::scopes::testing::OutOfProcessBenchmark::for_preview(std::shared_ptr<unity::scopes::ScopeBase> const&, unity::scopes::testing::Benchmark::PreviewConfiguration)@Base" 0.4.0+14.04.20140312.1
24 (c++)"unity::scopes::testing::OutOfProcessBenchmark::for_activation(std::shared_ptr<unity::scopes::ScopeBase> const&, unity::scopes::testing::Benchmark::ActivationConfiguration)@Base" 0.4.0+14.04.20140312.1
25 (c++)"unity::scopes::testing::OutOfProcessBenchmark::for_query(std::shared_ptr<unity::scopes::ScopeBase> const&, unity::scopes::testing::Benchmark::QueryConfiguration)@Base" 0.4.0+14.04.20140312.1
26 (c++)"unity::scopes::testing::OutOfProcessBenchmark::~OutOfProcessBenchmark()@Base" 0.4.0+14.04.20140312.1
27+ (c++)"unity::scopes::testing::TypedScopeFixtureHelper::set_registry(std::shared_ptr<unity::scopes::ScopeBase> const&, std::shared_ptr<unity::scopes::Registry> const&)@Base" 0replaceme
28 (c++)"unity::scopes::testing::Result::Result()@Base" 0.4.0+14.04.20140312.1
29 (c++)"unity::scopes::testing::Result::~Result()@Base" 0.4.0+14.04.20140312.1
30 (c++)"unity::scopes::testing::Benchmark::Result::save_to_xml(std::basic_ostream<char, std::char_traits<char> >&)@Base" 0.4.0+14.04.20140312.1
31@@ -426,22 +426,12 @@
32 (c++)"unity::scopes::testing::operator==(unity::scopes::testing::Benchmark::Result const&, unity::scopes::testing::Benchmark::Result const&)@Base" 0.4.0+14.04.20140312.1
33 (c++)"unity::scopes::testing::operator<<(std::basic_ostream<char, std::char_traits<char> >&, unity::scopes::testing::Benchmark::Result const&)@Base" 0.4.0+14.04.20140312.1
34 (c++)"unity::scopes::Category::Category(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unity::scopes::CategoryRenderer const&)@Base" 0.6.0+14.10.20140804.1
35- (c++)"unity::scopes::Category::Category(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<unity::scopes::CannedQuery const> const&, unity::scopes::CategoryRenderer const&)@Base" 0.6.0+14.10.20140804.1
36+ (c++)"unity::scopes::Category::Category(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<unity::scopes::CannedQuery const> const&, unity::scopes::CategoryRenderer const&)@Base" 0replaceme
37 (c++)"unity::scopes::Category::Category(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.0+14.04.20140312.1
38 (c++)"unity::scopes::Category::Category(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unity::scopes::CategoryRenderer const&)@Base" 0.6.0+14.10.20140804.1
39 (c++)"unity::scopes::Category::Category(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<unity::scopes::CannedQuery const> const&, unity::scopes::CategoryRenderer const&)@Base" 0.5.2+14.10.20140709.2
40 (c++)"unity::scopes::Category::Category(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.0+14.04.20140312.1
41 (c++)"unity::scopes::Category::~Category()@Base" 0.4.0+14.04.20140312.1
42- (c++)"unity::scopes::Location::has_altitude() const@Base" 0.6.0+14.10.20140804.1
43- (c++)"unity::scopes::Location::has_area_code() const@Base" 0.6.0+14.10.20140804.1
44- (c++)"unity::scopes::Location::has_region_code() const@Base" 0.6.0+14.10.20140804.1
45- (c++)"unity::scopes::Location::has_region_name() const@Base" 0.6.0+14.10.20140804.1
46- (c++)"unity::scopes::Location::has_country_code() const@Base" 0.6.0+14.10.20140804.1
47- (c++)"unity::scopes::Location::has_country_name() const@Base" 0.6.0+14.10.20140804.1
48- (c++)"unity::scopes::Location::has_zip_postal_code() const@Base" 0.6.0+14.10.20140804.1
49- (c++)"unity::scopes::Location::has_vertical_accuracy() const@Base" 0.6.0+14.10.20140804.1
50- (c++)"unity::scopes::Location::has_horizontal_accuracy() const@Base" 0.6.0+14.10.20140804.1
51- (c++)"unity::scopes::Location::has_city() const@Base" 0.6.0+14.10.20140804.1
52 (c++)"unity::scopes::Location::set_altitude(double)@Base" 0.6.0+14.10.20140804.1
53 (c++)"unity::scopes::Location::set_latitude(double)@Base" 0.6.0+14.10.20140804.1
54 (c++)"unity::scopes::Location::set_area_code(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.6.0+14.10.20140804.1
55@@ -487,7 +477,7 @@
56 (c++)"unity::scopes::internal::ScopeObject::search(unity::scopes::CannedQuery const&, unity::scopes::SearchMetadata const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, unity::scopes::internal::InvokeInfo const&)@Base" 0.4.0+14.04.20140312.1
57 (c++)"unity::scopes::internal::ScopeObject::preview(unity::scopes::Result const&, unity::scopes::ActionMetadata const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, unity::scopes::internal::InvokeInfo const&)@Base" 0.4.0+14.04.20140312.1
58 (c++)"unity::scopes::internal::ScopeObject::activate(unity::scopes::Result const&, unity::scopes::ActionMetadata const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, unity::scopes::internal::InvokeInfo const&)@Base" 0.4.0+14.04.20140312.1
59- (c++)"unity::scopes::internal::ScopeObject::ScopeObject(unity::scopes::internal::RuntimeImpl*, unity::scopes::ScopeBase*)@Base" 0.4.0+14.04.20140312.1
60+ (c++)"unity::scopes::internal::ScopeObject::ScopeObject(unity::scopes::internal::RuntimeImpl*, unity::scopes::ScopeBase*, bool)@Base" 0replaceme
61 (c++)"unity::scopes::internal::ScopeObject::~ScopeObject()@Base" 0.4.0+14.04.20140312.1
62 (c++)"unity::scopes::internal::smartscopes::SSScopeObject::perform_action(unity::scopes::Result const&, unity::scopes::ActionMetadata const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, unity::scopes::internal::InvokeInfo const&)@Base" 0.4.0+14.04.20140312.1
63 (c++)"unity::scopes::internal::smartscopes::SSScopeObject::query(unity::scopes::internal::InvokeInfo const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, std::function<std::shared_ptr<unity::scopes::QueryBase> ()> const&, std::function<void (std::shared_ptr<unity::scopes::QueryBase>)> const&)@Base" 0.4.0+14.04.20140312.1
64@@ -700,8 +690,8 @@
65 (c++)"unity::scopes::ScopeMetadata::serialize() const@Base" 0.4.0+14.04.20140312.1
66 (c++)"unity::scopes::ActionMetadata::scope_data() const@Base" 0.4.0+14.04.20140312.1
67 (c++)"unity::scopes::SearchMetadata::cardinality() const@Base" 0.4.0+14.04.20140312.1
68- (c++)"unity::scopes::SearchMetadata::contains_hint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@Base" 0.4.0+14.04.20140312.1
69 (c++)"unity::scopes::SearchMetadata::has_location() const@Base" 0.6.0+14.10.20140804.1
70+ (c++)"unity::scopes::SearchMetadata::contains_hint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@Base" 0replaceme
71 (c++)"unity::scopes::SearchMetadata::hints() const@Base" 0.4.0+14.04.20140312.1
72 (c++)"unity::scopes::SearchMetadata::location() const@Base" 0.6.0+14.10.20140804.1
73 (c++)"unity::scopes::SearchMetadata::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@Base" 0.4.0+14.04.20140312.1
74@@ -789,11 +779,21 @@
75 (c++)"unity::scopes::Location::region_name() const@Base" 0.6.0+14.10.20140804.1
76 (c++)"unity::scopes::Location::country_code() const@Base" 0.6.0+14.10.20140804.1
77 (c++)"unity::scopes::Location::country_name() const@Base" 0.6.0+14.10.20140804.1
78+ (c++)"unity::scopes::Location::has_altitude() const@Base" 0replaceme
79+ (c++)"unity::scopes::Location::has_area_code() const@Base" 0replaceme
80+ (c++)"unity::scopes::Location::has_region_code() const@Base" 0replaceme
81+ (c++)"unity::scopes::Location::has_region_name() const@Base" 0replaceme
82 (c++)"unity::scopes::Location::zip_postal_code() const@Base" 0.6.0+14.10.20140804.1
83+ (c++)"unity::scopes::Location::has_country_code() const@Base" 0replaceme
84+ (c++)"unity::scopes::Location::has_country_name() const@Base" 0replaceme
85 (c++)"unity::scopes::Location::vertical_accuracy() const@Base" 0.6.0+14.10.20140804.1
86+ (c++)"unity::scopes::Location::has_zip_postal_code() const@Base" 0replaceme
87 (c++)"unity::scopes::Location::horizontal_accuracy() const@Base" 0.6.0+14.10.20140804.1
88+ (c++)"unity::scopes::Location::has_vertical_accuracy() const@Base" 0replaceme
89+ (c++)"unity::scopes::Location::has_horizontal_accuracy() const@Base" 0replaceme
90 (c++)"unity::scopes::Location::city() const@Base" 0.6.0+14.10.20140804.1
91 (c++)"unity::scopes::Location::altitude() const@Base" 0.6.0+14.10.20140804.1
92+ (c++)"unity::scopes::Location::has_city() const@Base" 0replaceme
93 (c++)"unity::scopes::Location::latitude() const@Base" 0.6.0+14.10.20140804.1
94 (c++)"unity::scopes::Location::area_code() const@Base" 0.6.0+14.10.20140804.1
95 (c++)"unity::scopes::Location::longitude() const@Base" 0.6.0+14.10.20140804.1
96@@ -812,6 +812,7 @@
97 (c++)"unity::scopes::internal::RuntimeImpl::factory() const@Base" 0.4.0+14.04.20140312.1
98 (c++)"unity::scopes::internal::RuntimeImpl::registry() const@Base" 0.4.0+14.04.20140312.1
99 (c++)"unity::scopes::internal::RuntimeImpl::scope_id() const@Base" 0.4.0+14.04.20140312.1
100+ (c++)"unity::scopes::internal::ScopeConfig::debug_mode() const@Base" 0replaceme
101 (c++)"unity::scopes::internal::ScopeConfig::description() const@Base" 0.4.0+14.04.20140312.1
102 (c++)"unity::scopes::internal::ScopeConfig::search_hint() const@Base" 0.4.0+14.04.20140312.1
103 (c++)"unity::scopes::internal::ScopeConfig::display_name() const@Base" 0.4.0+14.04.20140312.1
104@@ -829,6 +830,8 @@
105 (c++)"unity::scopes::internal::ScopeLoader::scope_base() const@Base" 0.4.0+14.04.20140312.1
106 (c++)"unity::scopes::internal::ScopeLoader::libpath() const@Base" 0.4.0+14.04.20140312.1
107 (c++)"unity::scopes::internal::ScopeLoader::scope_id() const@Base" 0.4.2+14.04.20140404.2
108+ (c++)"unity::scopes::internal::ScopeObject::debug_mode() const@Base" 0replaceme
109+ (c++)"unity::scopes::internal::smartscopes::SSScopeObject::debug_mode() const@Base" 0replaceme
110 (c++)"unity::scopes::internal::smartscopes::SSRegistryObject::get_base_url(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@Base" 0.4.0+14.04.20140312.1
111 (c++)"unity::scopes::internal::smartscopes::SSRegistryObject::get_metadata(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@Base" 0.4.2+14.04.20140404.2
112 (c++)"unity::scopes::internal::smartscopes::SSRegistryObject::get_ssclient() const@Base" 0.4.0+14.04.20140312.1
113
114=== modified file 'include/unity/scopes/internal/ActivationReplyObject.h'
115--- include/unity/scopes/internal/ActivationReplyObject.h 2014-03-07 04:19:32 +0000
116+++ include/unity/scopes/internal/ActivationReplyObject.h 2014-08-13 14:26:04 +0000
117@@ -34,7 +34,8 @@
118 class ActivationReplyObject : public ReplyObject
119 {
120 public:
121- ActivationReplyObject(ActivationListenerBase::SPtr const& receiver, RuntimeImpl const* runtime, std::string const& scope_id);
122+ ActivationReplyObject(ActivationListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
123+ std::string const& scope_id, bool dont_reap = false);
124 virtual bool process_data(VariantMap const& data) override;
125
126 private:
127
128=== modified file 'include/unity/scopes/internal/DfltConfig.h.in'
129--- include/unity/scopes/internal/DfltConfig.h.in 2014-07-25 01:23:02 +0000
130+++ include/unity/scopes/internal/DfltConfig.h.in 2014-08-13 14:26:04 +0000
131@@ -28,10 +28,10 @@
132 namespace internal
133 {
134
135-static constexpr const char* DFLT_RUNTIME_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Runtime.ini";
136-static constexpr const char* DFLT_REGISTRY_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Registry.ini";
137+static constexpr char const* DFLT_RUNTIME_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Runtime.ini";
138+static constexpr char const* DFLT_REGISTRY_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Registry.ini";
139 static constexpr char const* DFLT_REGISTRY_ID = "Registry";
140-static constexpr const char* DFLT_SS_REGISTRY_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Smartscopes.ini";
141+static constexpr char const* DFLT_SS_REGISTRY_INI = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/Smartscopes.ini";
142 static constexpr char const* DFLT_SS_REGISTRY_ID = "SSRegistry";
143 static constexpr char const* DFLT_SCOPERUNNER_PATH = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@/scoperunner";
144 static constexpr char const* DFLT_MIDDLEWARE = "Zmq";
145
146=== modified file 'include/unity/scopes/internal/MWRegistry.h'
147--- include/unity/scopes/internal/MWRegistry.h 2014-06-04 17:49:34 +0000
148+++ include/unity/scopes/internal/MWRegistry.h 2014-08-13 14:26:04 +0000
149@@ -39,6 +39,7 @@
150 // Remote operations
151 virtual ScopeMetadata get_metadata(std::string const& scope_id) = 0;
152 virtual MetadataMap list() = 0;
153+ virtual ObjectProxy locate(std::string const& identity, int64_t timeout) = 0;
154 virtual ObjectProxy locate(std::string const& identity) = 0;
155 virtual bool is_scope_running(std::string const& scope_id) = 0;
156
157
158=== modified file 'include/unity/scopes/internal/MWScope.h'
159--- include/unity/scopes/internal/MWScope.h 2014-02-27 16:58:50 +0000
160+++ include/unity/scopes/internal/MWScope.h 2014-08-13 14:26:04 +0000
161@@ -44,6 +44,7 @@
162 virtual QueryCtrlProxy activate(VariantMap const& result, VariantMap const& hints, MWReplyProxy const& reply) = 0;
163 virtual QueryCtrlProxy perform_action(VariantMap const& result, VariantMap const& hints, std::string const& widget_id, std::string const& action_id, MWReplyProxy const& reply) = 0;
164 virtual QueryCtrlProxy preview(VariantMap const& result, VariantMap const& hints, MWReplyProxy const& reply) = 0;
165+ virtual bool debug_mode() = 0;
166
167 protected:
168 MWScope(MiddlewareBase* mw_base);
169
170=== modified file 'include/unity/scopes/internal/PreviewReplyObject.h'
171--- include/unity/scopes/internal/PreviewReplyObject.h 2014-03-07 04:19:32 +0000
172+++ include/unity/scopes/internal/PreviewReplyObject.h 2014-08-13 14:26:04 +0000
173@@ -37,7 +37,8 @@
174 class PreviewReplyObject : public ReplyObject
175 {
176 public:
177- PreviewReplyObject(PreviewListenerBase::SPtr const& receiver, RuntimeImpl const* runtime, std::string const& scope_id);
178+ PreviewReplyObject(PreviewListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
179+ std::string const& scope_id, bool dont_reap = false);
180 virtual ~PreviewReplyObject();
181
182 virtual bool process_data(VariantMap const& data) override;
183
184=== modified file 'include/unity/scopes/internal/ReplyObject.h'
185--- include/unity/scopes/internal/ReplyObject.h 2014-07-28 09:55:08 +0000
186+++ include/unity/scopes/internal/ReplyObject.h 2014-08-13 14:26:04 +0000
187@@ -47,7 +47,8 @@
188 public:
189 UNITY_DEFINES_PTRS(ReplyObject);
190
191- ReplyObject(ListenerBase::SPtr const& receiver_base, RuntimeImpl const* runtime, std::string const& scope_proxy);
192+ ReplyObject(ListenerBase::SPtr const& receiver_base, RuntimeImpl const* runtime,
193+ std::string const& scope_proxy, bool dont_reap);
194 virtual ~ReplyObject();
195
196 virtual bool process_data(VariantMap const& data) = 0;
197
198=== modified file 'include/unity/scopes/internal/ResultReplyObject.h'
199--- include/unity/scopes/internal/ResultReplyObject.h 2014-04-09 09:36:50 +0000
200+++ include/unity/scopes/internal/ResultReplyObject.h 2014-08-13 14:26:04 +0000
201@@ -37,10 +37,8 @@
202 class ResultReplyObject : public ReplyObject
203 {
204 public:
205- ResultReplyObject(SearchListenerBase::SPtr const& receiver,
206- RuntimeImpl const* runtime,
207- std::string const& scope_id,
208- int cardinality);
209+ ResultReplyObject(SearchListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
210+ std::string const& scope_id, int cardinality, bool dont_reap = false);
211 virtual ~ResultReplyObject();
212
213 virtual bool process_data(VariantMap const& data) override;
214
215=== modified file 'include/unity/scopes/internal/ScopeConfig.h'
216--- include/unity/scopes/internal/ScopeConfig.h 2014-07-22 08:02:32 +0000
217+++ include/unity/scopes/internal/ScopeConfig.h 2014-08-13 14:26:04 +0000
218@@ -52,6 +52,7 @@
219 std::string scope_runner() const; // Optional, throws NotFoundException if not present
220 int idle_timeout() const; // Optional, returns default value if not present
221 ScopeMetadata::ResultsTtlType results_ttl_type() const; // Optional, returns none if not present
222+ bool debug_mode() const; // Optional, returns false if not present
223
224 VariantMap appearance_attributes() const; // Optional, returns empty map if no attributes are present
225
226@@ -71,6 +72,7 @@
227 std::unique_ptr<std::string> scope_runner_;
228 int idle_timeout_;
229 ScopeMetadata::ResultsTtlType results_ttl_type_;
230+ bool debug_mode_;
231
232 VariantMap appearance_attributes_;
233 };
234
235=== modified file 'include/unity/scopes/internal/ScopeObject.h'
236--- include/unity/scopes/internal/ScopeObject.h 2014-02-27 16:58:50 +0000
237+++ include/unity/scopes/internal/ScopeObject.h 2014-08-13 14:26:04 +0000
238@@ -52,7 +52,7 @@
239 public:
240 UNITY_DEFINES_PTRS(ScopeObject);
241
242- ScopeObject(RuntimeImpl* runtime, ScopeBase* scope_base_);
243+ ScopeObject(RuntimeImpl* runtime, ScopeBase* scope_base, bool debug_mode = false);
244 virtual ~ScopeObject();
245
246 // Remote operation implementations
247@@ -78,12 +78,15 @@
248 MWReplyProxy const& reply,
249 InvokeInfo const& info) override;
250
251+ virtual bool debug_mode() const override;
252+
253 private:
254 MWQueryCtrlProxy query(MWReplyProxy const& reply, MiddlewareBase* mw_base,
255 std::function<QueryBase::SPtr(void)> const& query_factory_fun,
256 std::function<QueryObjectBase::SPtr(QueryBase::SPtr, MWQueryCtrlProxy)> const& query_object_factory_fun);
257 RuntimeImpl* const runtime_;
258 ScopeBase* const scope_base_;
259+ bool const debug_mode_;
260 };
261
262 } // namespace internal
263
264=== modified file 'include/unity/scopes/internal/ScopeObjectBase.h'
265--- include/unity/scopes/internal/ScopeObjectBase.h 2014-05-15 00:34:39 +0000
266+++ include/unity/scopes/internal/ScopeObjectBase.h 2014-08-13 14:26:04 +0000
267@@ -69,6 +69,8 @@
268 ActionMetadata const& hints,
269 MWReplyProxy const& reply,
270 InvokeInfo const& info) = 0;
271+
272+ virtual bool debug_mode() const = 0;
273 };
274
275 } // namespace internal
276
277=== modified file 'include/unity/scopes/internal/smartscopes/SSScopeObject.h'
278--- include/unity/scopes/internal/smartscopes/SSScopeObject.h 2014-02-27 16:58:50 +0000
279+++ include/unity/scopes/internal/smartscopes/SSScopeObject.h 2014-08-13 14:26:04 +0000
280@@ -74,6 +74,8 @@
281 MWReplyProxy const& reply,
282 InvokeInfo const& info) override;
283
284+ bool debug_mode() const override;
285+
286 private:
287 MWQueryCtrlProxy query(InvokeInfo const& info,
288 MWReplyProxy const& reply,
289
290=== modified file 'include/unity/scopes/internal/zmq_middleware/ScopeI.h'
291--- include/unity/scopes/internal/zmq_middleware/ScopeI.h 2014-02-27 15:46:44 +0000
292+++ include/unity/scopes/internal/zmq_middleware/ScopeI.h 2014-08-13 14:26:04 +0000
293@@ -43,8 +43,8 @@
294
295 private:
296 virtual void search_(Current const& current,
297- capnp::AnyPointer::Reader& in_params,
298- capnproto::Response::Builder& r);
299+ capnp::AnyPointer::Reader& in_params,
300+ capnproto::Response::Builder& r);
301 virtual void activate_(Current const& current,
302 capnp::AnyPointer::Reader& in_params,
303 capnproto::Response::Builder& r);
304@@ -54,6 +54,9 @@
305 virtual void preview_(Current const& current,
306 capnp::AnyPointer::Reader& in_params,
307 capnproto::Response::Builder& r);
308+ virtual void debug_mode_(Current const& current,
309+ capnp::AnyPointer::Reader& in_params,
310+ capnproto::Response::Builder& r);
311 };
312
313 } // namespace zmq_middleware
314
315=== modified file 'include/unity/scopes/internal/zmq_middleware/ZmqObjectProxy.h'
316--- include/unity/scopes/internal/zmq_middleware/ZmqObjectProxy.h 2014-05-29 15:41:42 +0000
317+++ include/unity/scopes/internal/zmq_middleware/ZmqObjectProxy.h 2014-08-13 14:26:04 +0000
318@@ -77,7 +77,7 @@
319 void invoke_oneway_(capnp::MessageBuilder& out_params);
320
321 ZmqReceiver invoke_twoway_(capnp::MessageBuilder& out_params);
322- ZmqReceiver invoke_twoway_(capnp::MessageBuilder& out_params, int64_t timeout);
323+ ZmqReceiver invoke_twoway_(capnp::MessageBuilder& out_params, int64_t twoway_timeout, int64_t locate_timeout = -1);
324
325 private:
326 ZmqReceiver invoke_twoway__(capnp::MessageBuilder& out_params, int64_t timeout);
327
328=== modified file 'include/unity/scopes/internal/zmq_middleware/ZmqRegistry.h'
329--- include/unity/scopes/internal/zmq_middleware/ZmqRegistry.h 2014-06-04 17:49:34 +0000
330+++ include/unity/scopes/internal/zmq_middleware/ZmqRegistry.h 2014-08-13 14:26:04 +0000
331@@ -51,6 +51,7 @@
332 // Remote operations.
333 virtual ScopeMetadata get_metadata(std::string const& scope_id) override;
334 virtual MetadataMap list() override;
335+ virtual ObjectProxy locate(std::string const& identity, int64_t timeout) override;
336 virtual ObjectProxy locate(std::string const& identity) override;
337 virtual bool is_scope_running(std::string const& scope_id) override;
338 };
339
340=== modified file 'include/unity/scopes/internal/zmq_middleware/ZmqScope.h'
341--- include/unity/scopes/internal/zmq_middleware/ZmqScope.h 2014-02-27 16:58:50 +0000
342+++ include/unity/scopes/internal/zmq_middleware/ZmqScope.h 2014-08-13 14:26:04 +0000
343@@ -62,6 +62,13 @@
344 virtual QueryCtrlProxy preview(VariantMap const& result,
345 VariantMap const& hints,
346 MWReplyProxy const& reply) override;
347+
348+ virtual bool debug_mode() override;
349+
350+private:
351+ ZmqReceiver invoke_scope_(capnp::MessageBuilder& out_params);
352+ std::mutex debug_mode_mutex_;
353+ std::unique_ptr<bool> debug_mode_;
354 };
355
356 } // namespace zmq_middleware
357
358=== modified file 'scoperegistry/scoperegistry.cpp'
359--- scoperegistry/scoperegistry.cpp 2014-07-29 10:22:45 +0000
360+++ scoperegistry/scoperegistry.cpp 2014-08-13 14:26:04 +0000
361@@ -389,7 +389,15 @@
362 scope_dir.filename().native();
363 }
364
365- exec_data.timeout_ms = timeout_ms;
366+ // Check if this scope has requested debug mode, if so, set the process timeout to 15s
367+ if (sc.debug_mode())
368+ {
369+ exec_data.timeout_ms = 15000;
370+ }
371+ else
372+ {
373+ exec_data.timeout_ms = timeout_ms;
374+ }
375
376 try
377 {
378
379=== modified file 'src/scopes/internal/ActivationReplyObject.cpp'
380--- src/scopes/internal/ActivationReplyObject.cpp 2014-03-07 04:19:32 +0000
381+++ src/scopes/internal/ActivationReplyObject.cpp 2014-08-13 14:26:04 +0000
382@@ -30,8 +30,9 @@
383 namespace internal
384 {
385
386-ActivationReplyObject::ActivationReplyObject(ActivationListenerBase::SPtr const& receiver, RuntimeImpl const* runtime, std::string const& scope_id) :
387- ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id),
388+ActivationReplyObject::ActivationReplyObject(ActivationListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
389+ std::string const& scope_id, bool dont_reap) :
390+ ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id, dont_reap),
391 receiver_(receiver)
392 {
393 assert(receiver_);
394
395=== modified file 'src/scopes/internal/PreviewReplyObject.cpp'
396--- src/scopes/internal/PreviewReplyObject.cpp 2014-03-07 04:19:32 +0000
397+++ src/scopes/internal/PreviewReplyObject.cpp 2014-08-13 14:26:04 +0000
398@@ -40,8 +40,9 @@
399 namespace internal
400 {
401
402-PreviewReplyObject::PreviewReplyObject(PreviewListenerBase::SPtr const& receiver, RuntimeImpl const* runtime, std::string const& scope_id) :
403- ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id),
404+PreviewReplyObject::PreviewReplyObject(PreviewListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
405+ std::string const& scope_id, bool dont_reap) :
406+ ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id, dont_reap),
407 receiver_(receiver)
408 {
409 assert(receiver_);
410
411=== modified file 'src/scopes/internal/RegistryObject.cpp'
412--- src/scopes/internal/RegistryObject.cpp 2014-08-06 04:54:06 +0000
413+++ src/scopes/internal/RegistryObject.cpp 2014-08-13 14:26:04 +0000
414@@ -261,7 +261,16 @@
415 "with empty id");
416 }
417
418- lock_guard<decltype(mutex_)> lock(mutex_);
419+ unique_lock<decltype(mutex_)> lock(mutex_);
420+
421+ auto proc_it = scope_processes_.find(scope_id);
422+ if (proc_it != scope_processes_.end())
423+ {
424+ // Kill process after unlocking, so we can handle on_process_death
425+ lock.unlock();
426+ proc_it->second.kill();
427+ lock.lock();
428+ }
429
430 scope_processes_.erase(scope_id);
431
432@@ -335,8 +344,7 @@
433 }
434
435 RegistryObject::ScopeProcess::ScopeProcess(ScopeProcess const& other)
436- : exec_data_(other.exec_data_)
437- , reg_publisher_(other.reg_publisher_)
438+ : ScopeProcess(other.exec_data_, other.reg_publisher_)
439 {
440 }
441
442
443=== modified file 'src/scopes/internal/ReplyObject.cpp'
444--- src/scopes/internal/ReplyObject.cpp 2014-07-30 21:34:13 +0000
445+++ src/scopes/internal/ReplyObject.cpp 2014-08-13 14:26:04 +0000
446@@ -41,7 +41,8 @@
447 namespace internal
448 {
449
450-ReplyObject::ReplyObject(ListenerBase::SPtr const& receiver_base, RuntimeImpl const* runtime, std::string const& scope_proxy) :
451+ReplyObject::ReplyObject(ListenerBase::SPtr const& receiver_base, RuntimeImpl const* runtime,
452+ std::string const& scope_proxy, bool dont_reap) :
453 listener_base_(receiver_base),
454 finished_(false),
455 origin_proxy_(scope_proxy),
456@@ -50,10 +51,14 @@
457 {
458 assert(receiver_base);
459 assert(runtime);
460- reap_item_ = runtime->reply_reaper()->add([this] {
461- string msg = "No activity on ReplyObject for scope " + this->origin_proxy_ + ": ReplyObject destroyed";
462- this->finished(CompletionDetails(CompletionDetails::Error, msg));
463- });
464+
465+ if (dont_reap == false)
466+ {
467+ reap_item_ = runtime->reply_reaper()->add([this] {
468+ string msg = "No activity on ReplyObject for scope " + this->origin_proxy_ + ": ReplyObject destroyed";
469+ this->finished(CompletionDetails(CompletionDetails::Error, msg));
470+ });
471+ }
472 }
473
474 ReplyObject::~ReplyObject()
475@@ -89,7 +94,10 @@
476 return; // Ignore replies that arrive after finished().
477 }
478
479- reap_item_->refresh();
480+ if (reap_item_)
481+ {
482+ reap_item_->refresh();
483+ }
484
485 {
486 unique_lock<mutex> lock(mutex_);
487@@ -148,7 +156,10 @@
488
489 // Only one thread can reach this point, any others were thrown out above.
490
491- reap_item_->destroy();
492+ if (reap_item_)
493+ {
494+ reap_item_->destroy();
495+ }
496
497 // Wait until all currently executing calls to push() have completed.
498 unique_lock<mutex> lock(mutex_);
499@@ -189,7 +200,10 @@
500 return; // Ignore info messages that arrive after finished().
501 }
502
503- reap_item_->refresh();
504+ if (reap_item_)
505+ {
506+ reap_item_->refresh();
507+ }
508 info_occurred_.exchange(true);
509
510 try
511
512=== modified file 'src/scopes/internal/ResultReplyObject.cpp'
513--- src/scopes/internal/ResultReplyObject.cpp 2014-05-29 10:03:56 +0000
514+++ src/scopes/internal/ResultReplyObject.cpp 2014-08-13 14:26:04 +0000
515@@ -43,11 +43,9 @@
516 namespace internal
517 {
518
519-ResultReplyObject::ResultReplyObject(SearchListenerBase::SPtr const& receiver,
520- RuntimeImpl const* runtime,
521- std::string const& scope_id,
522- int cardinality) :
523- ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id),
524+ResultReplyObject::ResultReplyObject(SearchListenerBase::SPtr const& receiver, RuntimeImpl const* runtime,
525+ std::string const& scope_id, int cardinality, bool dont_reap) :
526+ ReplyObject(std::static_pointer_cast<ListenerBase>(receiver), runtime, scope_id, dont_reap),
527 receiver_(receiver),
528 cat_registry_(new CategoryRegistry()),
529 runtime_(runtime),
530
531=== modified file 'src/scopes/internal/RuntimeImpl.cpp'
532--- src/scopes/internal/RuntimeImpl.cpp 2014-08-08 14:06:59 +0000
533+++ src/scopes/internal/RuntimeImpl.cpp 2014-08-13 14:26:04 +0000
534@@ -357,15 +357,18 @@
535 auto run_future = std::async(launch::async, [scope_base] { scope_base->run(); });
536
537 // Create a servant for the scope and register the servant.
538- auto scope = unique_ptr<internal::ScopeObject>(new internal::ScopeObject(this, scope_base));
539 if (!scope_ini_file.empty())
540 {
541+ // Check if this scope has requested debug mode, if so, disable the idle timeout
542 ScopeConfig scope_config(scope_ini_file);
543- int idle_timeout_ms = scope_config.idle_timeout() * 1000;
544+ int idle_timeout_ms = scope_config.debug_mode() ? -1 : scope_config.idle_timeout() * 1000;
545+
546+ auto scope = unique_ptr<internal::ScopeObject>(new internal::ScopeObject(this, scope_base, scope_config.debug_mode()));
547 mw->add_scope_object(scope_id_, move(scope), idle_timeout_ms);
548 }
549 else
550 {
551+ auto scope = unique_ptr<internal::ScopeObject>(new internal::ScopeObject(this, scope_base));
552 mw->add_scope_object(scope_id_, move(scope));
553 }
554
555
556=== modified file 'src/scopes/internal/ScopeConfig.cpp'
557--- src/scopes/internal/ScopeConfig.cpp 2014-08-08 12:31:23 +0000
558+++ src/scopes/internal/ScopeConfig.cpp 2014-08-13 14:26:04 +0000
559@@ -55,6 +55,7 @@
560 const string scoperunner_key = "ScopeRunner";
561 const string idle_timeout_key = "IdleTimeout";
562 const string results_ttl_key = "ResultsTtlType";
563+ const string debug_mode_key = "DebugMode";
564
565 const string scope_appearance_group = "Appearance";
566 const string fg_color_key = "ForegroundColor";
567@@ -189,6 +190,15 @@
568 {
569 }
570
571+ try
572+ {
573+ debug_mode_ = parser()->get_boolean(scope_config_group, debug_mode_key);
574+ }
575+ catch (LogicException const&)
576+ {
577+ debug_mode_ = false;
578+ }
579+
580 // read all display attributes from scope_appearance_group
581 try
582 {
583@@ -202,39 +212,40 @@
584 }
585
586 KnownEntries const known_entries = {
587- { scope_config_group,
588- {
589- overrideable_key,
590- scope_name_key,
591- description_key,
592- author_key,
593- art_key,
594- icon_key,
595- search_hint_key,
596- hot_key_key,
597- invisible_key,
598- location_data_needed_key,
599- scoperunner_key,
600- idle_timeout_key,
601- results_ttl_key
602- }
603- },
604- { scope_appearance_group,
605- {
606- fg_color_key,
607- bg_color_key,
608- shape_images_key,
609- category_header_bg_key,
610- preview_button_color_key,
611- logo_overlay_color_key,
612- pageheader_logo_key,
613- pageheader_fg_color_key,
614- pageheader_background_key,
615- pageheader_div_color_key,
616- pageheader_nav_bg_key
617- }
618- }
619- };
620+ { scope_config_group,
621+ {
622+ overrideable_key,
623+ scope_name_key,
624+ description_key,
625+ author_key,
626+ art_key,
627+ icon_key,
628+ search_hint_key,
629+ hot_key_key,
630+ invisible_key,
631+ location_data_needed_key,
632+ scoperunner_key,
633+ idle_timeout_key,
634+ results_ttl_key,
635+ debug_mode_key
636+ }
637+ },
638+ { scope_appearance_group,
639+ {
640+ fg_color_key,
641+ bg_color_key,
642+ shape_images_key,
643+ category_header_bg_key,
644+ preview_button_color_key,
645+ logo_overlay_color_key,
646+ pageheader_logo_key,
647+ pageheader_fg_color_key,
648+ pageheader_background_key,
649+ pageheader_div_color_key,
650+ pageheader_nav_bg_key
651+ }
652+ }
653+ };
654 check_unknown_entries(known_entries);
655 }
656
657@@ -380,6 +391,11 @@
658 return results_ttl_type_;
659 }
660
661+bool ScopeConfig::debug_mode() const
662+{
663+ return debug_mode_;
664+}
665+
666 VariantMap ScopeConfig::appearance_attributes() const
667 {
668 return appearance_attributes_;
669
670=== modified file 'src/scopes/internal/ScopeImpl.cpp'
671--- src/scopes/internal/ScopeImpl.cpp 2014-07-28 08:30:35 +0000
672+++ src/scopes/internal/ScopeImpl.cpp 2014-08-13 14:26:04 +0000
673@@ -95,7 +95,7 @@
674 throw unity::InvalidArgumentException("Scope::search(): invalid SearchListenerBase (nullptr)");
675 }
676
677- ReplyObject::SPtr ro(make_shared<ResultReplyObject>(reply, runtime_, to_string(), metadata.cardinality()));
678+ ReplyObject::SPtr ro(make_shared<ResultReplyObject>(reply, runtime_, to_string(), metadata.cardinality(), fwd()->debug_mode()));
679 MWReplyProxy rp = fwd()->mw_base()->add_reply_object(ro);
680
681 // "Fake" QueryCtrlProxy that doesn't have a real MWQueryCtrlProxy yet.
682@@ -149,7 +149,7 @@
683 throw unity::InvalidArgumentException("Scope::activate(): invalid ActivationListenerBase (nullptr)");
684 }
685
686- ActivationReplyObject::SPtr ro(make_shared<ActivationReplyObject>(reply, runtime_, to_string()));
687+ ReplyObject::SPtr ro(make_shared<ActivationReplyObject>(reply, runtime_, to_string(), fwd()->debug_mode()));
688 MWReplyProxy rp = fwd()->mw_base()->add_reply_object(ro);
689
690 shared_ptr<QueryCtrlImpl> ctrl = make_shared<QueryCtrlImpl>(nullptr, rp);
691@@ -197,7 +197,7 @@
692 throw unity::InvalidArgumentException("Scope::perform_action(): invalid ActivationListenerBase (nullptr)");
693 }
694
695- ActivationReplyObject::SPtr ro(make_shared<ActivationReplyObject>(reply, runtime_, to_string()));
696+ ReplyObject::SPtr ro(make_shared<ActivationReplyObject>(reply, runtime_, to_string(), fwd()->debug_mode()));
697 MWReplyProxy rp = fwd()->mw_base()->add_reply_object(ro);
698
699 shared_ptr<QueryCtrlImpl> ctrl = make_shared<QueryCtrlImpl>(nullptr, rp);
700@@ -246,7 +246,7 @@
701 throw unity::InvalidArgumentException("Scope::preview(): invalid PreviewListenerBase (nullptr)");
702 }
703
704- PreviewReplyObject::SPtr ro(make_shared<PreviewReplyObject>(reply, runtime_, to_string()));
705+ ReplyObject::SPtr ro(make_shared<PreviewReplyObject>(reply, runtime_, to_string(), fwd()->debug_mode()));
706 MWReplyProxy rp = fwd()->mw_base()->add_reply_object(ro);
707
708 shared_ptr<QueryCtrlImpl> ctrl = make_shared<QueryCtrlImpl>(nullptr, rp);
709
710=== modified file 'src/scopes/internal/ScopeObject.cpp'
711--- src/scopes/internal/ScopeObject.cpp 2014-08-05 05:29:56 +0000
712+++ src/scopes/internal/ScopeObject.cpp 2014-08-13 14:26:04 +0000
713@@ -47,9 +47,10 @@
714 namespace internal
715 {
716
717-ScopeObject::ScopeObject(RuntimeImpl* runtime, ScopeBase* scope_base) :
718+ScopeObject::ScopeObject(RuntimeImpl* runtime, ScopeBase* scope_base, bool debug_mode) :
719 runtime_(runtime),
720- scope_base_(scope_base)
721+ scope_base_(scope_base),
722+ debug_mode_(debug_mode)
723 {
724 assert(runtime);
725 assert(scope_base);
726@@ -217,6 +218,11 @@
727 );
728 }
729
730+bool ScopeObject::debug_mode() const
731+{
732+ return debug_mode_;
733+}
734+
735 } // namespace internal
736
737 } // namespace scopes
738
739=== modified file 'src/scopes/internal/smartscopes/SSScopeObject.cpp'
740--- src/scopes/internal/smartscopes/SSScopeObject.cpp 2014-07-28 08:30:35 +0000
741+++ src/scopes/internal/smartscopes/SSScopeObject.cpp 2014-08-13 14:26:04 +0000
742@@ -192,6 +192,11 @@
743 return info.mw->create_query_ctrl_proxy(reply->identity() + ".c", info.mw->get_query_ctrl_endpoint());
744 }
745
746+bool SSScopeObject::debug_mode() const
747+{
748+ return false;
749+}
750+
751 } // namespace smartscopes
752
753 } // namespace internal
754
755=== modified file 'src/scopes/internal/zmq_middleware/ScopeI.cpp'
756--- src/scopes/internal/zmq_middleware/ScopeI.cpp 2014-05-29 15:41:42 +0000
757+++ src/scopes/internal/zmq_middleware/ScopeI.cpp 2014-08-13 14:26:04 +0000
758@@ -60,6 +60,7 @@
759 QueryCtrl* preview(ValueDict result, ValueDict hints, Reply* replyProxy);
760 QueryCtrl* perform_action(ValueDict result, ValueDict hints, string action_id, Reply* replyProxy);
761 QueryCtrl* activate(ValueDict result, ValueDict hints, Reply* replyProxy);
762+ bool debug_mode();
763 };
764
765 */
766@@ -71,7 +72,8 @@
767 { "search", bind(&ScopeI::search_, this, _1, _2, _3) },
768 { "preview", bind(&ScopeI::preview_, this, _1, _2, _3) },
769 { "activate", bind(&ScopeI::activate_, this, _1, _2, _3) },
770- { "perform_action", bind(&ScopeI::perform_action_, this, _1, _2, _3) }
771+ { "perform_action", bind(&ScopeI::perform_action_, this, _1, _2, _3) },
772+ { "debug_mode", bind(&ScopeI::debug_mode_, this, _1, _2, _3) }
773 })
774 {
775 }
776@@ -81,8 +83,8 @@
777 }
778
779 void ScopeI::search_(Current const& current,
780- capnp::AnyPointer::Reader& in_params,
781- capnproto::Response::Builder& r)
782+ capnp::AnyPointer::Reader& in_params,
783+ capnproto::Response::Builder& r)
784 {
785 auto req = in_params.getAs<capnproto::Scope::CreateQueryRequest>();
786 auto query = internal::CannedQueryImpl::create(to_variant_map(req.getQuery()));
787@@ -135,8 +137,8 @@
788 }
789
790 void ScopeI::perform_action_(Current const& current,
791- capnp::AnyPointer::Reader& in_params,
792- capnproto::Response::Builder& r)
793+ capnp::AnyPointer::Reader& in_params,
794+ capnproto::Response::Builder& r)
795 {
796 auto req = in_params.getAs<capnproto::Scope::ActionActivationRequest>();
797 auto result = ResultImpl::create_result(to_variant_map(req.getResult()));
798@@ -192,6 +194,18 @@
799 p.setCategory(ctrl_proxy->target_category().c_str());
800 }
801
802+void ScopeI::debug_mode_(Current const&,
803+ capnp::AnyPointer::Reader&,
804+ capnproto::Response::Builder& r)
805+{
806+ auto delegate = dynamic_pointer_cast<ScopeObjectBase>(del());
807+ assert(delegate);
808+ auto debug_mode = delegate->debug_mode();
809+ r.setStatus(capnproto::ResponseStatus::SUCCESS);
810+ auto debug_mode_response = r.initPayload().getAs<capnproto::Scope::DebugModeResponse>();
811+ debug_mode_response.setReturnValue(debug_mode);
812+}
813+
814 } // namespace zmq_middleware
815
816 } // namespace internal
817
818=== modified file 'src/scopes/internal/zmq_middleware/ZmqObject.cpp'
819--- src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-08-08 12:22:19 +0000
820+++ src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-08-13 14:26:04 +0000
821@@ -206,7 +206,7 @@
822 return invoke_twoway_(out_params, timeout_);
823 }
824
825-ZmqReceiver ZmqObjectProxy::invoke_twoway_(capnp::MessageBuilder& out_params, int64_t timeout)
826+ZmqReceiver ZmqObjectProxy::invoke_twoway_(capnp::MessageBuilder& out_params, int64_t twoway_timeout, int64_t locate_timeout)
827 {
828 auto registry_proxy = mw_base()->registry_proxy();
829 auto ss_registry_proxy = mw_base()->ss_registry_proxy();
830@@ -221,7 +221,15 @@
831 {
832 try
833 {
834- ObjectProxy new_proxy = registry_proxy->locate(identity());
835+ ObjectProxy new_proxy;
836+ if (locate_timeout != -1)
837+ {
838+ new_proxy = registry_proxy->locate(identity(), locate_timeout);
839+ }
840+ else
841+ {
842+ new_proxy = registry_proxy->locate(identity());
843+ }
844 // update our proxy with the newly received data
845 // (we need to first store values in local variables outside of the mutex,
846 // otherwise we will deadlock on the following ZmqObjectProxy methods)
847@@ -244,7 +252,7 @@
848 }
849
850 // Try the invocation
851- return invoke_twoway__(out_params, timeout);
852+ return invoke_twoway__(out_params, twoway_timeout);
853 }
854
855 // Get a socket to the endpoint for this proxy and write the request on the wire.
856
857=== modified file 'src/scopes/internal/zmq_middleware/ZmqRegistry.cpp'
858--- src/scopes/internal/zmq_middleware/ZmqRegistry.cpp 2014-07-14 06:54:43 +0000
859+++ src/scopes/internal/zmq_middleware/ZmqRegistry.cpp 2014-08-13 14:26:04 +0000
860@@ -144,7 +144,7 @@
861 return sm;
862 }
863
864-ObjectProxy ZmqRegistry::locate(std::string const& identity)
865+ObjectProxy ZmqRegistry::locate(std::string const& identity, int64_t timeout)
866 {
867 capnp::MallocMessageBuilder request_builder;
868 auto request = make_request_(request_builder, "locate");
869@@ -152,7 +152,6 @@
870 in_params.setIdentity(identity.c_str());
871
872 // locate uses a custom timeout because it needs to potentially fork/exec a scope.
873- int64_t timeout = mw_base()->locate_timeout();
874 auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder, timeout); });
875 auto receiver = future.get();
876 auto segments = receiver.receive();
877@@ -192,6 +191,11 @@
878 }
879 }
880
881+ObjectProxy ZmqRegistry::locate(std::string const& identity)
882+{
883+ return locate(identity, mw_base()->locate_timeout());
884+}
885+
886 bool ZmqRegistry::is_scope_running(std::string const& scope_id)
887 {
888 capnp::MallocMessageBuilder request_builder;
889
890=== modified file 'src/scopes/internal/zmq_middleware/ZmqScope.cpp'
891--- src/scopes/internal/zmq_middleware/ZmqScope.cpp 2014-06-30 07:30:25 +0000
892+++ src/scopes/internal/zmq_middleware/ZmqScope.cpp 2014-08-13 14:26:04 +0000
893@@ -54,6 +54,7 @@
894 QueryCtrl* activate(string query, ValueDict hints, Reply* replyProxy);
895 QueryCtrl* perform_action(string query, ValueDict hints, string action_id, Reply* replyProxy);
896 QueryCtrl* preview(string query, ValueDict hints, Reply* replyProxy);
897+ bool debug_mode();
898 };
899
900 */
901@@ -90,7 +91,7 @@
902 p.setCategory(reply_proxy->target_category().c_str());
903 }
904
905- auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder); });
906+ auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_scope_(request_builder); });
907
908 auto receiver = future.get();
909 auto segments = receiver.receive();
910@@ -122,7 +123,7 @@
911 p.setIdentity(reply_proxy->identity().c_str());
912 }
913
914- auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder); });
915+ auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_scope_(request_builder); });
916
917 auto receiver = future.get();
918 auto segments = receiver.receive();
919@@ -157,7 +158,7 @@
920 p.setIdentity(reply_proxy->identity().c_str());
921 }
922
923- auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder); });
924+ auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_scope_(request_builder); });
925 future.wait();
926
927 auto receiver = future.get();
928@@ -190,7 +191,7 @@
929 p.setIdentity(reply_proxy->identity().c_str());
930 }
931
932- auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder); });
933+ auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_scope_(request_builder); });
934
935 auto receiver = future.get();
936 auto segments = receiver.receive();
937@@ -206,6 +207,41 @@
938 return make_shared<QueryCtrlImpl>(p, reply_proxy);
939 }
940
941+bool ZmqScope::debug_mode()
942+{
943+ lock_guard<std::mutex> lock(debug_mode_mutex_);
944+
945+ // We only need to retrieve the debug mode state once, so we cache it in debug_mode_
946+ if (!debug_mode_)
947+ {
948+ capnp::MallocMessageBuilder request_builder;
949+ make_request_(request_builder, "debug_mode");
950+
951+ auto future = mw_base()->twoway_pool()->submit([&] { return this->invoke_twoway_(request_builder); });
952+ auto receiver = future.get();
953+ auto segments = receiver.receive();
954+ capnp::SegmentArrayMessageReader reader(segments);
955+ auto response = reader.getRoot<capnproto::Response>();
956+ throw_if_runtime_exception(response);
957+
958+ auto debug_mode_response = response.getPayload().getAs<capnproto::Scope::DebugModeResponse>();
959+ debug_mode_.reset(new bool(debug_mode_response.getReturnValue()));
960+ }
961+
962+ return *debug_mode_;
963+}
964+
965+ZmqReceiver ZmqScope::invoke_scope_(capnp::MessageBuilder& out_params)
966+{
967+ // Check if this scope has requested debug mode, if so, disable two-way timeout and set
968+ // locate timeout to 15s.
969+ if (debug_mode())
970+ {
971+ return this->invoke_twoway_(out_params, -1, 15000);
972+ }
973+ return this->invoke_twoway_(out_params);
974+}
975+
976 } // namespace zmq_middleware
977
978 } // namespace internal
979
980=== modified file 'src/scopes/internal/zmq_middleware/capnproto/Scope.capnp'
981--- src/scopes/internal/zmq_middleware/capnproto/Scope.capnp 2014-02-04 15:15:25 +0000
982+++ src/scopes/internal/zmq_middleware/capnproto/Scope.capnp 2014-08-13 14:26:04 +0000
983@@ -75,3 +75,8 @@
984 hints @1 : ValueDict.ValueDict;
985 replyProxy @2 : Proxy.Proxy;
986 }
987+
988+struct DebugModeResponse
989+{
990+ returnValue @0 : Bool;
991+}
992
993=== modified file 'test/gtest/scopes/Invocation/CMakeLists.txt'
994--- test/gtest/scopes/Invocation/CMakeLists.txt 2014-05-13 01:40:09 +0000
995+++ test/gtest/scopes/Invocation/CMakeLists.txt 2014-08-13 14:26:04 +0000
996@@ -1,8 +1,9 @@
997 configure_file(Registry.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Registry.ini)
998 configure_file(Runtime.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Runtime.ini)
999 configure_file(Zmq.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Zmq.ini)
1000+configure_file(DebugTestScope.ini.in ${CMAKE_CURRENT_BINARY_DIR}/DebugTestScope.ini)
1001
1002-add_executable(Invocation_test Invocation_test.cpp TestScope.cpp EmptyScope.cpp)
1003+add_executable(Invocation_test Invocation_test.cpp TestScope.cpp EmptyScope.cpp DebugTestScope.cpp)
1004 target_link_libraries(Invocation_test ${TESTLIBS})
1005
1006 add_test(Invocation Invocation_test)
1007
1008=== added file 'test/gtest/scopes/Invocation/DebugTestScope.cpp'
1009--- test/gtest/scopes/Invocation/DebugTestScope.cpp 1970-01-01 00:00:00 +0000
1010+++ test/gtest/scopes/Invocation/DebugTestScope.cpp 2014-08-13 14:26:04 +0000
1011@@ -0,0 +1,59 @@
1012+/*
1013+ * Copyright (C) 2014 Canonical Ltd
1014+ *
1015+ * This program is free software: you can redistribute it and/or modify
1016+ * it under the terms of the GNU Lesser General Public License version 3 as
1017+ * published by the Free Software Foundation.
1018+ *
1019+ * This program is distributed in the hope that it will be useful,
1020+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1021+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1022+ * GNU Lesser General Public License for more details.
1023+ *
1024+ * You should have received a copy of the GNU Lesser General Public License
1025+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1026+ *
1027+ * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
1028+ */
1029+
1030+#include "DebugTestScope.h"
1031+
1032+#include <unity/scopes/ScopeBase.h>
1033+
1034+#include <thread>
1035+
1036+using namespace std;
1037+using namespace unity::scopes;
1038+
1039+namespace
1040+{
1041+
1042+class TestQuery : public SearchQueryBase
1043+{
1044+public:
1045+ TestQuery(CannedQuery const& query, SearchMetadata const& metadata)
1046+ : SearchQueryBase(query, metadata)
1047+ {
1048+ }
1049+
1050+ virtual void cancelled() override
1051+ {
1052+ }
1053+
1054+ virtual void run(SearchReplyProxy const&) override
1055+ {
1056+ }
1057+};
1058+
1059+} // namespace
1060+
1061+SearchQueryBase::UPtr DebugTestScope::search(CannedQuery const& query, SearchMetadata const& metadata)
1062+{
1063+ this_thread::sleep_for(chrono::milliseconds(2000)); // Attempt to timeout the two-way invocation
1064+ return SearchQueryBase::UPtr(new TestQuery(query, metadata));
1065+}
1066+
1067+PreviewQueryBase::UPtr DebugTestScope::preview(Result const&, ActionMetadata const&)
1068+{
1069+ return nullptr; // unused
1070+}
1071
1072=== added file 'test/gtest/scopes/Invocation/DebugTestScope.h'
1073--- test/gtest/scopes/Invocation/DebugTestScope.h 1970-01-01 00:00:00 +0000
1074+++ test/gtest/scopes/Invocation/DebugTestScope.h 2014-08-13 14:26:04 +0000
1075@@ -0,0 +1,33 @@
1076+/*
1077+ * Copyright (C) 2014 Canonical Ltd
1078+ *
1079+ * This program is free software: you can redistribute it and/or modify
1080+ * it under the terms of the GNU Lesser General Public License version 3 as
1081+ * published by the Free Software Foundation.
1082+ *
1083+ * This program is distributed in the hope that it will be useful,
1084+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1085+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1086+ * GNU Lesser General Public License for more details.
1087+ *
1088+ * You should have received a copy of the GNU Lesser General Public License
1089+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1090+ *
1091+ * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
1092+ */
1093+
1094+#ifndef TEST_DEBUGTESTSCOPE_H
1095+#define TEST_DEBUGTESTSCOPE_H
1096+
1097+#include <unity/scopes/ScopeBase.h>
1098+
1099+class DebugTestScope : public unity::scopes::ScopeBase
1100+{
1101+public:
1102+ virtual unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const&,
1103+ unity::scopes::SearchMetadata const&) override;
1104+ virtual unity::scopes::PreviewQueryBase::UPtr preview(unity::scopes::Result const&,
1105+ unity::scopes::ActionMetadata const&) override;
1106+};
1107+
1108+#endif
1109
1110=== added file 'test/gtest/scopes/Invocation/DebugTestScope.ini.in'
1111--- test/gtest/scopes/Invocation/DebugTestScope.ini.in 1970-01-01 00:00:00 +0000
1112+++ test/gtest/scopes/Invocation/DebugTestScope.ini.in 2014-08-13 14:26:04 +0000
1113@@ -0,0 +1,5 @@
1114+[ScopeConfig]
1115+DisplayName = Debug Test Scope
1116+Description = Debug Test Scope description
1117+Author = Canonical
1118+DebugMode = true
1119
1120=== modified file 'test/gtest/scopes/Invocation/Invocation_test.cpp'
1121--- test/gtest/scopes/Invocation/Invocation_test.cpp 2014-07-28 08:30:35 +0000
1122+++ test/gtest/scopes/Invocation/Invocation_test.cpp 2014-08-13 14:26:04 +0000
1123@@ -38,6 +38,7 @@
1124
1125 #include "EmptyScope.h"
1126 #include "TestScope.h"
1127+#include "DebugTestScope.h"
1128
1129 using namespace std;
1130 using namespace unity::scopes;
1131@@ -136,6 +137,26 @@
1132 EXPECT_EQ("", receiver->error_message());
1133 }
1134
1135+TEST(Invocation, no_timeout_in_debug_mode)
1136+{
1137+ auto reg_rt = run_test_registry();
1138+ auto rt = internal::RuntimeImpl::create("", "Runtime.ini");
1139+ auto mw = rt->factory()->create("DebugTestScope", "Zmq", "Zmq.ini");
1140+ mw->start();
1141+ auto proxy = mw->create_scope_proxy("DebugTestScope");
1142+ auto scope = internal::ScopeImpl::create(proxy, rt.get(), "TestScope");
1143+
1144+ auto receiver = make_shared<TestReceiver>();
1145+
1146+ // This call sleeps for 2s then returns
1147+ scope->search("test", SearchMetadata("unused", "unused"), receiver);
1148+ receiver->wait_until_finished();
1149+
1150+ // Check that the two-way invocation timeout did not kick in due to "DebugMode = true"
1151+ EXPECT_EQ(CompletionDetails::OK, receiver->status());
1152+ EXPECT_EQ("", receiver->error_message());
1153+}
1154+
1155 class NullReceiver : public SearchListenerBase
1156 {
1157 public:
1158@@ -154,6 +175,7 @@
1159
1160 TEST(Invocation, shutdown_with_outstanding_async)
1161 {
1162+ auto reg_rt = run_test_registry();
1163 auto rt = internal::RuntimeImpl::create("", "Runtime.ini");
1164 auto mw = rt->factory()->create("EmptyScope", "Zmq", "Zmq.ini");
1165 mw->start();
1166@@ -183,6 +205,12 @@
1167 rt->run_scope(&scope, runtime_ini_file, "");
1168 }
1169
1170+void debugtestscope_thread(Runtime::SPtr const& rt, string const& runtime_ini_file)
1171+{
1172+ DebugTestScope scope;
1173+ rt->run_scope(&scope, runtime_ini_file, "DebugTestScope.ini");
1174+}
1175+
1176 int main(int argc, char **argv)
1177 {
1178 ::testing::InitGoogleTest(&argc, argv);
1179@@ -193,6 +221,9 @@
1180 Runtime::SPtr esrt = move(Runtime::create_scope_runtime("EmptyScope", "Runtime.ini"));
1181 std::thread emptyscope_t(nullscope_thread, esrt, "Runtime.ini");
1182
1183+ Runtime::SPtr dsrt = move(Runtime::create_scope_runtime("DebugTestScope", "Runtime.ini"));
1184+ std::thread debugtestscope_t(debugtestscope_thread, dsrt, "Runtime.ini");
1185+
1186 // Give threads some time to bind to endpoints, to avoid getting ObjectNotExistException
1187 // from a synchronous remote call.
1188 this_thread::sleep_for(chrono::milliseconds(500));
1189@@ -205,5 +236,8 @@
1190 esrt->destroy();
1191 emptyscope_t.join();
1192
1193+ dsrt->destroy();
1194+ debugtestscope_t.join();
1195+
1196 return rc;
1197 }
1198
1199=== modified file 'test/gtest/scopes/Registry/Registry_test.cpp'
1200--- test/gtest/scopes/Registry/Registry_test.cpp 2014-08-01 03:19:32 +0000
1201+++ test/gtest/scopes/Registry/Registry_test.cpp 2014-08-13 14:26:04 +0000
1202@@ -240,6 +240,64 @@
1203 EXPECT_FALSE(r->is_scope_running("testscopeB"));
1204 }
1205
1206+TEST(Registry, no_idle_timeout_in_debug_mode)
1207+{
1208+ bool update_received = false;
1209+ std::mutex mutex;
1210+ std::condition_variable cond;
1211+
1212+ Runtime::UPtr rt = Runtime::create(TEST_RUNTIME_FILE);
1213+ RegistryProxy r = rt->registry();
1214+
1215+ // Configure testscopeC scope_state_callback
1216+ auto conn = r->set_scope_state_callback("testscopeC", [&update_received, &mutex, &cond](bool)
1217+ {
1218+ std::lock_guard<std::mutex> lock(mutex);
1219+ update_received = true;
1220+ cond.notify_one();
1221+ });
1222+
1223+ auto wait_for_state_update = [&update_received, &mutex, &cond]
1224+ {
1225+ // Wait for an update notification
1226+ std::unique_lock<std::mutex> lock(mutex);
1227+ bool success = cond.wait_for(lock, std::chrono::milliseconds(500), [&update_received] { return update_received; });
1228+ update_received = false;
1229+ return success;
1230+ };
1231+
1232+ // Move testscopeC into the scopes folder
1233+ filesystem::rename(TEST_RUNTIME_PATH "/other_scopes/testscopeC", TEST_RUNTIME_PATH "/scopes/testscopeC");
1234+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
1235+
1236+ auto meta = r->get_metadata("testscopeC");
1237+ auto sp = meta.proxy();
1238+
1239+ // testscopeC should not be running at this point
1240+ EXPECT_FALSE(r->is_scope_running("testscopeC"));
1241+ EXPECT_FALSE(wait_for_state_update());
1242+
1243+ // search would fail if testscopeC can't be executed
1244+ auto receiver = std::make_shared<Receiver>();
1245+ SearchListenerBase::SPtr reply(receiver);
1246+ auto ctrl = sp->search("foo", SearchMetadata("C", "desktop"), reply);
1247+ EXPECT_TRUE(receiver->wait_until_finished());
1248+
1249+ // testscopeC should now be running
1250+ EXPECT_TRUE(wait_for_state_update());
1251+ EXPECT_TRUE(r->is_scope_running("testscopeC"));
1252+
1253+ // check that the scope is still running after 4s
1254+ // (due to "DebugMode = true" and despite "IdleTimeout = 2")
1255+ std::this_thread::sleep_for(std::chrono::seconds{4});
1256+ EXPECT_FALSE(wait_for_state_update());
1257+ EXPECT_TRUE(r->is_scope_running("testscopeC"));
1258+
1259+ // Move testscopeC back into the other_scopes folder
1260+ filesystem::rename(TEST_RUNTIME_PATH "/scopes/testscopeC", TEST_RUNTIME_PATH "/other_scopes/testscopeC");
1261+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
1262+}
1263+
1264 TEST(Registry, list_update_notify_before_click_folder_exists)
1265 {
1266 bool update_received = false;
1267
1268=== modified file 'test/gtest/scopes/Registry/other_scopes/testscopeC/CMakeLists.txt'
1269--- test/gtest/scopes/Registry/other_scopes/testscopeC/CMakeLists.txt 2014-06-04 17:49:34 +0000
1270+++ test/gtest/scopes/Registry/other_scopes/testscopeC/CMakeLists.txt 2014-08-13 14:26:04 +0000
1271@@ -1,1 +1,3 @@
1272+add_library(testscopeC MODULE testscopeC.cpp)
1273+target_link_libraries(testscopeC ${LIBGTEST})
1274 configure_file(testscopeC.ini.in testscopeC.ini)
1275
1276=== added file 'test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.cpp'
1277--- test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.cpp 1970-01-01 00:00:00 +0000
1278+++ test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.cpp 2014-08-13 14:26:04 +0000
1279@@ -0,0 +1,99 @@
1280+/*
1281+ * Copyright (C) 2014 Canonical Ltd
1282+ *
1283+ * This program is free software: you can redistribute it and/or modify
1284+ * it under the terms of the GNU Lesser General Public License version 3 as
1285+ * published by the Free Software Foundation.
1286+ *
1287+ * This program is distributed in the hope that it will be useful,
1288+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1289+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1290+ * GNU Lesser General Public License for more details.
1291+ *
1292+ * You should have received a copy of the GNU Lesser General Public License
1293+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1294+ *
1295+ * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
1296+ */
1297+
1298+#include <unity/scopes/ScopeBase.h>
1299+
1300+#define EXPORT __attribute__ ((visibility ("default")))
1301+
1302+using namespace unity::scopes;
1303+
1304+class MyQuery : public SearchQueryBase
1305+{
1306+public:
1307+ MyQuery(CannedQuery const& query, SearchMetadata const& metadata) :
1308+ SearchQueryBase(query, metadata)
1309+ {
1310+ }
1311+
1312+ virtual void cancelled() override
1313+ {
1314+ }
1315+
1316+ virtual void run(SearchReplyProxy const&) override
1317+ {
1318+ }
1319+};
1320+
1321+class MyPreview : public PreviewQueryBase
1322+{
1323+public:
1324+ MyPreview(Result const& result, ActionMetadata const& metadata)
1325+ : PreviewQueryBase(result, metadata)
1326+ {
1327+ }
1328+
1329+ virtual void cancelled() override
1330+ {
1331+ }
1332+
1333+ virtual void run(PreviewReplyProxy const&) override
1334+ {
1335+ }
1336+};
1337+
1338+class MyScope : public ScopeBase
1339+{
1340+public:
1341+ virtual void start(std::string const&) override
1342+ {
1343+ }
1344+
1345+ virtual void stop() override {}
1346+
1347+ virtual SearchQueryBase::UPtr search(CannedQuery const& q, SearchMetadata const& metadata) override
1348+ {
1349+ SearchQueryBase::UPtr query(new MyQuery(q, metadata));
1350+ return query;
1351+ }
1352+
1353+ virtual PreviewQueryBase::UPtr preview(Result const& result, ActionMetadata const& metadata) override
1354+ {
1355+ PreviewQueryBase::UPtr preview(new MyPreview(result, metadata));
1356+ return preview;
1357+ }
1358+};
1359+
1360+extern "C"
1361+{
1362+
1363+ EXPORT
1364+ unity::scopes::ScopeBase*
1365+ // cppcheck-suppress unusedFunction
1366+ UNITY_SCOPE_CREATE_FUNCTION()
1367+ {
1368+ return new MyScope;
1369+ }
1370+
1371+ EXPORT
1372+ void
1373+ // cppcheck-suppress unusedFunction
1374+ UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope_base)
1375+ {
1376+ delete scope_base;
1377+ }
1378+}
1379
1380=== modified file 'test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.ini.in'
1381--- test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.ini.in 2014-06-04 17:49:34 +0000
1382+++ test/gtest/scopes/Registry/other_scopes/testscopeC/testscopeC.ini.in 2014-08-13 14:26:04 +0000
1383@@ -6,3 +6,5 @@
1384 Icon = /foo/scope-C.Icon
1385 SearchHint = scope-C.SearchHint
1386 HotKey = scope-C.HotKey
1387+IdleTimeout = 2
1388+DebugMode = true
1389
1390=== modified file 'test/gtest/scopes/ReplyReaper/CMakeLists.txt'
1391--- test/gtest/scopes/ReplyReaper/CMakeLists.txt 2014-07-30 21:34:13 +0000
1392+++ test/gtest/scopes/ReplyReaper/CMakeLists.txt 2014-08-13 14:26:04 +0000
1393@@ -1,6 +1,7 @@
1394 configure_file(Registry.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Registry.ini)
1395 configure_file(Runtime.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Runtime.ini)
1396 configure_file(Zmq.ini.in ${CMAKE_CURRENT_BINARY_DIR}/Zmq.ini)
1397+configure_file(DebugScope.ini.in ${CMAKE_CURRENT_BINARY_DIR}/DebugScope.ini)
1398
1399 add_definitions(-DTEST_DIR="${CMAKE_CURRENT_BINARY_DIR}")
1400
1401
1402=== added file 'test/gtest/scopes/ReplyReaper/DebugScope.ini.in'
1403--- test/gtest/scopes/ReplyReaper/DebugScope.ini.in 1970-01-01 00:00:00 +0000
1404+++ test/gtest/scopes/ReplyReaper/DebugScope.ini.in 2014-08-13 14:26:04 +0000
1405@@ -0,0 +1,5 @@
1406+[ScopeConfig]
1407+DisplayName = DebugScope
1408+Description = Debug Scope
1409+Author = Canonical
1410+DebugMode = true
1411
1412=== modified file 'test/gtest/scopes/ReplyReaper/ReplyReaper_test.cpp'
1413--- test/gtest/scopes/ReplyReaper/ReplyReaper_test.cpp 2014-08-06 04:54:06 +0000
1414+++ test/gtest/scopes/ReplyReaper/ReplyReaper_test.cpp 2014-08-13 14:26:04 +0000
1415@@ -104,5 +104,74 @@
1416 receiver->wait_until_finished();
1417
1418 no_reply_rt->destroy();
1419- scope_t.join();
1420+ if (scope_t.joinable())
1421+ {
1422+ scope_t.join();
1423+ }
1424+}
1425+
1426+class NoReapReceiver : public SearchListenerBase
1427+{
1428+public:
1429+ NoReapReceiver()
1430+ : query_complete_(false)
1431+ {
1432+ }
1433+
1434+ virtual void push(CategorisedResult /* result */) override
1435+ {
1436+ }
1437+
1438+ virtual void finished(CompletionDetails const& details) override
1439+ {
1440+ // Check that finished() was called by the reaper.
1441+ EXPECT_EQ(CompletionDetails::OK, details.status());
1442+ EXPECT_EQ("", details.message());
1443+ lock_guard<mutex> lock(mutex_);
1444+ query_complete_ = true;
1445+ cond_.notify_all();
1446+ }
1447+
1448+ void wait_until_finished()
1449+ {
1450+ unique_lock<mutex> lock(mutex_);
1451+ cond_.wait(lock, [this] { return this->query_complete_; });
1452+ }
1453+
1454+private:
1455+ bool query_complete_;
1456+ mutex mutex_;
1457+ condition_variable cond_;
1458+};
1459+
1460+void scope_thread_debug_mode(Runtime::SPtr const& rt, string const& runtime_ini_file)
1461+{
1462+ NoReplyScope scope;
1463+ rt->run_scope(&scope, runtime_ini_file, TEST_DIR "/DebugScope.ini");
1464+}
1465+
1466+TEST(ReplyReaper, no_reap_in_debug_mode)
1467+{
1468+ auto reg_rt = run_test_registry();
1469+
1470+ Runtime::SPtr no_reply_rt = move(Runtime::create_scope_runtime("NoReplyScope", TEST_DIR "/Runtime.ini"));
1471+ std::thread scope_t(scope_thread_debug_mode, no_reply_rt, TEST_DIR "/Runtime.ini");
1472+
1473+ // Run a query in the scope. The query will do nothing for 3 seconds,
1474+ // but the reaper will reap after at most 2 seconds.
1475+ auto rt = internal::RuntimeImpl::create("", TEST_DIR "/Runtime.ini");
1476+ auto mw = rt->factory()->create("NoReplyScope", "Zmq", TEST_DIR "/Zmq.ini");
1477+ mw->start();
1478+ auto proxy = mw->create_scope_proxy("NoReplyScope");
1479+ auto scope = internal::ScopeImpl::create(proxy, rt.get(), "NoReplyScope");
1480+
1481+ auto receiver = make_shared<NoReapReceiver>();
1482+ scope->search("test", SearchMetadata("en", "phone"), receiver);
1483+ receiver->wait_until_finished();
1484+
1485+ no_reply_rt->destroy();
1486+ if (scope_t.joinable())
1487+ {
1488+ scope_t.join();
1489+ }
1490 }
1491
1492=== modified file 'test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp'
1493--- test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-08-08 14:06:59 +0000
1494+++ test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-08-13 14:26:04 +0000
1495@@ -49,6 +49,7 @@
1496 EXPECT_EQ(300, cfg.idle_timeout());
1497 EXPECT_EQ(ScopeMetadata::ResultsTtlType::Large, cfg.results_ttl_type());
1498 EXPECT_TRUE(cfg.location_data_needed());
1499+ EXPECT_TRUE(cfg.debug_mode());
1500
1501 auto attrs = cfg.appearance_attributes();
1502 EXPECT_EQ(5, attrs.size());
1503@@ -78,6 +79,7 @@
1504 EXPECT_EQ(DFLT_SCOPE_IDLE_TIMEOUT, cfg.idle_timeout());
1505 EXPECT_EQ(ScopeMetadata::ResultsTtlType::None, cfg.results_ttl_type());
1506 EXPECT_FALSE(cfg.location_data_needed());
1507+ EXPECT_FALSE(cfg.debug_mode());
1508
1509 EXPECT_EQ(0, cfg.appearance_attributes().size());
1510
1511
1512=== modified file 'test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in'
1513--- test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-07-18 04:02:58 +0000
1514+++ test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-08-13 14:26:04 +0000
1515@@ -16,6 +16,7 @@
1516 ResultsTtlType = large
1517 LocationDataNeeded = true
1518 ConfinementType = unconfined
1519+DebugMode = true
1520
1521 [Appearance]
1522 arbitrary_key = true
1523
1524=== modified file 'test/gtest/scopes/internal/zmq_middleware/ZmqMiddleware/ZmqMiddleware_test.cpp'
1525--- test/gtest/scopes/internal/zmq_middleware/ZmqMiddleware/ZmqMiddleware_test.cpp 2014-07-24 10:43:37 +0000
1526+++ test/gtest/scopes/internal/zmq_middleware/ZmqMiddleware/ZmqMiddleware_test.cpp 2014-08-13 14:26:04 +0000
1527@@ -452,6 +452,11 @@
1528 {
1529 return nullptr;
1530 }
1531+
1532+ virtual bool debug_mode() const override
1533+ {
1534+ return false;
1535+ }
1536 };
1537
1538 // Make sure that multiple threads calling wait_for_shutdown() complete

Subscribers

People subscribed via source and target branches

to all changes: