Merge lp:~marcustomlinson/unity-scopes-api/debug_timeouts into lp:unity-scopes-api

Proposed by Marcus Tomlinson
Status: Superseded
Proposed branch: lp:~marcustomlinson/unity-scopes-api/debug_timeouts
Merge into: lp:unity-scopes-api
Diff against target: 257 lines (+56/-31)
13 files modified
CONFIGFILES (+4/-0)
include/unity/scopes/internal/MiddlewareBase.h (+1/-1)
include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h (+1/-1)
include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h (+1/-1)
src/scopes/internal/Reaper.cpp (+22/-13)
src/scopes/internal/RegistryConfig.cpp (+2/-2)
src/scopes/internal/RuntimeConfig.cpp (+2/-2)
src/scopes/internal/RuntimeImpl.cpp (+7/-4)
src/scopes/internal/ScopeConfig.cpp (+2/-2)
src/scopes/internal/zmq_middleware/ObjectAdapter.cpp (+1/-1)
src/scopes/internal/zmq_middleware/ZmqObject.cpp (+10/-1)
test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp (+2/-2)
test/gtest/scopes/internal/ScopeConfig/bad_timeout.ini.in (+1/-1)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/debug_timeouts
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Paweł Stołowski (community) Approve
Review via email: mp+230114@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-08.

Commit message

Allow timeout value of -1 to disable the scope idle timeout, reaper timeouts, and two-way invocation timeout.

Increased upper bound of process timeout to allow for slow scope startup when attaching the debugger.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good to me!

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

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CONFIGFILES'
2--- CONFIGFILES 2014-07-25 01:23:02 +0000
3+++ CONFIGFILES 2014-08-08 14:08:21 +0000
4@@ -84,6 +84,8 @@
5 or terminate correctly. If a scope does not respond
6 within the allotted time, it is killed with SIGKILL.
7
8+ Only values in the range 10 to 15000 milliseconds are accepted.
9+
10 The default value is 4000 milliseconds.
11
12 Note that this value must be less than Locate.Timeout in the [<Middleware>]
13@@ -168,6 +170,8 @@
14 this range would either cause locate() to falsely conclude that a scope
15 could not be started, or cause an unacceptably long wait time.)
16
17+ Only values in the range 10 to 15000 milliseconds are accepted.
18+
19 The default value is 5000 milliseconds.
20
21 - Registry.Timeout
22
23=== modified file 'include/unity/scopes/internal/MiddlewareBase.h'
24--- include/unity/scopes/internal/MiddlewareBase.h 2014-05-19 08:14:10 +0000
25+++ include/unity/scopes/internal/MiddlewareBase.h 2014-08-08 14:08:21 +0000
26@@ -82,7 +82,7 @@
27 virtual void add_dflt_query_object(QueryObjectBase::SPtr const& query) = 0;
28 virtual MWRegistryProxy add_registry_object(std::string const& identity, RegistryObjectBase::SPtr const& registry) = 0;
29 virtual MWReplyProxy add_reply_object(ReplyObjectBase::SPtr const& reply) = 0;
30- virtual MWScopeProxy add_scope_object(std::string const& identity, ScopeObjectBase::SPtr const& scope, int64_t idle_timeout = 0) = 0;
31+ virtual MWScopeProxy add_scope_object(std::string const& identity, ScopeObjectBase::SPtr const& scope, int64_t idle_timeout = -1) = 0;
32 virtual void add_dflt_scope_object(ScopeObjectBase::SPtr const& scope) = 0;
33 virtual MWStateReceiverProxy add_state_receiver_object(std::string const& identity, StateReceiverObject::SPtr const& state_receiver) = 0;
34
35
36=== modified file 'include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h'
37--- include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h 2014-05-20 04:20:46 +0000
38+++ include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h 2014-08-08 14:08:21 +0000
39@@ -59,7 +59,7 @@
40 std::string const& endpoint,
41 RequestMode m,
42 int pool_size,
43- int64_t idle_timeout = 0);
44+ int64_t idle_timeout = -1);
45 ~ObjectAdapter();
46
47 ZmqMiddleware* mw() const;
48
49=== modified file 'include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h'
50--- include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h 2014-07-24 10:43:37 +0000
51+++ include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h 2014-08-08 14:08:21 +0000
52@@ -102,7 +102,7 @@
53 int64_t timeout);
54
55 std::shared_ptr<ObjectAdapter> find_adapter(std::string const& name, std::string const& endpoint_dir,
56- std::string const& category, int64_t idle_timeout = 0);
57+ std::string const& category, int64_t idle_timeout = -1);
58
59 ZmqProxy safe_add(std::function<void()>& disconnect_func,
60 std::shared_ptr<ObjectAdapter> const& adapter,
61
62=== modified file 'src/scopes/internal/Reaper.cpp'
63--- src/scopes/internal/Reaper.cpp 2014-02-13 02:14:08 +0000
64+++ src/scopes/internal/Reaper.cpp 2014-08-08 14:08:21 +0000
65@@ -114,17 +114,20 @@
66 policy_(p),
67 finish_(false)
68 {
69- if (reap_interval < 1)
70- {
71- ostringstream s;
72- s << "Reaper: invalid reap_interval (" << reap_interval << "). Interval must be > 0.";
73- throw unity::InvalidArgumentException(s.str());
74- }
75- if (reap_interval > expiry_interval)
76- {
77- ostringstream s;
78- s << "Reaper: reap_interval (" << reap_interval << ") must be <= expiry_interval (" << expiry_interval << ").";
79- throw unity::LogicException(s.str());
80+ if (reap_interval != -1 && expiry_interval != -1)
81+ {
82+ if (reap_interval < 1)
83+ {
84+ ostringstream s;
85+ s << "Reaper: invalid reap_interval (" << reap_interval << "). Interval must be > 0.";
86+ throw unity::InvalidArgumentException(s.str());
87+ }
88+ if (reap_interval > expiry_interval)
89+ {
90+ ostringstream s;
91+ s << "Reaper: reap_interval (" << reap_interval << ") must be <= expiry_interval (" << expiry_interval << ").";
92+ throw unity::LogicException(s.str());
93+ }
94 }
95 }
96
97@@ -142,7 +145,10 @@
98 {
99 SPtr reaper(new Reaper(reap_interval, expiry_interval, p));
100 reaper->set_self();
101- reaper->start();
102+ if (reap_interval != -1 && expiry_interval != -1)
103+ {
104+ reaper->start();
105+ }
106 return reaper;
107 }
108
109@@ -168,7 +174,10 @@
110 finish_ = true;
111 do_work_.notify_one();
112 }
113- reap_thread_.join();
114+ if (reap_thread_.joinable())
115+ {
116+ reap_thread_.join();
117+ }
118 }
119
120 // Add a new entry to the reaper. If the entry is not refreshed within the expiry interval,
121
122=== modified file 'src/scopes/internal/RegistryConfig.cpp'
123--- src/scopes/internal/RegistryConfig.cpp 2014-08-04 06:31:27 +0000
124+++ src/scopes/internal/RegistryConfig.cpp 2014-08-08 14:08:21 +0000
125@@ -75,9 +75,9 @@
126 throw ConfigException(configfile + ": " + scoperunner_path_key + " must be an absolute path");
127 }
128 process_timeout_ = get_optional_int(registry_config_group, process_timeout_key, DFLT_PROCESS_TIMEOUT);
129- if (process_timeout_ < 10 || process_timeout_ > 5000)
130+ if (process_timeout_ < 10 || process_timeout_ > 15000)
131 {
132- throw_ex("Illegal value (" + to_string(process_timeout_) + ") for " + process_timeout_key + ": value must be 10-5000 ms");
133+ throw_ex("Illegal value (" + to_string(process_timeout_) + ") for " + process_timeout_key + ": value must be 10-15000 ms");
134 }
135
136 KnownEntries const known_entries = {
137
138=== modified file 'src/scopes/internal/RuntimeConfig.cpp'
139--- src/scopes/internal/RuntimeConfig.cpp 2014-08-04 06:31:27 +0000
140+++ src/scopes/internal/RuntimeConfig.cpp 2014-08-08 14:08:21 +0000
141@@ -83,12 +83,12 @@
142 default_middleware_ + default_middleware_configfile_key,
143 DFLT_MIDDLEWARE_INI);
144 reap_expiry_ = get_optional_int(runtime_config_group, reap_expiry_key, DFLT_REAP_EXPIRY);
145- if (reap_expiry_ < 1)
146+ if (reap_expiry_ < 1 && reap_expiry_ != -1)
147 {
148 throw_ex("Illegal value (" + to_string(reap_expiry_) + ") for " + reap_expiry_key + ": value must be > 0");
149 }
150 reap_interval_ = get_optional_int(runtime_config_group, reap_interval_key, DFLT_REAP_INTERVAL);
151- if (reap_interval_ < 1)
152+ if (reap_interval_ < 1 && reap_interval_ != -1)
153 {
154 throw_ex("Illegal value (" + to_string(reap_interval_) + ") for " + reap_interval_key + ": value must be > 0");
155 }
156
157=== modified file 'src/scopes/internal/RuntimeImpl.cpp'
158--- src/scopes/internal/RuntimeImpl.cpp 2014-08-01 03:01:40 +0000
159+++ src/scopes/internal/RuntimeImpl.cpp 2014-08-08 14:08:21 +0000
160@@ -358,13 +358,16 @@
161
162 // Create a servant for the scope and register the servant.
163 auto scope = unique_ptr<internal::ScopeObject>(new internal::ScopeObject(this, scope_base));
164- int idle_timeout_ms = 0;
165 if (!scope_ini_file.empty())
166 {
167 ScopeConfig scope_config(scope_ini_file);
168- idle_timeout_ms = scope_config.idle_timeout() * 1000;
169- }
170- mw->add_scope_object(scope_id_, move(scope), idle_timeout_ms);
171+ int idle_timeout_ms = scope_config.idle_timeout() * 1000;
172+ mw->add_scope_object(scope_id_, move(scope), idle_timeout_ms);
173+ }
174+ else
175+ {
176+ mw->add_scope_object(scope_id_, move(scope));
177+ }
178
179 // Inform the registry that this scope is now ready to process requests
180 reg_state_receiver->push_state(scope_id_, StateReceiverObject::State::ScopeReady);
181
182=== modified file 'src/scopes/internal/ScopeConfig.cpp'
183--- src/scopes/internal/ScopeConfig.cpp 2014-07-25 01:23:02 +0000
184+++ src/scopes/internal/ScopeConfig.cpp 2014-08-08 14:08:21 +0000
185@@ -152,10 +152,10 @@
186
187 // Negative values and values greater than max int (once multiplied by 1000 (s to ms)) are illegal
188 const int max_idle_timeout = std::numeric_limits<int>::max() / 1000;
189- if (idle_timeout_ < 0 || idle_timeout_ > max_idle_timeout)
190+ if ((idle_timeout_ < 0 || idle_timeout_ > max_idle_timeout) && idle_timeout_ != -1)
191 {
192 throw_ex("Illegal value (" + std::to_string(idle_timeout_) + ") for " + idle_timeout_key +
193- ": value must be > 0 and <= " + std::to_string(max_idle_timeout));
194+ ": value must be >= 0 and <= " + std::to_string(max_idle_timeout));
195 }
196
197
198
199=== modified file 'src/scopes/internal/zmq_middleware/ObjectAdapter.cpp'
200--- src/scopes/internal/zmq_middleware/ObjectAdapter.cpp 2014-07-25 05:04:47 +0000
201+++ src/scopes/internal/zmq_middleware/ObjectAdapter.cpp 2014-08-08 14:08:21 +0000
202@@ -57,7 +57,7 @@
203 endpoint_(endpoint),
204 mode_(m),
205 pool_size_(pool_size),
206- idle_timeout_(idle_timeout > 0 ? idle_timeout : zmqpp::poller::wait_forever),
207+ idle_timeout_(idle_timeout != -1 ? idle_timeout : zmqpp::poller::wait_forever),
208 state_(Inactive)
209 {
210 assert(!name.empty());
211
212=== modified file 'src/scopes/internal/zmq_middleware/ZmqObject.cpp'
213--- src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-07-28 13:06:45 +0000
214+++ src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-08-08 14:08:21 +0000
215@@ -281,7 +281,16 @@
216
217 zmqpp::poller p;
218 p.add(s);
219- p.poll(timeout);
220+
221+ if (timeout == -1)
222+ {
223+ p.poll();
224+ }
225+ else
226+ {
227+ p.poll(timeout);
228+ }
229+
230 if (!p.has_input(s))
231 {
232 // If a request times out, we must trash the corresponding socket, otherwise
233
234=== modified file 'test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp'
235--- test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-07-29 10:22:45 +0000
236+++ test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-08-08 14:08:21 +0000
237@@ -111,8 +111,8 @@
238 }
239 catch(ConfigException const& e)
240 {
241- boost::regex r("unity::scopes::ConfigException: \".*\": Illegal value \\(-1\\) for IdleTimeout: "
242- "value must be > 0 and <= [0-9]+");
243+ boost::regex r("unity::scopes::ConfigException: \".*\": Illegal value \\(-2\\) for IdleTimeout: "
244+ "value must be >= 0 and <= [0-9]+");
245 EXPECT_TRUE(boost::regex_match(e.what(), r));
246 }
247 }
248
249=== modified file 'test/gtest/scopes/internal/ScopeConfig/bad_timeout.ini.in'
250--- test/gtest/scopes/internal/ScopeConfig/bad_timeout.ini.in 2014-06-26 04:56:21 +0000
251+++ test/gtest/scopes/internal/ScopeConfig/bad_timeout.ini.in 2014-08-08 14:08:21 +0000
252@@ -2,4 +2,4 @@
253 DisplayName = Scope name
254 Description = Scope description
255 Author = Canonical
256-IdleTimeout = -1
257+IdleTimeout = -2

Subscribers

People subscribed via source and target branches

to all changes: