blob: b2590bac5616e251c21731df87bc3955179e3c93 [file] [log] [blame]
Scott James Remnant01735c02008-06-05 00:38:56 +010012008-06-05 Scott James Remnant <scott@netsplit.com>
2
Scott James Remnantdb7e92b2008-06-05 21:15:54 +01003 * init/event.h (event): Add blocking member.
4 * init/event.c (event_new): Initialising blocking list.
5 * init/tests/test_event.c (test_new): Make sure it's initialised
6 to an empty list.
7
Scott James Remnant9e919ba2008-06-05 21:01:42 +01008 * init/tests/test_job_process.c (test_handler): Update tests to use
9 Blocked.
10
Scott James Remnantea489282008-06-05 20:52:45 +010011 * init/event.c (event_pending_handle_jobs): Collect environment
12 and events independantly, which means we don't have to worry about
13 the list contents or freeing them up in case of error.
14 * init/event_operator.c (event_operator_events): Fix parent.
15 * init/tests/test_event.c (test_pending_handle_jobs): Update tests.
16 * init/init.supp: Update collect suppression.
17
Scott James Remnant3aa31c82008-06-05 20:18:17 +010018 * init/event_operator.c (event_operator_collect): Break in two.
19 (event_operator_environment): Collect the environment from the event,
20 appending the list of event names if necessary.
21 (event_operator_events): Block events and pass them to the
22 given list.
23 * init/event_operator.h: Update prototypes.
24 * init/tests/test_event_operator.c (test_operator_collect): Also
25 split into two new functions
26 (test_operator_environment, test_operator_events): Adjust
27
Scott James Remnant56a1da62008-06-05 19:47:45 +010028 * init/event_operator.c (event_operator_collect): Placed Blocked
29 structures in the list, rather than ordinary entries; I strongly
30 suspect that while it's nice to iterate the operator tree only once,
31 this needs to be three functions really.
32 * init/tests/test_event_operator.c (test_operator_collect): Update
33 test suite.
34
Scott James Remnantc33e1332008-06-05 19:33:17 +010035 * init/job.h (Job): Make blocking a statically defined list.
36 * init/job.c (job_new): Initialise rather than setting to NULL.
37 (job_unblock): Assume that blocking members are Blocked structures
38 and that the list itself is always iterable.
39 * init/tests/test_job.c (test_new): Check the list is empty, rather
40 than NULL.
41 (test_change_state, test_failed, test_unblock): Change tests cases
42 to expect blocking to always be present, and create members as Blocked
43 structures.
44
Scott James Remnantfa5ccfe2008-06-05 19:32:14 +010045 * init/blocked.c (blocked_new): Set destructor (forgotten)
46
Scott James Remnant5b2115f2008-06-05 19:31:58 +010047 * init/init.supp: Add setenv, which has crept in
48
Scott James Remnant0fb7dac2008-06-05 18:39:21 +010049 * init/blocked.h: Header containing enum, struct and prototype.
50 * init/blocked.c (blocked_new): Function to allocate the structure
51 with the right details.
52 * init/tests/test_blocked.c (test_new): Tests for the new function.
53 * init/Makefile.am (init_SOURCES): Compile using blocked.c and header
54 (TESTS): Build blocked test suite
55 (test_process_LDADD, test_job_class_LDADD)
56 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
57 (test_event_operator_LDADD, test_parse_job_LDADD)
58 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD):
59 Link blocked.o to most test suites.
60 (test_blocked_SOURCES, test_blocked_LDFLAGS, test_blocked_LDADD):
61 Details for test suite.
62
Scott James Remnantf3ef5112008-06-05 01:26:10 +010063 * init/main.c: Also remove SIGTERM handling, we don't re-exec
64 properly and this is a dangerous signal to use anyway.
65 (term_handler): Drop function.
66
Scott James Remnant6d271af2008-06-05 01:22:53 +010067 * init/main.c: Remove handling for stop/cont; there's no reason
68 a user should be able to pause the event queue.
69 (stop_handler): Drop function.
70 * init/event.c (event_poll): Remove paused handling.
71
Scott James Remnant3d703792008-06-05 01:20:35 +010072 * init/control.c: Fix doc string.
73
Scott James Remnant8523ba72008-06-05 01:14:33 +010074 * dbus/com.ubuntu.Upstart.xml (ReloadConfiguration): Add method
75 that's effectively the same as the HUP signal.
76 * init/control.c (control_reload_configuration): Unsurprisingly,
77 the implementation is identical.
78 * init/control.h: Add prototype.
79 * init/tests/test_control.c (test_reload_configuration): Make sure
80 the method works as expected.
81 (test_get_job_by_name, test_get_all_jobs): Add missing free calls for
82 message in cases of out of memory.
83
Scott James Remnant01735c02008-06-05 00:38:56 +010084 * dbus/com.ubuntu.Upstart.xml (JobAdded, JobRemoved): Add signals
85 for when new jobs are added to the known list and when existing jobs
86 are removed, this allows GUIs to always show an up-to-date list.
87 * dbus/com.ubuntu.Upstart.Job.xml (InstanceAdded, InstanceRemoved):
88 Also add matching signals for when instances are added to the list
89 for a job and when they're removed again.
90 * init/job_class.c (job_class_register): Emit the JobAdded signal
91 for this job when registering if the new signal argument is TRUE;
92 pass on the signal argument to job_register()
93 (job_class_add): Emit signals when registering jobs with existing
94 connections.
95 (job_class_unregister): Emit signals when unregistering a job.
96 * init/job.c (job_register): Likewise, emit the InstanceAdded signal
97 for the job class if the new signal argument is TRUE.
98 (job_new): Emit signals when registering instances with existing
99 connections.
100 (job_change_state): Emit the instance removed signal when destroying
101 an inactive instance.
102 * init/job_class.h, init/job.h: Add signal argument to prototypes
103 * init/control.c (control_register_all): When registering job classes
104 on a new connection, do not emit a signal since they will already
105 exist at the point when the name appears on the bus or the connection
106 is complete.
107 * init/tests/test_control.c (test_bus_open): Add comment that we
108 are testing for signal non-emission already with the fake server,
109 since it was this test that actually made me realise we had to
110 not emit them :p
111 * init/tests/test_job_class.c (test_register): Test that the signal
112 is emitted when signal is TRUE and not emitted when signal is FALSE
113 (test_unregister): Test that the JobRemoved signal is emitted
114 (test_get_instance_by_name, test_get_all_instances): Free message
115 if allocation failed.
116 (test_consider, test_reconsider): Test that the JobAdded and
117 JobRemoved signals are emitted (or not) when appropriate.
118 * init/tests/test_job.c (test_register): Make sure that the
119 InstanceAdded signal is emitted when TRUE is passed, and not when
120 FALSE is passed.
121 (test_new): Make sure the InstanceAdded signal is emitted when the
122 job is registered on the bus.
123 (test_change_state): Make sure the InstanceRemoved signal is sent
124 when deleting an instance.
125
Scott James Remnantbd3504a2008-06-02 16:00:27 +01001262008-06-02 Scott James Remnant <scott@netsplit.com>
127
Scott James Remnante49832c2008-06-02 16:12:22 +0100128 * init/tests/test_job.c (test_new, test_register): Also use a private
129 dbus server to avoid session bus problems.
130
Scott James Remnantf18c5ae2008-06-02 16:10:23 +0100131 * init/tests/test_job_class.c (test_consider, test_reconsider)
132 (test_register, test_unregister): Use a private dbus server instead
133 of connecting to the session bus, which might not be there.
134
Scott James Remnant77446ca2008-06-02 16:05:28 +0100135 * init/tests/test_control.c (test_disconnected): Simplify using a
136 private dbus server rather than faking one.
137
Scott James Remnantbd3504a2008-06-02 16:00:27 +0100138 * init/tests/test_control.c (test_bus_close): Don't rely on being
139 able to connect to the various buses, instead use a special private
140 one.
141
Scott James Remnant51980bc2008-06-01 19:22:11 +01001422008-06-01 Scott James Remnant <scott@netsplit.com>
143
Scott James Remnant92f2cc42008-06-01 20:42:30 +0100144 * dbus/com.ubuntu.Upstart.Job.xml (GetAllInstances): And also add
145 a similar method to return the object path of all instances of a
146 particular job.
147 * init/job_class.c (job_class_get_all_instances): Implement the
148 method, pretty much the same as the other.
149 * init/job_class.h: Add prototype.
150 * init/control.c: Fix comment.
151 * init/tests/test_control.c (test_get_all_jobs): Ensure that the
152 individual paths are children of the array.
153
Scott James Remnant30abe7c2008-06-01 20:31:09 +0100154 * dbus/com.ubuntu.Upstart.xml (GetAllJobs): Add method to return
155 the object path of all known jobs.
156 * init/control.c (control_get_all_jobs): Implement the method,
157 somewhat simple happily.
158 * init/control.h: Add prototype for the method.
159 * init/tests/test_control.c (test_get_all_jobs): Test that the
160 right data is returned.
161
Scott James Remnante9876b72008-06-01 19:49:39 +0100162 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
163 * dbus/com.ubuntu.Upstart.Instance.xml: Add libnih XML NS to the
164 files so that we can tag methods as sync or async later.
165
Scott James Remnant9c221382008-06-01 19:43:48 +0100166 * init/control.c (control_get_job_by_name): Remove const from
167 return parameter.
168 * init/control.h: Update prototype.
169 * init/tests/test_control.c (test_get_job_by_name): Remove const
170 from path type.
171
Scott James Remnant8c69f7b2008-06-01 19:40:33 +0100172 * init/job_class.c (job_class_get_instance_by_name): Remove wrong
173 const from parameter now that we've fixed the bindings generator.
174 * init/job_class.h: Update prototype to match.
175 * init/tests/test_job_class.c (test_get_instance_by_name): Change
176 type of path to match.
177
Scott James Remnant00c8b992008-06-01 19:27:04 +0100178 * HACKING (Dependencies): clarify that autoreconf and configure need
179 to be run for libnih first.
180
Scott James Remnant51980bc2008-06-01 19:22:11 +0100181 * init/Makefile.am (test_process_LDADD, test_job_class_LDADD)
182 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
183 (test_event_operator_LDADD, test_parse_job_LDADD)
184 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD): Link
185 the auto-generated D-Bus code in, otherwise the tests won't be
186 complete.
187
Scott James Remnant50677e02008-05-24 13:09:50 +02001882008-05-24 Scott James Remnant <scott@netsplit.com>
189
190 * HACKING: Changed branch location again, of both upstart and
191 libnih.
192
Scott James Remnant9a7282e2008-05-16 00:04:52 +02001932008-05-16 Scott James Remnant <scott@netsplit.com>
194
195 * init/job_class.c (job_class_consider, job_class_reconsider): Find
196 the best class first and compare against the current class before
197 acting, this avoids the re-register jump every time a job stops.
198 (job_class_select): Rename to job_class_add() since this is takes
199 a class and is the direct opposite to job_class_remove().
200
Scott James Remnant88345b82008-05-15 23:58:05 +02002012008-05-15 Scott James Remnant <scott@netsplit.com>
202
203 * init/event.c (event_new): We can't rely on the event poll function
204 being the last in the main loop, it's often the first, so after
205 adding an event to the queue ensure the loop is iterated at least
206 once so that the event poll occurs for it.
207
Scott James Remnanta645a992008-05-09 00:15:49 +01002082008-05-09 Scott James Remnant <scott@netsplit.com>
209
Scott James Remnant6308bb12008-05-09 03:05:47 +0100210 * TODO (Anytime): Update.
211
Scott James Remnant54ef7512008-05-09 03:04:49 +0100212 * dbus/com.ubuntu.Upstart.Instance.xml: format to match others
213
Scott James Remnantb0ce81e2008-05-09 03:04:29 +0100214 * dbus/com.ubuntu.Upstart.Job.xml (GetInstanceByName): Add method
215 * init/job_class.c (job_class_get_instance_by_name): Implementation.
216 * init/job_class.h: Add prototype.
217 * init/tests/test_job_class.c (test_get_instance_by_name): Tests
218 for new method.
219
Scott James Remnant6fa0b492008-05-09 02:58:41 +0100220 * init/job_class.h (JobClass): Make instances a hash table.
221 * init/job_class.c (job_class_new): Initialise instances as a hash
222 table now.
223 (job_class_register): Iterate instances as hash table.
224 (job_class_remove): Slightly odd construct needed to return FALSE
225 if there's anything in the hash table.
226 (job_class_unregister): Likewise to assert on no instances.
227 * init/tests/test_job_class.c (test_new): Check that instances is
228 now a hash table.
229 * init/job.h (Job): Make name the first member.
230 * init/job.c (job_new): Add to instances as hash table.
231 (job_instance): Drop entirely, replaced by a hash lookup.
232 * init/tests/test_job.c (test_instance): Drop.
233 * init/job_process.c (job_process_find): Iterate instances as a
234 hash table.
235 * init/event.c (event_pending_handle_jobs)
236 (event_finished_handle_jobs): Iterate instances as hash table.
237 (event_pending_handle_jobs): Replace job_instance call with an
238 ordinary hash lookup.
239 * init/tests/test_event.c: Update to use hash table.
240 * init/tests/test_conf.c: Update instances stealing for hash table
241
Scott James Remnant27d71f12008-05-09 02:35:26 +0100242 * init/job_class.c (job_class_new): initialise instance to the
243 empty string.
244 * init/tests/test_job_class.c: Update job_new() calls.
245 (test_new): Check instance against the empty string.
246 * init/job.c (job_new): name may no longer be NULL.
247 * init/tests/test_job.c: Update job_new() calls.
248 (test_instance): Reset back to "" when done.
249 * init/event.c (event_pending_handle_jobs): Always expand the
250 name, since the class->instance is always non-NULL.
251 * init/tests/test_event.c: Update job_new calls.
252 * init/tests/test_conf.c: Update job_new calls.
253 * init/tests/test_job_process.c: Update job_new calls.
254
Scott James Remnant07bdd4c2008-05-09 02:26:15 +0100255 * init/job.c (job_new): Singleton jobs have a fixed name of "",
256 rather than a NULL name, and a D-Bus name of "_".
257 (job_instance): Which rather simplifies this function (in fact,
258 it makes this function look like a common one).
259 (job_emit_event): Always set INSTANCE variable.
260 (job_name): Still distinguish in output, to avoid ugly "()" but
261 check character rather than NULL.
262 * init/tests/test_job.c (test_new): Check name is set to ""
263 and path to ".../_"
264 (test_change_state, test_emit_event): Update test cases to assume
265 an empty INSTANCE variable
266 (test_instance): Update to pass "" instead of NULL.
267 * init/job_process.c (job_process_run): Always set UPSTART_INSTANCE
268 * init/tests/test_job_process.c (test_run): Always assume an
269 UPSTART_INSTANCE variable, it may just be empty.
270 * init/tests/test_event.c (test_pending_handle_jobs): Expect
271 the name to be set to the empty string.
272
Scott James Remnanta1fb6862008-05-09 00:30:14 +0100273 * init/Makefile.am (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
274 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
275 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
276 Drop setting of data-type, turns out it doesn't work anyway.
277
Scott James Remnant31253ca2008-05-09 00:19:07 +0100278 * dbus/Upstart.conf: Add configuration file.
279 * dbus/Makefile.am (dbussystemdir, dist_dbussystem_DATA): Install
280 the configuration file into the right place.
281
Scott James Remnanta645a992008-05-09 00:15:49 +0100282 * dbus/com.ubuntu.Upstart.xml (GetJobByName): Add method
283 * init/control.c (control_get_job_by_name): Implementation.
284 * init/control.h: Prototype.
285 * init/tests/test_control.c (test_get_job_by_name): Test the
286 method using a fake message.
287
Scott James Remnant327c7df2008-05-08 10:18:27 +01002882008-05-08 Scott James Remnant <scott@netsplit.com>
289
Scott James Remnant8eb8dd22008-05-08 23:35:31 +0100290 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
291 * dbus/com.ubuntu.Upstart.Instance.xml: Add DTDs.
292
Scott James Remnant8877f442008-05-08 23:30:40 +0100293 * init/control.c (manager_interfaces): Export the general
294 com.ubuntu.Upstart interface
295 * init/job_class.c (job_class_interfaces): Export the
296 com.ubuntu.Upstart.Job interface
297 * init/job.c (job_interfaces): Export the
298 com.ubuntu.Upstart.Instance interface
299
Scott James Remnante1640612008-05-08 23:27:51 +0100300 * init/Makefile.am (BUILT_SOURCES)
301 (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
302 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
303 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
304 Generate C code and header files from the XML files which produce
305 object bindings.
306 (init_SOURCES): Link the built sources.
307 (CLEANFILES): Clean them up afterwards
308
Scott James Remnant08169c12008-05-08 23:14:22 +0100309 * dbus/com.ubuntu.Upstart.xml: Initially empty description for
310 manager object interface(s).
311 * dbus/com.ubuntu.Upstart.Job.xml: Initially empty description
312 for job class object interface(s).
313 * dbus/com.ubuntu.Upstart.Instance.xml: Initially empty
314 description for job instance object interface(s).
315 * dbus/Makefile.am: Distribute the three interface files,
316 they're used as sources elsewhere.
317 * configure.ac (AC_CONFIG_FILES): Generate dbus/Makefile
318 * Makefile.am (SUBDIRS): Descend into the dbus sub-directory.
319
Scott James Remnant0464dc12008-05-08 19:21:54 +0100320 * init/job_class.c (job_class_consider, job_class_reconsider):
321 Separate out the actual meat of the functions, since it's largely
322 duplicated between the two. This makes the difference between
323 the two functions clearer, consider always stages an election
324 no matter which is registered, reconsider only stages an election
325 if the current class is registered.
326 (job_class_select, job_class_remove): Functions containing the
327 common code, which now also handle registering and unregistering
328 the class with D-Bus. Here is the right place, not in new, since
329 we only export the current best class of a given name.
330 (job_class_register, job_class_unregister): Function to register
331 a job and its instances, and to unregister a job (we assert that
332 there must be no instances for us to do this).
333 * init/job_class.h: Add prototypes.
334 * init/tests/test_job_class.c (test_consider, test_reconsider):
335 Check that D-Bus registration and unregistration happens as
336 expected.
337 (test_register, test_unregister): test on their own.
338 * init/job.c (job_new): Register instances with D-Bus, since
339 instances can only ever exist for active classes, all instances
340 are always registered on the bus.
341 (job_register): Function to register an instance on the bus.
342 * init/job.h: Add prototype.
343 * init/tests/test_job.c (test_new): Test creating a job with an
344 active d-bus connection, which should have it registered.
345 (test_register): Test registration on its own.
346 * init/control.c (control_register_all): Make this always succeed,
347 and register existing jobs on the new connection.
348 (control_server_connect, control_bus_open): registration is
349 always successful.
350 * init/tests/test_control.c (test_server_connect, test_bus_open):
351 Test with existing jobs when we get a connection or create the
352 bus connection, ensure that the jobs and instances are registered.
353
Scott James Remnant327c7df2008-05-08 10:18:27 +0100354 * init/tests/test_job.c (test_change_state): Check for a bug where
355 a job with multiple instances will be freed when one instance is
356 deleted rather than the last instance.
357 * init/job.c (job_change_state): Add debugging messages when we
358 destroy a job that's no longer the current one or an instance
359 that's no longer active; also ensure that we never destroy a job
360 that's the current one.
361 * init/event.c (event_pending_handle_jobs): Add a debugging message
362 when we create a new instance of a job.
363 * init/conf.c (conf_file_destroy): Add a debugging message when
364 we destroy a job that's no longer the current one.
365
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +01003662008-05-07 Scott James Remnant <scott@netsplit.com>
367
Scott James Remnant1ba7f7a2008-05-07 23:52:11 +0100368 * init/control.c (control_server_open, control_server_close)
369 (control_server_connect): Create and manage a listening d-bus server
370 that is used for private direct connections to Upstart for when the
371 d-bus daemon is not available. Each new connection has the same
372 objects as the d-bus system bus, they only differ in their method.
373 (control_conns, control_init): Cache the open connections, including
374 the bus daemon and any private connections; we'll iterate this list
375 when sending signals.
376 (control_bus_open): Store connection in the list, don't worry about
377 setting close-on-exec, we check that by test case and rely on d-bus
378 to do it.
379 (control_bus_disconnected): Rename to control_disconnected
380 (control_disconnected): Work for system bus and private connections,
381 remove from the connections list.
382 * init/control.h: Add prototypes, remove global definition of bus
383 name to just being private again.
384 * init/tests/test_control.c (test_server_open, test_server_close)
385 (test_server_connect): Test the new functions.
386 (test_bus_open): add check for list entry
387 (test_bus_disconnected): rename to test_disconnected
388 * init/main.c: Open the listening server, warning if we're unable
389 to do so (but we won't treat it as a hard error since there's the
390 d-bus daemon as the default anyway).
391 * init/init.supp: suppress the fact that the control connections
392 list stays around.
393
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +0100394 * init/job_process.c (job_process_run): Use NIH_ZERO instead of
395 NIH_MUST and == 0
396
Scott James Remnant5635e072008-05-06 23:22:58 +01003972008-05-06 Scott James Remnant <scott@netsplit.com>
398
Scott James Remnantd1799d22008-05-06 23:34:56 +0100399 * init/environ.c (environ_expand_until): Odd gcc optimiser warning,
400 it reckons arg_start and end may be used uninitialised, but I don't
401 see how they can be.
402
Scott James Remnant5635e072008-05-06 23:22:58 +0100403 * init/main.c (main): Warn if we can't set the root directory.
404 * init/job_process.c (job_process_spawn)
405 (job_process_error_abort): loop on the return of write()
406 * init/tests/test_job_process.c (child, main): assert getcwd() works
407 (test_handler): initialise list and entry for gcc's blind spot.
408 (test_run): initialise ret for gcc's blind spot
409 * init/tests/test_job.c (test_name): jump through hoops for gcc
410 (test_change_state): list and entry.
411 * init/tests/test_event.c (test_finished_handle_jobs, test_finished)
412 (test_pending_handle_jobs, test_poll, test_pending): initialise to
413 NULL and buy gcc glasses
414 * init/tests/test_event_operator.c (test_operator_collect): another
415 NULL to make gcc happy.
416
Scott James Remnant70a8c8a2008-05-01 01:06:22 +01004172008-05-01 Scott James Remnant <scott@netsplit.com>
418
Scott James Remnant75f6fae2008-05-01 01:39:27 +0100419 * TODO: Update.
420
Scott James Remnant8d68b132008-05-01 01:21:07 +0100421 * init/init.supp: Suppress a few test case artefacts caused by
422 valgrind hating reachable memory at exec() time.
423
Scott James Remnant41f44aa2008-05-01 01:20:33 +0100424 * init/tests/test_job_process.c: Fix a few cases where we were
425 still dup'ing the name argument to job_new().
426 * init/tests/test_parse_job.c: Include missing signal.h
427
Scott James Remnant70a8c8a2008-05-01 01:06:22 +0100428 * init/event.c (event_pending_handle_jobs)
429 (event_finished_handle_jobs): Land the old job event handling
430 functions here as static functions, right now they're immense but
431 we'll actually move much of the code back out again as we go.
432 * init/tests/test_event.c (test_pending_handle_jobs)
433 (test_finished_handle_jobs): Also land the test cases in renamed
434 and somewhat restructued functions, since we now have to do the
435 testing through event_poll().
436 (test_poll, test_pending, test_finished): It never hurts to improve
437 test cases while you're in there.
438
Scott James Remnantb98ac992008-04-30 00:03:00 +01004392008-04-30 Scott James Remnant <scott@netsplit.com>
440
Scott James Remnant63fd5c72008-04-30 21:34:31 +0100441 * init/job.c (job_change_state): Change calls to job_process_run
442 and job_process_kill.
443 * init/main.c: Change to job_process_handler
444
Scott James Remnantf2d78e62008-04-30 21:33:38 +0100445 * init/job_process.c, init/job_process.h: Land the code from job.c
446 and defs from job.h that deal specifically with a job's processes,
447 rename the functions to job_process_*() in the process.
448 * init/tests/test_job_process.c: And land the test cases as well.
449
Scott James Remnanted255912008-04-30 21:09:48 +0100450 * init/job.c: Strip of everything not related to creation and finding
451 of instances and the core state machine; process stuff will move to
452 job_process.c and event handling to event.c, class (nee config) stuff
453 is already moved to job_class.c
454 (job_new): Don't reparent the name, it doesn't help anything, just
455 take a copy.
456 (job_name, job_failed, job_unblock, job_emit_event): Make extern since
457 we need to use these outside or just want to test them.
458 * init/job.h: Clean out also.
459 * init/tests/test_job.c: Also clean out.
460 (test_name, test_failed, test_unblock, test_emit_event): Add test cases
461 for newly extern functions.
462
Scott James Remnant5d82d902008-04-30 00:03:29 +0100463 * init/main.c: Include events.h to get the ones we need.
464
Scott James Remnantb98ac992008-04-30 00:03:00 +0100465 * init/control.c (control_job_config_path, control_job_path)
466 (control_path_append): Drop these functions (replaced by the more
467 generic nih_dbus_path() function)
468 * init/control.h: Make CONTROL_ROOT public, and drop other prototypes.
469 * init/tests/test_control.c (test_job_config_path)
470 (test_job_path): Drop tests.
471
Scott James Remnant07336532008-04-29 19:45:51 +01004722008-04-29 Scott James Remnant <scott@netsplit.com>
473
Scott James Remnante1725e82008-04-29 23:59:51 +0100474 * init/event.c, init/event.h, init/tests/test_event.c: Strip out the
475 event operator code and events list.
476
Scott James Remnant6f02f542008-04-29 23:59:12 +0100477 * init/job_class.c, init/job_class.h: We only need the event operator
478 code here now.
479
Scott James Remnantddbbaa62008-04-29 23:58:36 +0100480 * init/events.h, init/event_operator.c, init/event_operator.h,
481 init/tests/test_event_operator.c: Separate out the event operator
482 code and the list of events into separate source files.
483 * init/Makefile.am (init_SOURCES): Build and link event operator code
484 and use the lists of events.
485 (TESTS): Build and run the event operator test suite.
486 (test_event_operator_SOURCES, test_event_operator_LDFLAGS)
487 (test_event_operator_LDADD): Details for the event operator test
488 suite.
489 (test_process_LDADD, test_job_class_LDADD)
490 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
491 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
492 (test_control_LDADD): Link the event operator code.
493
Scott James Remnantf2f69d02008-04-29 23:38:23 +0100494 * init/job_class.c, init/main.c: Correct includes and some function
495 names.
496
Scott James Remnant9de968e2008-04-29 23:37:25 +0100497 * init/process.c, init/process.h, init/tests/test_process.c: Land
498 original Process code (used by job class and similar).
499
Scott James Remnant8092e792008-04-29 23:36:16 +0100500 * init/process.c, init/process.h, init/tests/test_process.c: Break
501 into two pieces, one part becomes job_process which requires both
502 job information and process information, the other becomes system
503 which requires no job information.
504 * init/errors.h: Update error name.
505 * init/Makefile.am (init_SOURCES): Build and link job process code
506 and header along with system code and header.
507 (TESTS): Build and run job process and system test suites.
508 (test_job_process_SOURCES, test_job_process_LDFLAGS)
509 (test_job_process_LDADD): Details for job process test suite.
510 (test_system_SOURCES, test_system_LDFLAGS, test_system_LDADD):
511 Details for system test suite.
512 (test_process_LDADD, test_job_class_LDADD, test_job_LDADD)
513 (test_event_LDADD, test_parse_job_LDADD, test_parse_conf_LDADD)
514 (test_conf_LDADD, test_control_LDADD): Link job process and system
515 code.
516
Scott James Remnant783a79d2008-04-29 20:00:52 +0100517 * init/parse_conf.c: Remove parse_job include.
518
Scott James Remnantc2791dd2008-04-29 19:59:41 +0100519 * init/init.supp: Update leak check for class init; remove
520 valgrind workaround since it's gone away with the change of that
521 function.
522
Scott James Remnant710c5152008-04-29 19:58:44 +0100523 * init/conf.h (ConfFile): Change type of job member, but leave name.
524 Add prototype for new function.
525 * init/conf.c (conf_reload_path): Somewhat simplify the case of
526 having parsed a job, we only need to call job_class_consider() now
527 to have it dealt with.
528 (conf_file_destroy): Likewise after removing the ConfFile from the
529 source (so it won't get considered) and marking the job class as
530 deleted, we only need to call job_class_reconsider() and check the
531 return value to see whether we've been replaced.
532 (conf_select_job): In return we provide the function to decide which
533 of the available job sources is the best one.
534 * init/tests/test_conf.c: Update types in tests.
535 (test_select_job): Test the new function.
536
Scott James Remnant11168f32008-04-29 19:46:03 +0100537 * init/parse_job.h: Update to include job_class.h and update prototype
538 to return JobClass, we'll keep the name though since we'll never
539 parse jobs and otherwise things get annoying.
540 * init/parse_job.c: Update to work on job classes.
541 * init/tests/test_parse_job.c: Update to match.
542
Scott James Remnant07336532008-04-29 19:45:51 +0100543 * init/job_class.h (JobClass): Factor out old JobConfig object into
544 a new JobClass object with the same properties, but in its own source
545 file.
546 (ExpectType): Rename old JobExpect to this to match other enums.
547 (ConsoleType): Move along with the object that uses it.
548 * init/job_class.c (job_class_init, job_class_new)
549 (job_class_environment): Bring along methods that only operate on
550 a JobClass, cleaning them up in the process.
551 (job_class_consider, job_class_reconsider): Replace job_config_replace
552 with these two functions that may be used for a new job class and
553 when discarding or finishing with an old one respectively.
554 * init/tests/test_job_class.c: Tests for the functions.
555 * init/Makefile.am (init_SOURCES): Build and link job class source
556 and header.
557 (TESTS): Build and run job class test suite.
558 (test_job_class_SOURCES, test_job_class_LDFLAGS)
559 (test_job_class_LDADD): Details for job class test suite.
560 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
561 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
562 (test_control_LDADD): Link job class code to other tests too.
563
Scott James Remnantf92d4832008-04-28 20:32:35 +01005642008-04-28 Scott James Remnant <scott@netsplit.com>
565
Scott James Remnantbee70f52008-04-28 22:09:23 +0100566 * init/control.c (control_job_config_path, control_job_path): Add
567 functions to generate D-Bus object paths for jobs and instances
568 (control_path_append): and a static function used by both to append
569 escaped path elements.
570 * init/control.h: Add prototypes.
571 * init/tests/test_control.c (test_job_config_path)
572 (test_job_path): Add test cases for the new functions.
573 * init/job.h (JobConfig, Job): Add path member to both structures.
574 * init/job.c (job_config_new, job_new): Initialise the path members.
575 * init/tests/test_job.c (test_config_new, test_new): Make sure
576 the path members are initialised to something sensible.
577 * init/init.supp: Valgrind whines, I do not know why.
578
Scott James Remnantf92d4832008-04-28 20:32:35 +0100579 * init/control.c (control_bus_open): Call out to register objects
580 on the new bus connection.
581 (control_register_all): Start off by registering the connection
582 manager object, no methods/signals for now.
583 * init/tests/test_control.c (test_bus_open): Make sure the manager
584 object is registered.
585
Scott James Remnant00c71a02008-04-27 23:04:17 +01005862008-04-27 Scott James Remnant <scott@netsplit.com>
587
Scott James Remnanta6cb3542008-04-27 23:10:55 +0100588 * init/tests/test_control.c (test_bus_open): Correct name of
589 error macro.
590
Scott James Remnant00c71a02008-04-27 23:04:17 +0100591 * init/job.c (job_emit_event): Make INSTANCE the second variable.
592 * init/tests/test_job.c (test_next_state): Update tests.
593
Scott James Remnant7fbefc12008-04-25 00:51:18 +01005942008-04-25 Scott James Remnant <scott@netsplit.com>
595
596 * init/tests/test_control.c (test_bus_open): Use D-bus macros for
597 error strings instead of naming them by hand.
598
Scott James Remnantaec48692008-04-22 07:44:48 +01005992008-04-22 Scott James Remnant <scott@netsplit.com>
600
601 * init/tests/test_control.c (test_bus_close): Add another missing
602 call to dbus_shutdown.
603
Scott James Remnant7e965822008-04-21 22:41:11 +01006042008-04-21 Scott James Remnant <scott@netsplit.com>
605
606 * init/tests/test_control.c (test_bus_open): Under valgrind we seem
607 to get NoReply instead of Disconnected which is a wee bit odd.
608 Add missing call
609 (test_bus_disconnected): Add missing call to dbus_shutdown.
610
Scott James Remnant30555d52008-04-19 11:52:04 +01006112008-04-19 Scott James Remnant <scott@netsplit.com>
612
Scott James Remnantfbdd3cd2008-04-19 19:42:31 +0100613 * init/process.c: Add missing limits.h include
614
Scott James Remnant15a1eea2008-04-19 16:47:32 +0100615 * init/job.h (JobConfig): Merge instance and instance_name; if
616 instance is set, the job is multi-instance with the name derived
617 from that; if unset the job is singleton. We will not support
618 unlimited instances.
619 * init/job.c (job_config_new): Initialise instance to NULL.
620 (job_new): Assert that name is set for instance jobs.
621 (job_instance): Alter to only deal with singleton and instance
622 jobs, the unlimited instances case is gone.
623 (job_handle_event): Use instance instead of instance_name
624 * init/tests/test_job.c (test_config_new): Check instance is NULL
625 (test_find_by_pid): Adjust the way instance jobs are made, which
626 means we have to pass a name to job_config_new now.
627 (test_instance): Adjust tests to remove unlmited-instance tests
628 and pass name to job_config_new
629 (test_change_state, test_run_process): Pass instance name to
630 job_new as an allocated argument rather than waiting to set it
631 until afterwards.
632 (test_handle_event): Set instance instead of instance_name
633 * init/parse_job.c (stanza_instance): Make the argument mandatory.
634 * init/tests/test_parse_job.c (test_stanza_instance): Remove the
635 checks for without argument, and make sure that without argument
636 is an error.
637
Scott James Remnantc75e8242008-04-19 13:01:43 +0100638 * init/parse_job.c (stanza_oom): Oops, forgot to free never arg.
639
Scott James Remnant4e3365d2008-04-19 13:00:42 +0100640 * init/job.h (JobConfig): NihList is rather overkill for emits,
641 which is static configuration; turn into a NULL-terminated array
642 which'll make it easier to turn into a D-Bus property later.
643 * init/job.c (job_config_new): Initialise to NULL now.
644 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
645 * init/parse_job.c (stanza_emits): Store in an array instead.
646 * init/tests/test_parse_job.c (test_stanza_emits): Redo tests.
647
Scott James Remnant264f7e92008-04-19 12:55:58 +0100648 * init/job.c (job_emit_event): Append exported variables to the
649 job event without overwriting the builtins.
650 * init/tests/test_job.c (test_change_state): Check that exported
651 environment is added to the job events.
652
Scott James Remnant4b7b9d72008-04-19 12:39:52 +0100653 * init/parse_job.c (stanza_export): Parse a new export stanza,
654 which takes one or more environment variable names.
655 * init/tests/test_parse_job.c (test_stanza_export): Test the new
656 stanza.
657
Scott James Remnant65da8662008-04-19 12:28:44 +0100658 * init/job.h (JobConfig): Add new export member.
659 * init/job.c (job_config_new): Initialise to NULL.
660 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
661
Scott James Remnantf2f53652008-04-19 12:15:47 +0100662 * init/environ.c (environ_add, environ_set): Add a replace argument
663 which when FALSE does not replace existing entries in the environment
664 table.
665 * init/environ.h: Adjust prototypes.
666 * init/tests/test_environ.c (test_add): Add tests for non-replacement
667 mode, including corner cases.
668 (test_set): Replace should be TRUE in this test.
669 * init/event.c (event_operator_collect): Always replace existing
670 environment members.
671 * init/job.c (job_config_environment, job_run_process): Always replace
672 existing environment members.
673 (job_emit_event): Always replace existing environment members, and
674 rework this function to get rid of the confusing gotos.
675
Scott James Remnant30555d52008-04-19 11:52:04 +0100676 * init/tests/test_job.c (test_change_state): Add tests to make sure
677 we include the INSTANCE variable in the event environment.
678
Scott James Remnant9fab4e92008-04-18 13:19:06 +01006792008-04-18 Scott James Remnant <scott@netsplit.com>
680
Scott James Remnantd8fe7022008-04-18 18:24:43 +0100681 * init/process.c (process_kill): Make sure we do send the signal to
682 the process group; in practice this makes no difference, but it pays
683 to be explicit in such things.
684 * init/tests/test_process.c (test_kill): Add a test case for when
685 the session leader is no more.
686
Scott James Remnantac3d4ea2008-04-18 18:11:47 +0100687 * init/job.h (JobConfig): Another day, another obscure job config
688 detail. This one is for adjusting how likely you are to be killed
689 by the OOM Killer.
690 * init/job.c (job_config_new): Set to zero by default.
691 * init/tests/test_job.c (test_config_new): And make sure it is zero.
692 * init/parse_job.c (stanza_oom): And it helps to have a function
693 to set that one.
694 * init/tests/test_parse_job.c (test_stanza_oom): Test it.
695 * init/errors.h: And we need an error if its out of bounds.
696 * init/conf.c (conf_reload_path): Which also needs to be caught.
697 * init/process.c (process_spawn): Of course, we have to do something
698 with the oom adjustment.
699 (process_error_read): message for failure error.
700 * init/process.h (processErrorType): And need an error if it fails
701
Scott James Remnant7c1accf2008-04-18 13:32:01 +0100702 * init/main.c: Drop the legacy configuration directory, the format
703 of jobs has changed sufficiently to not support it.
704 * init/Makefile.am (AM_CPPFLAGS): Remove LEGACY_CONFDIR definition.
705 (install-data-local): Don't create it, either.
706
Scott James Remnantaaa59582008-04-18 13:30:05 +0100707 * init/enum.c, init/enum.h, init/tests/test_enum.c: Remove these
708 source files, a hold-over from when we had them in a separate
709 library and passed around the integer values.
710 * init/job.c, init/job.h, init/tests/test_job.c: Restore in their
711 proper place.
712 * init/Makefile.am: Remove enum.* from build instructions.
713
Scott James Remnantf8491442008-04-18 13:19:24 +0100714 * init/main.c: Attempt to connect to the system bus on startup,
715 but don't expect it to work.
716
Scott James Remnant9fab4e92008-04-18 13:19:06 +0100717 * init/control.c (control_bus_open, control_bus_disconnected)
718 (control_bus_close): Functions to open a connection to the D-Bus
719 system bus, clean up if disconnected or disconnect ourselves
720 explicitly.
721 * init/control.h: Prototypes.
722 * init/tests/test_control.c (test_bus_open)
723 (test_bus_disconnected, test_bus_close): Test the functions using
724 a fake D-Bus system bus daemon.
725 * init/errors.h: Add error for "name taken".
726 * init/Makefile.am (init_SOURCES): Build and link control.c and
727 control.h
728 (TESTS): Build and run control test suite.
729 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
730 Details for control test suite.
731 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
732 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
733 Link control.o
734
Scott James Remnantf8db5892008-04-16 14:39:59 +01007352008-04-16 Scott James Remnant <scott@netsplit.com>
736
737 * init/job.h (JobConfig): Add leader member.
738 * init/job.c (job_config_new): Initialise leader to FALSE.
739 * init/tests/test_job.c (test_config_new): Make sure leader is FALSE.
740 (test_change_goal, test_change_state, test_run_process)
741 (test_kill_process, test_child_handler, test_handle_event)
742 (test_handle_event_finished): Jobs have to be leaders now to allow
743 waitpid() to work in test cases.
744 * init/parse_job.c (stanza_session): Parse "session leader" stanza
745 to set to TRUE.
746 * init/tests/test_parse_job.c (test_stanza_session): Test new
747 stanza parsing.
748 (test_stanza_console): Add missing "missing argument" test.
749 * init/process.c (process_error_read): Deal with new fork error.
750 (process_spawn): If we're not to be a session leader, fork again and
751 write the pid back on the open socket.
752 * init/process.h (ProcessErrorType): Introduce new fork error.
753 * init/tests/test_process.c (test_spawn): Test that we can't start
754 a non-session-leader and still have process details.
755 (test_spawn, test_kill): Other jobs have to be leaders now to
756 allow waitpid() to work.
757 * init/tests/test_event.c (test_poll): Jobs have to be leaders now
758 to allow waitpid() to work.
759
Scott James Remnant048c79a2008-04-12 11:11:22 +01007602008-04-12 Scott James Remnant <scott@netsplit.com>
761
Scott James Remnant477d9d42008-04-12 14:07:48 +0100762 * configure.ac (NIH_INIT): Require that libnih build D-Bus support,
763 failing configure if we can't get it.
764 * init/Makefile.am (AM_CFLAGS): Build with D-Bus CFLAGS,
765 (init_LDADD, test_process_LDADD, test_job_LDADD, test_event_LDADD)
766 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): and
767 link with libnih-dbus.la and D-Bus LIBS.
768 (init_LDFLAGS): No need for -static now since libnih will only exist
769 statically anyway.
770
Scott James Remnant2c0bd592008-04-12 12:31:49 +0100771 * init/main.c: Use a better name for kbdrequest
772 * init/event.h (KBDREQUEST_EVENT): Rename event to keyboard-request
773
Scott James Remnant4b56d6f2008-04-12 12:23:15 +0100774 * init/main.c: Drop the attempt to rescue a crashed system by
775 carrying on with no state
776 (crash_handler): After the child has core dumped, the parent will
777 die and the kernel will panic. That's the best we can do, I think.
778
Scott James Remnant6fd5acc2008-04-12 12:10:27 +0100779 * init/job.c (job_change_state): Don't generate the stalled event;
780 there's nothing useful you can do with it other than start a root
781 shell and that's just a security hole waiting to happen.
782 (job_new): Don't increment the instances counter.
783 * init/job.h: Remove extern for instances counter.
784 * init/tests/test_job.c (test_new): Remove the check that the
785 instance counter is incremented.
786 (test_change_state): Remove the test for the stalled event.
787 * init/event.h (STALLED): Remove stalled event definition,
788 * TODO: Update.
789
Scott James Remnant830370a2008-04-12 11:51:45 +0100790 * init/job.h (Job): And while we're at it, the instance name is
791 guaranteed unique for a given job name, which is also guaranteed
792 to be unique - so don't bother with job ids either, since they
793 also get reused in bad cases.
794 * init/job.c (job_next_id): Drop this function.
795 (job_new): Don't assign an id anymore.
796 (job_find_by_id): Drop this function.
797 (job_run_process): Set UPSTART_INSTANCE to the instance name if set.
798 (job_name): Function to create the string used in messages.
799 (job_change_goal, job_change_state, job_run_process)
800 (job_kill_process, job_kill_timer, job_child_handler)
801 (job_process_terminated, job_process_trace_new)
802 (job_process_trace_new_child, job_process_trace_signal)
803 (job_process_trace_fork, job_process_trace_exec): Use the instance
804 name in messages (if set) in place of the job id.
805 * init/tests/test_job.c (test_new): Drop checks on the id field.
806 (test_find_by_id): Drop test.
807 (test_run_process): Check that UPSTART_INSTANCE is set only for
808 named job instances, and contains the instance name.
809 (test_change_state, test_run_process, test_child_handler): Remove
810 id setting and update error message checks.
811 * TODO: Update.
812
Scott James Remnant048c79a2008-04-12 11:11:22 +0100813 * init/event.h (Event): We don't use the id field for anything;
814 and it can't be guaranteed to be unique since it can wrap over
815 and get reused. Drop it.
816 * init/event.c (event_next_id): Drop this function.
817 (event_new): Don't assign an id anymore.
818 (event_find_by_id): Drop this function.
819 * init/tests/test_event.c (test_new): Drop checks on the id field
820 (test_find_by_id): Drop test.
821 (test_poll): Drop id setting which was needless anyway.
822
Scott James Remnant4dce7b32008-04-11 10:47:08 +01008232008-04-11 Scott James Remnant <scott@netsplit.com>
824
Scott James Remnantf2874b82008-04-11 14:55:27 +0100825 * init/tests/test_job.c (test_child_handler): Add tests to make
826 sure that respawn works for both services and tasks; the only
827 difference we want for tasks is that zero is a normal exit code.
828 * init/job.c (job_process_terminated): Status need not be non-zero
829 if the job is not a task.
830
Scott James Remnant2c1c57f2008-04-11 14:41:55 +0100831 Change the default job type from task to service, which will
832 finally match people's expectations.
833
834 * init/job.h (JobConfig): Replace service member with task
835 * init/job.c (job_config_new): Initialise task to FALSE
836 (job_change_state): Unblock if not a task instead of if a service
837 * init/tests/test_job.c (test_config_new): Make sure task is FALSE
838 (test_change_state): Check service by default, task with flag;
839 this also means we expect blockers to be cleared if we end up in
840 running for the other checks
841 (test_child_handler): Expect blockers to be cleared if we end up
842 in running now that service is the default.
843 * init/tests/test_event.c (test_poll): Test with a task since
844 we want to remain blocked for longer.
845 * init/parse_job.c (stanza_respawn): Don't set service to TRUE
846 (stanza_service): Rename to stanza_task and set task flag instead
847 * init/tests/test_parse_job.c (test_stanza_respawn): Remove checks
848 for setting of service flag
849 (test_stanza_service): Rename to test_stanza_task and test task
850
Scott James Remnant4dce7b32008-04-11 10:47:08 +0100851 * init/job.c (job_init): Create hash using nih_hash_string_new()
852 * init/conf.c (conf_source_new): Likewise.
853
Scott James Remnantf8f19e92008-03-08 01:41:51 +00008542008-03-08 Scott James Remnant <scott@netsplit.com>
855
Scott James Remnantb598eba2008-03-08 18:17:38 +0000856 * HACKING: Terminology changes: Bazaar-NG is now just Bazaar;
Scott James Remnantf6466b42008-04-11 10:38:04 +0100857 Malone is now just Launchpad's bug tracking system. Update bugs
Scott James Remnantb598eba2008-03-08 18:17:38 +0000858 URL to match modern form.
859
Scott James Remnant76e3bc92008-03-08 16:12:12 +0000860 * init/enum.h (JobWaitType): Rename to JobExpect
861 * init/job.h (JobConfig): Rename wait_for to expect
862 * init/job.c (job_config_new, job_change_state, job_run_process)
863 (job_process_stopped, job_process_trace_new_child): Rename wait_for
864 to expect in all occurances.
865 * init/tests/test_job.c: Likewise rename all occurances.
866 * init/parse_job.c (stanza_wait): Rename to stanza_expect and drop
867 the intermediate argument.
868 * init/tests/test_parse_job.c (test_stanza_wait): Rename to
869 test_stanza_expect and adjust tests to match new syntax.
870 * init/tests/test_process.c (test_spawn): Remove set of wait_for.
871
Scott James Remnantda695302008-03-08 01:50:56 +0000872 * doc/states.dot: Remove the state transition from starting to
873 waiting ("emit_stopped" in the graph); we don't have a "respawning
874 too fast" exit here anymore, so always go to stopping.
875 * doc/states.png: Regenerate.
876
Scott James Remnantf8f19e92008-03-08 01:41:51 +0000877 * TODO: Document the problems with overflowing ids and instance
878 counter before I forget about them.
879
Scott James Remnant7b6c16c2008-03-07 15:16:29 +00008802008-03-07 Scott James Remnant <scott@netsplit.com>
881
Scott James Remnantd62ef892008-03-07 23:20:50 +0000882 * TODO: Update.
883
Scott James Remnantdebbdc92008-03-07 23:20:34 +0000884 * init/job.h (JobConfig): Add instance_name member.
885 (Job): Add name member.
886 * init/job.c (job_config_new): Initialise instance name to NULL.
887 (job_new): Accept the name as an argument, reparenting and stealing
888 (job_handle_event): Expand the instance name and pass to job_new
889 (job_instance): Accept a name and look that up in the list of current
890 instances returning the instance if found.
891 * init/tests/test_job.c: Add extra argument to all job_new calls
892 (test_config_new): Make sure instance name is initialised to NULL.
893 (test_handle_event): Make sure the job name is set from the instance,
894 and make sure an existing instance is reused if we can.
895 (test_instance): Make sure that the existing instance is returned.
896 * init/parse_job.c (stanza_instance): Check for an optional argument
897 and store it in the instance_name member if it exists, otherwise
898 free and reset the instance_name member.
899 * init/tests/test_parse_job.c (test_stanza_instance): Check the new
900 argument is handled properly and stored in the right place.
901 * init/tests/test_conf.c (test_source_reload_job_dir)
902 (test_file_destroy): Add extra NULL to job_new
903 * init/tests/test_event.c (test_poll): Add extra NULL to job_new
904
Scott James Remnant6f857582008-03-07 21:32:53 +0000905 * init/event.c (event_operator_match): Accept an environment array
906 and expand the operator value against it before attempting to match.
907 (event_operator_handle): Also accept the environment array and pass
908 through to calls to event_operator_match().
909 * init/event.h: Update prototypes.
910 * init/tests/test_event.c (test_operator_match): Add extra NULL
911 argument to most tests, and add tests for known and unknown variable
912 references.
913 (test_operator_handle): Add extra NULL arguments to most tests, and
914 add test for passing of environment through.
915 (test_operator_reset): Add extra NULL argument to call.
916 * init/job.c (job_handle_event): Pass the job environment for the
917 stop event handling, but NULL for the start event.
918 * init/tests/test_job.c (test_handle_event): Make sure that a stop
919 operator is expanded from the job environment before being matched
920 against the stop event.
921
Scott James Remnant7d4ffbb2008-03-07 20:56:15 +0000922 * init/event.c, init/event.h, init/environ.c: Documentation tweaks.
923
Scott James Remnantb605dfc2008-03-07 19:24:52 +0000924 * init/job.c (job_change_state): Remove the code to check for runaway
925 jobs from here, we'll always let people explicitly start an instance.
926 (job_process_terminated): Call job_catch_runaway when actually doing
927 the respawn instead.
928 * init/tests/test_job.c (test_change_state): Remove "too fast" checks,
929 we're going to allow start/stop requests to restart jobs as much as
930 they like since this is an external request.
931 (test_handle_event, test_handle_event_finished): No need to remove
932 a respawn limit with this behaviour.
933 (test_child_handler): Instead check that the respawn counter is
934 dealt with by the child handler.
935
Scott James Remnant67e86ff2008-03-07 18:38:12 +0000936 * TODO: Update, I found a bug with the current model.
937
Scott James Remnant7b6c16c2008-03-07 15:16:29 +0000938 * init/tests/test_environ.c (test_expand): Check that a string
939 without an expansion still works ok.
940
Scott James Remnant46ba8e92008-03-06 20:24:08 +00009412008-03-06 Scott James Remnant <scott@netsplit.com>
942
943 * init/event.c (event_operator_collect): Just use strcat functions.
944
Scott James Remnanta8430552008-03-03 00:28:51 +00009452008-03-03 Scott James Remnant <scott@netsplit.com>
946
Scott James Remnant7d2c9fb2008-03-03 17:29:13 +0000947 * init/environ.c (environ_valid): New function to check the validity
948 of an environment variable name, should call before accepting any.
949 (environ_expand_until): New function to expand variable references
950 in a string using an environment table; supports a few common
951 shell-like expressions.
952 (environ_getn): Change to return the value of the string, not the
953 entire environment string.
954 * init/environ.h: Add prototypes.
955 * init/errors.h: Add errors raised by new functions.
956 * init/tests/test_environ.c (test_valid, test_expand): Add test
957 cases for the new functions.
958 (test_get, test_getn): Change test case to check for the variable
959 value instead of returning the whole string.
960
Scott James Remnant2c342d92008-03-03 10:52:29 +0000961 * TODO: Add thoughts on blocking commands.
962
Scott James Remnant62f2d862008-03-03 02:13:19 +0000963 * TODO: Update.
964
Scott James Remnant089298d2008-03-03 01:48:34 +0000965 * init/event.h (Event): Remove the refs member; we now never hold
966 a reference to an event we're blocking since we always copy the
967 environment out if we want to keep it.
968 (EventOperator): Events are always blocked while we hold them,
969 so drop the blocked member.
970 (EventProgress): The done state is no longer needed, we can free
971 in finished now.
972 * init/event.c (event_ref, event_unref): Drop these functions.
973 (event_new): Don't ininitialise the refs member since it's gone.
974 (event_poll): Remove the done state since it's directly freed
975 in event_finished again
976 (event_finished): No done state, event is freed before return.
977 (event_operator_new): No blocked member.
978 (event_operator_copy): Always block the event after copying.
979 (event_operator_destroy): Simply unblock.
980 (event_operator_handle): Simply block the event on match.
981 (event_operator_collect): Always block the copied event
982 (event_operator_unblock): This function is no longer required, since
983 it has an identical effect to reset.
984 (event_operator_reset): Simply unblock the event.
985 * init/tests/test_event.c (test_new): Drop the check for refs
986 being initialised to zero.
987 (test_ref, test_unref, test_operator_collect): Drop test for
988 functions that have been dropped in the code.
989 (test_operator_new): Drop the check for blocked being initialised
990 to FALSE.
991 (test_block, test_unblock, test_operator_destroy): Drop any references
992 to the refs member.
993 (test_operator_destroy): Actually fix the function to test things.
994 (test_poll): Drop the check for remaining in the done state.
995 (test_operator_new, test_operator_copy): Drop the checks for blocked.
996 (test_operator_handle, test_operator_collect, test_opreator_reset):
997 Drop references to refs and blocked.
998 * init/job.c (job_unblock, job_handle_event): Drop the call to
999 event_unref() since the next call was always event_unblock() and
1000 that's the one that we didn't delete.
1001 * init/tests/test_job.c (test_change_state, test_child_handler)
1002 (test_handle_event, test_handle_event_finished): Events don't
1003 have references anymore, so remove calls to reference, unreference
1004 and checks for the reference count - it's all done with blocks now.
1005 (test_new): Remove check that the operator is not blocked for a
1006 new job since there's no such thing now.
1007 (test_handle_event): Operators don't have a blocked member anymore,
1008 if there's an event, it's blocked.
1009
Scott James Remnant00ad0002008-03-03 01:15:39 +00001010 * init/job.c (job_change_state): Don't reference the event we're
1011 blocked on, we'll always know when it's finished.
1012 (job_handle_event_finished): Likewise no reason to unreference it.
1013 * init/tests/test_job.c (test_change_goal, test_child_handler)
1014 (test_handle_event, test_change_state)
1015 (test_handle_event_finished): Remove the expectation that the blocked
1016 event is referenced by the job.
1017 * init/tests/test_event.c (test_poll): Don't reference the event,
1018 since the job would not have.
1019
Scott James Remnant66fe4e22008-03-03 01:07:16 +00001020 * init/job.c (job_emit_event): Use environ_add/set for style
1021 reasons.
1022
Scott James Remnantd719fdc2008-03-03 00:52:52 +00001023 * init/job.c (job_handle_event): Reset the stop_on operator after
1024 processing the event, thus the expression needs to be completely
1025 reevaluated before the job can be stopped again by it. At last,
1026 correct behaviour!
1027 (job_change_state): No reason to reset the stop_on operator when
1028 starting since it's always reset after evaluating to TRUE now;
1029 likewise no reason to reset on re-entering running or waiting,
1030 job_unblock() is sufficient.
1031 (job_failed): No reason to iterate stop_on to set failed, it's
1032 empty - job_unblock() does what we want.
1033 * init/tests/test_job.c (test_handle_event): Check that the operator
1034 is actually reset and the event not referenced when handling from
1035 the event.
1036 (test_change_state, test_child_handler): Don't put anything in stop_on
1037 and thus don't expect anything to come out of it -- event environment
1038 is all done in stop_env and blocking done in blocking.
1039
Scott James Remnanta8430552008-03-03 00:28:51 +00001040 * init/job.c (job_handle_event): Collect the stop events and store
1041 them in the blocking list, unblocking any that were there before
1042 such as the start events.
1043 (job_change_state): Unblock blocking events when returning to running
1044 from pre-stop.
1045 * init/tests/test_job.c (test_handle_event): Make sure the stop
1046 events are collected and replace any previously blocking events.
1047 (test_change_state, test_child_handler): Test that stop events in
1048 the blocking list are kept and unblocked when necessary.
1049
Scott James Remnante4be2c52008-03-02 00:05:47 +000010502008-03-02 Scott James Remnant <scott@netsplit.com>
1051
Scott James Remnant8e402682008-03-02 23:45:31 +00001052 * init/job.c (job_change_state): Shouldn't emit the started event
1053 on pre-stop cancellation, and shouldn't unblock the job because
1054 it's a service.
Scott James Remnanta8430552008-03-03 00:28:51 +00001055
Scott James Remnant56ec5602008-03-02 22:42:21 +00001056 * init/job.c (job_change_state): Throw away the stop environment
1057 when starting and returning to running.
1058 * init/tests/test_job.c (test_change_state): Make sure the stop
1059 environment is actually thrown away.
1060
Scott James Remnant3a06f5c2008-03-02 22:30:17 +00001061 * init/job.c (job_run_process): Append the environment from the
1062 stop events if given the pre-stop process to run; do this before
1063 the special events so they can never be overriden.
1064 * init/tests/test_job.c (test_run_process): Check that the stop event
1065 environment is included for pre-stop and not for other jobs.
1066
Scott James Remnant562a4f12008-03-02 22:20:27 +00001067 * init/job.c (job_handle_event): Remove setting of UPSTART_JOB
1068 and UPSTART_JOB_ID, we set that when we run the process.
1069 * init/tests/test_job.c (test_handle_event): Don't check for
1070 UPSTART_JOB and UPSTART_JOB_ID since we no longer copy it in here.
1071
Scott James Remnant99c6e4a2008-03-02 22:18:14 +00001072 * init/job.c (job_run_process): Copy the environment to pass it to
1073 the job, appending the UPSTART_JOB and UPSTART_JOB_ID variables here;
1074 we never want to be able to match these, etc.
1075 * init/tests/test_job.c (test_run_process): Add tests to make sure
1076 that the environment is actually set in the processes we run.
1077
Scott James Remnant96986832008-03-02 21:52:50 +00001078 * init/job.h (Job): Add stop_env member to store environment from
1079 stop events for the stop script.
1080 * init/job.c (job_new): Initialise stop_env to NULL.
1081 (job_handle_event): Copy environment from the stop_on operator into
1082 the stop_env member.
1083 * init/tests/test_job.c (test_new): Check that stop_env is NULL.
1084 (test_handle_event): Add lots of tests to make sure that the
1085 environment is collected from the events and stored in stop_env
1086 properly, overwriting what was there already if necessary.
1087
Scott James Remnantf1755ad2008-03-02 20:42:00 +00001088 * init/init.supp (job-run-process-args): Add a suppression for the
1089 fact that job_run_process will leak its arguments to a new process
1090 assuming that it will call exec() or exit()
1091
Scott James Remnant5f68a522008-03-02 20:41:19 +00001092 * init/tests/test_job.c (test_child_handler): Remove bogus free tag
1093 of the list, which we don't use in this test (valgrind failure)
1094
Scott James Remnantdd6e9422008-03-02 20:40:45 +00001095 * init/job.h (Job): Remove the start_on member.
1096 * init/job.c (job_new): Don't initialise start_on since it's gone.
1097 (job_change_state): Drop call to unblock the start_on operator since
1098 the events are already unblocked by job_unblock.
1099 (job_failed): Drop setting of start_on events to failed since this
1100 is already done by job_unblock. This results in a slight change in
1101 behaviour, now when a job fails to start - the event or command will
1102 be immediately unblocked since there's no point waiting until it
1103 stops again - it was waiting for it to start.
1104 * init/tests/test_job.c (test_new): Remove start_on checks
1105 (test_change_state, test_child_handler, test_handle_event): Remove
1106 all references to start_on, instead relying on the blocking checks
1107 instead.
1108 * init/tests/test_event.c (test_poll): Remove solitary reference
1109 to job's start_on, this wasn't necessary anyway - we proved that it
1110 was the right event by affecting the job. Revert previous commit
1111 that temporarily increased the number of references, they should be
1112 one again now only the blocking list holds them.
1113
Scott James Remnant37305082008-03-02 20:08:07 +00001114 * init/job.h (job): Add blocking member, a list of events that we're
1115 blocking from finishing.
1116 * init/job.c (job_new): Initialise blocking member to NULL.
1117 (job_handle_event): Collect the list of events from the operator
1118 and store them in the job's blocking list (unblocking any existing
1119 first); if the job is already running, unblock unref and discard.
1120 (job_unblock): New function to deal with unblocking the events we're
1121 holding onto and resetting the blocking list; this will be extended
1122 later to also unblock any command.
1123 (job_change_state): Unblock events in running for services and in
1124 waiting for everything.
1125 (job_failed): Unblock events and mark them as failed.
1126 * init/tests/test_job.c (test_new): Check that it's initialised to NULL
1127 (test_handle_event): Extend the test cases to check the value of the
1128 blocking list, and to make sure that the previous blocking list is
1129 overwritten when necessary.
1130 (test_change_state, test_child_handler): Extend test cases so that
1131 wherever we're had a blocked event in start_on, we also have that in
1132 the blocking list.
1133 * init/tests/test_event.c (test_poll): Temporarily increase the
1134 expected number of references/blockers to the event in the poll
1135 test.
1136
Scott James Remnanteec6b102008-03-02 12:24:22 +00001137 * init/job.h (Job): Add start_env member, this stores the environment
1138 to use when starting the event so it doesn't overwrite the current
1139 environment of a restarting job.
1140 * init/job.c (job_handle_event): Do the heavy lifting of starting a
1141 new job instance here; construct the environment from the built-ins
1142 and configured, append that collected from the start events, locate
1143 or create a new instance, add the job name and id then copy into
1144 the new start_env member before starting the job. At some point
1145 this will probably all become a function since it'll be similar for
1146 the control functions.
1147 (job_change_state): Copy the start_env member into the env member
1148 when in the starting state; thus the job environment remains the same
1149 until restarted.
1150 (job_new): Remove code to initialise the environment, we now do that
1151 when actually starting the instance.
1152 * init/tests/test_job.c (test_handle_event): Add test cases for
1153 starting the job, making sure that the environment is correctly
1154 copied into the right field and also checking what happens if it's
1155 already stopping or running.
1156 (test_change_state): Make sure that start_env is correctly copied
1157 over into env, overwriting what is there if non-NULL or keeping it
1158 if NULL.
1159 (test_new): Remove checks for environment setup, since we don't do
1160 that anymore here; replace with checking for NULL and restore the
1161 alloc fail tests.
1162 * TODO: Update.
1163
Scott James Remnant377f6162008-03-02 02:23:52 +00001164 * init/environ.c (environ_add): Allow it to accept NULL length, since
1165 we can't always keep that around.
1166
Scott James Remnantf83e4cf2008-03-02 01:33:06 +00001167 * init/process.c (process_spawn): Accept the environment list as
1168 a parameter, then finally we can change this function to take a
1169 JobConfig as the first argument.
1170 (process_error_read): Remove the associated error handler.
1171 * init/process.h: Change prototype.
1172 (ProcessErrorType): Remove error enum for environment.
1173 * init/tests/test_process.c (test_spawn): Update calls in test to
1174 just pass in an environment array (direct testing).
1175 * init/job.c (job_run_process): Pass configuration and environment
1176 to process_spawn.
1177
Scott James Remnantaf44bfe2008-03-02 01:22:29 +00001178 * init/process.c (process_spawn): Take the environment directly out
1179 the job structure, rather than recreating it.
1180 (process_environment): Drop function, absorbed elsewhere.
1181 * init/process.h: Remove prototype.
1182 * init/tests/test_process.c (test_spawn): Set the job_id variable
1183 before calling job_new and set config->start_on instead of
1184 job->start_on so that job_new can pick up both.
1185 (test_environment): Remove test cases.
1186
Scott James Remnant01c0ba72008-03-02 01:16:10 +00001187 * init/job.h (Job): finally gains env pointer of its own.
1188 * init/job.c (job_new): Initialise the environment, moving the last
1189 of the code from process_environment -- this is only temporary
1190 though in the interests of refactoring, it'll move out of here again
1191 soon enough.
1192 * init/tests/test_job.c (test_new): Make sure that the environment is
1193 set in a manner which tests the overriding of things by other things;
1194 we have to temporarily comment out the alloc fail stuff though :-(
1195
Scott James Remnant61b11fc2008-03-02 01:16:03 +00001196 * init/event.c (event_operator_collect): Make list the last argument
1197 for consistency with future functions.
1198 * init/event.h: Update prototype.
1199 * init/tests/test_event.c (test_operator_collect): Swap arguments.
1200 * init/process.c (process_environment): Update.
1201
Scott James Remnanta6ce1292008-03-02 00:24:08 +00001202 * init/job.c (job_config_environment): Function to generate an
1203 environment table from a JobConfig, code largely moved from process.c
1204 * init/job.h: Add protoyype.
1205 (JOB_DEFAULT_ENVIRONMENT): List of environment variables to always
1206 copy from the environment (moved from process.h)
1207 * init/tests/test_job.c (test_config_environment): Add test case,
1208 again largely copied from test_process.c
1209 * init/process.c (process_environment): Call job_config_environment
1210 instead of the code moved out.
1211 * init/process.h (PROCESS_ENVIRONMENT): Move to job.h
1212 * TODO: Update.
1213
Scott James Remnante4be2c52008-03-02 00:05:47 +00001214 * TODO: Update.
1215
Scott James Remnantec8ea0e2008-03-01 17:58:15 +000012162008-03-01 Scott James Remnant <scott@netsplit.com>
1217
Scott James Remnant9fd25422008-03-01 23:56:31 +00001218 * init/event.c (event_operator_collect): Create a mega-function to
1219 iterate an EventOperator tree (filtering out those bits that aren't
1220 TRUE) and collect the events, adding them to a linked list, adding
1221 their environment to a table and making a string list for another
1222 environment variable. Fundamentally this function marshals data
1223 out of the Event subsystem into the right format for the Job subsystem.
1224 * init/event.h: Add prototype.
1225 * init/tests/test_event.c (test_operator_collect): Tests for the
1226 collector function; some bits may seem similar to test_process.c
1227 * init/process.c (process_environment): Use event_operator_collect
1228 to gather the environment, instead of its own code (which pretty
1229 much got pasted into event_operator_collect anyway). Force everything
1230 else to allocate matching the caller.
1231 * init/tests/test_process.c (test_spawn, test_environment): Had
1232 forgotten to set the value of the intermediate AND operator to TRUE,
1233 necessary now.
1234
Scott James Remnant8e695502008-03-01 21:34:12 +00001235 * init/process.c (process_environment_add): Move and rename this
1236 function, since it's not really process associated
1237 (process_environment): Change to use environ_add or environ_setf
1238 instead.
1239 * init/process.h: Remove prototype.
1240 * init/environ.c (environ_add): New name/location of
1241 process_environment_add, modified to not take a copy of the string
1242 (environ_set): Wrapper for the above for common dealing with
1243 environment we want to set from a format string.
1244 (environ_get, environ_getn, environ_lookup): Functions to get an
1245 environment variable entry; largely cripped from event.c but
1246 bug-fixed at the same time.
1247 * init/environ.h: Function prototypes.
1248 * init/event.c (event_operator_match): Change to use environ_lookup
1249 * init/tests/test_process.c (test_environment_add): Move the tests.
1250 * init/tests/test_environ.c: Test suite for environment handling
1251 * init/Makefile.am (init_SOURCES): Build environ.c and environ.h
1252 (TESTS): Build environment test suite
1253 (test_environ_SOURCES, test_environ_LDFLAGS, test_environ_LDADD):
1254 Details for environment test suite
1255 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
1256 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
1257 Link environ.o to other test suites
1258
Scott James Remnantec8ea0e2008-03-01 17:58:15 +00001259 * init/job.c (job_new): Increment the number of instances.
1260 (job_instance): Simplify the function, it now only returns the
1261 existing instance or NULL. This makes it easier to extend when
1262 we have env-limited instances later on.
1263 (job_handle_event): If job_instance returns NULL, create
1264 a new instance with job_new() and always reset the operator afterwards.
1265 * init/tests/test_job.c (test_new): Check that the instances variable
1266 is incremented when a new job is created.
1267 (test_instance): Change to check that it returns NULL when there is
1268 no active instance, or for multi-instance jobs, instead of creating
1269 a new one itself.
1270 (test_config_replace, test_find_by_pid)
1271 (test_find_by_id, test_change_goal, test_change_state)
1272 (test_next_state, test_run_process, test_kill_process)
1273 (test_child_handler, test_handle_event)
1274 (test_handle_event_finished): Call job_new to create a new instance
1275 from a config, instead of job_instance.
1276
1277 * init/tests/test_conf.c (test_source_reload_job_dir)
1278 (test_file_destroy): Call job_new to create a new instance from a
1279 config, instead of job_instance.
1280 * init/tests/test_event.c (test_poll): Call job_new to create a new
1281 instance from a config, instead of job_instance.
1282 * init/tests/test_process.c (test_spawn, test_environment): Call
1283 job_new to create a new instance from a config, instead of job_instance
1284
Scott James Remnant9f468de2008-02-29 16:17:17 +000012852008-02-29 Scott James Remnant <scott@netsplit.com>
1286
Scott James Remnant680d2fd2008-02-29 17:41:38 +00001287 * configure.ac: Compare the evaluated $sbindir against the common
1288 things we put in PATH, if it doesn't match, define EXTRA_PATH to
1289 contain it.
1290 * init/paths.h: Append EXTRA_PATH to PATH if defined.
1291
Scott James Remnant9f468de2008-02-29 16:17:17 +00001292 * init/Makefile.am (AM_CPPFLAGS): Replace TELINIT definition with
1293 SBINDIR, pointing at the common directory.
1294 * compat/sysv/Makefile.am (AM_CPPFLAGS): Replace SHUTDOWN definition
1295 with SBINDIR, pointing at the common directory.
1296 * init/paths.h (TELINIT): Redefine to be SBINDIR with "/telinit"
1297 on the end; define SBINDIR if necessary.
1298 * compat/sysv/reboot.c (SHUTDOWN): Redefine to be SBINDIR with
1299 "/shutdown" on the end; define SBINDIR if necessary.
1300
Scott James Remnantc3c78b02008-02-22 14:55:12 +000013012008-02-22 Scott James Remnant <scott@netsplit.com>
1302
Scott James Remnant72da2fe2008-02-22 20:10:53 +00001303 * init/event.c (event_operator_match): Rewrite to match both
1304 positionally and by name.
1305 * init/tests/test_event.c (test_operator_match): Update tests to
1306 check the new behaviour works.
1307
Scott James Remnantff48a242008-02-22 15:46:30 +00001308 * init/parse_job.c (parse_on_operand): Add arguments to env list
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00001309 rather than args; sanity check afterwards to ensure that positional
1310 doesn't follow name-based -- when parsing the job is the right place
1311 to catch this.
Scott James Remnantff48a242008-02-22 15:46:30 +00001312 * init/tests/test_parse_job.c (test_stanza_start)
1313 (test_stanza_stop): Change args to env when checking operators.
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00001314 Check that arguments may be quoted in manners that we expect to be
1315 sane. Check that positional arguments cannot follow name-based ones.
1316 * init/errors.h: Add new error.
1317 * init/conf.c (conf_reload_path): Treat expected variable as a
1318 permanent error.
Scott James Remnantff48a242008-02-22 15:46:30 +00001319
Scott James Remnantd816fbd2008-02-22 15:13:07 +00001320 * init/tests/test_process.c (test_spawn, test_environment):
1321 Update event_new() calls to remove extra argument.
1322
Scott James Remnant36eea462008-02-22 15:11:05 +00001323 * init/main.c (main, cad_handler, kbd_handler, pwr_handler):
1324 Update event_new() calls to remove extra argument.
1325
Scott James Remnantc398d782008-02-22 15:07:54 +00001326 * init/job.c (job_change_state): Update event_new () call.
1327 (job_emit_event): Update to put failure information in environment.
1328 * init/tests/test_job.c (test_new, test_instance)
1329 (test_child_handler, test_handle_event)
1330 (test_handle_event_finished): Remove extra argument to event_new,
1331 rename args to env in operator where necessary.
1332 (test_change_state): Update to check emitted event by full environment.
1333
Scott James Remnant53cb0012008-02-22 14:55:53 +00001334 * init/event.h (Event): Remove args member.
1335 (EventOperator): Rename args member to env.
1336 Update prototypes to match.
1337 * init/event.c (event_new): Remove args member.
1338 (event_finished): Remove copying of args member to failed event.
1339 (event_operator_new): Rename args member to env.
1340 (event_operator_copy): Rename args copying to env.
1341 (event_operator_match): ??
1342 * init/tests/test_event.c (test_new): Update test to remove args.
1343 (test_operator_new): Update test to rename args to env.
1344 (test_operator_copy): Update test to rename args to env.
1345 (test_operator_match): ???
1346
Scott James Remnantc3c78b02008-02-22 14:55:12 +00001347 * TODO: Update with job atomicity notes.
1348
Scott James Remnantc488ddb2008-02-20 16:35:24 +000013492008-02-20 Scott James Remnant <scott@netsplit.com>
1350
Scott James Remnant37fb28a2008-02-20 16:38:01 +00001351 * init/job.c: Switch around job_find_by_pid and job_find_by_id
1352 * init/job.h: Likewise.
1353
Scott James Remnantc488ddb2008-02-20 16:35:24 +00001354 * init/job.h: Update prototypes to match variable names in the
1355 code.
1356
Scott James Remnant676c9052008-02-17 16:08:40 +000013572008-02-17 Scott James Remnant <scott@netsplit.com>
1358
Scott James Remnant742d4662008-02-17 18:29:26 +00001359 * init/process.c (process_kill): Change to accept a JobConfig rather
1360 than a Job, since in theory this should only ever need that in a
1361 future where we can specify a kill signal (right now it's not used
1362 for anything!)
1363 * init/process.h: Update prototype.
1364 * init/tests/test_process.c (test_kill): Update test cases.
1365 * init/job.c (job_kill_process, job_kill_timer): Pass in JobConfig
1366 instead of Job.
1367
Scott James Remnantd37dd062008-02-17 18:25:51 +00001368 * init/process.c (process_spawn): Accept trace as an argument instead
1369 of using a random piece of job state to determine whether to trace
1370 or not.
1371 * init/process.h: Update prototype.
1372 * init/tests/test_process.c (test_spawn): Update tests to pass in
1373 via argument whether to trace the job or not.
1374 * init/job.c (job_run_process): Pass in the trace variable rather
1375 than relying on it working it out for itself; this means we don't
1376 need to set the state until after, therefore don't need to reset it.
1377
Scott James Remnant6b1c7ee2008-02-17 18:00:33 +00001378 * AUTHORS, logd/jobs.d/logd.in: Update e-mail addresses.
1379
Scott James Remnant676c9052008-02-17 16:08:40 +00001380 * README: Update kernel recommendation to 2.6.24, since that's
1381 the oldest version that the test suite will complete under.
1382
Scott James Remnanta3239f62008-01-17 03:34:27 +000013832008-01-17 Scott James Remnant <scott@netsplit.com>
1384
Scott James Remnant85a96502008-01-17 03:38:44 +00001385 * TODO: Update.
1386
Scott James Remnantdc4162b2008-01-17 03:37:02 +00001387 * init/job.c (job_run_process): Don't append the list of event
1388 names, they can be found in $UPSTART_EVENTS now. This is better
1389 since it's consistent for exec and script.
1390 * init/tests/test_job.c (test_run_process): Drop test case.
1391
Scott James Remnanta3239f62008-01-17 03:34:27 +00001392 * init/process.c (process_environment): Function to build an
1393 environment table for a job containing built-in variables, those
1394 from the configuration, events and finally the upstart job ones.
1395 (process_environment_add): Helper function for the above that
1396 handles adding a variable to the array; dealing with fetching the
1397 value from init's environment if necessary.
1398 (process_setup_environment): This function now gets dropped in
1399 favour of the new ones.
1400 (process_spawn): Call the new process_environment() function and set
1401 the environ variable directly.
1402 * init/process.h (PROCESS_ENVIRONMENT): Define built-in environment
1403 variables that are always copied from our own environment.
1404 Add prototypes.
1405 * init/tests/test_process.c (test_environment): Check that the
1406 environment is built correctly and that each bit overrides the
1407 right other bit.
1408 (test_environment_add): Check that the array is built correctly.
1409 (test_spawn): Adjust order and values of expected environment
1410 to match what's now set.
1411
Scott James Remnant5c87e6e2008-01-16 00:27:22 +000014122008-01-16 Scott James Remnant <scott@netsplit.com>
1413
Scott James Remnantb150df62008-01-16 03:14:16 +00001414 * init/job.c (job_failed): Separate the logic that marks the job
1415 and its associated events as failed into its own function, since
1416 it's a large enough amount of code that we were otherwise duplicating
1417 everywhere else (and in a few places, failing to mark the events as
1418 failed as well).
1419 (job_change_state, job_process_terminated): Call job_failed instead
1420 of doing it ourselves.
1421 (job_emit_event): De-nest the logic and fix so that we don't add
1422 environment to the failed respawn event.
1423 * init/tests/test_job.c (test_change_state): Add checks on whether
1424 the event was marked as failed or not.
1425
Scott James Remnant340083b2008-01-16 02:06:51 +00001426 * TODO: Update.
1427
Scott James Remnant30bc02b2008-01-16 01:49:20 +00001428 * configure.ac (AC_COPYRIGHT): Update copyright to 2008.
1429
Scott James Remnant4ff4a7d2008-01-16 01:47:20 +00001430 * TODO: Update.
1431
Scott James Remnant75e801a2008-01-16 00:44:17 +00001432 * init/tests/test_job.c (test_child_handler): Don't run the signal
1433 and ptrace tests while in valgrind, sometimes signals (specifically
1434 SIGCONT after SIGSTOP) don't behave right and we kinda need that
1435 reliability.
1436
Scott James Remnant798284f2008-01-16 00:31:23 +00001437 * init/tests/test_job.c (test_child_handler): After adding extra
1438 processes, make sure we clean up again so each test is roughly
1439 independant. Fix the final test case to not rely on previous
1440 setup and work on its own.
1441
Scott James Remnant0cfd4e72008-01-16 00:30:26 +00001442 * init/tests/test_job.c (test_change_state): Remove useless check
1443 of job->start_on from a killed/post-stop check (noticed while
1444 writing the other).
1445
Scott James Remnant5c87e6e2008-01-16 00:27:22 +00001446 * init/job.c (job_change_state): Check the return value of
1447 job_run_process() and if particular processes fail, change the
1448 goal to stop and push the job into the next state; setting the job
1449 as failed along the way.
1450 (job_emit_event): If the exit_status is -1 then it means the job
1451 failed to spawn, so don't place EXIT_SIGNAL or EXIT_STATUS in the
1452 event environment.
1453 * init/tests/test_job.c (test_change_state): Check what happens when
1454 each process type fails, make sure that the job is stopped for
1455 pre-start, spawned and post-stop and the failure is ignored for
1456 post-start and pre-stop.
1457
Scott James Remnantfa733382008-01-15 15:33:27 +000014582008-01-15 Scott James Remnant <scott@netsplit.com>
1459
Scott James Remnant9f62a8e2008-01-15 19:22:36 +00001460 * init/main.c: Selectively compile out certain pieces when make is
1461 run with CPPFLAGS=-DDEBUG, giving us a build that'll happily run from
1462 a user terminal.
1463 * init/event.h: Change the startup event to "debug" when built like
1464 that, so we don't accidentally do bad things.
1465
Scott James Remnantb53527f2008-01-15 19:15:29 +00001466 * init/job.c (job_run_process): Catch PROCESS_ERROR and abort the
1467 attempt to run the process, returning a non-temporary error condition.
1468 * init/tests/test_job.c (test_run_process): Add test case for
1469 attempting to spawn a file that doesn't exist.
1470
Scott James Remnant85a2a0e2008-01-15 19:09:23 +00001471 * init/process.c (process_error_read): Avoid the word process, since
1472 it's likely included in the higher error message.
1473
Scott James Remnantfaa898c2008-01-15 19:05:04 +00001474 * init/process.c (process_spawn): Call process_error_abort() on any
1475 error condition.
1476 * init/tests/test_process.c (test_spawn): Add a test case for failing
1477 to spawn a process and receiving ProcessError correctly; fix other
1478 cases to ensure they return a pid.
1479
Scott James Remnantc7211972008-01-15 18:55:59 +00001480 * init/errors.h: Add PROCESS_ERROR to the enum, but not to the string
1481 list since there's no specific defined string for this one.
1482 * init/process.h (ProcessError): Structure that builds on NihError
1483 to add additional information for a process error.
1484 (ProcessErrorType): enum of different process error types.
1485 * init/process.c (process_spawn): After forking read the error in
1486 the parent, returning if we raise one.
1487 Ensure we close the pipe if the fork fails.
1488 Re-order so that we set the environment, umask and priority after the
1489 resource limits (which should apply to them).
1490 (process_error_abort): New function to immediately abort with an
1491 error, writing it on the pipe first.
1492 (process_error_read): Counterpart function to read the error from
1493 the pipe and raise it, with appropriate error messages.
1494
Scott James Remnant66738782008-01-15 17:01:19 +00001495 * init/process.c (process_spawn): Create a pipe to use for
1496 communication with the child, ensuring its closed before the parent
1497 returns and ensuring that the writing end is close-on-exec in the
1498 child.
1499
Scott James Remnant2e23f6b2008-01-15 16:38:28 +00001500 * init/job.c (job_run_process): Change to return a value indicating
1501 whether there's been a non-temporary error (always returns zero so
1502 far).
1503 * init/job.h: Update prototype.
1504 * init/tests/test_job.c (test_run_process): Check that job_run_process
1505 always returns zero.
1506
Scott James Remnant5dee92e2008-01-15 16:30:23 +00001507 * init/job.c (job_change_goal): Document in which states this function
1508 has unexpected side-effects such as freeing the job, since we do
1509 attempt to call it from within job_change_state().
1510
Scott James Remnantfa733382008-01-15 15:33:27 +00001511 * init/process.c (process_setup_limits): Integrate this function back
1512 into process_spawn() since there's no reason for it to be separate.
1513 (process_setup_console): Alter this function so it closes the original
1514 console descriptors, opens the new ones and can reset them to if
1515 required -- in particular, this no longer takes a Job parameter.
1516 (process_spawn): Use the new process_setup_console function and
1517 integrate code from process_setup_limits().
1518 * init/process.h: Update function prototype.
1519 * init/main.c (main): Use the new process_setup_console() argument
1520 form. Move syslog opening to the end of the function, rather than
1521 where it is now where it could be at risk of being closed again
1522 immediately. Change the root directory in case we're run in some
1523 weird way.
1524 (reset_console): Remove function since the code is now in
1525 process_setup_console()
1526 * init/enum.h (console_type): Remove CONSOLE_LOGGED and make the
1527 CONSOLE_NONE constant be zero.
1528 * init/parse_job.c (stanza_console): Drop parsing of "logged"
1529 * init/tests/test_parse_job.c (test_stanza_console): Drop testing
1530 of "logged" parsing.
1531
Scott James Remnantde581cc2008-01-14 21:35:53 +000015322008-01-14 Scott James Remnant <scott@netsplit.com>
1533
1534 * HACKING: Correct bzr URLs to trunk.
1535
Scott James Remnant20d3a1c2007-12-15 14:52:33 +000015362007-12-15 Scott James Remnant <scott@netsplit.com>
1537
Scott James Remnantcc6810d2007-12-15 15:39:02 +00001538 * init/process.c (process_spawn): Fix some documentation strings.
1539
Scott James Remnant206c97a2007-12-15 14:55:51 +00001540 * init/process.c (process_kill): Move to beneath the process setup
1541 functions.
1542 * init/process.h: Adjust ordering here too.
1543
Scott James Remnant20d3a1c2007-12-15 14:52:33 +00001544 * init/process.c (process_spawn): Group console closing and setup
1545 together, becoming the session and process group leader first.
1546
Scott James Remnant6f1e41f2007-12-07 00:32:21 +000015472007-12-07 Scott James Remnant <scott@netsplit.com>
1548
Scott James Remnante4178252007-12-07 13:35:45 +00001549 * init/process.c (process_spawn): Drop the debug message since
1550 it's always repeated by the caller.
1551 * init/job.c (job_run_process): Drop the word Active which is a
1552 hold-over from when we had different process states.
1553
Scott James Remnant64c8c772007-12-07 10:20:13 +00001554 * TODO: Update.
1555
Scott James Remnant0f688672007-12-07 10:17:25 +00001556 * init/job.c (job_child_handler): Add code to handle the trapped
1557 signal and ptrace event cases, distinguishing between a trapped
1558 signal and process stopped after exec or fork using our trace
1559 state member. Call out to other functions to do the work.
1560 (job_process_trace_new): Called after the first exec to set the
1561 ptrace options, update the trace state and allow the process to
1562 continue without delivering the signal. Also called after the
1563 fork to do the same.
1564 (job_process_trace_new_child): Called after a fork for the new child;
1565 increments the fork counter and if it goes over the number we want,
1566 detaches from the process and allows it to move to running. Otherwise
1567 calls job_process_trace_new() instead.
1568 (job_process_trace_signal): Called when a signal is trapped, simply
1569 delivers it to the process unchanged.
1570 (job_process_trace_fork): Called before a fork for the parent, obtains
1571 the new child process id from the event, updating the job structure,
1572 and detaches from the parent which we're no longer interested in.
1573 (job_process_trace_exec): Called after an exec other than the first,
1574 assumed to be the end of forking so detaches from the process and
1575 allows it to move to running.
1576 * init/tests/test_job.c (test_child_handler): Add test cases for
1577 the various ptrace states.
1578
Scott James Remnante3c10ae2007-12-07 09:18:38 +00001579 * init/job.c (job_run_process): Set process trace state to new for
1580 the main job if we need to wait for the daemon or fork; otherwise
1581 reset the state.
1582 * init/tests/test_job.c (test_run_process): Add test cases to make
1583 sure the trace state is set right and picked up by process_spawn.
1584
Scott James Remnant3525ffd2007-12-07 09:04:10 +00001585 * init/process.c (process_spawn): Set a ptrace before execing the
1586 binary if the trace state is TRACE_NEW, set by the caller.
1587 * init/tests/test_process.c (test_spawn): Make sure that a job is
1588 ptraced if set up properly.
1589 (child): Add a simple case that just exits immediately for testing
1590 the above.
1591
Scott James Remnantd431eea2007-12-07 09:01:58 +00001592 * init/job.h (Job): Add new trace_forks member to keep count of how
1593 many forks we've seen and trace_state member to track whether we've
1594 just started the trace or just forked.
1595 * init/enum.h (TraceState): Add enumeration to keep track of ptrace
1596 state to differentiate between a signal and an event.
1597 * init/job.c (job_new): Initialise new members.
1598 * init/tests/test_job.c (test_new): Check new members are initialised
1599
Scott James Remnant319c7f92007-12-07 08:57:48 +00001600 * init/enum.h (JobWaitType): Add new daemon and fork wait types.
1601 * init/parse_job.c (stanza_wait): Add parsing for daemon and fork.
1602 * init/tests/test_parse_job.c (test_stanza_wait): Add tests too.
1603
Scott James Remnant58d23f52007-12-07 00:42:50 +00001604 * init/job.h (JobConfig): Remove daemon and pid members.
1605 (Job): Remove pid_timer member.
1606 (JOB_DEFAULT_PID_TIMEOUT): Remove this constant.
1607 * init/job.c (job_config_new, job_new): Remove initialisation of
1608 removed members.
1609 (job_change_state): Stay in spawned unless we're not waiting for
1610 anything -- remove the daemon flag.
1611 * init/tests/test_job.c (test_config_new, test_new): Remove checks
1612 for initialisation of removed members.
1613 (test_change_state): Remove daemon flag stays in spawned check since
1614 the daemon flag has gone.
1615 * init/parse_job.c (stanza_daemon, stanza_pid): Remove these
1616 functions since they have no members to set.
1617 * init/tests/test_parse_job.c (test_stanza_daemon, test_stanza_pid):
1618 Remove the tests for the now non-existant functions.
1619
Scott James Remnant6f1e41f2007-12-07 00:32:21 +00001620 * init/process.c (process_spawn): raise the system error before
1621 calling another syscall, in case we overwrite errno.
1622
Scott James Remnant5fdadda2007-12-06 11:09:00 +000016232007-12-06 Scott James Remnant <scott@netsplit.com>
1624
Scott James Remnant5ebc6c62007-12-06 16:01:13 +00001625 * init/job.c (job_child_handler): Implement a combined child event
1626 handler to replace the multiple separate ones. This handler deals
1627 with adding appropriate messages to the log and decoding any state
1628 information before calling specific action functions.
1629 (job_child_reaper): Remove, moving the bulk of the code into new
1630 (job_process_terminated): function that handles it cleanly.
1631 (job_child_minder): Remove, moving the bulk of the code into new
1632 (job_process_stopped): function that's a lot cleaner.
1633 * init/job.h: Update prototypes.
1634 * init/tests/test_job.c (test_child_reaper, test_child_minder):
1635 Combine unit tests from both functions into single new
1636 (test_child_handler): function.
1637 * init/main.c (main): Call the combined function on child events
1638 instead of separate ones.
1639
Scott James Remnant5fdadda2007-12-06 11:09:00 +00001640 * init/job.c (job_child_minder): Add informational message and
1641 improve style and documentation.
1642
Scott James Remnantab882c22007-12-02 18:17:09 +000016432007-12-02 Scott James Remnant <scott@netsplit.com>
1644
1645 * init/enum.h (JobWaitType): Introduce a new enum that specifies
1646 how to transition the job from spawned to running; either we don't
1647 wait, or we wait for it to emit the stopped signal.
1648 * init/job.h (JobConfig): Add the wait_for member.
1649 Add protoype for job_child_minder.
1650 * init/job.c (job_config_new): Initialise to JOB_WAIT_NONE.
1651 (job_child_minder): New function to catch when a process is stopped
1652 by a signal, and move it to the next state when it does so.
1653 * init/tests/test_job.c (test_config_new): Check the initialisation
1654 of wait_for to JOB_WAIT_NONE.
1655 (test_child_minder): Tests for the new function.
1656 (test_change_state): Copy the daemon test case to refer to waiter.
1657 * init/main.c (main): Call job_child_minder whenever the job is
1658 stopped by a signal
1659 * init/parse_job.c (stanza_wait): Parse a new "wait" stanza that
1660 specifies what to wait for before leaving the spawned state.
1661 * init/tests/test_parse_job.c (test_stanza_wait): Check the new
1662 stanza.
1663
Scott James Remnant4bef98a2007-11-30 01:28:28 +000016642007-11-29 Scott James Remnant <scott@netsplit.com>
1665
1666 * init/tests/test_job.c (test_change_state): Add a few sets to NULL
1667 so gcc is happy.
1668
Scott James Remnant0eade492007-11-15 05:48:07 +000016692007-11-15 Scott James Remnant <scott@netsplit.com>
1670
1671 * init/job.c (job_child_reaper): Update argument names and types
1672 to match new NihChildHandler pattern; switch on event instead,
1673 which can now have three values not two (it always could, this was
1674 a bug) to output warning and assume that status is always non-zero
1675 if killed so no need to check that separately.
1676 * init/job.h: Update prototype.
1677 * init/tests/test_job.c (test_child_reaper): Update calls to
1678 job_child_reaper to pass an NihChildEvents member instead of FALSE
1679 or TRUE for killed.
1680 * init/main.c: Adjust call to nih_child_add_watch to indicate which
1681 events we want to pass to the reaper; we don't use NIH_CHILD_ALL
1682 since we're going to add ptrace stuff to a different function.
1683
Scott James Remnant5c408432007-11-07 21:42:25 -050016842007-11-07 Scott James Remnant <scott@netsplit.com>
1685
1686 * init/main.c (main): Tidy up.
1687
Scott James Remnantbc9b6712007-11-04 01:49:04 -040016882007-11-04 Scott James Remnant <scott@netsplit.com>
1689
1690 Complete the simplification of job config; rather than try and
1691 precompute job replacements, keeping them all in the same hash table
1692 and chaining them together, we just work it out when it's actually
1693 necessary based on what's in the conf_sources list.
1694
1695 * init/job.h (JobConfig): Remove the replacement and replacement_for
1696 members and put a deleted member in instead.
1697 * init/job.c (job_config_new): Initialise deleted to FALSE; don't
1698 replace the job into the hash table, since we only want the current
1699 one in there now.
1700 (job_config_find_by_name): Now that there is only ever one job
1701 config in the hash table, we don't need any special function and
1702 can just use nih_hash_lookup directly, so drop this function.
1703 (job_config_should_replace): Rename to job_config_replace
1704 (job_config_replace): Rework, it now checks to see whether there
1705 are instances, and if not removes the job from the hash table
1706 before selecting a new one (which might be the same job).
1707 * init/tests/test_job.c (test_config_new): Update test to check
1708 deleted starts off as FALSE and that the job isn't in the hash.
1709 (test_config_find_by_name): Drop.
1710 (test_config_should_replace): Rename and rewrite to test replacement
1711 actually works as we expect.
1712 (test_change_state): Update tests for entering the waiting mode and
1713 replacing jobs.
1714 (test_find_by_pid, test_find_by_id, test_handle_event)
1715 (test_handle_event_finished): Add jobs to the hash table, otherwise
1716 we can't find them
1717 (test_child_reaper): Add job to the hash table, and also create a
1718 source for it since we end up with it in the waiting state so need
1719 to be able to keep it.
1720 * init/Makefile.am (test_process_LDADD, test_job_LDADD)
1721 (test_event_LDADD): Need the full .o file list now.
1722 * init/conf.c (conf_file_destroy): Rewrite to mark the job deleted,
1723 call job_config_replace if it's the current job and free it if
1724 it isn't the current job either before or after that call.
1725 (conf_reload_path): Handle job replacement here; look up the
1726 old job in the hash table, if it exists attempt a replacement
1727 otherwise add the new job to the hash table.
1728 * init/tests/test_conf.c (test_source_reload_job_dir)
1729 (test_source_reload_conf_dir, test_source_reload_file): Update
1730 tests to check job->deleted and use nih_hash_lookup to see whether
1731 it's the current job.
1732 (test_file_destroy): Write tests to check the common cases, we don't
1733 need to worry about the intermediate now since they can't happen.
1734 * init/parse_job.c (parse_job): Massively simplify, this only creates
1735 the config and parses it now.
1736 * init/tests/test_parse_job.c (test_parse_job): Remove the replacement
1737 checks.
1738 * init/tests/test_event.c (test_poll): Add configs to the hash
1739 table so they can be found.
1740 * TODO: Update.
1741
Scott James Remnant9fa1ce82007-11-03 02:06:54 -040017422007-11-03 Scott James Remnant <scott@netsplit.com>
1743
1744 * init/conf.h (ConfSource): Remove priority, we'll place these
1745 in a linked list and use that order instead.
1746 (ConfSourcePriority): Drop accordingly.
1747 (ConfItem): Drop this structure; permitting jobs and states to be
1748 defined inside larger conf files made things complicated for no
1749 benefit; move the item union into
1750 (ConfFile): here, instead of the items list.
1751 (ConfItemType): Drop accordingly.
1752 * init/conf.c (conf_init): Store sources in a linked list, instead
1753 of a hash table; no idea why it ever was.
1754 (conf_source_new): Drop priority argument and add to list not hash.
1755 (conf_file_new): Set data to NULL instead of initialising items,
1756 set destructor to conf_file_destroy.
1757 (conf_item_destroy): Rename to conf_file_destroy
1758 (conf_file_destroy): and adjust to refer to ConfItem instead,
1759 getting the item type through the source.
1760 (conf_item_new): Drop.
1761 (conf_reload): Iterate as linked list not hash table.
1762 (conf_reload_path): Simplify handling of old files and items a
1763 little, just look it up and always free if it exists before parsing
1764 the new file.
1765 (conf_file_get): No longer any need for this function.
1766 * init/tests/test_conf.c (test_file_get, test_item_new): Drop
1767 test functions for those that have been removed.
1768 (test_item_destroy): Rename to test_file_destroy.
1769 (test_source_new): Don't pass or check priority, or hash lookup.
1770 (test_file_new): Check data is set correctly.
1771 (test_source_reload_job_dir, test_source_reload_conf_dir)
1772 (test_source_reload_file): Update tests accordingly.
1773 * init/parse_conf.c (stanza_job): Drop the job stanza, jobs
1774 may only be defined in dedicated directories.
1775 * init/tests/test_parse_conf.c (test_parse_conf): Simply check to only
1776 make sure the file is parsed.
1777 (test_stanza_job): Drop function.
1778 * init/main.c: Update calls to conf_source_new.
1779 * init/init.supp: Update intermediate function in suppression.
1780
Scott James Remnantb4169fa2007-10-26 13:54:41 -040017812007-10-26 Scott James Remnant <scott@netsplit.com>
1782
1783 * init/process.c (process_spawn): Mask out all signals across the
1784 fork() rather than just SIGCHLD; reset the signal handlers to default
1785 before unmasking again. The original rationale was we needed to
1786 avoid SIGCHLD occurring before we'd stashed the pid, but that's no
1787 longer a problem; the new rationale is that we want to avoid the
1788 signal handlers running in the newly forked child.
1789
Scott James Remnantd29da6f2007-10-20 00:08:52 +010017902007-10-20 Scott James Remnant <scott@netsplit.com>
1791
Scott James Remnant333ad2d2007-10-20 15:30:29 +01001792 * init/job.c (job_init): The job's name is the first item in the
1793 structure again, so we can use nih_hash_string_key.
1794 (job_config_name): Drop this function, then.
1795
Scott James Remnanteda29582007-10-20 14:44:24 +01001796 * init/conf.h (ConfSourcePriority): Add a priority enum
1797 (ConfSource): Add priority member.
1798 * init/conf.c (conf_source_new): Take priority as an argument and
1799 set it in the structure.
1800 * init/tests/test_conf.c (test_source_new): Make sure priority
1801 is set from the argument.
1802 (test_file_new, test_file_get, test_item_new)
1803 (test_source_reload_job_dir, test_source_reload_conf_dir)
1804 (test_source_reload_file, test_source_reload, test_item_destroy):
1805 Pass in a priority when creating a ConfSource.
1806 * init/tests/test_parse_conf.c (test_parse_conf): Likewise.
1807 * init/main.c (main): Set relative priorities for the configuration
1808 directories.
1809
Scott James Remnant388621b2007-10-20 14:29:40 +01001810 * init/conf.h (conf_file, conf_item): Add source and file members
1811 respectively that point to the parent structure.
1812 * init/conf.c (conf_file_new, conf_item_new): Set the members.
1813 * init/tests/test_conf.c (test_file_new, test_file_get)
1814 (test_item_new): Make sure the new members are set properly.
1815
Scott James Remnant87145d62007-10-20 14:02:59 +01001816 * util/Makefile.am (install-data-hook, install-exec-hook): Apply
1817 transform to source and destination of both manpage and program
1818 symlinks.
1819 * compat/sysv/Makefile.am (install-data-hook, install-exec-hook):
1820 Likewise for the compatibility symlinks.
1821
Scott James Remnant9f093752007-10-20 02:16:39 +01001822 * TODO: Update.
1823
Scott James Remnant1518f6c2007-10-20 02:14:29 +01001824 * init/tests/test_process.c (test_spawn): Make the event a child
1825 of the operator so it doesn't get freed first.
1826
Scott James Remnant509f7912007-10-20 02:06:23 +01001827 * init/job.c (job_instance): Increment an instances counter each
1828 time we spawn an instance.
1829 (job_change_state): Decrement the instances counter again.
1830 (job_detect_stalled): Drop the main loop function, since we perform
1831 active detection of stall now.
1832 * init/job.h: Update header.
1833 * init/tests/test_job.c (test_change_state): Check that we get the
1834 stalled event for the last instance.
1835 (test_detect_stalled): Drop the test.
1836 * init/main.c: Remove job_detect_stalled from the main loop.
1837
Scott James Remnant0af43242007-10-20 01:16:04 +01001838 * init/event.c (event_operator_destroy): Destructor for an
1839 EventOperator that unblocks and unreferences the event first.
1840 (event_operator_new): Set the operator.
1841 (event_operator_copy): Remove error handling since it's unnecessary
1842 with the destructor in place.
1843 * init/event.h: Add prototype.
1844 * init/tests/test_event.c (test_operator_destroy): Make sure it
1845 works properly.
1846 (test_operator_copy): Don't unblock or unref events before freeing
1847 them, since that's now taken care of when it's referenced.
1848 * init/job.c (job_new): Remove unnecessary error handling.
1849 * init/tests/test_job.c (test_run_process): Reference the event
1850 when setting it, otherwise we'll assert when we try to free it.
1851 * TODO: Update.
1852
Scott James Remnant2be7d582007-10-20 00:43:19 +01001853 * init/job.c (job_new): Drop the parent argument for consistency.
1854 (job_instance): Update call to job_new.
1855 * init/job.h: Update prototype.
1856 * init/tests/test_job.c (test_new): Adjust call, check the parent
1857 and make sure that start_on and stop_on are copied over properly.
1858 * TODO: Update.
1859
Scott James Remnante548bc72007-10-20 00:29:39 +01001860 * init/conf.c (conf_file_get): Split out the allocation code from here
1861 (conf_file_new): into this new function.
1862 * init/conf.h: Add prototype.
1863 * init/tests/test_conf.c (test_file_new): New tests.
1864 * TODO: Update.
1865
Scott James Remnantd29da6f2007-10-20 00:08:52 +01001866 * init/job.c (job_change_state): Hardcode the next state when we
1867 catch a runaway job to be JOB_WAITING.
1868 (job_next_state): Change next state for JOB_STARTING when goal is
1869 JOB_STOP to be JOB_STOPPING for consistency with the others; otherwise
1870 if our goal is stopped during our starting event, we'll never emit
1871 a stopping event to match it.
1872 * init/tests/test_job.c (test_next_state): Update test case.
1873 * doc/states.dot: Adjust the state transitions.
1874 * doc/states.png: Regenerate.
1875 * TODO: Update.
1876
Scott James Remnant493f5cd2007-10-19 22:49:09 +010018772007-10-19 Scott James Remnant <scott@netsplit.com>
1878
1879 Dealing with instances has always been tricky since they're copies
1880 that exist in the hash table; this patch changes that so the job's
1881 configuration is separated from its state. The only difference
1882 between instance and non-instance jobs now is that non-instance
1883 jobs only ever have one entry in their instances list.
1884
1885 * init/job.h (Job): Separate out the members that come from the
1886 configuration into a new JobConfig structure which can be shared
1887 amongst all of the instances; this means we can drop instance_of.
1888 (JobConfig): Add instances list.
1889 (JobProcess): Remove pid member, replaced by pid list in Job.
1890 Update prototypes of functions to match.
1891 * init/job.c (job_new): Split off initialisation of configuration
1892 pieces into new job_config_new function leaving the state here;
1893 copy the start_on and stop_on members from JobConfig
1894 (job_copy): Drop this function, we don't need to copy jobs now.
1895 (job_name): Rename to job_config_name.
1896 (job_init): Set key function to job_config_name.
1897 (job_process_new): Drop initialisation of pid.
1898 (job_process_copy): Drop this function entirely, we don't need it.
1899 (job_find_by_name): Rename to job_config_find_by_name; massively
1900 simplify now we won't find instances or deleted jobs in the list.
1901 (job_should_replace): Rename to job_config_should_replace; simplify
1902 now that we can do a simple check to see whether a job exists or not
1903 (job_find_by_pid, job_find_by_id): Loop through the instances after
1904 looping through the hash table.
1905 (job_instance): Simplify, now all it needs to do is call job_new()
1906 if there isn't anything in the instances list, or it's multi-instance.
1907 (job_change_goal): Document that job should not be used on return.
1908 No need to check for instance jobs anymore. Place the job id in
1909 the output.
1910 (job_change_state): Document that job should not be used on return.
1911 Place the job id in the output. Check for information in the job's
1912 config. Merge the waiting and deleted states, so that a job instance
1913 is automatically deleted when it finishes.
1914 (job_next_state): Assert that we never call job_next_state when
1915 in JOB_WAITING since there's no possible next state. Check config
1916 for whether a main process exists.
1917 (job_emit_event): Obtain config-replaced pieces from the job's config
1918 (job_run_process): Obtain process information from the job's config
1919 but store the pid in the Job. Put job id in the output.
1920 (job_kill_process, job_kill_timer): We don't need to obtain the
1921 JobProcess just the pid from the job. Put job id in the output.
1922 (job_child_reaper): Put job id in the output. Check job config.
1923 (job_handle_event): Iterate job instances and process their stop_on
1924 operators, but process the start_on from the job configs.
1925 (job_handle_event_finished): Loop through the instances too.
1926 (job_detect_stalled): Check start_on from the config and just
1927 check whether there are any instances in the list.
1928 (job_free_deleted): No deleted state, so drop this function.
1929 * init/tests/test_job.c (test_new): Split into test_new and
1930 new test_config_new function. Create JobConfig object and spawn
1931 Job instances from that.
1932 (test_copy): Drop the tests.
1933 (test_process_new): Drop check of pid.
1934 (test_process_copy): Drop test.
1935 (test_find_by_name): Rename to test_config_find_by_name.
1936 (test_should_replace): Rename to test_config_should_replace.
1937 (test_instance): Create JobConfig object, and adjust tests to ensure
1938 that we always get a Job object.
1939 (test_find_by_pid, test_find_by_id, test_change_goal): Create
1940 JobConfig object and spawn Job instances from that.
1941 (test_change_state): Create JobConfig object and spawn Job
1942 instances from that. Adjust tests that previously checked for
1943 JOB_WAITING to check for job being freed. Drop checks for JOB_DELETED.
1944 (test_next_state): Create JobConfig object and spawn Job instances
1945 from that. Drop JOB_DELETED and JOB_WAITING checks.
1946 (test_run_process, test_kill_process, test_child_reaper)
1947 (test_handle_event, test_detect_stalled): Create JobConfig object
1948 and spawn Job instances from that.
1949 (test_free_deleted): Drop.
1950 * init/main.c: Don't add job_free_deleted to the main loop.
1951 * init/enum.h (JobState): Drop JOB_DELETED.
1952 * init/enum.c (job_state_name, job_state_from_name): Drop JOB_DELETED.
1953 * init/tests/test_enum.c (test_state_name, test_state_from_name):
1954 Drop tests that use the JOB_DELETED value.
1955 * init/process.c (process_spawn, process_setup_limits)
1956 (process_setup_environment, process_setup_console): Get details
1957 from the job config. Put job id in the output.
1958 * init/tests/test_process.c (test_spawn, test_kill): Create
1959 a JobConfig object and make Job instances from that.
1960 * init/tests/test_event.c (test_poll): Create a JobConfig object
1961 and make Job instances from that.
1962 (test_operator_copy): Set pointers to NULL to avoid gcc complaining.
1963 * init/conf.h (ConfItem): Make the type for a job be JobConfig.
1964 * init/conf.c (conf_item_destroy): Don't attempt to replace the
1965 new middle-man target, if it was due to be replaced it would have
1966 already been. If we can replace the config, ensure nothing points
1967 at it and then free it, rather than kicking state.
1968 * init/tests/test_conf.c (test_source_reload_job_dir)
1969 (test_source_reload_conf_dir, test_source_reload_file)
1970 (test_source_reload, test_item_destroy): Call job_config_new to
1971 create JobConfig objects, track when they are freed rather than
1972 marked in the deleted state. Create instances with job_instance,
1973 and fetch from the instances list. Expect the job to be freed
1974 with the item.
1975 * init/tests/test_parse_conf.c (test_parse_conf)
1976 (test_stanza_job): Change expected type from Job to JobConfig.
1977 * init/parse_job.c: Update prototypes of all functions to refer to
1978 JobConfig instead of Job.
1979 (parse_job): If the old job already has a replacement, remove the
1980 replacement from the hash table -- but don't free it because it's
1981 linked by a ConfItem -- this is temporary. Likewise for when we
1982 replace the old job.
1983 * init/parse_job.h: Update prototype.
1984 * init/tests/test_parse_job.c: Update all functions to use JobConfig
1985 instead of Job.
1986 (test_parse_job): Create an instance.
1987 * doc/states.dot: Remove the deleted state.
1988 * doc/states.png: Regenerate.
1989 * TODO: Update with notes from the conversion.
1990
Scott James Remnantf9ec8292007-10-16 00:08:33 +010019912007-10-16 Scott James Remnant <scott@netsplit.com>
1992
1993 Update to catch up with changes in libnih that make code a little
1994 bit easier to follow (we hope).
1995
1996 * init/tests/test_process.c (test_spawn, test_kill): Replace calls
1997 to nih_list_free() with nih_free()
1998 * init/event.c (event_poll): Replace nih_list_free with nih_free
1999 since the former function has gone from libnih.
2000 (event_new): Adjust setting of the destructor.
2001 (event_operator_new): Set destructor for the tree node.
2002 * init/tests/test_event.c (test_new, test_find_by_id, test_ref)
2003 (test_unref, test_block, test_unblock, test_poll)
2004 (test_operator_match): Replace nih_list_free with nih_free.
2005 (test_poll): Use TEST_FREE_TAG and TEST_FREE rather than abusing
2006 destructors.
2007 * init/job.c (job_new): Set destructor to nih_list_destroy.
2008 (job_copy, job_free_deleted): Use nih_free instead of nih_list_free
2009 * init/tests/test_job.c (test_new, test_copy, test_find_by_name)
2010 (test_find_by_pid, test_find_by_id, test_instance)
2011 (test_change_goal, test_change_state, test_next_state)
2012 (test_should_replace, test_run_process, test_kill_process)
2013 (test_child_reaper, test_handle_event)
2014 (test_handle_event_finished, test_detect_stalled)
2015 (test_free_deleted): Replace all uses of nih_list_free with nih_free
2016 (test_child_reaper, test_free_deleted): Replace destructor abuse
2017 with TEST_FREE, etc.
2018 * init/conf.c (conf_reload_path): Use nih_free instead of nih_list_free
2019 (conf_source_new, conf_file_get, conf_item_new): Set destructor
2020 (conf_source_reload, conf_delete_handler): Use nih_free not the
2021 custom conf_file_free() function.
2022 (conf_reload_path): Use nih_free not the custom conf_item_free()
2023 function.
2024 (conf_delete_handler): Use nih_free not nih_watch_free()
2025 (conf_source_free, conf_file_free): Drop these functions, since
2026 all the free chaining happens properly with destructors.
2027 (conf_item_free): Rename to conf_item_destroy and turn into destructor
2028 * init/conf.h: Update prototypes.
2029 * init/tests/test_conf.c (test_source_new, test_file_get)
2030 (test_item_new, test_source_reload_job_dir)
2031 (test_source_reload_conf_dir, test_source_reload_file)
2032 (test_item_free): Replace nih_list_free calls with nih_free
2033 (test_source_reload_job_dir, test_source_reload_conf_dir)
2034 (test_source_reload_file, test_source_reload, test_item_free): Replace
2035 calls to conf_source_free with nih_free
2036 (test_source_free, test_file_free): Drop functions.
2037 (test_item_free): Rename to test_item_destroy
2038 (test_item_new): Assign a job before freeing, otherwise the destroy
2039 function will foul up as it expects one.
2040 * init/parse_conf.c (stanza_job): Replace nih_list_free with nih_free
2041 * init/tests/test_parse_conf.c (test_parse_conf)
2042 (test_stanza_job): Replace conf_source_free() with nih_free()
2043 (test_parse_conf, test_stanza_job): Replace conf_item_free()
2044 with nih_free()
2045 * init/parse_job.c (parse_job, parse_on_paren, parse_on_collect):
2046 Replace nih_list_free with nih_free
2047 (parse_on): always cut out the stack head before returning (it won't
2048 be empty on error) otherwise we end up with a bunch of list entries
2049 pointing to it -- and it's way out of scope when we try and free them
2050 (parse_on_operator, parse_on_operand): Use the job as the context
2051 not the operator for consistency of freeing.
2052 * init/tests/test_parse_job.c: Replace all instances of nih_list_free
2053 with nih_free (too many functions to list).
2054
Scott James Remnant5d6466d2007-10-15 01:40:52 +010020552007-10-15 Scott James Remnant <scott@netsplit.com>
2056
Scott James Remnant3e32e082007-10-16 00:08:24 +01002057 Strip out all of the IPC code, removing it and consigning it to the
2058 great revision control history in the sky. We're going to switch
2059 from home-brew to D-BUS. so all this is somewhat obsolete. Rather
2060 than maintain this while we carry on developing, we'll strip it out
2061 now and put the D-BUS code in ater once the rest of the core changes
2062 are done (otherwise we'd just be dragging those through maintenance
2063 too).
2064
2065 * Makefile.am (SUBDIRS): Remove the upstart sub-directory entirely;
2066 comment out util, compat/sysv & logd since we'll fix them up later
2067 * configure.ac (AC_CONFIG_FILES): Remove from here too.
2068 * upstart/enum.c, upstart/enum.h, upstart/tests/test_enum.c: Move
2069 these files into the init/ sub-directory; strictly speaking we'll
2070 probably need to share them again later in some way, but for now
2071 they can live with the rest of the daemon code.
2072 * upstart/: Delete.
2073 * init/Makefile.am (init_SOURCES): Remove control.c, control.h,
2074 notify.c and notify.h; add enum.c and enum.h
2075 (TESTS): Remove test_control and test_notify; add test_enum
2076 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD)
2077 (test_notify_SOURCES, test_notify_LDADD): Remove.
2078 (test_enum_SOURCES, test_enum_LDFLAGS, test_enum_LDADD): Add details
2079 (init_LDADD): Remove libupstart
2080 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2081 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): Remove
2082 libupstart, control.o and notify.o; add enum.o
2083 * init/control.c, init/control.h, init/tests/test_control.c: Delete
2084 * init/notify.c, init/notify.h, init/tests/test_notify.c: Delete
2085 * init/enum.c, init/job.c, init/job.h: Update include path for enum.h
2086 * init/parse_job.c: Remove unnecessary enum.h include
2087 * init/tests/test_enum.c: Update to reflect where it is.
2088 * init/main.c (main): Drop control socket opening.
2089 * init/tests/test_job.c: Remove unnecessary control.h include
2090 * init/event.c (event_pending, event_finished): Remove calls to
2091 notify_event and notify_event_finished
2092 * init/job.c (job_change_goal, job_change_state): Remove calls
2093 to notify_job.
2094 * init/tests/test_parse_conf.c: Remove calls to notify_init
2095 * init/tests/test_parse_job.c: Remove calls to notify_init
2096 * init/tests/test_event.c (test_poll): Strip out the part of the
2097 test that checks processes are notified.
2098 (check_event, check_event_finished): Remove.
2099
Scott James Remnanta86d3982007-10-15 17:55:09 +01002100 * configure.ac: Bump Autoconf dependency to 2.61 to match libnih
2101 * HACKING: Bump dependency in docs too.
2102
Scott James Remnant5d6466d2007-10-15 01:40:52 +01002103 * NEWS: Copy in news from 0.3.9; that release doesn't appear in
2104 this ChangeLog since it was made on a separate branch by backporting
2105 bug fixes made here.
2106 * configure.ac: Bump version to 0.5.0, which is where development
2107 is heading for.
2108
Scott James Remnant56d2d822007-10-12 18:06:21 +010021092007-10-12 Scott James Remnant <scott@netsplit.com>
2110
2111 * HACKING: Change URL for libnih.
2112
Scott James Remnant0c3bef32007-10-08 13:20:56 +010021132007-10-08 Scott James Remnant <scott@netsplit.com>
2114
Scott James Remnante16d32c2007-10-08 13:37:44 +01002115 * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.16.1 since this
2116 version of gettext is needed for compatibility with Automake 1.10
2117 * HACKING: Bump version in the docs too.
2118
Scott James Remnante6478362007-10-08 13:21:51 +01002119 * compat/sysv/Makefile.am: Only create symlinks if COMPAT_SYSV is
2120 enabled, otherwise we leave dangling ones.
2121
Scott James Remnant0c3bef32007-10-08 13:20:56 +01002122 * Makefile.am (ACLOCAL_AMFLAGS): Specify that aclocal install
2123 ordinarily system-wide macros into m4 (libtool.m4, specifically).
2124 This makes it easier for packagers to modify autoconfery since
2125 aclocal is no longer a destructive event.
2126 * configure.ac (AM_INIT_AUTOMAKE): Increase Automake requirement to
2127 1.10 to ensure we have aclocal --instal
2128 * HACKING: Increase Automake version in the docs.
2129
Scott James Remnant52ada042007-09-21 15:59:12 +010021302007-09-21 Scott James Remnant <scott@netsplit.com>
2131
2132 * init/job.c (job_detect_stalled, job_free_deleted): Call job_init()
2133 on entry, since we don't have a Job pointer passed to us, we need
2134 to make sure we don't dereference a potentially NULL list.
2135
Scott James Remnant65e21ac2007-06-22 12:48:14 +010021362007-06-22 Scott James Remnant <scott@netsplit.com>
2137
Scott James Remnant1e2e0b32007-06-22 16:59:29 +01002138 * TODO: Update.
2139
Scott James Remnant3a807ca2007-06-22 16:53:35 +01002140 * init/job.h: Update prototype of job_change_goal.
2141 (Job): Remove cause member.
2142 * init/job.c (job_change_goal): Drop additional argument since cause
2143 is no longer used.
2144 (job_change_state, job_child_reaper, job_handle_event): Only pass
2145 two arguments to job_change_goal.
2146 * init/control.c (control_job_start, control_job_stop): Only pass
2147 two argumenst to job_change_goal.
2148 * init/tests/test_job.c (test_change_goal, test_change_state): Only
2149 pass two arguments to job_change_goal.
2150
Scott James Remnant134e0592007-06-22 16:51:02 +01002151 * init/job.c (job_new): Drop setting of cause.
2152 (job_change_cause): Drop this function entirely.
2153 (job_change_goal, job_change_state): Drop calls to job_change_cause
2154 (job_change_state, job_child_reaper): Don't pass job->cause to
2155 job_change_goal calls.
2156
2157 * init/tests/test_job.c: Remove all tests that checked the value of
2158 job->cause, since that variable is going away.
2159 (test_change_goal): Remove the specific tests that checked whether
2160 cause was updated or not.
2161
Scott James Remnant108152d2007-06-22 16:43:07 +01002162 * init/job.c (job_run_process): Replace the arguments from the event
2163 with a list of event names.
2164 * init/tests/test_job.c (test_run_process): Update test case to
2165 supply arguments from the list of events.
2166
Scott James Remnantbc683992007-06-22 16:37:10 +01002167 * init/process.c (process_setup_environment): Drop the UPSTART_EVENT
2168 environment variable; it doesn't make sense when you can have multiple
2169 events.
2170 (process_setup_environment): Put all variables from the job's start
2171 events into the job's environment; replacing the UPSTART_EVENT variable
2172
Scott James Remnant47f5a762007-06-22 15:57:26 +01002173 * init/job.c (job_change_cause): Don't notify the job event
2174 subscribers when changing the cause.
2175 * init/notify.c (notify_job_finished): Instead notify them when
2176 the job reaches a rest state.
2177
Scott James Remnantfed4f262007-06-22 15:50:51 +01002178 * init/notify.c (notify_job): Call notify_job_event regardless,
2179 since this now looks over the start_on and stop_on fields.
2180 (notify_job_event): Rewrite to iterate over start_on and stop_on,
2181 and notifying for each cause event found.
2182 (notify_job_event_caused): Static function that is the guts of the
2183 above function.
2184 * init/tests/test_notify.c (test_job, test_job_event): Modify tests
2185 to refer exclusively to the start_on/stop_on expressions rather than
2186 the cause.
2187
Scott James Remnante379ab92007-06-22 15:35:42 +01002188 * init/job.c (job_change_cause): Only notify the job event and
2189 update the cause member, we don't need to ref or block it anymore
2190 since that's handled by start_on and stop_on.
2191 * init/tests/test_job.c (test_change_goal): Drop checks on cause
2192 being referenced and blocked.
2193 (test_change_state, test_child_reaper, test_handle_event): Update
2194 test cases to not reference ->cause, and not count any references
2195 or blockers towards it.
2196 * init/tests/test_event.c (test_poll): Update expected reference
2197 and block counts for events handled by jobs.
2198
Scott James Remnant06218642007-06-22 15:15:56 +01002199 * init/tests/test_process.c (test_kill): Make sure that all processes
2200 in the process group are killed, rather than just the lone one.
2201 * init/process.c (process_kill): Send the signal to all processes
2202 in the same process group as the pid.
2203 * init/tests/test_job.c (test_change_state, test_kill_process):
2204 After spawning a child, call setpgid() to put it in its own process
2205 group otherwise we could end up TERMing ourselves.
2206
Scott James Remnante84eb012007-06-22 13:42:14 +01002207 * init/tests/test_job.c (test_child_reaper): Update test cases to
2208 include checking of the start_on and stop_on expression trees.
2209 * init/job.c (job_child_reaper): Mark all blocked events in the
2210 start_on and stop_on trees as failed; since these are copies of
2211 the cause event, we can drop that setting already.
2212
Scott James Remnant65e21ac2007-06-22 12:48:14 +01002213 * TODO: Update again, still thinking about the atomicity of event
2214 expressions.
2215
Scott James Remnante332fa92007-06-21 15:35:53 +010022162007-06-21 Scott James Remnant <scott@netsplit.com>
2217
Scott James Remnantb4556392007-06-21 18:38:20 +01002218 * init/tests/test_job.c (test_change_state): Include tests on a job's
2219 start_on and stop_on event expression trees, and make sure that events
2220 are unblocked and unreferenced at the appropriate moments.
2221 * init/job.c (job_change_state): Unblock the events that started the
2222 job in running (if a service), and reset when we reach waiting (leave
2223 referenced otherwise so the environment is always present).
2224 Unblock and unreference the events that stopped the job in
2225 starting (for restarting), running (if coming from pre-stop) and
2226 waiting.
2227
Scott James Remnant7e198e42007-06-21 17:02:12 +01002228 * init/tests/test_job.c (test_handle_event): Rewrite tests using
2229 event expressions, and make sure events are referenced and blocked
2230 correctly matching how jobs are affected. Include tests for correct
2231 instance behaviour.
2232 (test_instance): Make sure that instances copy across the expression
2233 state, and reset the parent.
2234 * init/job.c (job_instance): After spawning a new instance, reset
2235 the start_on expression of the master job.
2236
Scott James Remnant625c8d02007-06-21 16:28:43 +01002237 * init/event.c (event_operator_copy): Change to making the parent
2238 of copies nodes be the actual tree parent, rather than the top
2239 parent; otherwise you can't free an entire tree in one go.
2240 * init/tests/test_event.c (test_operator_copy): Check parents of
2241 copied nodes.
2242 * init/tests/test_job.c (test_copy): Update parent checks here too.
2243
Scott James Remnante332fa92007-06-21 15:35:53 +01002244 * init/tests/test_job.c (test_copy): Make sure that the job copy
2245 references and blocks the event; and in the event of failure, doesn't
2246 * init/job.c (job_copy): Reset the start_on and stop_on expressions
2247 in the event of failure.
2248
Scott James Remnante7b6cd62007-06-20 22:17:09 +010022492007-06-20 Scott James Remnant <scott@netsplit.com>
2250
Scott James Remnant9b1d5202007-06-20 23:26:37 +01002251 * TODO: Update.
2252
Scott James Remnantce628ca2007-06-20 23:25:02 +01002253 * init/parse_job.c (parse_on): New generic parsing function to deal
2254 with event expressions, including operators, parentheses, etc.
2255 (parse_on_operator): Function called by parse_on() to deal with an
2256 operator or operand.
2257 (parse_on_paren): Function called by parse_on() to deal with a
2258 parenthesis.
2259 (parse_on_operand): Function called by parse_on_operator() to deal
2260 with a non-operator token.
2261 (parse_on_collect): Function called by all of the above to collect
2262 the operators on the stack and deposit them into the output box,
2263 either for collection by a later operator or for returning from
2264 parse_on().
2265 (stanza_start, stanza_stop): Call the new parse_on() function to
2266 deal with "start on" and "stop on", storing it in the appropriate
2267 part of the job.
2268 * init/tests/test_parse_job.c (test_parse_job): Replace list empty
2269 checks for start_events/stop_events with NULL checks on the new
2270 start_on/stop_on members.
2271 (test_stanza_start, test_stanza_stop): Test new stanza code.
2272
2273 * init/errors.h (PARSE_EXPECTED_EVENT, PARSE_EXPECTED_OPERATOR)
2274 (PARSE_MISMATCHED_PARENS): Add numerics and strings for the errors
2275 that can be generated by parsing an event expression.
2276 * init/conf.c (conf_reload_path): Handle the new errors properly,
2277 including the line number where they occurred.
2278 * logd/jobs.d/logd.in: Update "stop on" to work with the new parser.
2279
Scott James Remnant404f99c2007-06-20 22:18:39 +01002280 * init/parse_job.c (stanza_emits): Each entry in the emits list
2281 is now an NihListEntry with the event name as the string data
2282 pointer, rather than an EventInfo structure (since that structure
2283 is gone).
2284 * init/tests/test_parse_job.c (test_stanza_emits): Update test
2285 case to check for NihListEntry structures.
2286
Scott James Remnante7b6cd62007-06-20 22:17:09 +01002287 * init/parse_job.c: Where the stanza function parses an argument and
2288 can possibly reject it, save the position and line number and do not
2289 return that unless we're happy with the argument. This ensures errors
2290 are raised pointing *at* the argument, rather than past it.
2291 * init/tests/test_parse_job.c: Fix several test case errors where
2292 the buffer was built incorrectly. Pedantically check pos and lineno
2293 after successful parsing, and after errors, to make sure they are
2294 where they should be.
2295
Scott James Remnant77e9d342007-06-18 12:59:22 +010022962007-06-18 Scott James Remnant <scott@netsplit.com>
2297
Scott James Remnantc8ca88e2007-06-18 15:18:02 +01002298 * init/job.h (Job): Replace the start_events and stop_events NihLists
2299 with start_on and stop_on EventOperators.
2300 * init/job.c (job_new): Drop list initialising, and instead just set
2301 the new start_on/stop_on members to NULL.
2302 (job_copy): Copy the entire event operator tree to the new job,
2303 including references and blockers. emits has changed to a list of
2304 NihListEntry with embedded strings, so copy them that way.
2305 (job_run_process): Drop "->info."
2306 (job_handle_event): Instead of iterating the events lists, call
2307 event_operator_handle and check the return value and top node value.
2308 (job_detect_stalled): Modify to iterate the start_on tree.
2309 * init/tests/test_job.c (test_change_state, test_detect_stalled):
2310 Drop references to "->info." since we can get the variables directly.
2311 (test_new): Check that start_on and stop_on are NULL.
2312 (test_copy): Adjust tests of copying start_on and stop_on trees as
2313 well as the emits list.
2314 (test_handle_event, test_handle_event_finished)
2315 (test_detect_stalled): Change references from start_events to start_on,
2316 stop_events to stop_on and construct using EventOperators instead.
2317 (test_handle_event): Update number of blockers now that the event
2318 expressions themselves will block the event.
2319 * init/tests/test_event.c (test_poll): Update number of blockers since
2320 both the events and cause will block it for now; also change
2321 start_events and stop_events to start_on and stop_on respectively.
2322
Scott James Remnant210d6fa2007-06-18 15:12:29 +01002323 * init/event.c (event_operator_copy): Copy the children nodes as well.
2324 * init/tests/test_event.c (test_operator_copy): Test copying
2325 with children nodes.
2326
Scott James Remnant77e7a382007-06-18 14:10:39 +01002327 * init/tests/test_control.c (test_event_emit): Drop "->info."
2328
Scott James Remnant5b27f0b2007-06-18 14:09:49 +01002329 * init/notify.c (notify_event, notify_event_finished): Drop
2330 "->info." from event references.
2331
Scott James Remnant61b7ae82007-06-18 14:05:00 +01002332 * init/process.c (process_setup_environment): Drop "->info." from
2333 cause references
2334 * init/tests/test_process.c (test_spawn): Likewise.
2335
Scott James Remnant77e9d342007-06-18 12:59:22 +01002336 * init/event.h (Event): Directly include the name, args and env
2337 fields rather than using an interim structure; this makes more sense
2338 since we use them differently than a match does.
2339 (EventOperatorType, EventOperator): New structure to build event
2340 expression trees that combine a match with "or" and "and" boolean
2341 operators; solve some problems by holding the reference and blocker
2342 on the matched event inside this structure directly and provide
2343 methods to unblock and reset them.
2344 (EventInfo): Drop this structure completely now that it is unused.
2345 * init/event.c (event_info_new): Rename this structure to
2346 event_operator_new() and initialise the new fields properly.
2347 (event_info_copy): Likewise rename to event_operator_copy and deal
2348 with copying event references and blockers over to the new structure,
2349 since the state is useful to copy.
2350 (event_match): Rename to event_operator_match and switch the arguments
2351 around since it makes slightly more sense that way.
2352 (event_operator_update): Function to update the value of an EVENT_OR
2353 or EVENT_AND operator based on the value of the two children.
2354 (event_operator_handle): Function to iterate an entire expression
2355 tree looking for a given event, and update the values of other
2356 operators if matched.
2357 (event_operator_unblock): Function to iterate an expression tree
2358 and release any events we're blocking.
2359 (event_operator_reset): Function to iterate an expression tree,
2360 unreferencing any events and resetting all values back to FALSE.
2361 (event_new, event_pending, event_finished): Update references to
2362 the Event structure to discard the intermediate "->info."
2363 * init/tests/test_event.c (test_info_new): Rename to
2364 test_operator_new() and test various features of the function added
2365 in the converstion.
2366 (test_info_copy): Likewise rename to test_operator_copy() and add a
2367 few more tests, especially that blockers and references are copied.
2368 (test_match): Rename to test_operator_match() and adjust argument
2369 order to match the change.
2370 (test_new) Call event_init() to avoid a valgrind error and update
2371 references to drop "->info."
2372 (test_poll): Use EventOperators in the job to test event polling,
2373 rather than the old structures.
2374 (test_operator_update, test_operator_handle, test_operator_unblock)
2375 (test_operator_reset): Test behaviour of the new functions.
2376
Scott James Remnantf050aa62007-06-13 12:37:16 +010023772007-06-13 Scott James Remnant <scott@netsplit.com>
2378
2379 * TODO: Update utmp/wtmp thoughts.
2380
Scott James Remnantf9aec8c2007-06-12 12:18:15 +010023812007-06-12 Scott James Remnant <scott@netsplit.com>
2382
Scott James Remnantdd9249d2007-06-12 15:30:19 +01002383 * init/paths.h: Remove extra /, oops.
2384 * init/Makefile.am (install-data-local): Make destination
2385 configuration directories as part of "make install".
2386 (AM_CPPFLAGS): Define LEGACY_CONFDIR to be $(sysconfdir)/event.d
2387 * logd/Makefile.am (jobs.d/logd): Replace mkdir_p with MKDIR_P
2388 * init/main.c: Use macro to pick up /etc/event.d so it can be moved
2389 by configure
2390
Scott James Remnantdc6b5e42007-06-12 14:57:14 +01002391 * TODO: Update.
2392
Scott James Remnant0b3171a2007-06-12 14:55:58 +01002393 * init/Makefile.am (AM_CPPFLAGS): Define CONFDIR to be
2394 $(sysconfdir)/init, replacing the old CFG_DIR definition.
2395 * init/paths.h (CFG_DIR): Replace with CONFDIR definition,
2396 and set the default to /etc/init
2397 * init/main.c: Load configuration from /etc/init/init.conf,
2398 /etc/init/conf.d and /etc/init/jobs.d; retain loading from /etc/event.d
2399 for the time being.
2400 * init/man/init.8: Change reference to directory.
2401 * logd/Makefile.am: Replace references of eventdir with jobsdir,
2402 and event.d with jobs.d
2403 * logd/event.d: Rename to logd/jobs.d
2404
Scott James Remnant2b8a5052007-06-12 14:49:16 +01002405 * init/conf.c (conf_reload): Ignore ENOENT, it's not interesting
2406 in the general case.
2407
Scott James Remnant018e3562007-06-12 14:47:42 +01002408 * init/tests/test_conf.c (test_source_reload): Test the general
2409 reload function.
2410
Scott James Remnant0ca92cb2007-06-12 14:37:09 +01002411 * init/tests/test_conf.c (test_source_free): s/unlink/rmdir/
2412 (test_source_reload_file): Test that configuration files work, and
2413 are parsed with anything alongside ignored automatically.
2414 * init/conf.c (conf_file_filter): As well as not filtering out the
2415 source path itself, we also need to not filter out the path we're
2416 watching which is different in the case of files; we need to know
2417 about it because we handle its removal.
2418 (conf_delete_handler): Compare the path deleted against the path
2419 we're watching, rather than the source path, since this means the
2420 watch needs to be freed.
2421
Scott James Remnantf9aec8c2007-06-12 12:18:15 +01002422 * compat/sysv/shutdown.c: Use nih pidfile functions since they're
2423 more reliable than doing it ourselves.
2424
Scott James Remnant11b08b52007-06-11 12:00:40 +010024252007-06-11 Scott James Remnant <scott@netsplit.com>
2426
Scott James Remnant7e6d3a92007-06-11 18:37:44 +01002427 * init/conf.c (conf_reload_path): Call parse_conf for mixed files
2428 and directories. Make a correction to the old_items code, was
2429 passing the wrong arguments to nih_list_add; the effect we wanted
2430 was that we add the old items head into the list, and remove the
2431 existing head (what we did was add the first item to the old_items
2432 list and then cut the rest out).
2433 * init/tests/test_conf.c (test_source_reload_dir): Rename to
2434 test_source_reload_job_dir, since that's what this does.
2435 (test_source_reload_conf_dir): Add another function that tests
2436 directories of mixed configuration.
2437
Scott James Remnantc12704a2007-06-11 17:17:22 +01002438 * init/parse_conf.c (parse_conf): Parse a configuration file that
2439 defines jobs by name.
2440 (stanza_job): Job stanza, slightly trickier than it would appear to
2441 need to be, to parse the block in-place and keep pos/lineno
2442 consistent.
2443 * init/parse_conf.h: Prototype for external function.
2444 * init/tests/test_parse_conf.c: Test suite for mixed configuration
2445 parsing.
2446 * init/Makefile.am (init_SOURCES): Build and link parse_conf.c and
2447 parse_conf.h
2448 (TESTS): Build and run parse_conf tests
2449 (test_parse_conf_SOURCES, test_parse_conf_LDFLAGS)
2450 (test_parse_conf_LDADD): Details for parse_conf test suite.
2451 (test_conf_LDADD): Add parse_conf.o and conf.o since this calls
2452 them now.
2453
Scott James Remnantc14ec862007-06-11 16:47:34 +01002454 * init/conf.c (conf_source_reload, conf_source_reload)
2455 (conf_reload_path): Add some debugging messages.
2456
Scott James Remnant142a3222007-06-11 16:22:33 +01002457 * init/conf.c (conf_source_new): Add missing call to conf_init()
2458
Scott James Remnant11b08b52007-06-11 12:00:40 +01002459 * init/conf.c (conf_item_new): Drop source parameter, since it's
2460 unused in the function and makes it harder to call this when we
2461 only have one data pointer.
2462 (conf_reload_path): Drop source from conf_item_new() call.
2463 * init/conf.h: Update prototype.
2464 * init/tests/test_conf.c (test_item_new, test_item_free)
2465 (test_file_free): Drop source parameter from calls.
2466
Scott James Remnant56760be2007-06-10 14:23:53 +010024672007-06-10 Scott James Remnant <scott@netsplit.com>
2468
Scott James Remnant7ba2cf62007-06-10 22:20:38 +01002469 * init/main.c (main): Add a handler for the SIGHUP signal
2470 (hup_handler): Handler for SIGHUP, just calls conf_reload().
2471
Scott James Remnant54b2a952007-06-10 22:15:24 +01002472 * init/main.c (main): Read the configuration again.
2473
Scott James Remnantd9619482007-06-10 22:11:42 +01002474 * TODO: Update.
2475
Scott James Remnant4b324142007-06-10 22:08:40 +01002476 * init/tests/test_conf.c (test_source_reload_dir): Reset the priority
2477 and clean up consumed inotify instances.
2478 (test_source_free, test_file_free, test_item_free): Test the free
2479 functions on their own, paying special attention to conf_item_free()
2480 even though this really duplicates other tests.
2481
Scott James Remnant4561b262007-06-10 21:43:52 +01002482 * init/conf.c (conf_reload_path): In the case where we fail to map
2483 the file into memory, we still need to purge all the items that
2484 previously existed.
2485 * init/tests/test_conf.c (test_source_reload): Rename to
2486 test_source_reload_dir, so that we can keep this and the file
2487 tests separate to make it easier to deal with.
2488 (test_source_reload_dir): Add tests for physical and parse errors
2489 when re-loading jobs with and without inotify, and for inotify-based
2490 modification handling of jobs.
2491
Scott James Remnantde27a552007-06-10 21:17:55 +01002492 * init/tests/test_conf.c (test_source_reload): Add test for walk
2493 of non-existant directory with and without inotify; also test for
2494 what happens when the top-level directory is deleted, again with
2495 and without inotify.
2496 * init/conf.c (conf_delete_handler): Handle the case of the top-level
2497 directory being deleted by freeing the watch (so next time we asked
2498 to reload, we can restore it).
2499
Scott James Remnant4ee170f2007-06-10 20:58:09 +01002500 * init/tests/test_conf.c (test_source_reload): Add a test for
2501 deletion of a running job.
2502
Scott James Remnantcf52ef72007-06-10 20:55:41 +01002503 * init/conf.c (conf_item_free): Fix this up; when deleting an item
2504 from a source, we first mark it for deletion unless it's already
2505 marked for replacement. Then if it's the replacement for something
2506 else, we mark that to be replaced by whatever we're being replaced
2507 by (so there are no references to us) and change that state if
2508 necessary. Finally we replace our own item and free the record
2509 before returning.
2510 * init/tests/test_conf.c (test_source_reload): Check that we handle
2511 the cases of modiciation of a running job, modification of a
2512 replacement of a running job and deletion of a replacement for a
2513 running job.
2514
Scott James Remnanta77229e2007-06-10 20:52:55 +01002515 * init/parse_job.c (parse_job): Instead of freeing the previous
2516 replacement, which could leave invalid references to it, mark it
2517 for deletion and change the state.
2518 * init/tests/test_parse_job.c (test_parse_job): Adjust the test so
2519 that we hold a reference to the replacement job and make sure that
2520 the state is changed to deleted, rather than checking for a destructor
2521 being called on it.
2522
Scott James Remnantf1de26c2007-06-10 20:43:16 +01002523 * init/init.supp (conf-init): Add valgrind suppression for the
2524 configuration sources hash table.
2525
Scott James Remnant11a1cf22007-06-10 17:38:06 +01002526 * init/conf.c (conf_item_free): Don't overwrite any previous
2527 replacement, only mark us for deletion if we wouldn't otherwise
2528 be replaced. Add some commented possible code for testing.
2529 * init/tests/test_conf.c (test_source_reload): Test replacement of
2530 jobs works properly; test modification with direct write and with
2531 atomic rename replace; test deletion.
2532
Scott James Remnantfa38c532007-06-10 16:49:13 +01002533 * init/conf.c (conf_reload_path): It turns out that the flag trick
2534 doesn't work for items since we often reparse them within the same
2535 file tag (it works with files because they're atomic and reparsed).
2536 Store the old items in a different list instead.
2537 (conf_source_free): We need to be careful about freeing sources,
2538 so have a function to do it properly.
2539 (conf_item_new): Since the flag member isn't useful, don't bother
2540 setting it.
2541 * init/conf.h: Add conf_source_free prototype.
2542 (ConfFile): Remove flag member.
2543 * init/tests/test_conf.c (test_source_reload): Add test for inotify
2544 create detection.
2545
Scott James Remnant79b9bde2007-06-10 15:43:18 +01002546 * init/conf.c (conf_file_delete): Rename to conf_file_free and match
2547 the pattern of those kinds of functions.
2548 (conf_item_delete): Likewise rename to conf_item_free and match the
2549 pattern of these kinds of functions.
2550 * init/conf.h: Add prototypes.
2551
Scott James Remnantdb56d502007-06-10 15:37:28 +01002552 * init/conf.c (conf_reload_path): Fix bug with job name generation.
2553 Allow non-parsing errors to be returned from the function.
2554 (conf_item_delete): Drop all replacement management code, we'll put
2555 this back through testing.
2556 * init/tests/test_conf.c (test_source_reload): Test reloading adds
2557 the right inotify watch and parses the files, also check that loading
2558 without inotify and mandatory reloading work.
2559
Scott James Remnant56760be2007-06-10 14:23:53 +01002560 * init/conf.c (conf_source_reload): Move the item deletion detection
2561 code from this function, where it would only happen on a mandatory
2562 reload
2563 (conf_reload_path): to this function, where it will happen every time
2564 the file is parsed; which is actually what we want.
2565
Scott James Remnantac1f0682007-06-08 16:04:50 +010025662007-06-08 Scott James Remnant <scott@netsplit.com>
2567
2568 * init/conf.h (ConfItem): Drop the name and replace it with a type.
2569 (ConfItemType): Enum for different types of configuration items
2570 (ConfFile): Change items from a hash table to a list.
2571 * init/conf.c (conf_file_get): Initialise the items member as a list.
2572 (conf_item_set): Rename to conf_item_new again.
2573 (conf_item_new): Allocates a new ConfItem and adds it to the file's
2574 list, we won't reuse items anymore since it doesn't really make sense.
2575 (conf_source_reload): Adjust clean-up code now that items is a list.
2576 (conf_reload_path): Work out the name of jobs found by filename,
2577 allocate a new item for them and parse the job into it. Perform
2578 handling of errors by outputting a warning.
2579 (conf_item_delete): Takes both source and file so we can make
2580 intelligent decisions.
2581 (conf_file_delete): Takes a source and passes it to conf_item_delete
2582 (conf_delete_handler): Pass both source and file to conf_file_delet
Scott James Remnantac1f0682007-06-08 16:04:50 +01002583 * init/tests/test_conf.c (test_file_get): Check that the items
2584 list is empty; rather than the hash being unallocated.
2585 (test_item_set): Rename back to test_item_new and only allocate a
2586 single item which should get added to the list.
2587
Scott James Remnant3c063422007-06-06 13:25:15 +010025882007-06-06 Scott James Remnant <scott@netsplit.com>
2589
Scott James Remnanta940d5c2007-06-06 15:45:26 +01002590 * init/parse_job.c (stanza_respawn): Permit the word "unlimited",
2591 raise a specific error for illegal limit and illegal interval.
2592 (stanza_pid, stanza_kill, stanza_normal, stanza_umask)
2593 (stanza_nice, stanza_limit): Raise specific errors rather than
2594 a generic "illegal value" error.
2595 * init/tests/test_parse_job.c (test_stanza_respawn): Check that
2596 we can use "unlimited", also check for new error return.
2597 (test_stanza_pid, test_stanza_kill, test_stanza_normal)
2598 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Check
2599 for new specific errors.
2600 * init/errors.h: Replace CFG_ILLEGAL_VALUE with a series of parse
2601 errors.
2602
Scott James Remnantd516e3a2007-06-06 13:37:45 +01002603 * init/conf.c: Comments.
2604
Scott James Remnantf5ade4a2007-06-06 13:36:24 +01002605 * init/conf.c (conf_item_set): Call out to conf_item_delete() to
2606 handle unsetting of an item's data.
2607 (conf_source_reload): Add code to deal with mandatory reloading,
2608 calls conf_file_delete() and/or conf_item_delete() as appropriate.
2609 (conf_delete_handler): Call conf_file_delete() on the ConfFile that
2610 we find.
2611 (conf_file_delete): Function to delete all items in a file.
2612 (conf_item_delete): Placeholder function to delete an item.
2613
Scott James Remnant3c063422007-06-06 13:25:15 +01002614 * init/conf.c (conf_file_new): Rename to conf_file_get; in practice
2615 we never just want to allocate one of these, we always want to
2616 return the existing entry if it exists.
2617 (conf_item_new): Rename to conf_item_set; again in practice we always
2618 want to update an existing item. This function will grow the "deal
2619 with replacement" stuff.
2620 (conf_reload): Start putting in place the code that will allow
2621 mandatory reloads, as well as initial setup. This function iterates
2622 over the sources and deals with errors.
2623 (conf_source_reload): Function to reload an individual source, calls
2624 out to one of the following two functions and will eventually perform
2625 the deleted items scan.
2626 (conf_source_reload_file): Set up a watch on a file, and reload it.
2627 (conf_source_reload_dir): Set up a watch on a directory and reload it.
2628 (conf_file_filter): Filter for watching parent directory of files.
2629 (conf_create_modify_handler): File creation and modification handler.
2630 (conf_delete_handler): File deletion handler.
2631 (conf_file_visitor): Tree walk handler.
2632 (conf_reload_path): Function that deals with files themselves,
2633 currently just sorts out the ConfFile structure and maps the file
2634 into memory.
2635 * init/conf.h: Add new prototypes, update existing ones.
2636 * init/tests/test_conf.c (test_file_new): Rename to test_file_get,
2637 also test repeated calls when already in the table.
2638 (test_item_new): Rename to test_item_set, also test repeated calls
2639 when already in the table.
2640 (test_source_reload): Start of test for reloading sources.
2641
Scott James Remnant83826412007-06-05 16:52:12 +010026422007-06-05 Scott James Remnant <scott@netsplit.com>
2643
2644 * init/conf.c: Make a start on the new configuration management
2645 routines, which will allow finer-grained tracking of configuration
2646 and support mandatory reloading.
2647 (conf_source_new, conf_file_new, conf_item_new): Start off with the
2648 functions to allocate the tracking structures we need to use.
2649 * init/conf.h: Structures and prototypes
2650 * init/tests/test_conf.c: Test suite for allocation functions.
2651 * init/Makefile.am (init_SOURCES): Build and link conf.c and conf.h
2652 (TESTS): Run the conf test suite.
2653 (test_conf_SOURCES, test_conf_LDFLAGS, test_conf_LDADD): Details for
2654 the conf test suite.
2655
Scott James Remnant1f719242007-06-04 10:14:38 +010026562007-06-04 Scott James Remnant <scott@netsplit.com>
2657
Scott James Remnant758cd3a2007-06-04 11:49:02 +01002658 * init/parse_job.c (stanza_description, stanza_author, stanza_version)
2659 (stanza_chroot, stanza_chdir, stanza_pid): Instead of erroring when
2660 the string has already been allocated, free it and replace it with the
2661 new one. Attempting to forbid duplicates is just too inconsistent,
2662 especially for the integer ones which we compare against the default;
2663 using the last one allows us to be entirely consistent.
2664 (stanza_daemon, stanza_respawn, stanza_service, stanza_instance):
2665 Don't error if the flag is already set, just ignore it.
2666 (stanza_respawn, stanza_pid, stanza_kill, stanza_console)
2667 (stanza_umask, stanza_nice): Don't compare the current value against
2668 the default, just overwrite it!
2669 (parse_exec, parse_script): Free existing process command string
2670 before setting a new one over the top.
2671 (parse_process, stanza_exec, stanza_script, stanza_limit): Instead of
2672 erroring if the structure is already set and allocated, just don't
2673 allocate a new one and allow its members to be overwritten.
2674 * init/tests/test_parse_job.c (test_stanza_exec)
2675 (test_stanza_script, test_stanza_pre_start)
2676 (test_stanza_post_start, test_stanza_pre_stop)
2677 (test_stanza_post_stop, test_stanza_description)
2678 (test_stanza_author, test_stanza_version, test_stanza_daemon)
2679 (test_stanza_respawn, test_stanza_service, test_stanza_instance)
2680 (test_stanza_pid, test_stanza_kill, test_stanza_console)
2681 (test_stanza_umask, test_stanza_nice, test_stanza_limit)
2682 (test_stanza_chroot, test_stanza_chdir): Replace tests that check
2683 for an error in the case of duplicate stanzas with tests that make
2684 sure the last of the duplicates is used.
2685 * init/errors.h (CFG_DUPLICATE_VALUE, CFG_DUPLICATE_VALUE_STR): Drop
2686 this error, since we don't consider this a problem anymore.
2687
Scott James Remnant1f719242007-06-04 10:14:38 +01002688 * upstart/Makefile.am (libupstart_la_LIBADD): Add $(LTLIBINTL)
2689 * init/Makefile.am (init_LDADD): Reorder and add $(LTLIBINTL)
2690 * util/Makefile.am (initctl_LDADD): Reorder and add $(LTLIBINTL)
2691 * compat/sysv/Makefile.am (reboot_LDADD): Reorder and add $(LTLIBINTL)
2692 (runlevel_LDADD): add $(LTLIBINTL)
2693 (shutdown_LDADD): Reorder and add $(LTLIBINTL)
2694 (telinit_LDADD): Reorder and add $(LTLIBINTL)
2695 * logd/Makefile.am (logd_LDADD): Add $(LTLIBINTL)
2696
Scott James Remnante8b584e2007-06-03 19:08:38 +010026972007-06-03 Scott James Remnant <scott@netsplit.com>
2698
Scott James Remnant48a3a942007-06-03 19:21:34 +01002699 * init/tests/test_job.c (test_run_process): Add a test case for a
2700 crasher when the event has no arguments.
2701 * init/job.c (job_run_process): Fix the bug, we need to check the
2702 arguments before trying to append them.
2703
Scott James Remnante8b584e2007-06-03 19:08:38 +01002704 * init/cfgfile.c, init/cfgfile.h, init/tests/test_cfgfile.c: Rename
2705 to parse_job and strip out all functions except the parsing and stanza
2706 ones.
2707 * init/Makefile.am (init_SOURCES): Build and link parse_job.c and h
2708 (TESTS): Run the parse job test suite
2709 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
2710 Rename and update.
2711 * init/parse_job.c: Rename all cfg_stanza_*() functions to just
2712 stanza_*(), rename all cfg_parse_*() functions to just parse_*().
2713 (parse_job, parse_process, stanza_exec, stanza_script, stanza_start)
2714 (stanza_stop, stanza_emits, stanza_normal, stanza_env, stanza_limit):
2715 Don't use NIH_MUST, it's fine to be out of memory and we should fail
2716 in that case with a useful error. The user can always reload the
2717 config file.
2718 (cfg_read_job, cfg_watch_dir, cfg_job_name, cfg_create_modify_handler)
2719 (cfg_delete_handler, cfg_visitor): Drop these functions for now.
2720 * init/parse_job.h: Update so it just contains the one prototype.
2721 * init/tests/test_parse_job.c: Update all tests to pass a string
2722 to parse_job(), and check errors raised; rather than mucking around
2723 with file descriptors all of the time. Spend the effort while we're
2724 in here to run TEST_ALLOC_FAIL where we can.
2725 * init/main.c: Drop config file loading for now since it's missing.
2726
Scott James Remnanta482d9a2007-05-27 16:57:35 +010027272007-05-27 Scott James Remnant <scott@netsplit.com>
2728
Scott James Remnante7464fd2007-06-02 11:43:11 +01002729 * init/cfgfile.h (CFG_DIR): Drop this define, since it's in paths.h
2730 (CfgDirectory):
2731
Scott James Remnanta482d9a2007-05-27 16:57:35 +01002732 * init/cfgfile.c (cfg_read_job): Separate out the job-handling code
2733 into a new function that we could call from a stanza if we want
2734 later; this one now just maps the file into memory and deals with
2735 exceptions from the parsing.
2736 (cfg_parse_job): Function containing the seperated out code; parses
2737 a new job, marking it as a replacement for any existing job with the
2738 same name. Drop the warnings for using pid options without a daemon,
2739 since these are actually useful for other things later.
2740 * init/tests/test_cfgfile.c (test_read_job): Drop the check on
2741 unexpected daemon options, since we don't issue these warnings
2742 anymore.
2743
Scott James Remnant4fa7b872007-05-20 13:09:17 +010027442007-05-20 Scott James Remnant <scott@netsplit.com>
2745
Scott James Remnant2b4e0ed2007-05-20 14:00:06 +01002746 * init/event.c (event_match): Change to accept Event as the first
2747 argument and EventInfo as the second, making it obvious that this
2748 matches a received Event against known EventInfo rather than just
2749 comparing two info structs (since the order matters).
2750 * init/event.h: Update prototype.
2751 * init/tests/test_event.c (test_match): Update test accordingly.
2752 (test_poll): Fix typo.
2753 * init/job.c (job_handle_event): Pass in the event as the first
2754 argument to event_match, rather than its info.
2755 * TODO: Update.
2756
Scott James Remnant64b5f682007-05-20 13:14:51 +01002757 * init/job.c (job_emit_event): Return the event that we emit; don't
2758 bother tracking block status or setting blocked, leave that to the
2759 state loop so things are more obvious.
2760 (job_change_state): Set the blocked flag here for starting and stopping
2761 to the return value of job_emit_event().
2762
Scott James Remnant4fa7b872007-05-20 13:09:17 +01002763 * init/event.c (event_ref, event_unref): Reference counting of events
2764 so we don't free those we still need.
2765 (event_block, event_unblock): Blocker counting that replaces the
2766 previous jobs member.
2767 (event_new): Initialise refs and blockers fields.
2768 (event_emit_finished): Remove this function.
2769 (event_poll): Handle the new done state, and deal with the blockers
2770 and references counts; turns out that we can fall all the way through
2771 this switch if these are zero without needing to check again.
2772 (event_pending): Remove call to event_emit_finished, the event_poll()
2773 loop handles this case now.
2774 (event_finished): Set progress to done on the way out.
2775 * init/event.h (EventProgress): Add new done state
2776 (Event): Add refs and blockers members, replacing jobs
2777 * init/tests/test_event.c (test_new): Check refs and blockers are
2778 initialised to zero.
2779 (test_ref, test_unref, test_block, test_unblock): Check the ref
2780 counting function behaviours.
2781 (test_emit_finished): Drop this function since it's not used
2782 * init/job.c (job_change_cause): Reference and block the event,
2783 and unblock and unreference before changing.
2784 (job_emit_event): Reference the event that blocks the job from
2785 continuing.
2786 (job_handle_event_finished): Unreference the blocking event again.
2787 (job_change_state): Make sure that blocked has been cleared before
2788 allowing a state change.
2789 * init/tests/test_job.c: Change tests to use refs/blockers on the
2790 cause event when counting, and also to follow the status of blocked
2791 since that is now ref-counted as well.
2792
Scott James Remnantfea1e9c2007-05-18 15:42:25 +010027932007-05-18 Scott James Remnant <scott@netsplit.com>
2794
Scott James Remnant186ecdc2007-05-18 20:18:17 +01002795 * init/main.c (main, cad_handler, kbd_handler, pwr_handler): Use
2796 event_new rather than event_emit.
2797 * init/job.h (Job): Change type of cause and blocked to Event
2798 * init/job.c (job_change_goal, job_change_cause, job_emit_event)
2799 (job_handle_event, job_handle_event_finished): Update all references
2800 to EventEmission to use Event instead.
2801 (job_detect_stalled): Call event_new instead of event_emit
2802 (job_run_process): Use the info member of cause, not event member
2803 * init/tests/test_job.c (test_change_goal, test_change_state)
2804 (test_run_process, test_child_reaper, test_handle_event)
2805 (test_handle_event_finished): Update all references to EventEmission
2806 to use Event instead.
2807 (test_detect_stalled): Correct to use right structure types.
2808 * init/process.c (process_setup_environment): Use cause's info member,
2809 rather than event member.
2810 * init/tests/test_process.c (test_spawn): Update to use Event.
2811 * init/notify.h (NotifySubscription): Change member to event
2812 * init/notify.c (notify_subscribe_event)
2813 (notify_subscription_find, notify_job_event, notify_event)
2814 (notify_event_finished): Update functions to use event member and
2815 Event structures.
2816 * init/tests/test_notify.c (test_subscribe_event)
2817 (test_subscription_find, test_job, test_job_event, test_event)
2818 (test_event_finished): Update to use Event instead of EventEmission
2819 * init/control.c (control_event_emit): Update to use event_new.
2820 * init/tests/test_control.c (test_event_emit)
2821 (test_subscribe_events, test_unsubscribe_events): Update to use
2822 Event rather than EventEmission.
2823
2824 * init/event.h: Fix up a few references.
2825 * init/tests/test_event.c (test_new): Remove reference to emission.
2826
Scott James Remnant3a6b7f62007-05-18 19:54:45 +01002827 * init/event.h (EventEmission): Rename to Event, and rename event
2828 member to info.
2829 * init/event.c (event_emit_next_id): Rename to event_next_id
2830 (event_emit): Rename to event_new, and add standard parent argument.
2831 (event_emit_find_by_id): Rename to event_find_by_id
2832 (event_poll): Iterate over Events in the list
2833 (event_pending, event_finished): Operate on Event
2834 * init/tests/test_event.c (test_emit): Rename to test_new and
2835 adjust for names and arguments.
2836 (test_emit_find_by_id): Rename to test_find_by_id and adjust for
2837 names.
2838 (test_emit_finished, test_poll): Adjust names.
2839
Scott James Remnant23adaa42007-05-18 19:17:42 +01002840 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
2841 (cfg_stanza_emits): Convert to use EventInfo and event_info_*.
2842 * init/job.c (job_copy): Use EventInfo and event_info_copy.
2843 (job_handle_event, job_detect_stalled): Iterate EventInfo structures
2844 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop)
2845 (test_stanza_emits): Update to use EventInfo
2846 * init/tests/test_job.c (test_copy, test_handle_event)
2847 (test_handle_event_finished, test_detect_stalled): Update to use
2848 EventInfo and event_info_new
2849 * init/event.c (event_copy): Use nih_str_array_copy here, to make the
2850 code somewhat simpler.
2851 (event_finished): Copy the arguments and environment from the old
2852 event, rather than stealing and reparenting.
2853 * init/job.c (job_copy): Use nih_str_array_copy here too.
2854 (job_run_process): Use nih_str_array_append to add the arguments from
2855 the emission onto the command run.
2856
Scott James Remnantccf3ac22007-05-18 19:17:36 +01002857 * init/event.h (Event): Rename to EventInfo, since this structure
2858 representations information about an event, rather than an actual
2859 event in progress.
2860 * init/event.c (event_new): Rename to event_info_new, also now can
2861 take arguments and environment like event_emit() can.
2862 (event_copy): Rename to event_info_copy.
2863 * init/tests/test_event.c (test_new): Rename to test_info_new,
2864 update names in test and test being given args or env.
2865 (test_copy): Rename to test_info_copy and update names in test.
2866 (test_match, test_poll): Use EventInfo.
Scott James Remnant4a558b62007-05-18 18:41:12 +01002867
Scott James Remnantfea1e9c2007-05-18 15:42:25 +01002868 * TODO: Update.
2869
Scott James Remnantc043a8a2007-04-24 12:59:54 +010028702007-04-24 Scott James Remnant <scott@netsplit.com>
2871
2872 * configure.ac: Add AM_PROG_CC_C_O since we use per-target flags
2873 for one of the test cases.
2874
Scott James Remnant0495ff82007-03-16 17:18:00 +000028752007-03-16 Scott James Remnant <scott@netsplit.com>
2876
2877 * upstart/message.c (upstart_message_newv): Add va_end to match
2878 va_copy because the standard says so.
2879 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add
2880 va_end here as well.
2881
Scott James Remnant5b78ebf2007-03-13 17:04:16 +000028822007-03-13 Scott James Remnant <scott@netsplit.com>
2883
Scott James Remnantd03c53c2007-03-13 19:13:19 +00002884 * init/main.c: Wait until we've closed inherited standard file
2885 descriptors and opened the console instead before trying to open the
2886 control socket; otherwise we end up closing it by accident if we
2887 weren't opened with sufficient descriptors in the first place.
2888 Also wait until we've set up the logger before trying to parse the
2889 configuration. In fact both of these things need to be pretty low
2890 down the main() function.
2891
Scott James Remnantdde290e2007-03-13 18:52:30 +00002892 * init/tests/test_job.c (test_run_process): Skip /dev/fd test cases
2893 if that's not available.
2894
Scott James Remnant32844192007-03-13 18:47:54 +00002895 * init/tests/test_control.c (test_log_priority): Make sure we know
2896 that the message has been sent before calling the watcher.
2897
Scott James Remnanta951cec2007-03-13 18:39:13 +00002898 * init/cfgfile.c (cfg_watch_dir): We get ENOSYS for missing inotify
2899 support, not EOPNOTSUPP.
2900 * init/tests/test_cfgfile.c (test_watch_dir): Actually make the
2901 directory tree before testing for inotify, since we use the same
2902 tree there too.
2903
Scott James Remnant7f6ac152007-03-13 18:08:31 +00002904 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
2905 name can be used uninitialised.
2906 * init/tests/test_cfgfile.c (test_watch_dir): Correct an error where
2907 i wouldn't be initialised if we skipped the inotify tests.
2908
2909 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
Scott James Remnant7e5d0062007-03-13 17:27:38 +00002910 * init/process.c (process_setup_environment): job id fits inside
2911 a %u now
2912
Scott James Remnant72301022007-03-13 17:27:09 +00002913 * upstart/message.h: Style; always refer to "unsigned int" as
2914 "unsigned int", and never "unsigned.
2915 * upstart/tests/test_message.c (my_handler): Catch a stray couple
2916 of "unsigned"s
2917
Scott James Remnant25a71542007-03-13 17:25:34 +00002918 * init/control.c (control_job_query, control_job_start)
2919 (control_job_stop): Change type of id argument to unsigned int,
2920 and call printf with %u to output it.
2921 * init/tests/test_control.c (check_job, check_job_instance)
2922 (check_job_instance_end, check_job_status__waiting)
2923 (check_job_status_end__waiting, check_job_status__starting)
2924 (check_job_status_end__starting, check_job_status__running)
2925 (check_job_status_end__running, check_job_status__pre_stop)
2926 (check_job_status_end__pre_stop, check_job_status__stopping)
2927 (check_job_status_end__stopping, check_job_status__deleted)
2928 (check_job_status_end__deleted, check_job_unknown)
2929 (check_job_invalid, check_job_unchanged, check_event): Change
2930 type of id arguments to unsigned int.
2931 (check_list): Change type of id to unsigned int.
2932 * init/tests/test_notify.c (check_job_status)
2933 (check_job_status_end, check_job_finished, check_event)
2934 (check_event_caused, check_event_finished): Change type of id
2935 arguments to unsigned int.
2936
Scott James Remnant4e7af0c2007-03-13 17:20:20 +00002937 * init/job.h (Job): Change the type of the id to unsigned int.
2938 * init/job.c (job_next_id): Change ids to be unsigned ints, and now
2939 we can just use %u in the nih_error call.
2940 (job_find_by_id): Change argument to be unsigned int
2941 * init/tests/test_job.c (test_find_by_id): Change id type to unsigned
2942 int.
2943 * init/event.h (Event): Change the type of the id to unsigned int.
2944 * init/event.c (event_emit_next_id): Change ids to be unsigned ints,
2945 and now we can just use %u in the nih_error call.
2946 (event_emit_find_by_id): Change argument to be unsigned int
2947 * init/tests/test_event.c (test_emit, test_emit_find_by_id)
2948 (check_event, check_event_finished): Change id type to unsigned int.
2949
Scott James Remnant8de2c532007-03-13 17:14:27 +00002950 * util/initctl.c (output_name): Use an unsigned int for the job id,
2951 which means we can use ordinary %u for the printf argument.
2952 (handle_job, handle_job_finished, handle_job_instance)
2953 (handle_job_instance_end, handle_job_status)
2954 (handle_job_status_end, handle_job_unknown, handle_job_invalid)
2955 (handle_job_unchanged, handle_event, handle_event_caused)
2956 (handle_event_finished): Change argument type of id from uint32_t
2957 to unsigned int.
2958 (job_info_output): Change output type of id from %zu to %u
2959
Scott James Remnant92406412007-03-13 17:10:40 +00002960 * upstart/message.c (upstart_message_handle): Use unsigned int for
2961 ids, rather than a fixed-width type.
2962 * upstart/tests/test_message.c (my_handler): Use unsigned int for
2963 the ids, and give "unsigned int" instead of "unsigned" to va_arg as
2964 a matter of style.
2965
Scott James Remnant5b78ebf2007-03-13 17:04:16 +00002966 * upstart/wire.c (upstart_push_int, upstart_pop_int): Send over the
2967 wire using a plain old integer type, instead of a fixed width type;
2968 there's no advantage to using the fixed-width type and we could hurt
2969 ourselves if we tried running on ILP64.
2970 (upstart_push_unsigned, upstart_pop_unsigned): Likewise use a plain
2971 unsigned int over the wire.
2972 (upstart_push_string, upstart_pop_string): Use an unsigned int for
2973 the length of the string, technically this means that we silently
2974 truncate any string that's greater than 4GB on 64-bit platforms;
2975 it's either that or make the test cases harder (we did this before
2976 anyway).
2977 (upstart_push_header, upstart_pop_header): Type is always an unsigned
2978 int (best conversion from an enum)
2979
Scott James Remnant57f02a72007-03-11 12:53:49 +000029802007-03-11 Scott James Remnant <scott@netsplit.com>
2981
Scott James Remnantfc7e60d2007-03-11 19:13:41 +00002982 * configure.ac: Bump version to 0.3.9
2983
Scott James Remnant7c862ed2007-03-11 19:13:24 +00002984 * NEWS: Update.
2985
Scott James Remnant2bc5c5e2007-03-11 19:01:57 +00002986 * util/man/initctl.8: Document the new commands.
2987
Scott James Remnantd055a9d2007-03-11 17:58:15 +00002988 * TODO: Update.
2989
Scott James Remnant19198252007-03-11 17:57:34 +00002990 * init/job.c (job_handle_event): Correct the function so we don't
2991 try and stop the master of an instance, and cause an assertion error.
2992
Scott James Remnantbea9e8d2007-03-11 17:41:58 +00002993 * util/initctl.c: Oops, correct function pointers in command table
2994
2995 * util/tests/test_initctl.c (test_version_action):
2996
Scott James Remnant509f8a62007-03-11 17:39:27 +00002997 * util/initctl.c (handle_version): Handle receipt of the version
2998 reply.
2999 (version_action): Send the version-query message to the server and
3000 expect one response.
3001 (log_priority_action): Parse the single argument into an NihLogLevel
3002 and send it to the server.
3003
Scott James Remnantae1927e2007-03-11 13:45:13 +00003004 * init/control.c (control_version_query, control_log_priority):
3005 Functions to handle the new messages from the server pov
3006 * init/tests/test_control.c (test_version_query)
3007 (test_log_priority): Test the new messages are handled properly.
3008 (check_version): Check the version string matches.
Scott James Remnantebeb2b62007-03-11 13:33:36 +00003009 * upstart/message.h: Add messages for querying the version of the
3010 init daemon and changing the log priority.
3011 * upstart/message.c (upstart_message_newv)
3012 (upstart_message_handle): Marshal the new messages.
3013 * upstart/tests/test_message.c (test_new, my_handler)
3014 (test_handle): Test the marshalling of the new messages,
3015
Scott James Remnant57312ad2007-03-11 12:55:32 +00003016 * upstart/libupstart.ver: Add enum functions to the global list.
3017
Scott James Remnant57f02a72007-03-11 12:53:49 +00003018 * util/initctl.c (start_action, stop_action): Imply --no-wait if
3019 we take the job id or name from an environment variable, since we'd
3020 end up waiting for ourselves otherwise
3021 * util/tests/test_initctl.c (test_start_action, test_stop_action):
3022 Update test cases to make sure no-wait is implied.
3023
Scott James Remnantcd84c312007-03-09 12:51:31 +000030242007-03-09 Scott James Remnant <scott@netsplit.com>
3025
Scott James Remnantb1c7eb22007-03-09 21:35:52 +00003026 * configure.ac: Bump version to 0.3.8
3027
Scott James Remnant79a3c9a2007-03-09 21:35:31 +00003028 * NEWS: Updated.
3029 * configure.ac: Increase version to 0.3.7
3030
Scott James Remnantcf8ede02007-03-09 19:56:07 +00003031 * init/tests/test_job.c (test_change_state): Add a test case for
3032 deleting the last instance of a replaced job.
3033 * init/job.c (job_change_state): When moving a instance of a job into
3034 the deleted state, check whether we should replace the job it's an
3035 instance of, and if so, change that job's state too.
3036 * TODO: Update.
3037
Scott James Remnant51881912007-03-09 18:15:58 +00003038 * util/initctl.c (handle_job_list): Always allocate current_list,
3039 since we need it to be the parent of pointers we attach to it.
3040 (handle_job_list_end): Always free the current list, only suppress
3041 output if there aren't any entries in it.
3042 (initctl_recv): Check the current_list pointer, no need for in_list
3043 (handle_job_instance, handle_job_instance_end, handle_job_status):
3044 Check current_list not in_list.
3045 * util/tests/test_initctl.c: Correct some memory leaks.
3046
Scott James Remnant46390a72007-03-09 17:38:35 +00003047 * init/process.c (process_setup_environment): Set the UPSTART_JOB_ID
3048 environment variable to the job's unique id.
3049 * init/tests/test_process.c (test_spawn): Make sure it's set.
3050
Scott James Remnant671c31c2007-03-09 17:34:34 +00003051 * util/man/initctl.8: Update the initctl manpage.
3052 * compat/sysv/man/reboot.8: Correct a minor grammar error.
3053 * compat/sysv/man/shutdown.8: Fix reference from runlevel to telinit.
3054
Scott James Remnantecf322c2007-03-09 16:58:48 +00003055 * README: Add a README that copies the text from the web page and
3056 adds some notes about recommended operating system versions.
3057
Scott James Remnant4f19cb92007-03-09 16:48:41 +00003058 * util/initctl.c: Completely rewrite initctl, top to bottom; handling
3059 of the new messages is done natively, meaning that the commands just
3060 vary the requests send and number of responses expected.
3061 * util/tests/test_initctl.c: Test all of the new code.
3062
Scott James Remnant06abbec2007-03-09 13:02:38 +00003063 * init/main.c: Improve restarting and rescuing a little; store the
3064 program path in a static variable so we can always access it, and
3065 use the exported loglevel to pass the same to the new process.
3066 * TODO: Update.
3067
Scott James Remnantcd84c312007-03-09 12:51:31 +00003068 * compat/sysv/shutdown.c: More error/fatal adjustments.
3069 * compat/sysv/telinit.c: More error/fatal adjustments.
3070
Scott James Remnantab1dd0d2007-03-08 12:29:02 +000030712007-03-08 Scott James Remnant <scott@netsplit.com>
3072
Scott James Remnant31421b72007-03-08 23:53:05 +00003073 * init/main.c (main, crash_handler): Promote deadly errors to nih_fatal
3074 * logd/main.c (main): Promote deadly errors to nih_fatal
3075 * compat/sysv/reboot.c (main): Promote deadly errors to nih_fatal
3076 * compat/sysv/shutdown.c (main, shutdown_now): Promote deadly errors
3077 to nih_fatal
3078 * compat/sysv/telinit.c (main): Promote deadly errors to nih_fatal
3079
Scott James Remnant12d741e2007-03-08 23:39:59 +00003080 * init/event.c (event_pending): The message that we're handling an
3081 event should be logged with --verbose.
3082
Scott James Remnant5cf17ea2007-03-08 15:42:32 +00003083 * init/cfgfile.c (cfg_parse_script): Remove the unnecessary check for
3084 a token inside a script block.
3085
Scott James Remnant3ee512d2007-03-08 14:30:21 +00003086 * TODO: Update.
3087
Scott James Remnant9435b8b2007-03-08 14:22:45 +00003088 * init/control.c (control_watch_jobs): Rename to control_subscribe_jobs
3089 and update to handle new event name.
3090 (control_unwatch_jobs): Rename to control_unsubscribe_jobs and update
3091 to handle the new event name.
3092 (control_watch_events): Rename to control_subscribe_events and update
3093 to handle the new event name.
3094 (control_unwatch_events): Rename to control_unsubscribe_events and
3095 update to handle the new event name.
3096 * init/tests/test_control.c (test_watch_jobs): Rename to
3097 test_subscribe_jobs and update to new event name.
3098 (test_unwatch_jobs): Rename to test_unsubscribe_jobs and update to
3099 new event name.
3100 (test_watch_events): Rename to test_subscribe_events and update to
3101 new event name.
3102 (test_unwatch_events): Rename to test_unsubscribe events and update
3103 to new event name.
3104
3105 * upstart/message.h: Rename the watch commands to subscribe/unsubscribe
3106 and regroup with new message numbers.
3107 * upstart/message.c (upstart_message_newv)
3108 (upstart_message_handle): Marshal the updated subscription messages.
3109 * upstart/tests/test_message.c (test_new, my_handler)
3110 (test_handle): Update tests to new names and numbers.
3111 * TODO: Update.
3112
Scott James Remnant47d4b8b2007-03-08 13:24:59 +00003113 * upstart/message.c (upstart_message_handle): Raise a the unknown
3114 message error if the type is unknown, rather than the invalid message
3115 error.
3116 * upstart/tests/test_message.c (test_handle): Correct test case.
3117
Scott James Remnant05345162007-03-08 12:37:09 +00003118 * init/job.c (job_change_state): Correct a problem here too, when
3119 moving from pre-stop to running, we don't want to emit a started event
3120 since we never emitted a stopping event and never killed the process
3121 anyway. We do need to notify the job as finished, since the process
3122 that tried to stop it will need to be told not to wait any longer.
3123 * init/tests/test_job.c (test_change_state): Add a test for pre-stop
3124 back to running.
3125
Scott James Remnantab1dd0d2007-03-08 12:29:02 +00003126 * doc/states.dot: Fix an error in the state diagram; when moving from
3127 starting back to waiting, due to a failed respawn, we need to emit
3128 the stopped event otherwise it will never happen.
3129 * doc/states.png: Update.
3130
Scott James Remnant609b24e2007-03-05 12:05:20 +000031312007-03-05 Scott James Remnant <scott@netsplit.com>
3132
Scott James Remnantfd5609b2007-03-05 20:48:06 +00003133 * upstart/message.c (upstart_message_new): Make this a wrapper around
3134 (upstart_message_newv): which has all the old code, but accepts a
3135 va_list instead of making its own.
3136 * upstart/message.h: Add prototype.
3137
Scott James Remnant502ea702007-03-05 20:47:18 +00003138 * init/main.c (crash_handler): Simply trying to leave a SEGV handler
3139 doesn't work so well, we end up repeating the problem instruction.
3140 We really can't resume from this point, and can't even jump elsewhere
3141 since our state is probably buggered up. Only thing for it is to
3142 re-exec ourselves with a clean state.
3143
Scott James Remnantb27ad2e2007-03-05 20:45:04 +00003144 * init/cfgfile.c (cfg_read_job, cfg_delete_handler): Don't try and
3145 free the magic (void *)-1 replacement (delete).
3146
Scott James Remnant4cd63672007-03-05 16:15:39 +00003147 * util/events.c, util/events.c, util/jobs.c, util/jobs.h: With the
3148 new message responses, that intermix event and job information freely,
3149 it no longer makes sense to distinguish between them. So fold these
3150 files back into the main initctl.c
3151 * util/initctl.h: Drop unused header.
3152 * util/Makefile.am (initctl_SOURCES): Update sources list.
3153 (TESTS): Change which tests we build
3154 (test_initctl_SOURCES, test_initctl_CFLAGS, test_initctl_LDFLAGS)
3155 (test_initctl_LDADD): Build the new combined test case binary, use
3156 an automake feature to rebuild initctl.c with -DTEST and a different
3157 .o file, and thus be able to define out main()
3158
3159 * util/tests/test_events.c, util/tests/test_jobs.c: Collapse the two
3160 test case files into one single
3161 * util/tests/test_initctl.c
3162
Scott James Remnant751245c2007-03-05 14:35:09 +00003163 * init/control.c (control_job_find): And implement the find function
3164 that returns a list of jobs matching an optional pattern.
3165 * init/tests/test_control.c: Make sure we do send all messages.
3166 (check_list): Complex function to check the responses to a job list
3167 (test_job_find): Test a couple of job lists.
3168 * init/tests/test_notify.c: Make sure we do send all messages.
3169
Scott James Remnant4ea9ddd2007-03-05 13:33:55 +00003170 * init/control.c (control_job_query): Implement the query message,
3171 this just needs to return the status or instance set.
3172 * init/tests/test_control.c (test_job_query): Test the query command.
3173 (check_job_status__deleted, check_job_status_end__deleted): Pair of
3174 functions to check we can query deleted jobs directly.
3175
Scott James Remnanteca04df2007-03-05 13:18:00 +00003176 * init/control.c (control_send_instance): Function to send an instance
3177 job, collating all of its instances together.
3178 * init/control.h: Update.
3179 * init/tests/test_control.c (test_send_instance): Check we receive
3180 the right messages.
3181 (check_job_instance, check_job_instance_end): Pair of functions to
3182 check the instance messages.
3183
Scott James Remnantd62b9042007-03-05 13:04:02 +00003184 * upstart/message.h: Add new UPSTART_JOB_INSTANCE and
3185 UPSTART_JOB_INSTANCE_END messages which we'll use to communicate that
3186 a job is an instance, and group the instances of it together.
3187 * upstart/message.c (upstart_message_new, upstart_message_handle):
3188 Marshal the new instance messages.
3189 * upstart/tests/test_message.c (test_new, my_handler)
3190 (test_handle): Test the new message types.
3191
Scott James Remnant609b24e2007-03-05 12:05:20 +00003192 * upstart/message.h: Restore arguments to JOB_LIST, but rename to
3193 pattern since that's what it is.
3194 * upstart/message.c (upstart_message_handle): Restore arguments
3195 with updated name.
3196 * upstart/tests/test_message.c (test_new, my_handler)
3197 (test_handle): Restore tests for arguments, rename and make sure we
3198 include a wildcard.
3199
Scott James Remnantf1091d12007-03-04 01:09:16 +000032002007-03-04 Scott James Remnant <scott@netsplit.com>
3201
Scott James Remnantbfb31a12007-03-04 20:52:43 +00003202 * upstart/message.h: Drop arguments to JOB_LIST.
3203 * upstart/message.c (upstart_message_new, upstart_message_handle):
3204 Drop arguments to JOB_LIST.
3205 * upstart/tests/test_message.c (test_new, my_handler)
3206 (test_handle): Drop the arguments from the test.
3207
Scott James Remnant117e16c2007-03-04 20:17:25 +00003208 * init/control.c (control_job_start): Update to return INVALID for
3209 instances and replacements; add the forgotten UPSTART_JOB message.
3210 (control_job_stop): Update to return INVALID for replacements; add
3211 the forgotten UPSTART_JOB message. Deal with instance masters
3212 magically by iterating all instances and stopping those instead.
3213 * init/tests/test_control.c (check_job_deleted): Rename to
3214 check_job_invalid and check that message.
3215 (check_job): Function to check the job we've acted upon.
3216 (test_job_start): Check that we get the UPSTART_JOB message first,
3217 restore the check on deleted jobs causing an error and add checks
3218 that instance and replacement jobs also cause an error.
3219 (test_job_stop): Check that we get the UPSTART_JOB message first,
3220 restore the check on deleted jobs causing an error. Make sure
3221 instances are handled.
3222
Scott James Remnant510b8082007-03-04 19:54:56 +00003223 * upstart/message.h: More message changes; add a JOB_FIND message
3224 and replace UPSTART_JOB_DELETED with UPSTART_JOB_INVALID since there's
3225 a few more problem conditions.
3226 * upstart/message.c (upstart_message_new, upstart_message_handle):
3227 Marshal the new message and update names.
3228 * upstart/tests/test_message.c (test_new, my_handler)
3229 (test_handle): Update tests to check the new message and update the
3230 values and names of the existing ones.
3231
Scott James Remnanta7e3bf12007-03-04 19:39:32 +00003232 * init/job.h (Job): Remove the delete flag, add replacement and
3233 replacement_for pointers instead.
3234 * init/job.c (job_new): Initialise replacement and replacement_for
3235 pointers to NULL.
3236 (job_find_by_name): Update to return what job the one we found is
3237 a replacement for, and to skip DELETED jobs.
3238 (job_instance): Make it simply illegal to call this for deleted jobs,
3239 instances or replacements.
3240 (job_change_goal): Make it illegal to change the goal of a replacement
3241 job.
3242 (job_free_deleted): Remove the previous code to handle deleted instance
3243 masters, because it's now bogus.
3244 (job_should_replace): New function to determine whether a job is
3245 replaceable.
3246 * init/tests/test_job.c (test_new): Check pointers are set.
3247 (test_copy): Check that replacement and replacement_for are not
3248 copied, since their state of an individual job.
3249 (test_find_by_name): Update tests to make sure we ignore deleted jobs,
3250 instances and replacements.
3251 (test_instance): Remove test that will now cause an assertion,
3252 and no longer check delete is set.
3253 (test_change_goal): Remove test that will now cause an assertion.
3254 (test_free_deleted): Remove test cases for deleted masters.
3255 (test_should_replace): Test the new check function.
3256 (test_change_state): Make sure that we end up in deleted for instances
3257 and replaced jobs, and that replacements become the real job.
3258 * init/cfgfile.c (cfg_read_job): Update to handle replacement jobs;
3259 the old job's previous replacement is discarded, and set to the
3260 current job; and then if the job should be replaced, it's moved
3261 to deleted (which should promote the new job).
3262 (cfg_delete_handler): Handle deletion of a job in a similar manner,
3263 except we sent the replacement pointer to the special -1 value since
3264 we have no actual replacement.
3265 * init/tests/test_cfgfile.c (test_watch_dir): Update tests to make
3266 sure that deletion and modification are handled wrt replacement.
3267 (test_read_job): Make sure that reparsing an existing file is handled.
3268 * init/tests/test_control.c (test_job_start): Remove checks that
3269 delete gets set to true for instances.
3270 (test_job_stop, test_job_start): Temporarily comment out deleted
3271 job behaviour, since that's been somewhat changed.
3272
Scott James Remnantffcbc5f2007-03-04 17:34:38 +00003273 * upstart/message.h: We're not going to return JOB_LIST for JOB_STOP
3274 since that's just awkward for the client; just act on the master,
3275 and return JOB_UNCHANGED.
3276
Scott James Remnant78dce1d2007-03-04 17:04:28 +00003277 * init/notify.c (notify_job_status): Move this function to
3278 * init/control.c (control_send_job_status): here, since we need it for
3279 the new control responses.
3280 (control_job_query): New single function to list all jobs or a
3281 particular job.
3282 * init/control.h: Add prototype.
3283 * init/tests/test_control.c (test_error_handler): Simplify this a
3284 little to just sending a NO_OP message, since we can send an entire
3285 stream of messages and leave them in the queue.
3286 (check_job_status__stopping, check_job_process)
3287 (check_job_status_end__stopping): Trio of check functions for a job
3288 status that's stopping, with an active main process.
3289 (test_send_job_status): Test the now global status function.
3290 (check_job_status__starting, check_job_status_end__starting): Pair
3291 of check functions for a starting job with no process yet.
3292 (test_watch_jobs, test_unwatch_jobs): Update to expect the full new
3293 job status messages, with an optional process part as well.
3294 (check_event): Function to check an event.
3295 (test_watch_events): Minor update to use above function.
3296 (check_job_status__waiting, check_job_status_end__waiting): Pair of
3297 check functions for the first step in starting a job (goal change only)
3298 (check_job_unknown, check_job_deleted, check_job_unchanged): Trio
3299 of functions to check common error responses.
3300 (test_job_start): Update tests to newer behaviour.
3301 (check_job_status__running, check_job_status_end__running)
3302 (check_job_status__pre_stop, check_job_status_end__pre_stop): Checks
3303 for the states we go through when stopping a job.
3304 (test_job_stop): Update tests to newer behaviour.
3305 * init/notify.c (notify_job, notify_job_event, notify_job_finished):
3306 Update to call the newly exported function.
3307 * init/job.c: Make job_id and job_id_wrapped externally available.
3308 * init/job.h: Update.
3309 * init/event.c: Make emission_id and emission_id_wrapped externally
3310 available.
3311 * init/event.h: Update.
3312
Scott James Remnanta90e6422007-03-04 14:41:05 +00003313 * upstart/message.h: Rename UPSTART_JOB_INVALID to
3314 UPSTART_JOB_UNCHANGED, as it's not really invalid just a no-op
3315 * upstart/message.c (upstart_message_new, upstart_message_handle):
3316 Update the constant, fields are unchanged,
3317 * upstart/tests/test_message.c (test_new, my_handler)
3318 (test_handle): Rename constants/messages.
3319
Scott James Remnant82626a92007-03-04 14:37:12 +00003320 * upstart/message.h: Turns out we need extra errors to indicate that
3321 the job was deleted or already at that goal, otherwise the client
3322 would sit there waiting for the finished event.
3323 * upstart/message.c (upstart_message_new, upstart_message_handle):
3324 Marshal the new error messages.
3325 * upstart/tests/test_message.c (test_new, my_handler)
3326 (test_handle): Test the handling of the new messages.
3327
Scott James Remnantd39165c2007-03-04 14:27:41 +00003328 * init/tests/test_job.c (test_free_deleted): Found a bug; because
3329 master instances never change state, they never end up in the deleted
3330 state so are never reaped. Add some test cases for cleaning them up,
3331 but not while they have remaining instances.
3332 * init/job.c (job_free_deleted): Implement the bug fix.
3333
Scott James Remnantd3cbc562007-03-04 14:18:36 +00003334 * init/job.c (job_instance): Split out the instance spawning code
3335 into its own function, as we'll frequently need a pointer to the
3336 instance before we try and change the goal.
3337 (job_change_goal): Clean this function back up again, it no longer
3338 needs to return values and can assert that it's never called for
3339 deleted jobs or instance mastersr.
3340 (job_handle_event): Spawn an instance when we get a start event.
3341 * init/job.h: Update.
3342 * init/tests/test_job.c (test_instance): Check instance creation.
3343 (test_change_goal): Update tests now that it doesn't return a value
3344 again, and doesn't spawn instances itself.
3345 (test_handle_event): Make sure instances are spawned.
3346
Scott James Remnant5bcc62b2007-03-04 13:27:15 +00003347 * init/tests/test_event.c (test_poll): Needs a slight fix now that
3348 we generate more events than we check, and that subscriptions go
3349 away automatically.
3350
Scott James Remnantb844efb2007-03-04 13:00:06 +00003351 * init/notify.c (notify_job_status): Static function to handle
3352 sending the more complicated job status message series
3353 (notify_job): Call notify_job_status() to send the new-style message
3354 (notify_job_event): Send the new UPSTART_EVENT_CAUSED message with
3355 the emission id, then call notify_job_status() to send the new-style
3356 common status message.
3357 (notify_job_finished): New function to be called when we reach the
3358 job rest state, notifies and unsubscribes directly subscribed
3359 processes, and includes failed information.
3360 (notify_event_finished): Unsubscribe processes after sending the
3361 finished event, since the event has gone away. Also don't send
3362 this to processes subscribed to all events, since it's not useful
3363 for them.
3364 * init/notify.h: Add prototype.
3365 * init/tests/test_notify.c: Update all test cases and helper
3366 functions to the new message types.
3367 (test_job_finished): Check the new finished message is sent with
3368 a status message preceeding it.
3369 * init/job.c (job_change_state, job_change_state): Notify subscribed
3370 processes with notify_job_finished() when in the running (for service)
3371 or waiting states, just before we drop the cause.
3372
Scott James Remnant79c95ff2007-03-04 12:30:37 +00003373 * upstart/message.h: Add failed, failed_process and exit_status
3374 arguments to UPSTART_JOB_FINISHED.
3375 * upstart/message.c (upstart_message_new, upstart_message_handle):
3376 Marshal the new arguments.
3377 * upstart/tests/test_message.c (test_new, my_handler)
3378 (test_handle): Test the new arguments.
3379
Scott James Remnantf1091d12007-03-04 01:09:16 +00003380 * upstart/message.h: Update the message types, introducing a more
3381 structured job message set and replacing the UPSTART_EVENT_JOB_STATUS
3382 message with UPSTART_EVENT_CAUSED which will be immediately followed
3383 by an ordinary UPSTART_JOB_STATUS message.
3384 * upstart/message.c (upstart_message_new, upstart_message_handle):
3385 Marshal the new messages.
3386 * upstart/tests/test_message.c (test_new, my_handler)
3387 (test_handle): Test the new message types.
3388 * TODO: Update.
3389
Scott James Remnant15538792007-03-03 15:30:23 +000033902007-03-03 Scott James Remnant <scott@netsplit.com>
3391
Scott James Remnantcd157612007-03-03 17:09:09 +00003392 * TODO: Update.
3393
Scott James Remnant8568a062007-03-03 17:06:43 +00003394 * init/cfgfile.c (cfg_parse_exec, cfg_parse_script): Separate out
3395 the parsing of an exec or script stanza into separate functions,
3396 seeing as this is quite a common operation. This also means we
3397 just need to change them in one place now.
3398 (cfg_parse_process): Function to call either of the above depending
3399 on the next argument.
3400 (cfg_stanza_exec): Call cfg_parse_exec instead.
3401 (cfg_stanza_script): Call cfg_parse_script instead.
3402 (cfg_stanza_pre_start, cfg_stanza_post_start)
3403 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Call cfg_parse_process
3404 with the right arguments instead of doing by hand in each function.
3405
Scott James Remnant15538792007-03-03 15:30:23 +00003406 * init/event.c (event_emit_next_id): Split the id assigning code into
3407 a static inline function for easier modification.
3408 * init/job.c (job_next_id): Use the same style function here too.
3409
Scott James Remnant3d39c7d2007-03-02 10:50:14 +000034102007-03-02 Scott James Remnant <scott@netsplit.com>
3411
Scott James Remnant9c7a9112007-03-02 17:08:46 +00003412 * init/event.c (event_emit): Port the slightly more efficient in the
3413 early case code from job_new.
3414
Scott James Remnantb61f5932007-03-02 17:06:44 +00003415 * init/job.h (Job): Add a unique id to the job structure.
3416 * init/job.c (job_new): Assign an incrementing id to each new job
3417 allocated.
3418 (job_find_by_id): Locate a job by its unique id, sadly not very
3419 efficient in a hash table ;-)
3420 (job_name): New hash key function since name isn't the first entry
3421 anymore.
3422 (job_init): Change hash key function.
3423 * init/tests/test_job.c (test_find_by_id): Make sure we can find a
3424 job by its id.
3425
Scott James Remnant5e453162007-03-02 16:27:57 +00003426 * init/job.c (job_change_goal): Return the new instance in that
3427 circumstance, and clean up a little bit.
3428 * init/job.h: Update prototype.
3429 * init/tests/test_job.c (test_change_goal): Update tests.
3430
Scott James Remnant3caa9f42007-03-02 15:09:34 +00003431 * init/job.c (job_find_by_name): Skip jobs marked for deletion too.
3432 * init/tests/test_job.c (test_find_by_name): Update test case.
3433
Scott James Remnant0720acf2007-03-02 14:58:27 +00003434 * init/event.h, init/notify.h, upstart/message.h: Provide C-level names
3435 for enums, this makes the compiler generate things that gdb can get.
3436
Scott James Remnantf60ee622007-03-02 13:13:11 +00003437 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
3438 Change process argument to be a plain ProcessType, this means we
3439 know exactly which process we're trying to run or kill.
3440 (job_change_state): Update calls to job_run_process
3441 and job_kill_process
3442 * init/tests/test_job.c (test_run_process, test_kill_process): Update
3443 function calls to just pass a ProcessType in.
3444
Scott James Remnantdb61ca82007-03-02 13:02:42 +00003445 * upstart/enum.h: Rename JobAction to ProcessType.
3446 * upstart/enum.c (job_action_name): Rename to process_name.
3447 (job_action_from_name): Rename to process_from_name.
3448 * upstart/tests/test_enum.c (test_action_name, test_action_from_name):
3449 Rename and update to match.
3450 * init/job.c (job_new, job_copy, job_change_state)
3451 (job_next_state): Change JOB_*_ACTION constants to PROCESS_*.
3452 (job_find_by_pid): Change JobAction argument to ProcessType.
3453 (job_emit_event): Call process_name on the failed process.
3454 (job_child_reaper): Update to use ProcessType instead of JobAction.
3455 * init/job.h (Job): Change type of failed_process to ProcessType.
3456 * init/tests/test_job.c (test_find_by_pid): Update to use ProcessType
3457 instead of JobAction in tests.
3458 (test_new, test_copy, test_change_goal, test_change_state)
3459 (test_next_state, test_run_process, test_kill_process)
3460 (test_child_reaper, test_handle_event_finished): Change JOB_*_ACTION
3461 constants to PROCESS_*
3462 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
3463 (cfg_stanza_pre_start, cfg_stanza_post_start)
3464 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Change JOB_*_ACTION
3465 constants to PROCESS_*
3466 * init/tests/test_cfgfile.c (test_stanza_exec)
3467 (test_stanza_script, test_stanza_pre_start)
3468 (test_stanza_post_start, test_stanza_pre_stop)
3469 (test_stanza_post_stop, test_read_job, test_watch_dir): Change
3470 JOB_*_ACTION constants to PROCESS_*
3471 * init/tests/test_event.c (test_poll): Change JOB_*_ACTION constants
3472 to PROCESS_*
3473 * init/tests/test_control.c (test_job_start, test_job_stop): Change
3474 JOB_*_ACTION constants to PROCESS_*
3475
Scott James Remnant4a104b52007-03-02 12:21:45 +00003476 * init/cfgfile.c (cfg_watch_dir): Restore the prefix argument; pass
3477 as the data pointer to the inotify callbacks and visitor function.
3478 Change the return value to be the watch structure.
3479 (cfg_job_name): Add prefix argument and prepend to relative path.
3480 (cfg_create_modify_handler, cfg_delete_handler, cfg_visitor): Get
3481 the prefix for the job names from the data pointer and pass to
3482 cfg_job_name().
3483 * init/cfgfile.h: Update prototypes.
3484 * init/tests/test_cfgfile.c (test_watch_dir): Actually test the
3485 watch functions.
3486 * init/main.c (main): Pass NULL for the prefix for the global job
3487 directory, compare the return value against (void *)-1.
3488 * TODO: Update.
3489
Scott James Remnant002dcda2007-03-02 11:05:56 +00003490 * init/cfgfile.c (cfg_stanza_on): Drop the simple on stanza.
3491 * init/tests/test_cfgfile.c (test_stanza_on): Remove test case.
3492
Scott James Remnant3d39c7d2007-03-02 10:50:14 +00003493 * TODO: Update.
3494
Scott James Remnantbc1ebc02007-03-01 12:27:09 +000034952007-03-01 Scott James Remnant <scott@netsplit.com>
3496
Scott James Remnant75914fd2007-03-01 19:05:45 +00003497 * util/jobs.c (handle_job_status): Drop the process field from the
3498 output for now.
3499 * util/events.c (handle_event_job_status): Likewise
3500 * util/tests/test_jobs.c (test_start_action, test_list_action)
3501 (test_jobs_action): Drop pid from messages we simulate.
3502 * util/tests/test_events.c (test_emit_action): Likewise.
3503
Scott James Remnant0c68cc12007-03-01 18:53:23 +00003504 * upstart/message.c (upstart_message_new, upstart_message_handle):
3505 Remove the pid field from the job status and event job status
3506 messages.
3507 * upstart/message.h: Update description of job status and event
3508 job status message to remove the pid field.
3509 * upstart/tests/test_message.c (test_new, my_handler)
3510 (test_handle): Remove checks using the pid field.
3511
Scott James Remnantd134fe82007-03-01 18:46:53 +00003512 * init/control.c (control_job_start, control_job_stop)
3513 (control_job_query, control_job_list): Remove the pid field from
3514 the messages, it'll come back later when we get better message
3515 formats.
3516 * init/tests/test_control.c (check_job_status, check_job_waiting)
3517 (check_job_started, check_job_stopped): Remove checks on the process
3518 id, since that field is gone from the message.
3519 (test_job_stop): Use the pid field of the main process.
3520 (test_job_start): Initialise the main action process.
3521
Scott James Remnantdd1a6742007-03-01 18:42:42 +00003522 * init/notify.c (notify_job, notify_job_event): Remove the pid field
3523 from the message, it'll come back later when we get better message
3524 formats.
3525 * init/tests/test_notify.c (check_job_status)
3526 (check_event_job_status): Remove checks on the pid, since that field
3527 is no longer present.
3528
Scott James Remnante2ce6372007-03-01 18:37:53 +00003529 * init/job.c (job_process_copy): Use job_process_new here, oops.
3530
Scott James Remnant8ed70e42007-03-01 18:34:37 +00003531 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
3532 (cfg_stanza_pre_start, cfg_stanza_post_start)
3533 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Use job_process_new
3534 to allocate process structures and store in the process array.
3535 * init/tests/test_cfgfile.c (test_read_job, test_stanza_exec)
3536 (test_stanza_script, test_stanza_pre_start)
3537 (test_stanza_post_start, test_stanza_pre_stop)
3538 (test_stanza_post_stop): Update test cases to use process array
3539 member information.
3540
Scott James Remnant42479f92007-03-01 18:12:34 +00003541 * init/tests/test_event.c (test_poll): Update to use newer job process
3542 array and find the pid under there.
3543
Scott James Remnantc8f15ac2007-03-01 18:03:22 +00003544 * init/job.h (Job): Remove the pid and aux_pid fields; replace the
3545 individual JobProcess pointers with an array of them of a fixed
3546 minimum size; replace failed_state with failed_process.
3547 (JobProcess): add a pid field here, so now we can obtain the pid on
3548 an individual process/action basis rather than global.
3549 * init/job.c (job_process_new): Function to create a JobProcess
3550 structure, setting the initial values to FALSE/NULL/0.
3551 (job_process_copy): Function to copy a JobProcess.
3552 (job_new): Don't initialise the pid or aux_pid members, initialise
3553 the process array to a fixed initial size and set the members to NULL,
3554 initialise the failed_process member to -1.
3555 (job_copy): Update to use job_process_copy and copy the process array.
3556 (job_find_by_pid): Look through the process structures in the job's
3557 process array to find the pid, and optionally return which action it
3558 was.
3559 (job_change_state): Call job_kill_process in the JOB_KILLED state if
3560 we have a main process and that has a pid, pass in the main process.
3561 (job_next_state): Check the process id of the main process when
3562 deciding what the next state is for running.
3563 (job_run_process): Store the process id in the process structure
3564 (job_kill_process): Accept a process structure and use that to obtain
3565 the process id we need to send TERM too. Remove the code that forced
3566 a state change if kill() failed, since we will get a child signal
3567 anyway and should do it there.
3568 (job_kill_timer): Likewise, accept a process structure and don't
3569 forcibly change the state anymore.
3570 (job_child_reaper): Rewrite to switch based on the action that died,
3571 rather than the state we were in; assert that the state is what we
3572 expected.
3573 (job_emit_event): The argument to the failed event is now the action
3574 name, rather than the state name; an action of -1 indicates that
3575 respawn failed.
3576 * init/tests/test_job.c (test_process_new, test_process_copy): Make
3577 sure the structure is created and copied properly.
3578 (test_new, test_copy): Drop checks on the pid and aux_pid members,
3579 add checks for the process array and pid members of processes.
3580 (test_find_by_pid): Update test case to make sure we can find the pid
3581 of any process, returning the action index rather than the process
3582 pointer.
3583 (test_run_process, test_kill_process, test_change_goal)
3584 (test_change_state, test_next_state, test_child_reaper): Update test
3585 cases to use pid fields inside process structures rather than the
3586 pid or aux_pid members.
3587 (test_handle_event, test_handle_event_finished)
3588 (test_free_deleted): Update to avoid pid field checks.
3589
Scott James Remnant4652e3b2007-03-01 16:25:56 +00003590 * upstart/enum.h (JobAction): Enumeration of different actions.
3591 * upstart/enum.c (job_action_name, job_action_from_name): Enumeration
3592 to string conversion functions.
3593 * upstart/tests/test_enum.c (test_action_name)
3594 (test_action_from_name): Tests for the new functions.
3595
Scott James Remnantdc9d7902007-03-01 12:57:37 +00003596 * init/cfgfile.c (cfg_read_job): Instead of trying to copy over an
3597 old job's state and instances into the new one, mark the old job
3598 as deleted. This ensures we never end up applying a new post-stop
3599 script to a job started with an old pre-start script, etc. It also
3600 makes life so much simpler.
3601 * init/tests/test_cfgfile.c (test_read_job): Update tests to make
3602 sure the old job is marked for deletion, instead of freed.
3603 * TODO: Update.
3604
Scott James Remnant26a41cf2007-03-01 12:50:10 +00003605 * init/notify.c (notify_job): Split out notification to processes
3606 subscribed to the cause event into a new function
3607 (notify_job_event): We can call this when we change cause.
3608 * init/job.c (job_change_state): Notify anyone subscribed to the
3609 job after we've changed the state, rather than before, otherwise
3610 we won't know the new pids or anything.
3611 (job_change_cause): Call notify_job_event before changing the cause
3612 so that subscribers get a final status update.
3613 * init/tests/test_notify.c (test_job_event): Check the new function.
3614 * TODO: Update.
3615
Scott James Remnantbc1ebc02007-03-01 12:27:09 +00003616 * init/cfgfile.c (cfg_stanza_respawn): Remove the shortcut that
3617 lets you specify "respawn COMMAND". It was confusing as it hid
3618 the common "[when] exec"/"[when] script" syntax, made it non-obvious
3619 that "exec" and "respawn" were the same flag, etc.
3620 * init/tests/test_cfgfile.c (test_stanza_respawn): Update tests.
3621 (test_stanza_service): Fix test case to not use shortcut.
3622 * logd/event.d/logd.in: Update to not use respawn shortcut.
3623
Scott James Remnantb1f34052007-02-25 09:12:53 +000036242007-02-25 Scott James Remnant <scott@netsplit.com>
3625
Scott James Remnant43d8f092007-02-25 12:56:37 +00003626 * init/job.c (job_child_reaper): Shift the signal value into the
3627 higher byte to make it easier to detect, and not stamp over exit
3628 statuses between 128 and 255.
3629 (job_emit_event): Detect the signal stored in the new way.
3630 * init/cfgfile.c (cfg_stanza_normal): Store signal in the higher bytes.
3631 * init/tests/test_job.c (test_copy, test_change_state)
3632 (test_child_reaper): Update test cases.
3633 * init/tests/test_cfgfile.c (test_stanza_normal): Update test.
3634
Scott James Remnant8a77b5d2007-02-25 11:45:47 +00003635 * TODO: Update.
3636
Scott James Remnant2c950692007-02-25 09:13:38 +00003637 * init/event.h (PWRSTATUS_EVENT): Add new power-status-changed event.
3638 * init/main.c (pwd_handler): Handle the SIGPWR signal by generating
3639 the new event, leave it up to a job to parse the file and do
3640 whatever it likes.
3641
Scott James Remnantb1f34052007-02-25 09:12:53 +00003642 * TODO: Update.
3643
Scott James Remnant7e3ad172007-02-13 15:53:39 +000036442007-02-13 Scott James Remnant <scott@netsplit.com>
3645
3646 * upstart/tests/test_message.c (test_reader, test_handle_using)
3647 (test_handle); Usual fix for gcc optimiser thinking that fixed
3648 for loops might not be.
3649 * init/tests/test_job.c (test_run_process, test_kill_process):
3650 Likewise.
3651 * init/tests/test_notify.c (test_subscription_find): I still don't
3652 know what a type-punned pointer is, nor why dereferencing such a
3653 thing would break strict-aliasing rules.
3654 * init/tests/test_cfgfile.c (test_read_job): More type-punning.
3655 * util/tests/test_jobs.c (test_start_action): More for-loop action.
3656 * util/tests/test_events.c (test_emit_action): And again.
3657
Scott James Remnant5c89c502007-02-11 14:08:19 +000036582007-02-11 Scott James Remnant <scott@netsplit.com>
3659
Scott James Remnant17305e12007-02-11 18:20:19 +00003660 * init/job.c (job_change_goal): We need to be able to stop a running
3661 job without a process, because that's what a job-as-state is! The
3662 check was added because job_child_reaper calls job_change_goal and
3663 then job_change_state immediately after, we should fix that instead.
3664 (job_child_reaper): If we call job_change_goal while in the running
3665 state, it will call job_change_state for us; so check for that first
3666 and don't change the state!
3667 * init/tests/test_job.c (test_change_goal): Update the test to ensure
3668 that we can stop a job with no running process.
3669
Scott James Remnantddda5f92007-02-11 14:18:00 +00003670 * init/cfgfile.c (cfg_stanza_normalexit): normalexit is inconsistent,
3671 change to "normal exit"
3672 * init/tests/test_cfgfile.c (test_stanza_normalexit): Update.
3673
Scott James Remnant5c89c502007-02-11 14:08:19 +00003674 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
3675 (cfg_stanza_pre_start, cfg_stanza_post_start)
3676 (cfg_stanza_pre_stop, cfg_stanza_post_stop, cfg_stanza_respawn):
3677 We're not going to allow stanza keywords to be quoted, since this
3678 gives us an easy way to allow users to make something explicitly
3679 not a keyword.
3680
Scott James Remnant5dd50e32007-02-10 00:44:44 +000036812007-02-10 Scott James Remnant <scott@netsplit.com>
3682
Scott James Remnant9675c072007-02-10 21:36:48 +00003683 * configure.ac: Bump version to 0.3.6
3684
Scott James Remnant4e977172007-02-10 21:24:29 +00003685 * configure.ac: Increase version to 0.3.5
3686 * NEWS: Update.
3687 * TODO: Update.
3688
Scott James Remnanta2f0a542007-02-10 18:07:26 +00003689 * TODO: More notes.
3690
Scott James Remnant78456a52007-02-10 17:46:21 +00003691 * TODO: Note an issue with using JobProcess->pid
3692
Scott James Remnantd11d0fd2007-02-10 17:45:17 +00003693 * init/cfgfile.c (cfg_stanza_pre_start, cfg_stanza_post_start)
3694 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Add a needed check
3695 for a token when parsing "exec". Correct line number we expect
3696 to see the duplicated value on. Correct expected error for missing
3697 argument from "Unexpected token" to "Expected token".
3698
3699 * init/tests/test_cfgfile.c (main): Actually invoke the tests for
3700 the scripts.
3701
Scott James Remnant2ebe37b2007-02-10 17:35:33 +00003702 * init/cfgfile.c (cfg_read_job): Correct type of lineno in error.
3703
Scott James Remnant178f3a62007-02-10 17:34:02 +00003704 * TOOD: Minor notify bug
3705
Scott James Remnante72695c2007-02-10 17:11:26 +00003706 * TODO: Big update.
3707
Scott James Remnant743c1c12007-02-10 16:49:17 +00003708 * init/tests/test_job.c (test_child_reaper): Make sure that we can
3709 reap post-start and pre-stop processes, and have only the aux_pid
3710 changed. Also make sure that if the running process dies while
3711 in these states, with or without an aux process, that we don't
3712 transition badly.
3713
Scott James Remnanta54bfd02007-02-10 14:33:32 +00003714 * init/job.c (job_find_by_pid): Check aux_pid as well.
3715 * init/tests/test_job.c (test_find_by_pid): Make sure we can find it.
3716
Scott James Remnant153e3b52007-02-10 14:15:47 +00003717 * init/job.h (Job): Add an auxiliary pid member.
3718 * init/job.c (job_new): Initialise the aux_pid member.
3719 (job_change_state): Run the post-start and pre-stop scripts when we
3720 enter the state with the same name (assuming they exist).
3721 (job_run_process): Store the pid in aux_pid when starting the
3722 post-start or pre-stop processes.
3723 * init/tests/test_job.c (test_change_state): Add tests for running
3724 the new post-start and pre-stop scripts; which get their process ids
3725 stored in aux_pid instead of pid.
3726 (test_new): Make sure the aux_pid member is initialised properly.
3727 (test_copy): Make sure the aux_pid member is not copied.
3728
3729 * TODO: Update.
3730
Scott James Remnantf415d8d2007-02-10 13:55:04 +00003731 * init/tests/test_job.c (test_change_state): Add a check for the
3732 daemon stanza holding the job in spawned; we snuck this in a while
3733 back and never tested it (there's no support to get it out of
3734 spawned yet).
3735
Scott James Remnante9332be2007-02-10 13:46:50 +00003736 * init/job.h (Job): Add new post_start and pre_stop scripts.
3737 * init/job.c (job_new): Initialise new scripts to NULL.
3738 (job_copy): Copy the information from the new scripts over as well.
3739 * init/tests/test_job.c (test_new): Check they're initialised.
3740 (test_copy): Check that the information is copied properly.
3741 * init/cfgfile.c (cfg_stanza_post_start, cfg_stanza_pre_stop): Add
3742 new script stanza functions for the additional two scripts that
3743 we want.
3744 * init/tests/test_cfgfile.c (test_stanza_post_start)
3745 (test_stanza_pre_stop): Add tests for the new stanzas.
3746
Scott James Remnant5dd50e32007-02-10 00:44:44 +00003747 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script): Rewrite to
3748 allocate a JobProcess and parse the command or script into it.
3749 (cfg_read_job): Fix the long broken assumption that pid_file and
3750 pid_binary are required for respawn, when they're actually required
3751 for daemon.
3752 (cfg_stanza_start, cfg_stanza_stop): Remove script second-level.
3753 (cfg_stanza_respawn): Parse into the job's process.
3754 (cfg_stanza_pre_start, cfg_stanza_post_stop): New stanzas for the
3755 processes alone.
3756 * init/tests/test_cfgfile.c (test_read_job): Update a few test
3757 cases to match reality.
3758 (test_stanza_start, test_stanza_stop): Remove script-related checks.
3759
Scott James Remnante885d552007-02-09 00:01:46 +000037602007-02-09 Scott James Remnant <scott@netsplit.com>
3761
Scott James Remnant315a80a2007-02-09 22:50:00 +00003762 * init/tests/test_job.c (test_kill_process): Poll the event queue
3763 after each test to get rid of the allocated events and make valgrind
3764 happy.
3765 * init/tests/test_control.c (test_job_start, test_job_stop)
3766 (test_event_emit): Poll the event queue after each test to get rid
3767 of the allocated events, as they make valgrind complain.
3768 (test_event_emit): Free args and env when done.
3769
Scott James Remnant1ada0e22007-02-09 22:40:51 +00003770 * init/job.h (JobName): Drop obsolete structure
3771 (JobProcess): Add a new structure to represent a single process
3772 within the job, instead of using two variables to pick either the
3773 script or command.
3774 (Job): Change command and script to a single JobProcess called process;
3775 change start_script and stop_script to a JobProcess called pre_start
3776 and post_stop respectively.
3777 * init/job.c (job_new): Initialise new members to NULL.
3778 (job_copy): Copy the process structures across, including contents.
3779 (job_change_state): Call job_run_process passing in the structure;
3780 rather than fiddling with if statements.
3781 (job_run_script, job_run_command, job_run_process): Combine all of
3782 these three functions into a single new job_run_process function.
3783 * init/tests/test_job.c (test_new, test_copy, test_change_goal)
3784 (test_change_state, test_child_reaper)
3785 (test_handle_event_finished): Change to using JobProcess for when
3786 we need to construct a command.
3787 (test_run_script, test_run_command): Merge into single new
3788 (test_run_process) function.
3789 * init/tests/test_event.c (test_poll): Replace command with process.
3790 * init/tests/test_control.c (test_job_start): Change to using
3791 JobProcess to specify the command.
3792
Scott James Remnantc6740472007-02-09 21:16:28 +00003793 * init/main.c (main): Run job_free_deleted each time through the
3794 main loop.
3795
Scott James Remnantcb468602007-02-09 21:13:16 +00003796 * init/job.c (job_change_goal): Minor tweak to the logic; we may
3797 have just made the job an instance, that should still let us stop
3798 the one underneath.
3799
Scott James Remnant3fbdda72007-02-09 21:12:10 +00003800 * TODO: Update.
3801
Scott James Remnantdde96ff2007-02-09 21:10:45 +00003802 * util/jobs.c (do_job): Always expect a list of replies.
3803
Scott James Remnantf9409952007-02-09 21:02:18 +00003804 * init/control.c (control_job_status, control_job_stop)
3805 (control_job_query): Reply with information about all instances of
3806 the job.
3807 * init/tests/test_control.c (test_job_status, test_job_stop)
3808 (test_job_query): Make sure we get the list end even for a single job;
3809 and make sure we get details of all instances attached to the job.
3810
Scott James Remnant6cfc8ab2007-02-09 20:34:37 +00003811 * init/tests/test_job.c (test_change_goal): Check that starting
3812 an instance job actually starts a new instance of it.
3813
Scott James Remnant87c46472007-02-09 20:05:32 +00003814 * init/cfgfile.c (cfg_stanza_limit): Support the word "unlimited" in
3815 limit arguments for both the soft and hard values.
3816 * init/tests/test_cfgfile.c (test_stanza_limit): Make sure that we
3817 can make limits be unlimited.
3818
Scott James Remnant22ac92f2007-02-09 19:39:42 +00003819 * init/event.c (event_copy): Function to copy an event structure.
3820 * init/event.h: Add prototype.
3821 * init/tests/test_event.c (test_copy): Make sure we copy the event
3822 correctly, with or without arguments and/or environment.
3823 * init/job.c (job_copy): Function to copy a job structure, leaving
3824 the state as it is.
3825 * init/job.h: Add prototype.
3826 * init/tests/test_job.c (test_copy): Make sure that we copy the
3827 job details whether they are NULL or non-NULL, but don't copy the
3828 state.
3829 * init/init.supp: Update supression.
Scott James Remnant099ece22007-02-09 18:13:51 +00003830 * init/job.c (job_find_by_name): If we get a job that's an instance,
3831 return what it's an instance of.
3832 * init/tests/test_job.c (test_find_by_name): Restore accidentally
3833 deleted test function; test that we get the real job, not an instance.
3834
Scott James Remnant99e3ecc2007-02-09 18:08:45 +00003835 * init/job.c (job_new): instance_of is initialised to NULL.
3836 * init/job.h: Add a new instance_of pointer, pointing to the parent
3837 that we're an instance of.
3838 * init/tests/test_job.c (test_new): Check that.
3839 * init/tests/test_cfgfile.c (test_read_job): Make sure instance_of
3840 pointers are updated.
3841
Scott James Remnant4513fae2007-02-09 17:52:32 +00003842 * init/job.c (jobs): Store jobs in a hash table.
3843 (job_new): Add to hash table, not to a list.
3844 (job_handle_event, job_handle_event_finished, job_detect_stalled)
3845 (job_free_deleted): Iterate across the hash table, rather than list.
3846 (job_find_by_name): Use nih_hash_lookup, we keep this function because
3847 we'll add "is instance or not" smarts soon!
3848 (job_find_by_pid): Iterate across the entire hash table.
3849 * init/tests/test_job.c (test_find_by_name): Drop test since this
3850 function is now gone.
3851 (test_free_deleted): Can't assume things are in a line now.
3852 * init/control.c (control_job_list): Iterate the hash table.
3853
Scott James Remnant3f9624c2007-02-09 17:16:07 +00003854 * init/event.c: Don't hide the events list anymore
3855 * init/event.h: Publish it and the init function.
3856 * init/job.c: Don't hide the jobs list anymore.
3857 (job_list): Since we don't hide it, we can drop this.
3858 * init/job.h: Publish it and the init function.
3859 * init/notify.c: Don't hide the subscriptions list anymore.
3860 * init/notify.h: Publish it and the init function.
3861 * init/control.c (control_job_list): Iterate the job list directly
3862 * init/tests/test_control.c (test_event_emit): Use the events list
3863 available to us.
3864 * init/tests/test_event.c (test_poll): Call job_init directly and
3865 just use the events list available to us.
3866 * init/tests/test_job.c (test_new): Call job_init directly.
3867 (test_change_state): Use the events list available to us.
3868 * init/tests/test_notify.c (test_unsubscribe): Use the subscriptions
3869 list available to us.
3870
Scott James Remnant9709a8d2007-02-09 16:08:21 +00003871 * doc/states.dot: Add updated state graph.
3872 * doc/Makefile.am (EXTRA_DIST): Ship the states diagram.
3873 (states.png): Include rules to build the png, we'll put it in bzr
3874 anyway, but this is useful.
3875
Scott James Remnant92b01602007-02-09 15:46:55 +00003876 * init/cfgfile.c (cfg_delete_handler): Handle deleted jobs; mark
3877 the job as deleted, and if it's dormant, invoke a state change.
3878
Scott James Remnant9c0215a2007-02-09 15:42:20 +00003879 * upstart/enum.h: Add a new JOB_DELETED state.
3880 * upstart/enum.c (job_state_name, job_state_from_name): Add the new
3881 state to the string functions.
3882 * upstart/tests/test_enum.c (test_state_name)
3883 (test_state_from_name): Check the enum works.
3884 * init/job.c (job_change_goal): New decision; we can start a waiting
3885 job if it's marked delete (it might be a new instance) -- we'll use
3886 the new deleted state to decide that we shouldn't.
3887 (job_change_state): Once we reach waiting, if the job is to be deleted,
3888 move to the next state.
3889 (job_next_state): The next state for a waiting job if the goal is stop
3890 is deleted. We should never call job_next_state () for a deleted job.
3891 (job_free_deleted): Very simple function, just detects
3892 deleted jobs and frees them.
3893 * init/job.h: Add prototype for new function.
3894 * init/tests/test_job.c (test_change_goal): Update test to use new
3895 deleted state; and don't even change the goal.
3896 (test_change_state): Add a check to make sure we end up in deleted.
3897 (test_next_state): Make sure waiting goes to deleted.
3898 (test_free_deleted): Check the function.
3899
Scott James Remnant07dd5db2007-02-09 15:20:25 +00003900 * init/job.c (job_change_goal): Don't try and start a job if it's
3901 marked to be deleted and is just waiting for cleanup.
3902 * init/tests/test_job.c (test_change_state): Make sure that the cause
3903 is released when we reach waiting.
3904
Scott James Remnanta1ade132007-02-09 15:07:30 +00003905 * init/tests/test_cfgfile.c (test_read_job): Make sure that a deleted
3906 job gets resurrected.
3907
Scott James Remnant25873b52007-02-09 13:35:43 +00003908 * init/cfgfile.c (cfg_visitor): Correct number of arguments and call
3909 to cfg_job_name.
3910
Scott James Remnant3b5daf62007-02-09 13:31:01 +00003911 * TODO: Update.
3912
Scott James Remnant845c6cb2007-02-09 13:29:27 +00003913 * init/cfgfile.c (cfg_stanza_daemon): Don't allow arguments anymore.
3914 * init/tests/test_cfgfile.c (test_stanza_daemon): Update tests.
3915
Scott James Remnant1cdc1632007-02-09 13:26:09 +00003916 * init/job.c (job_handle_event_finished): Function to unblock all
3917 jobs blocked on a given event emission.
3918 (job_new, job_emit_event): Rename blocker to blocked; it's useful for
3919 testing for truth.
3920 * init/job.h: Add prototype, rename member.
3921 * init/tests/test_job.c (test_handle_event_finished): Test it.
3922 (test_new, test_change_state): Update name here too.
3923 * init/event.c (event_finished): Call job_handle_event_finished
3924 function to unblock jobs.
3925 * init/tests/test_event.c (test_poll): Make sure the job gets
3926 unblocked; a few other tests have to change since running event_poll
3927 always unblocks the job if nothing listens to it.
3928
Scott James Remnantba5ebb02007-02-09 04:46:39 +00003929 * init/job.c (job_child_reaper): Set failed back to FALSE if
3930 we're respawning, since we don't want to be failing.
3931 * init/tests/test_job.c (test_child_reaper): cause will be NULL.
3932 also free and poll events when done.
3933 (test_handle_event): pid can never be -1
3934 (test_change_state): poll events when done
3935
Scott James Remnantfd0cc552007-02-09 04:39:36 +00003936 * init/tests/test_job.c (test_child_reaper): Process will always
3937 be zero on return from reaper.
3938
Scott James Remnantef11ca42007-02-09 04:37:24 +00003939 * init/tests/test_job.c (test_child_reaper): Killed doesn't go past
3940 stopping; it goes to waiting, which will clear the cause.
3941
Scott James Remnanta5034982007-02-09 04:36:12 +00003942 * init/tests/test_job.c (test_child_reaper): Fill in values before
3943 we test against them.
3944
Scott James Remnantda1ae312007-02-09 04:35:33 +00003945 * init/tests/test_job.c (test_kill_process): Fix violated assertion
3946
Scott James Remnant011e4ae2007-02-09 04:35:00 +00003947 * init/tests/test_job.c (test_change_state): This should be failed
3948 because nothing cleared it.
3949
Scott James Remnant4f4ea832007-02-09 04:33:50 +00003950 * init/tests/test_job.c (test_change_state): Fix a couple of array
3951 index problems.
3952
Scott James Remnantaf9b63f2007-02-09 04:32:50 +00003953 * init/tests/test_job.c (test_change_state): Why set that which
3954 does not change?
3955
Scott James Remnantfcc51902007-02-09 04:30:43 +00003956 * init/tests/test_job.c (test_change_state): Add newline to test.
3957
Scott James Remnant5f936192007-02-09 04:29:54 +00003958 * init/job.c (job_emit_event): Add the job name as an argument;
3959 oops.
3960
Scott James Remnantf89b1612007-02-09 04:28:09 +00003961 * init/tests/test_control.c (test_job_stop): Need to kill the process
3962 ourselves, as we're blocked on an event.
3963 (test_job_query): Fix wrong value in test.
3964 (check_job_stopped, test_job_stop, test_unwatch_jobs): Change job
3965 name to match the test.
3966
Scott James Remnant7178e722007-02-09 04:22:04 +00003967 * init/job.c (job_change_state): Must only not enter some states
3968 with no process now; others like killed actually usually want one!
3969
Scott James Remnant851a05c2007-02-09 04:18:20 +00003970 * init/tests/test_cfgfile.c (test_read_job): Fix test case.
3971
Scott James Remnant6c088782007-02-09 04:13:43 +00003972 * init/tests/test_job.c (test_handle_event): Clean up tests.
3973 (test_detect_stalled): Clean up.
3974
Scott James Remnantbfcb6162007-02-09 04:08:53 +00003975 * init/job.c (job_child_reaper): Update the reaping of the child
3976 processes; there's a much larger state range for the main process
3977 now, so that needs to be taken into account.
3978 * init/tests/test_job.c (test_child_reaper): New test cases.
3979
Scott James Remnantd7ac93f2007-02-09 03:39:00 +00003980 * init/job.c (job_next_state): Encapsulate the slightly odd three
3981 exit states of running in this function, otherwise we'll end up
3982 special-casing it in places I'd rather not think about.
3983 (job_change_goal): Only change the state of a running job if it
3984 has a process.
3985 * init/tests/test_job.c (test_next_state): Add a test case for the
3986 dead running job
3987 (test_change_goal): Add test case for the dead running job
3988
Scott James Remnantd285b832007-02-09 02:49:06 +00003989 * init/tests/test_job.c (test_change_state): Add test cases for
3990 the forgotten stopping to killed transition.
3991
Scott James Remnant999fc9a2007-02-09 02:44:25 +00003992 * init/job.c (job_kill_process, job_kill_timer): Just check the pid
3993 and state, and no longer any need to notify jobs since we're just
3994 called from one state amongst many.
3995 (job_change_state): Skip over the killed state if there's no process.
3996 * init/tests/test_job.c (test_kill_process): Update test cases.
3997
Scott James Remnantad011612007-02-09 02:34:03 +00003998 * init/job.c (job_run_process): Simplify a little bit, no need to
3999 do the state assertions here, just make sure there's no already
4000 a process running.
4001 * init/tests/test_job.c (test_run_command, test_run_script): Run
4002 tests in the spawned state, since that's where we run the primary
4003 command or script. Drop check for process state since that's no
4004 longer set.
4005
Scott James Remnant8bd1b042007-02-09 02:27:40 +00004006 * init/job.c (job_change_state, job_next_state): Ok, here's the big
4007 one ... rewrite this to use the new state transitions. This has
4008 suddenly got a lot simpler and easier to read, this was definitely a
4009 good idea.
4010 (job_emit_event): Function to make emission of events easier.
4011 (job_failed_event): replaces this one which wasn't so easy.
4012 * init/tests/test_job.c (test_change_state): I can't say how much I
4013 wasn't looking forwards to rewriting these test cases; anyway, it's
4014 done now and I hope they're all right;
4015 (test_next_state): Make sure the state transitions are correct too.
4016
Scott James Remnant6aee3782007-02-09 00:45:29 +00004017 * init/job.h: Rename is_instance to delete and spawns_instance to
4018 just instance.
4019 * init/job.c (job_new): Update.
4020 * init/tests/test_job.c (test_new): Update.
4021 * init/cfgfile.c (cfg_stanza_instance): Update.
4022 * init/tests/test_cfgfile.c (test_stanza_instance): Update.
4023
Scott James Remnant535c6902007-02-09 00:43:03 +00004024 * init/event.h: Correct the event names.
4025
Scott James Remnante2edac92007-02-09 00:39:24 +00004026 * init/job.h: Add blocker event member.
4027 * init/job.c (job_new): Initialise it to NULL.
4028 * init/tests/test_job.c (test_new): Check it.
4029
Scott James Remnante885d552007-02-09 00:01:46 +00004030 * init/job.c (job_change_goal): Have a stab at this function with the
4031 new state machine; it gets somewhat simpler (until we introduce the
4032 second scripts), now we just induce things by a state change.
4033 * init/tests/test_job.c (test_change_goal): Made easier (for now)
4034 because we don't need to deal with processes and can just wait to
4035 be blocked on an event.
4036
Scott James Remnant9e13a242007-02-08 00:24:21 +000040372007-02-08 Scott James Remnant <scott@netsplit.com>
4038
Scott James Remnant5e469e42007-02-08 23:49:01 +00004039 * init/cfgfile.c (cfg_read_job): Drop check for useless respawn script
4040 (cfg_stanza_respawn): Drop handling of "respawn script"
4041 * init/tests/test_cfgfile.c (test_stanza_respawn): Drop the checks
4042 for "respawn script"
4043
Scott James Remnant4fdf7552007-02-08 23:45:34 +00004044 * init/job.h: Move things about a bit more; remove respawn_script
4045 since that state is going away.
4046 * init/job.c (job_new): Drop initialisation of process_state.
4047 * init/tests/test_job.c (test_new): Improve the tests.
4048
Scott James Remnant3856c632007-02-08 23:29:17 +00004049 * init/main.c (STATE_FD): Remove this define, not used anymore.
4050
Scott James Remnantbc281c32007-02-08 23:25:33 +00004051 * init/tests/test_event.c (test_poll): Update the event checking
4052 to match what's likely to happen.
4053
Scott James Remnant049b50f2007-02-08 23:23:29 +00004054 * init/event.h: Remove commented out bit.
4055
Scott James Remnant1abebfd2007-02-08 23:20:02 +00004056 * init/tests/test_notify.c (check_job_status, test_job): Correct
4057 state usage to match a possible state.
4058
Scott James Remnant64bc2a82007-02-08 22:59:46 +00004059 * init/control.c (control_job_start, control_job_stop)
4060 (control_job_query, control_job_list): Drop process state and
4061 description from the job status messages we send back.
4062 * init/tests/test_control.c (test_error_handler)
4063 (check_job_started, test_job_start, check_job_stopped)
4064 (check_job_stopping, test_job_query, check_job_starting)
4065 (test_job_list, test_watch_jobs, test_unwatch_jobs): Remove
4066 process_state and description, and update usage of job states.
4067
Scott James Remnantcb178f82007-02-08 22:47:42 +00004068 * init/notify.c (notify_job): Don't include process state or
4069 description in the job status message anymore.
4070 * init/tests/test_notify.c (check_job_status, test_job): Update tests
4071
Scott James Remnant79cd4bf2007-02-08 22:44:46 +00004072 * init/cfgfile.c (cfg_read_job): Drop the copying of the process_state
4073 member, since it doesn't exist anymore.
4074 * init/tests/test_cfgfile.c (test_read_job): Drop the check too.
4075
Scott James Remnant6f0ff592007-02-08 22:43:04 +00004076 * init/job.h (Job): Drop the process_state member.
4077
Scott James Remnant56a1fa82007-02-08 22:40:01 +00004078 * util/jobs.c (handle_job_status): Drop the process_state and
4079 description arguments; output a process id only if it's greater
4080 than zero.
4081 * util/tests/test_jobs.c (test_start_action, test_list_action)
4082 (test_jobs_action): Update tests to use newer states and arguments.
4083 * util/events.c (handle_event_job_status): Simplify in the same way
4084
Scott James Remnantac0c88b2007-02-08 22:31:00 +00004085 * upstart/message.h: Remove process_state and description from the
4086 job status event (we already had the foresight to not put them in
4087 the event job status event).
4088 * upstart/message.c (upstart_message_new, upstart_message_handle):
4089 Update handling of the messages to reduce the arguments.
4090 * upstart/tests/test_message.c (test_new, my_handler)
4091 (test_handle): Update the tests for the new job status message.
4092
Scott James Remnante76986a2007-02-08 22:21:22 +00004093 * upstart/enum.h (JobState): Change the job states to the new set
4094 of states that we've planned.
4095 (ProcessState): Drop process state entirely; this information is now
4096 contained in the single JobState field.
4097 * upstart/enum.c (job_state_name, job_state_from_name): Update
4098 strings to match the new state names.
4099 (process_state_name, process_state_from_name): Drop these functions.
4100 * upstart/tests/test_enum.c (test_state_name)
4101 (test_state_from_name): Update test cases to match new names.
4102 (test_process_state_name, test_process_state_from_name): Drop.
4103
Scott James Remnant08100e02007-02-08 17:57:21 +00004104 * init/main.c (main): Remove the logd hack for now.
4105 * init/job.c (job_new): Change the default console to none for now.
4106 * init/tests/test_job.c (test_new): Update test.
4107 * init/cfgfile.c (cfg_stanza_console): Can't guard against duplicates
4108 for a while.
4109 * init/tests/test_cfgfile.c (test_stanza_console): Comment out dup test
4110
Scott James Remnantf247adf2007-02-08 15:23:43 +00004111 * init/cfgfile.c (cfg_read_job): Remove the restriction that there
4112 must be either an 'exec' or 'script' for a job; jobs without either
4113 define states others can use.
4114 * init/tests/test_cfgfile.c (test_read_job): Convert the test to
4115 a "must work".
4116 * init/job.c (job_change_state): Remove restriction that we must
4117 have either a script or a command; having neither should just wedge
4118 the job at the running rest state. Note that there's no way to get
4119 it out yet, because we don't force that particular state change.
4120 * init/tests/test_job.c (test_change_state): Make sure that works.
4121
Scott James Remnant920d65b2007-02-08 13:49:53 +00004122 * init/job.c (job_change_cause): Put the knowledge about how to
4123 change the cause into a separate function, since it's slightly
4124 tricky.
4125 (job_change_goal, job_change_state): Set the cause using the above
4126 function.
4127
Scott James Remnanta3bcac12007-02-08 13:40:53 +00004128 * init/job.h (Job): Rename goal_event to cause, also shuffle things
4129 around so that the state is mostly together.
4130 * init/job.c, init/process.c, init/notify.c, init/cfgfile.c: Update
4131 references (and comments) to match the new name.
4132 * init/tests/test_job.c, init/tests/test_event.c,
4133 init/tests/test_process.c, init/tests/test_cfgfile.c,
4134 init/tests/test_notify.c: Likewise.
4135
Scott James Remnantef119832007-02-08 13:24:16 +00004136 * init/job.c (job_child_reaper): Don't change the goal event; the
4137 state changes will handle this.
4138 (job_change_goal): Only dereference/reference the goal event if we're
4139 actually changing it.
4140 * init/tests/test_job.c (test_change_state, test_child_reaper):
4141 Update tests to not assume that the goal event gets changed.
4142 (test_kill_process): Eliminate race condition.
4143
Scott James Remnant93376ef2007-02-08 12:53:53 +00004144 * init/job.c (job_child_reaper): Correct some problems with job and
4145 event failure; we now don't overwrite an existing failure record,
4146 and don't record failure if the main process failed and the goal was
4147 stop; since we likely caused it.
4148 * init/tests/test_job.c (test_child_reaper): More test cases.
4149
Scott James Remnantc3db81c2007-02-08 12:38:19 +00004150 * logd/event.d/logd.in: Stop on the new runlevel events, not the
4151 shutdown event.
4152
Scott James Remnante8d263c2007-02-08 03:20:30 +00004153 * compat/sysv/shutdown.c (shutdown_now): Emit an ordinary runlevel
4154 change event now; including the INIT_HALT environment variable
4155 * compat/sysv/man/shutdown.8: Update the manual
4156
Scott James Remnant52360ea2007-02-08 03:06:40 +00004157 * compat/sysv/telinit.c: Now just sends out a runlevel event with
4158 an argument giving the new runlevel.
4159 * compat/sysv/man/telinit.8: Update description of the command.
4160
Scott James Remnant8662bd02007-02-08 02:57:56 +00004161 * upstart/message.h: Remove the UPSTART_SHUTDOWN message.
4162 * upstart/message.c (upstart_message_new, upstart_message_handle):
4163 Remove handling for the shutdown message.
4164 * upstart/tests/test_message.c (test_new, test_handle): Remove
4165 tests against the shutdown message.
4166 * init/control.c (control_shutdown): Remove the shutdown command
4167 from the server.
4168 * init/tests/test_control.c (test_shutdown): Remove tests for it.
4169 * init/event.h: Remove the shutdown event.
4170 * util/initctl.c: Remove the shutdown command reference.
4171 * util/events.c (shutdown_action): Remove the command.
4172 * util/events.h: Update.
4173 * util/tests/test_events.c (test_shutdown_action): Remove tests.
4174
Scott James Remnant65906602007-02-08 02:51:39 +00004175 * init/job.c (job_detect_idle): Rename to job_detect_stalled
4176 (job_detect_stalled): Remove the idle state detection
4177 (job_set_idle_event): Idle event has been removed.
4178 * init/job.h: Update.
4179 * init/tests/test_job.c (test_detect_idle): Rename to
4180 (test_detect_stalled): and remove idle detection tests.
4181 * init/main.c (main): Replace job_detect_idle with job_detect_stalled
4182 * init/control.c (control_shutdown): Don't set the idle event.
4183 * init/tests/test_control.c (test_shutdown): Don't detect the idle
4184 event (and thus the second event)
4185
Scott James Remnantb0d99d52007-02-08 02:40:43 +00004186 * init/cfgfile.c (cfg_stanza_service): Parser for service stanza.
4187 * init/tests/test_cfgfile.c (test_stanza_service): Test the service
4188 stanza.
4189 (test_stanza_respawn): Check that respawn implies service.
4190 * TODO: Update.
4191
4192 * init/job.h (Job): Add a new service member.
4193 * init/job.c (job_new): Service starts off as false.
4194 (job_change_state): Check service instead of respawn.
4195 * init/tests/test_job.c (test_change_state): Check with service
4196 instead of respawn, since that's what we really mean.
4197
Scott James Remnante4ab75c2007-02-08 02:28:19 +00004198 * init/cfgfile.c (cfg_read_job): Copy a whole bunch more state
4199 into the newly parsed job.
4200 * init/job.c (job_run_process): Only output the first error.
4201 * init/tests/test_cfgfile.c (test_read_job): Make sure important
4202 things are copied.
4203 * TODO: Update.
4204
Scott James Remnantdb31c152007-02-08 02:05:38 +00004205 * init/main.c: Restore a much simplified version of the term
4206 handler that doesn't try and copy across any state.
4207
Scott James Remnant517f5552007-02-08 02:02:52 +00004208 * compat/sysv/telinit.c: Update call to event_emit; we'll revisit
4209 this shortly when we get rid of the shutdown event.
4210
Scott James Remnant1dc0de52007-02-08 01:57:34 +00004211 * util/events.c (handle_event): Add new id field (but ignore it)
4212 Functio
4213 (handle_event_job_status): New function to handle the new event.
4214 (handle_event_finished): Function to handle the end of the event.
4215 (emit_action): Send the newer event, and loop over replies until
4216 we get a finished one.
4217 * util/tests/test_events.c (test_emit_action): Update tests cases.
4218
Scott James Remnantd9520172007-02-08 01:18:24 +00004219 * init/control.c (control_event_emit): New function to handle the
4220 new-style emit message.
4221 * init/tests/test_control.c (test_event_emit): Make sure the new
4222 message function behaves.
4223
Scott James Remnantb3e539e2007-02-08 01:10:12 +00004224 * init/event.c, init/job.c, init/main.c, init/tests/test_event.c,
4225 init/tests/test_job.c: Completely drop the serialisation code, it's
4226 getting out of date and in the way.
4227
Scott James Remnant71b91fc2007-02-08 01:07:56 +00004228 * init/event.h: Remove compatibility macros.
4229 (EventEmission): Drop the callback function; it was too error prone
4230 to try and do it this way, and we only ever wanted to release a job
4231 anyway as control requests are better handled through the notify
4232 interface.
4233 (EventEmissionCb): Drop unused typedef.
4234 * init/event.c (event_emit): Drop callback argument.
4235 (event_finished): Don't call the callback
4236 * init/tests/test_event.c: Update to avoid callbacks.
4237 * init/job.c (job_change_state): Convert to using event_emit and
4238 EventEmission.
4239 (job_detect_idle): Drop extra arguments to event_emit.
4240 * init/main.c (main, cad_handler, kbd_handler): Drop extra arguments
4241 to event_emit.
4242 * init/control.c (control_shutdown): Use event_emit instead of
4243 event_queue.
4244 * init/tests/test_control.c (test_shutdown): Convert to using
4245 EventEmission.
4246 (test_watch_events, test_unwatch_events): Drop extra arguments to
4247 event_emit.
4248 * init/tests/test_notify.c (test_subscribe_event, test_job)
4249 (test_event, test_event_finished): Drop extra arguments to event_emit
4250 * init/tests/test_job.c (test_change_goal, test_change_state)
4251 (test_run_script, test_child_reaper, test_detect_idle): Drop
4252 extra arguments to event_emit.
4253 * init/tests/test_process.c (test_spawn): Drop extra arguments to
4254 event_emit.
4255
Scott James Remnantf082fc42007-02-08 00:50:11 +00004256 * TODO: Update.
4257
Scott James Remnant716f75c2007-02-08 00:49:40 +00004258 Rewrite the notification subsystem quite significantly; now we
4259 have individual functions to subscribe to different types of
4260 notification, and can even subscribe to individual jobs or events.
4261
4262 * init/notify.c (notify_subscribe_job, notify_subscribe_event)
4263 (notify_unsubscribe): New subscription and unsubscription functions
4264 that assume one record per subscription, not process.
4265 (notify_subscription_find): Function to find a subscription.
4266 (notify_job): Send a message to anything subscribed to the goal event
4267 as well.
4268 (notify_event): Use EventEmission and include the id in the event.
4269 (notify_event_finished): New function, sends a finished message and
4270 includes both the id and whether the event failed.
4271 * init/notify.h (NotifySubscribe): New notify structure that is
4272 once per subscription, rather than per-process; and allows
4273 subscription to individual jobs or events.
4274 * init/tests/test_notify.c (test_subscribe_job)
4275 (test_subscribe_event, test_unsubscribe): Test the new subscription
4276 functions, replacing the old
4277 (test_subscribe): tests.
4278 (test_subscription_find): Check finding works
4279 (check_event, test_event): Update to use emissions, and check that the
4280 id is correct.
4281 (test_event_finished): Check this one works too
4282 (check_event_job_status, test_job): Make sure processes subscribed
4283 via the goal event are notified too.
4284 * init/event.c (event_pending): Pass the emission directly.
4285 (event_finished): Notify subscribers that the event has finished.
4286 * init/control.c (control_error_handler): Call notify_unsubscribe
4287 (control_watch_jobs, control_unwatch_jobs, control_watch_events)
4288 (control_unwatch_events): Update to the new subscription API.
4289 * init/tests/test_control.c (test_error_handler): Use new API
4290 (test_watch_jobs, test_unwatch_jobs, test_watch_events)
4291 (test_unwatch_events): Also update these to the new API; use a
4292 destructor to make sure the subscription is freed.
4293
Scott James Remnant9e13a242007-02-08 00:24:21 +00004294 * init/tests/test_process.c: Don't use printf, use TEST_FUNCTION
4295
Scott James Remnante627ad42007-02-07 00:23:57 +000042962007-02-07 Scott James Remnant <scott@netsplit.com>
4297
Scott James Remnant459aee32007-02-07 22:44:08 +00004298 * upstart/message.h: Allocate new grouped event messages.
4299 * upstart/message.c (upstart_message_new, upstart_message_handle):
4300 Add support for the new grouped event messages.
4301 * upstart/tests/test_message.c (test_new, test_handle)
4302 (my_handler): Make sure the new messages are passed correctly.
4303
Scott James Remnant1d792152007-02-07 20:56:01 +00004304 * init/job.c (job_change_state): Clear the goal event whenever we
4305 reach the final rest state of a job (waiting for all jobs, running
4306 for services).
4307 * init/tests/test_job.c (test_change_state): Check that the goal
4308 event goes away at the right times.
4309 * TODO: Update.
4310
Scott James Remnantab17ab92007-02-07 20:38:01 +00004311 * init/tests/test_job.c (test_child_reaper): Make sure that the
4312 event is marked failed properly
4313
Scott James Remnant6d007b82007-02-07 20:21:54 +00004314 * init/job.c (job_start_event, job_stop_event): There's no reason
4315 for these to exist as seperate functions anymore, especially since
4316 we want to eventually have some kind of match table.
4317 (job_handle_event): Perform the iterations and match calls here
4318 instead, since we just call job_change_goal now.
4319 * init/job.h: Remove prototypes.
4320 * init/tests/test_job.c (test_start_event, test_stop_event): Fold into
4321 (test_handle_event): which now handles all the cases.
4322
Scott James Remnant269b7b92007-02-07 20:04:42 +00004323 * init/job.c (job_detect_idle): Call event_emit
4324 * init/main.c (main, cad_handler, kbd_handler): Call event_emit
4325 instead of event_queue.
4326 * init/tests/test_event.c (test_new): Call event_poll
4327 * init/tests/test_job.c (test_change_state, test_child_reaper)
4328 (test_detect_idle, test_change_state): Update to use newer event API.
4329 * TODO: Update.
4330
Scott James Remnant80eabbc2007-02-07 19:54:27 +00004331 * init/job.c (job_start, job_stop): Drop these functions; call
4332 job_change_goal instead (which is now public).
4333 (job_change_state, job_child_reaper): Call job_change_goal instead.
4334 * init/job.h: Update.
4335 * init/tests/test_job.c (test_start, test_stop): Merge into new
4336 (test_change_goal): function.
4337 * init/main.c (main): Call job_change_goal instead of job_start.
4338 * init/control.c (control_job_start, control_job_stop): Call
4339 job_change_goal instead.
4340
Scott James Remnant4522f4d2007-02-07 19:38:19 +00004341 * init/tests/test_job.c (test_new, test_change_state)
Scott James Remnant80eabbc2007-02-07 19:54:27 +00004342 (test_run_script, test_start, test_stop, test_start_event):
Scott James Remnant4522f4d2007-02-07 19:38:19 +00004343
4344 * init/job.h (Job): goal_event is now an EventEmission, and is
4345 a direct pointer to the one in the events queue, rather than a copy.
4346 * init/process.c (process_setup_environment): Reference the event
4347 name and environment through the goal event, not directly.
4348 * init/job.c (job_run_script): Reference the event name and
4349 environment through the goal event, not directly.
4350 (job_change_state, job_child_reaper): Replace direct setting of the
4351 job goal with a call to job_stop; the process state is always
4352 PROCESS_NONE in all three cases, so this is completely safe.
4353 (_job_start, _job_stop): Merge these two functions together into
4354 (job_change_goal): which behaves a lot more like job_change_state,
4355 except that it doesn't loop. This handles the changing of the
4356 emission.
4357 (job_start, job_start_event, job_stop, job_stop_event): Simplify
4358 these functions, now they just call job_change_goal passing in
4359 the emission pointer (or NULL).
4360
Scott James Remnantb1db7a32007-02-07 16:33:27 +00004361 * init/main.c, init/job.c, init/job.h, init/event.c, init/event.h,
4362 init/tests/test_job.c, init/tests/test_event.c: Remove state
4363 serialisation code for the time being; maintaining it is getting
4364 increasingly harder, and it introduces some major bugs. It will
4365 get rewritten shortly.
4366
Scott James Remnant4216cc82007-02-07 16:22:47 +00004367 * init/event.c (event_pending): Pass the emission directly to
4368 job_handle_event now.
4369 * init/job.c (job_handle_event, job_start_event, job_stop_event):
4370 Deal with event emissions rather than just plain events, the change
4371 so far doesn't do anything else other than take the structure change.
4372 * init/job.h: Change prototypes.
4373 * init/tests/test_job.c (test_start_event, test_stop_event)
4374 (test_handle_event): Update tests to use emissions.
4375
Scott James Remnantb2d06d42007-02-07 15:55:33 +00004376 * init/tests/test_event.c (test_read_state, test_write_state): Check
4377 the passing of the progress information.
4378 * init/event.c (event_read_state, event_write_state): Add progress
4379 field to the serialisation (oops).
4380
Scott James Remnantab132da2007-02-07 15:48:02 +00004381 * init/event.h: Add missing attribute for event_read_state.
4382 * init/cfgfile.h: Add missing attributes.
4383 * init/main.c (read_state): Don't discard return value.
4384 * TODO: Update.
4385
Scott James Remnantfcc9a0d2007-02-07 15:41:57 +00004386 * init/main.c (read_state): Handle the Emission keyword; also handle
4387 Event really being an EventEmission.
4388 * init/event.c (event_emit): Make the next emission id a static global
4389 (event_read_state, event_write_state): Serialise event emission
4390 structures, not plain events; also send over the last id we used so
4391 it appears seamless. This doesn't yet handle the callback/data bit
4392 of the serialisation, which turns out to be a little tricky ... oops
4393 * init/event.h: Update.
4394 * init/tests/test_event.c (test_read_state, test_write_state): Check
4395 that serialisation is done with EventEmissions instead, and all the
4396 fields are passed (except callback and data which are ... tricky).
4397
Scott James Remnanta39da0f2007-02-07 13:52:42 +00004398 * init/main.c (main): Call event_poll instead of event_queue_run.
4399
Scott James Remnante47588c2007-02-07 13:50:01 +00004400 * init/event.c (event_poll): Add the new function that replaces
4401 event_queue_run(); handles the new-style event emission structures
4402 in the list and only returns when there are no non-handling events.
4403 (event_pending, event_finished): Handling of particular event states
4404 during poll; split out for readability.
4405 (event_queue, event_queue_run): Drop these obsolete functions.
4406 (event_read_state): Force type from event_queue.
4407 * init/event.h: Add event_poll prototype; remove prototypes of old
4408 functions, replacing with #defines for now so things still compile.
4409 * init/tests/test_event.c (test_queue): Drop tests.
4410 (test_read_state, test_write_state): Force type from event_queue
4411 Change type we check size of.
4412 (test_poll): Pretty thoroughly test the new poll function.
4413 * init/job.c (job_change_state): Force type from event_queue
4414 * init/control.c (control_event_queue): Force type from event queue
4415 * init/tests/test_job.c (test_detect_idle): Force type from event_queue
4416 * init/tests/test_control.c (test_event_queue, test_shutdown):
4417 Force type from event_queue
4418
Scott James Remnant162c2b22007-02-07 11:32:04 +00004419 * init/event.c: Revert to a single list of events with an enum
4420 (event_emit): Set the progress to pending initially.
4421 (event_emit_find_by_id): Simplify now it just checks one list
4422 (event_emit_finished): Function for jobs to call once they've done
4423 with an event; just sets the progress to finished for the event
4424 queue to pick up.
4425 * init/tests/test_event.c (test_emit_finished): Check it.
4426
4427 * init/event.h: Add prototype.
4428 (EventProgress): Add new enum
4429 (EventEmission): And add progress member to this structure
4430 * init/tests/test_event.c (test_emit): Make sure the event is pending
4431
Scott James Remnantd379a602007-02-07 10:58:06 +00004432 * init/event.c (event_emit_find_by_id): Locate an event emission
4433 by its id in either the pending or handling queue.
4434 * init/event.h: Add prototype
4435 * init/tests/test_event.c (test_emit): Make sure that the emission
4436 id is unique each time.
4437 (test_emit_find_by_id): Test the function.
4438
Scott James Remnant7282c9a2007-02-07 03:14:08 +00004439 * init/event.c (event_emit): New function to replace event_queue();
4440 returns an EventEmission structure with the details filled in as
4441 given.
4442 * init/event.h: Add prototype.
4443
Scott James Remnant81cc7942007-02-07 02:54:25 +00004444 * init/event.c (event_init): Rename the single events queue to
4445 pending and add a new handling list.
4446
4447 * init/event.h (EventEmission, EventEmissionCb): Add a new emission
4448 structure that wraps an event, for use in the queue.
4449
Scott James Remnantd82109e2007-02-07 02:15:39 +00004450 * util/tests/test_events.c (test_events_action): Update test now
4451 that nih_message is more sensible.
4452 * util/tests/test_jobs.c (test_start_action, test_list_action)
4453 (test_jobs_action): Update test
4454
Scott James Remnante5d3f012007-02-07 01:59:57 +00004455 * util/events.c (emit_action): Actually pass the emit_env array
4456 * util/tests/test_events.c (test_emit_action): Make sure it does.
4457
4458 * util/initctl.c (main): Catch nih_command_parser() returning a
4459 negative value to indicate an internal error, and always exit 1.
4460
Scott James Remnant2cb93052007-02-07 01:49:43 +00004461 * util/events.c (handle_event): Build up multiple lines to describe
4462 the event, including its arguments and environment.
4463 * util/tests/test_events.c (test_events_action): Check the new output
4464 format is right.
4465
Scott James Remnant685644e2007-02-07 01:29:28 +00004466 * init/main.c (main): Take out inadvertantly leaked debugging code;
4467 sorry about that.
4468
Scott James Remnant5130e6d2007-02-07 01:18:38 +00004469 * init/job.c (job_child_reaper): Rewrite this to make the logic a
4470 little easier to follow, and support signals in normalexit. This
4471 also now applies to deciding whether the job failed, if it did, we
4472 store that information in the job so the stop and stopped events
4473 can get it.
4474 * init/tests/test_job.c (test_child_reaper): Add new test cases for
4475 the setting of the failed flags.
4476
Scott James Remnant18935fe2007-02-07 00:38:13 +00004477 * init/cfgfile.c (cfg_stanza_normalexit): Allow signal names in the
4478 arguments, which are added to the normalexit array or'd with 0x80
4479 * init/tests/test_cfgfile.c (test_stanza_normalexit): Check that we
4480 can now parse signal names correctly.
4481
Scott James Remnant326c2312007-02-07 00:31:18 +00004482 * init/job.c (job_failed_event): Change add to addp to fix leak.
4483
Scott James Remnante627ad42007-02-07 00:23:57 +00004484 * init/job.c (job_failed_event): Function to turn an event into one
4485 that includes all the necessary arguments and environment.
4486 (job_change_state): Call job_failed_event for the stop and stopped
4487 events (bit hacky at the moment, will improve later).
4488 * init/tests/test_job.c (test_change_state): Check that the failed
4489 events are generated properly.
4490
Scott James Remnant2b2b7d12007-02-06 00:07:28 +000044912007-02-06 Scott James Remnant <scott@netsplit.com>
4492
Scott James Remnant038ef4d2007-02-06 23:46:53 +00004493 * init/job.c (job_change_state): Reset the failed member when
4494 we enter the starting state.
4495 * init/tests/test_job.c (test_change_state): Make sure that the
4496 failed member is reset when we enter the starting state.
4497
Scott James Remnantbd7ad1a2007-02-06 23:43:59 +00004498 * init/job.h (Job): Add failed, failed_state and exit_status members.
4499 * init/job.c (job_new): Initialise new members.
4500
Scott James Remnantddbf1162007-02-06 23:40:30 +00004501 * init/job.c (job_child_reaper): Convert signals to names when
4502 outputting status messages.
4503 * init/tests/test_job.c (test_child_reaper): Check that the signal
4504 name gets converted over.
4505
Scott James Remnantf11b7dc2007-02-06 23:03:48 +00004506 * init/event.h (CTRLALTDEL_EVENT): Now we've broken the shared
4507 namespace of events and jobs, rename the control-alt-delete event
4508 back to control-alt-delete.
4509
Scott James Remnant0ef0d392007-02-06 23:00:28 +00004510 * init/job.c (job_change_state): Replace the events generated as
4511 part of the job state, named for the job and state, with new state
4512 events that have the job name as an argument.
4513 * init/event.h: Define new job event names.
4514 * init/tests/test_job.c (test_change_state): Make sure the new
4515 events are correct, with the job name as an argument.
4516
Scott James Remnant1416d052007-02-06 22:42:55 +00004517 * init/job.c (job_change_state): Remove the job event; this has
4518 been repeatedly proved to be confusing.
4519 * init/tests/test_job.c (test_change_state): Remove checks for the
4520 job event.
4521
Scott James Remnant08146b92007-02-06 20:45:38 +00004522 * util/events.c (emit_action): Pass in extra arguments.
4523 (env_option): Function to parse an option given an environment
4524 variable.
4525 * util/events.h: Add prototype.
4526 * util/tests/test_events.c (test_emit_action): Make sure that the
4527 emit action works with no arguments and with arguments.
4528 (test_events_action): Send back events with the right number of args.
4529 (test_env_option): Check the env option parser works.
4530 * util/initctl.c: Give shutdown its own command and options, give
4531 emit a new -e option.
Scott James Remnante8f3ef92007-02-06 20:20:33 +00004532
Scott James Remnant7f69c622007-02-06 20:16:50 +00004533 * util/events.c (shutdown_action): Split out from emit, seeing as
4534 these are going to be different from now on.
4535 * util/events.h: Add prototype.
4536 * util/tests/test_events.c (test_shutdown_action): Copy test cases.
4537
Scott James Remnantca2df742007-02-06 20:13:32 +00004538 * init/control.c (control_event_queue): Take the arguments and
4539 environment from the event queue request; and reparent into the
4540 event.
4541 * init/tests/test_control.c (test_event_queue): Check that arguments
4542 and environment are copied across properly.
4543
Scott James Remnanta30a25f2007-02-06 20:08:22 +00004544 * init/notify.c (notify_event): Pass in the arguments and environment
4545 for the event.
4546 * init/tests/test_notify.c (check_event): Check for event arguments
4547 and environment from the notify process.
4548 (test_event): Add arguments and environment to the event we test with
4549
Scott James Remnantce51bfb2007-02-06 20:04:05 +00004550 * upstart/tests/test_message.c (test_new, test_handle): Send
4551 arguments and environment with the UPSTART_EVENT_QUEUE and
4552 UPSTART_EVENT messages.
4553 * upstart/wire.c (upstart_pop_int, upstart_pop_unsigned): Shrink
4554 only once.
4555 (upstart_pop_string): Check the length is at least one first, as
4556 we may just have an 'S'.
4557
4558 * upstart/message.c (upstart_message_new, upstart_message_handle):
4559 The UPSTART_EVENT and UPSTART_EVENT_QUEUE messages gain new array
4560 arguments containing the arguments and environment for the event.
4561 * upstart/message.h: Document the new arguments.
4562
Scott James Remnantd1a65342007-02-06 19:25:38 +00004563 * util/tests/test_events.c, util/tests/test_jobs.c: Update the
4564 message format checks here too.
4565
Scott James Remnantfb45e432007-02-06 19:07:24 +00004566 * upstart/tests/test_wire.c (test_pop_pack): Free the array.
4567
Scott James Remnanta8882032007-02-06 19:06:44 +00004568 * upstart/tests/test_message.c (test_new, test_handle)
4569 (test_handle_using, test_reader): Update tests to include and
4570 expect new type markers between each field.
4571
Scott James Remnantf9663f02007-02-06 18:58:37 +00004572 * upstart/wire.c (upstart_push_int, upstart_push_unsigned):
4573 Take out silly asserts; it must have room!
4574
Scott James Remnantc874a942007-02-06 18:57:34 +00004575 * upstart/wire.c (upstart_push_string, upstart_pop_string): Rewrite
4576 to use a type like the rest of the functions; this removes the strange
4577 length restriction and allows us to make the pop function
4578 non-destructive.
4579 * upstart/tests/test_wire.c (test_push_string): Update.
4580 (test_pop_string): Update, adding in non-destructive, wrong type
4581 and insufficient space for type test cases.
4582 (test_push_array, test_pop_array): These needed updated too,
4583 changing the string format changed the array format.
4584 (test_push_pack, test_pop_pack): And obviously the pack format changed.
4585
Scott James Remnant9ed52092007-02-06 18:36:51 +00004586 * upstart/wire.c (upstart_pop_header): Make the function
4587 non-destructive in the face of errors.
4588 * upstart/tests/test_wire.c (test_pop_header): Make sure that
4589 invalid headers are non-destructive on error.
4590
Scott James Remnantdc4436f2007-02-06 18:33:27 +00004591 * upstart/tests/test_wire.c (test_pop_int, test_pop_unsigned):
4592 Make sure that insufficient space is non-destructive.
4593
Scott James Remnantafc5b8c2007-02-06 18:32:08 +00004594 * upstart/wire.c (upstart_push_int, upstart_pop_int)
4595 (upstart_push_unsigned, upstart_pop_unsigned): Convert to array-style
4596 type first format.
4597 (upstart_push_string, upstart_push_header): Write the length and
4598 type fields out by hand so they don't get an 'i' prefix.
4599 (upstart_pop_string, upstart_pop_header): Read the length and type
4600 fields by hand so they don't get an 'i' prefix.
4601 * upstart/tests/test_wire.c (test_push_int, test_pop_int)
4602 (test_push_unsigned, test_pop_unsigned): Update test cases to match.
4603 (test_push_pack, test_pop_pack): Pack format was changed too.
4604
Scott James Remnanta63d4862007-02-06 18:10:58 +00004605 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add calls
4606 to push and pop array.
4607 * upstart/tests/test_wire.c (test_push_pack, test_pop_pack): Test
4608 support for arrays.
4609
Scott James Remnant5b6a2022007-02-06 18:00:49 +00004610 * upstart/wire.c (upstart_push_array, upstart_pop_array): Implement
4611 new array functions; note that these use a newer format that allows
4612 us to transmit NULL without needing to limit the size of the array.
4613 * upstart/wire.h: Add prototypes.
4614 * upstart/tests/test_wire.c (test_push_array, test_pop_array):
4615 Test the new array functions.
4616
Scott James Remnantf1d51112007-02-06 16:22:48 +00004617 * init/job.c (job_run_script): Build up the argument list, appending
4618 those from the goal event if one is set.
4619 (job_run_command): Use nih_str_array_add to build up the arguments,
4620 but don't append those from the goal event (use script).
4621 * init/tests/test_job.c (test_run_script): Make sure the arguments get
4622 passed to the running shell scripts.
4623
Scott James Remnant2efe5562007-02-06 15:51:19 +00004624 * init/job.c (job_run_script): Only use the /dev/fd trick if we can
4625 actually stat /dev/fd; also don't hardcode that path ...
4626 * init/paths.h (DEV_FD): Add here.
4627
Scott James Remnantefa8c7e2007-02-06 15:02:23 +00004628 * init/process.c (process_setup_environment): Copy environment
4629 variables from the goal event into the job's process.
4630 * init/tests/test_process.c (test_spawn): Make sure the environment
4631 reaches the job, but doesn't override that in the job already.
4632
4633 * init/tests/test_job.c (test_start_event):
4634
Scott James Remnant0071dd32007-02-06 14:57:37 +00004635 * init/job.c (job_start_event, job_stop_event): Copy the arguments
4636 and environment from the event into the goal event.
4637
Scott James Remnantb3d4dee2007-02-06 14:39:35 +00004638 * init/job.c (job_read_state, job_write_state): Read and write
4639 arguments and environment for goal event.
4640 * init/tests/test_job.c (test_read_state, test_write_state): Test
4641 with arguments and environment to the goal event.
4642
Scott James Remnant4bba9702007-02-06 14:28:10 +00004643 * init/event.c (event_read_state, event_write_state): Read and write
4644 the arguments and environment of the event.
4645 * init/tests/test_event.c (test_read_state, test_write_state): Make
4646 sure arguments and environment are correctly serialised.
4647
Scott James Remnant462e7172007-02-06 13:30:24 +00004648 * init/cfgfile.c (cfg_stanza_console): Fix a leak of the console
4649 argument in the case of duplicated options.
4650 (cfg_stanza_env): Drop the counting now nih_str_array_addp does it;
4651 and be sure to use that function.
4652 (cfg_stanza_umask): Fix leak of umask argument
4653 (cfg_stanza_nice): Fix leak of nice argument
4654 * init/tests/test_event.c (test_new): Call event_queue_run so init
4655 is called outside of a TEST_ALLOC_FAIL block.
4656
Scott James Remnantfd196342007-02-06 13:19:03 +00004657 * init/event.c (event_new): Start off with NULL args and env, to
4658 match job (saves a few bytes).
4659 (event_match): Watch for NULL arguments!
4660 * init/tests/test_event.c (test_new): Check for NULL not alloc'd
4661
Scott James Remnantfc9a76e2007-02-06 13:14:46 +00004662 * init/cfgfile.c (cfg_stanza_on, cfg_stanza_start)
4663 (cfg_stanza_stop): Parse arguments to the on stanza and store them
4664 directly in the event.
4665 * init/tests/test_cfgfile.c (test_stanza_on, test_stanza_start)
4666 (test_stanza_stop): Make sure arguments are parsed into the event.
4667
Scott James Remnant5dd1bc92007-02-06 12:57:50 +00004668 * init/event.c (event_new): Use nih_str_array_new.
4669 * init/cfgfile.c (cfg_stanza_env): Rewrite to use nih_str_array.
4670
Scott James Remnant4d0fc0f2007-02-06 11:34:41 +00004671 * init/job.c (job_run_script): Check the error returned from
4672 nih_io_reopen; don't just loop. We only ever expect ENOMEM (the
4673 other error, EBADF, is impossible).
4674
Scott James Remnanteb8cb142007-02-06 11:31:27 +00004675 * init/job.c (job_change_state): Reset the goal_event to NULL when
4676 we catch a run-away job (as it's not stopping for the same event
4677 it started with).
4678 (job_child_reaper): Reset the goal_event to NULL after setting the
4679 goal to STOP.
4680 * init/tests/test_job.c (test_change_state, test_child_reaper):
4681 Check that the goal event gets reset whenever the goal gets changed.
4682
Scott James Remnant62e22f42007-02-06 02:08:19 +00004683 * init/tests/test_event.c: Use TEST_ALLOC_FAIL
4684
Scott James Remnant93cd4d22007-02-06 02:07:45 +00004685 * init/event.c (event_match): Match arguments using fnmatch() and
4686 allow more arguments in event1 than event2 (but not the other way
4687 around).
4688 * init/tests/test_event.c (test_match): Check the new permitted
4689 combinations.
4690
Scott James Remnant34b7c712007-02-06 01:57:45 +00004691 * init/event.h (Event): Add args and env members to Event.
4692 * init/event.c (event_new): Initialise args and env members to
4693 zero-length arrays.
4694 * init/tests/test_event.c (test_new): Use TEST_ALLOC_FAIL and
4695 make sure args and env are both initialised to a list containing
4696 just NULL.
4697
Scott James Remnantb36c1962007-02-06 01:48:09 +00004698 * util/jobs.c (start_action): Get the UPSTART_JOB environment variable
4699 and use that if we don't have any arguments passed to us.
4700 (do_job): Code split from the above function that handles a named job
4701 * util/tests/test_jobs.c (test_start_action): Make sure UPSTART_JOB
4702 is picked up.
4703
Scott James Remnant2a0b0852007-02-06 01:35:56 +00004704 * init/process.h: Add necessary attributes.
4705
Scott James Remnant0b10d502007-02-06 01:28:01 +00004706 * init/process.c (process_setup_environment): Set the UPSTART_JOB
4707 environment variable from the job, and the UPSTART_EVENT environment
4708 variable from the job's goal_event member (if set).
4709 * init/tests/test_process.c (test_spawn): Make sure we get the
4710 environment in the job.
4711
Scott James Remnantafce5282007-02-06 01:22:54 +00004712 * init/job.h: Add attributes to job_new and job_read_state.
4713 * init/tests/test_job.c: Use CHECK_ALLOC_FAIL on the functions we
4714 didn't get around to touching while we were in here.
4715
Scott James Remnant1b9914d2007-02-06 01:01:11 +00004716 * init/job.c (job_start_event, job_stop_event): Set the goal_event
4717 member to a copy of the event we found.
4718 (job_read_state): Use event_new instead of trying to do it by hand.
4719 * init/tests/test_job.c (test_start_event, test_stop_event): Use
4720 CHECK_ALLOC_FAIL; and make sure the goal_event is set properly.
4721 (test_start, test_stop, test_write_new): Use event_new here too
4722
Scott James Remnant9e7d25c2007-02-06 00:42:41 +00004723 * init/job.c (job_write_state): Output a goal_event field containing
4724 the event name or nothing for NULL.
4725 (job_read_state): Parse the goal_event field
4726 * init/tests/test_job.c (test_write_state): Make sure the state is
4727 written out properly.
4728 (test_read_state): Make sure that the state is parsed correctly too.
4729
Scott James Remnant7aa22b62007-02-06 00:32:30 +00004730 * init/job.c (job_start, job_stop): Split all of the code except
4731 the goal_event setting into two new static functions that this calls
4732 (_job_start, _job_stop): New static functions
4733 (job_start_event, job_stop_event): Call _job_start and _job_stop
4734 instead of job_start and job_stop
4735
Scott James Remnante4111be2007-02-06 00:17:27 +00004736 * init/job.c (job_catch_runaway): Move this function up a bit.
4737
Scott James Remnant5761ef02007-02-06 00:15:51 +00004738 * init/job.c (job_start, job_stop): Clear the goal_event member,
4739 these functions are called for a manual start.
4740 * init/tests/test_job.c (test_start, test_stop): Make sure the
4741 goal_event member is freed and set to NULL.
4742
Scott James Remnant2b2b7d12007-02-06 00:07:28 +00004743 * init/job.h (Job): Add a new goal_event member
4744 * init/job.c (job_new): Initialise the goal_event member to NULL.
4745 * init/tests/test_job.c (test_new): Check with TEST_ALLOC_FAIL;
4746 also make sure goal_event is initialised to NULL.
4747
Scott James Remnant506ad092007-02-05 21:09:30 +000047482007-02-05 Scott James Remnant <scott@netsplit.com>
4749
Scott James Remnantee7e5552007-02-05 23:14:10 +00004750 * configure.ac: Bump version to 0.3.3
4751
Scott James Remnantcf64c482007-02-05 23:14:00 +00004752 * NEWS: Update.
4753
Scott James Remnant506ad092007-02-05 21:09:30 +00004754 * init/process.c (process_spawn): Exit with 255 so we don't clash
4755 with anything that uses 1 as a normal exit code. Note why we only
4756 close 0..2 (everything else is FD_CLOEXEC).
4757 * init/cfgfile.c (cfg_watch_dir): Mark the inotify watch descriptor
4758 as FD_CLOEXEC.
4759 * init/control.c (control_open): nih_io_set_cloexec can only ever
4760 return EINVAL, so no point checking it.
4761
Scott James Remnant0b74ff62007-02-04 00:43:20 +000047622007-02-04 Scott James Remnant <scott@netsplit.com>
4763
4764 * init/tests/test_control.c: Remove strange old code.
4765
Scott James Remnant9c44a422007-02-03 12:17:14 +000047662007-02-03 Scott James Remnant <scott@netsplit.com>
4767
Scott James Remnant7b618862007-02-03 23:41:33 +00004768 * init/control.c (control_open_sock, control_reopen)
4769 (control_close_handler): Drop these functions; unconnected datagram
4770 sockets don't close -- so why try dealing with it?
4771 (control_error_handler): Don't reopen the socket on error, just log
4772 it -- the socket should be fine, there's no remote end to be lost,
4773 after all.
4774 * init/tests/test_control.c (test_close_handler): Drop.
4775 (test_error_handler): Drop the reopen tests.
4776
Scott James Remnant88c1aac2007-02-03 23:26:36 +00004777 * init/tests/test_job.c (test_run_script): Control socket doesn't
4778 get unexpectedly opened anymore; so no need to close it.
4779
4780 * init/control.c (control_open): Remove the strange behaviour that
4781 this can be called to get the socket. Instead make control_io
4782 global; we're all adults after all.
4783 * init/tests/test_control.c (test_open): Remove the test for the
4784 silly behaviour.
4785 * init/notify.c (notify_job, notify_event): Use the control_io
4786 pointer directly, and just do nothing if we lost it somehow.
4787
Scott James Remnant2e204b72007-02-03 23:15:28 +00004788 * init/main.c (main): Being unable tp open the control socket, or
4789 parse the configuration, should be a fatal error; stop being so
4790 damned liberal! <g> Don't reset the signal state if we're
4791 being restarted, as this loses any pending signals -- be happy
4792 that our parent left them in a good state. Set SIGCHLD to the
4793 standard handler, otherwise we might lose this before we start
4794 the main loop (which does the same anyway).
4795 (term_handler): Rework so we don't need to close and open the
4796 control socket; instead we just close it in the child that's
4797 going to send the state, and notify the parent that it's safe to
4798 exec (which will cause it to be closed so the new init can open it).
4799
Scott James Remnant3af85462007-02-03 18:31:54 +00004800 * init/tests/test_control.c (test_open): Fix valgrind error
4801 * init/tests/test_notify.c (test_subscribe): Fix valgrind error
4802
Scott James Remnante443b9c2007-02-03 18:24:18 +00004803 * init/notify.c (notify_subscribe): Make safe against ENOMEM.
4804 * init/tests/test_notify.c (test_subscribe): Use TEST_ALLOC_FAIL
4805
Scott James Remnant4b601d12007-02-03 18:20:00 +00004806 * init/control.c: Add needed attributes; tidy up formatting.
4807 (control_open): Don't let ENOMEM fail opening the control socket.
4808 * init/control.h: Add needed attributes.
4809 * init/tests/test_control.c (test_open): Test for failed allocation.
4810 * init/main.c (term_handler): Make sure we catch failure to open
4811 the control socket again.
4812
Scott James Remnantd308b432007-02-03 17:36:41 +00004813 * TODO: Update
4814
Scott James Remnant272938f2007-02-03 17:35:11 +00004815 * init/cfgfile.c (cfg_watch_dir): Clean this up a bit; now we only
4816 output a warning if inotify failed for any reason other than not
4817 being supported AND walking worked.
4818
Scott James Remnantd78d00e2007-02-03 17:27:32 +00004819 * init/cfgfile.c (cfg_watch_dir): Update to even newer watch API;
4820 our create_handler is now always called if inotify is successful,
4821 so we just need to fall back to walking the directory when it
4822 isn't -- if inotify isn't supported, don't even bother complaining.
4823 (cfg_create_modify_handler): Check the stat of the file visited to
4824 make sure it's a regular file.
4825 (cfg_visitor): Check the stat of the file visited to make sure it's
4826 a regular file.
4827
Scott James Remnantbcbb1122007-02-03 17:11:21 +00004828 * init/cfgfile.c: Update include to upstart/enum.h
4829 * init/job.c: Update include to upstart/enum.h
4830 * init/job.h: Update include to upstart/enum.h
4831
Scott James Remnant801f9e12007-02-03 17:10:06 +00004832 * logd/main.c: Add attribute to open_logging
4833
Scott James Remnantcbd0cf82007-02-03 17:05:39 +00004834 * util/initctl.c: Split out the command functions into new files;
4835 * util/jobs.c: This gets the job-related commands
4836 * util/events.h: This gets the event-related commands
4837 * util/initctl.h, util/jobs.h, util/events.h: Headers
4838 * util/tests/test_jobs.c: Test suite for job-related commands.
4839 * util/tests/test_events.c: Test suite for event-related commands.
4840 * util/Makefile.am (initctl_SOURCES): Add new files.
4841 (TESTS): Build new test suites.
4842 (test_jobs_SOURCES, test_jobs_LDFLAGS, test_jobs_LDADD):
4843 Details for job-related commands test suite binary.
4844 (test_events_SOURCES, test_events_LDFLAGS, test_events_LDADD):
4845 Details for event-related commands test suite binary.
4846 * TODO: Remove item about splitting initctl now we've done it.
4847
Scott James Remnantadfcc3f2007-02-03 12:24:07 +00004848 * TODO: Big update; strip anything we have a spec for.
4849
Scott James Remnant1157bbf2007-02-03 12:17:55 +00004850 * upstart/message.c (upstart_message_handle): Make sure that if we
4851 fail to parse a message, we don't leave strings around in memory.
4852 * upstart/tests/test_message.c (test_open): Check that we get a
4853 raised EADDRINUSE if we try an open a socket twice.
4854 (test_handle): Add lots of checks for things like NULL names and
4855 incomplete messages; as well as the obvious unknown message.
4856 (test_reader): Make sure that errors while handling messages are
4857 dealt with by logging it.
4858
Scott James Remnant9c44a422007-02-03 12:17:14 +00004859 * upstart/job.c, upstart/job.h, upstart/tests/test_job.c: Rename to
4860 enum.c, enum.h and tests/test_enum.c; since this just includes enums
4861 and convert functions really.
4862 * upstart/Makefile.am: Update.
4863 * upstart/libupstart.h: Update include.
4864 * upstart/tests/test_message.c: Update include.
4865
Scott James Remnant1e57ab22007-02-01 16:51:28 +000048662007-02-01 Scott James Remnant <scott@netsplit.com>
4867
Scott James Remnant0f1d9b62007-02-01 18:20:00 +00004868 * logd/main.c (main): Ensure we error if daemonise fails.
4869
Scott James Remnant36911572007-02-01 18:18:27 +00004870 * compat/sysv/shutdown.c (main): Ensure that signals and timers
4871 are added, even if we run out of memory.
4872
Scott James Remnant9b705ee2007-02-01 17:34:39 +00004873 * upstart/tests/test_message.c: Change from assert to assert0
4874 * upstart/tests/test_wire.c: Change from assert to assert0
4875 * init/tests/test_notify.c: Change from assert to assert0
4876 * init/tests/test_control.c: nih_io_message_send should always return
4877 a value greater than zero.
4878
Scott James Remnant91c6eb72007-02-01 17:19:32 +00004879 * upstart/tests/test_wire.c: Change to use assert instead of NIH_ZERO;
4880 the rationale here is that in test cases we just want to fail, not
4881 try again repeatedly.
4882 * upstart/tests/test_message.c: Likewise.
4883
Scott James Remnant9caf2822007-02-01 17:04:34 +00004884 * init/tests/test_control.c: Use assert to ensure we get the expected
4885 return values of functions that raise errors.
4886 * init/tests/test_notify.c: Use assert to ensure we get the expected
4887 return values of functions that raise errors.
4888
Scott James Remnant1e57ab22007-02-01 16:51:28 +00004889 * init/cfgfile.c (cfg_watch_dir): Port to the new NihWatch API and
4890 use nih_dir_walk(). This also fixes the long-standing bug where we
4891 wouldn't watch the configuration directory if inotify was disabled.
4892 Drop both the parent and prefix members for now, until we clean this
4893 up later.
4894 (cfg_create_modify_handler): Wrap cfg_read_job after figuring out
4895 the job name.
4896 (cfg_job_name): Function to figure out the job name from a path.
4897 (cfg_visitor): Visitor function to handle initial parsing, figuring
4898 out the job name; otherwise identical to the standard handler.
4899 * init/cfgfile.h: Update prototype for cfg_watch_dir.
4900 * init/main.c (main): Update call to cfg_watch_dir.
4901
Scott James Remnantbfd712d2007-01-31 12:13:25 +000049022007-01-31 Scott James Remnant <scott@netsplit.com>
4903
4904 * upstart/tests/test_message.c: Use TEST_ALLOC_FAIL to make sure
4905 allocations are handled properly.
4906
Scott James Remnant44828472007-01-30 11:53:33 +000049072007-01-30 Scott James Remnant <scott@netsplit.com>
4908
Scott James Remnant2cc36542007-01-30 17:12:34 +00004909 * upstart/wire.c: Note that if any of the push functions fail, the
4910 entire buffer should be discarded.
4911 * upstart/tests/test_wire.c (test_push_int, test_push_unsigned)
4912 (test_push_string, test_push_header, test_push_pack): Us
4913 TEST_ALLOC_FAIL to ensure that failing to allocate memory is caught.
4914
Scott James Remnant1084c682007-01-30 15:17:41 +00004915 * upstart/tests/test_message.c (my_handler): Free the name and
4916 description after checking; they aren't otherwise.
4917
Scott James Remnantdc8b3292007-01-30 15:01:30 +00004918 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Consume
4919 a copy of the va_list, so these can be called multiple times on the
4920 same list without ill effect.
4921
Scott James Remnant92d87442007-01-30 15:01:21 +00004922 * upstart/message.h: Add warn_unused_result attributes to
4923 upstart_message_handle and upstart_message_handle_using as they raise
4924 errors.
4925
Scott James Remnant2de25012007-01-30 14:57:27 +00004926 * upstart/wire.c: push functions return negative values to indicate
4927 insufficient memory.
4928 * upstart/wire.h: Add warn_unused_result attributes to push functions
4929
Scott James Remnant4ccebcf2007-01-30 14:51:17 +00004930 * upstart/tests/test_message.c: Guard calls to nih_io_buffer_push and
4931 nih_io_message_add_control with NIH_ZERO to ensure they succeed.
4932 * upstart/tests/test_wire.c: Guard calls to nih_io_buffer_push
4933
Scott James Remnant44828472007-01-30 11:53:33 +00004934 * HACKING: Update from libnih with new Documentation,
4935 Function Attributes and Test Cases sections.
4936
Scott James Remnant16a286f2007-01-10 15:38:33 +000049372007-01-10 Scott James Remnant <scott@netsplit.com>
4938
Scott James Remnantde443012007-01-10 18:45:40 +00004939 * init/main.c (crash_handler): s/SEGV/SIGSEGV/
4940
Scott James Remnant505f9282007-01-10 18:44:38 +00004941 * init/main.c (main): Rename variable
4942
Scott James Remnant56a4d062007-01-10 17:33:39 +00004943 * TODO: Update.
4944
Scott James Remnant78626fb2007-01-10 16:48:10 +00004945 * init/main.c (main): Change the way we clear the arguments; by
4946 deleting just the final NULL terminator, we fool the kernel into
4947 only returning one argument in cmdline.
4948
Scott James Remnant16a286f2007-01-10 15:38:33 +00004949 * init/main.c (segv_handler): Rename to crash_handler and handle
4950 SIGABRT as well, so we can catch assertion errors. Of course, in
4951 theory, with our high test converage this should never happen in
4952 practice <chortle>
4953
Scott James Remnant39ec35b2007-01-09 08:16:01 +000049542007-01-09 Scott James Remnant <scott@netsplit.com>
4955
Scott James Remnant7f4db422007-01-09 20:51:08 +00004956 * init/main.c (main): Clear arguments so that upstart only ever
4957 appears as /sbin/init in ps, top, etc.
4958
Scott James Remnant8fd06de2007-01-09 20:38:27 +00004959 * TODO: Update.
4960
Scott James Remnant4d0481d2007-01-09 20:38:07 +00004961 * util/initctl.c: Add data pointer to functions and handle calls.
4962
Scott James Remnantbcf9e972007-01-09 20:34:47 +00004963 * init/control.c: Add data pointer to all functions.
4964 * init/tests/test_control.c: Pass data pointer to
4965 upstart_message_handle_using()
4966 * init/tests/test_notify.c: Pass data pointer to
4967 upstart_message_handle_using()
4968
Scott James Remnant6aa008c2007-01-09 20:26:44 +00004969 * upstart/message.c (upstart_message_handle)
4970 (upstart_message_handle_using): Add a data pointer argument to these
4971 functions and pass it to the handler.
4972 (upstart_message_reader): Pass the io structure's data pointer.
4973 * upstart/message.h (UpstartMessageHandler): Add a data pointer to
4974 the message handler.
4975 * upstart/tests/test_message.c (test_handle, test_handle_using):
4976 Pass a data pointer to the function call and check it's passed
4977 to the handler correctly.
4978 (test_reader): Check that the io data pointer gets passed.
4979
Scott James Remnantc7017d32007-01-09 18:44:58 +00004980 * init/tests/test_cfgfile.c (test_stanza_console, test_stanza_env)
4981 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Finish off
4982 the newer style test cases.
4983
Scott James Remnante63ef802007-01-09 17:54:56 +00004984 * init/cfgfile.c (cfg_stanza_console, cfg_stanza_umask)
4985 (cfg_stanza_nice, cfg_stanza_limit, cfg_stanza_chroot)
4986 (cfg_stanza_chdir): Guard against duplicate uses of the stanzas.
4987 * init/tests/test_cfgfile.c (test_stanza_daemon)
4988 (test_stanza_respawn): Check that neither daemon or respawn override
4989 exec if they have no arguments.
4990 (test_stanza_script): Add missing function
4991 (test_stanza_chroot, test_stanza_chdir): Add tests for these simple
4992 stanzas.
4993
Scott James Remnant0cd393d2007-01-09 17:36:34 +00004994 * init/cfgfile.c: Change remaining uses of nih_error_raise and
4995 return to just nih_return_error.
4996
Scott James Remnantc352b632007-01-09 17:31:41 +00004997 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_daemon)
4998 (cfg_stanza_respawn, cfg_stanza_script): Disallow duplicates,
4999 both of command strings, scripts, limits and of just the flags.
5000 * init/tests/test_cfgfile.c (test_stanza_exec)
5001 (test_stanza_daemon, test_stanza_respawn, test_stanza_instance):
5002 Check the behaviour of these stanzas.
5003
Scott James Remnant94188d42007-01-09 16:43:58 +00005004 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop): Disallow
5005 duplicate values for the script.
5006 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop):
5007 Test cases for those two functions.
5008
Scott James Remnant474a6ff2007-01-09 16:17:49 +00005009 * init/cfgfile.c (cfg_stanza_description, cfg_stanza_author)
5010 (cfg_stanza_version): Don't allow stanza to be duplicated anymore.
5011 * init/tests/test_cfgfile.c (test_stanza_description)
5012 (test_stanza_author, test_stanza_version): Test cases for these
5013 simple stanza; making sure duplication is not permitted.
5014 (test_stanza_on): Add a test case for this stanza too.
5015
Scott James Remnant49e8bb82007-01-09 15:57:59 +00005016 * init/cfgfile.c (cfg_stanza_kill): Guard against duplicate uses
5017 of the kill timeout stanza.
5018 * init/tests/test_cfgfile.c (test_stanza_kill): Test the complex
5019 kill stanza.
5020 (test_stanza_pid): Check duplicate usage results in an error.
5021
Scott James Remnant443ef2e2007-01-09 15:47:24 +00005022 * init/job.h (Job): Rename pidfile to pid_file and binary to pid_binary
5023 * init/job.c (job_new): Update names here too.
5024 * init/errors.h: Add a new "duplicate value" error.
5025 * init/cfgfile.c (cfg_read_job): Change name of variables, and catch
5026 the duplicate value error to add the line number.
5027 (cfg_stanza_pid): Change variable names, and clean this function up
5028 a little. Make it an error to use a stanza more than once.
5029 * init/tests/test_cfgfile.c (test_stanza_pid): Write a newer test
5030 case function for the pid stanza.
5031
Scott James Remnant34ff87d2007-01-09 09:00:30 +00005032 * init/cfgfile.c (cfg_stanza_normalexit): Use do/while instead of
5033 while, that we don't have to test has_token first as next_arg does
5034 that for us.
5035
Scott James Remnanta7354692007-01-09 08:56:02 +00005036 * init/cfgfile.c (cfg_stanza_normalexit): Change to peek at the next
5037 token to see whether it's missing or not, and then just fetch each
5038 next argument at a time. This is more efficient than parsing them
5039 all in one go, and also means we can report the error in the right
5040 place!
5041 * init/tests/test_cfgfile.c (test_stanza_normalexit): Since we've
5042 changed the function that parses the stanza, add a proper test case
5043 function for it, covering all the behaviours.
5044
Scott James Remnant92e7fda2007-01-09 08:40:13 +00005045 * init/job.c (job_new): Initialise the emits member to an empty list.
5046 * init/job.h (Job): Add the emits member as a list.
5047 * init/tests/test_job.c (test_new): Check the emits list starts off
5048 empty.
5049 * init/tests/test_cfgfile.c (test_stanza_emits): Test the new emits
5050 stanza; this function will also serve as a prototype for cleaning up
5051 the config tests.
5052
5053 * init/cfgfile.c (cfg_stanza_emits): Add function to parse the new
5054 emits stanza.
5055
Scott James Remnant39ec35b2007-01-09 08:16:01 +00005056 * init/cfgfile.c (cfg_stanza_depends): Remove the depends stanza
5057 from the configuration file. Dependency support has never been used,
5058 and is to be replaced by a more flexible event/state configuration
5059 and blocking on the starting/stopping events.
5060 * init/tests/test_cfgfile.c: Remove references and tests for the
5061 depends stanza.
5062 * init/job.h: Remove the depends list from the job structure.
5063 * init/job.c (job_new): No depends list to initialise.
5064 (job_change_state): No dependencies to release
5065 (job_start): No dependencies to iterate; this removes a particularly
5066 hairy and complex interaction between state changes. Remove the
5067 dependency event.
5068 (job_release_depends): Drop this function.
5069 * init/tests/test_job.c (test_start, test_stop): Massively simplify
5070 these tests cases now we don't have dependencies to worry about.
5071 (test_release_depends): Drop tests
5072
Scott James Remnantd4f5fb82007-01-08 23:25:23 +000050732007-01-08 Scott James Remnant <scott@netsplit.com>
5074
5075 * init/cfgfile.c: Rewrite using the nih_config API, rather than one
5076 huge function we now just have seperate handler functions for each
5077 stanza. We can also use more fine-grained parsing than slurping
5078 all args in and counting them.
5079 (cfg_read_job): Catch exceptions from the configuration parser and
5080 add the line number where the problem occurred to an output message.
5081 Parser errors are now fatal, and not ignored.
5082 * init/errors.h: Add a file containing errors raised within the init
5083 daemon codebase.
5084 * init/Makefile.am (init_SOURCES): Build with errors.h
5085 * init/tests/test_cfgfile.c: Update test cases now we don't expect
5086 a job to be returned if there's a parser error.
5087
5088 * TODO: Update
5089
Scott James Remnant66384202007-01-06 14:23:18 +000050902007-01-06 Scott James Remnant <scott@netsplit.com>
5091
Scott James Remnant4f968192007-01-06 20:31:13 +00005092 * logd/main.c (logging_reader): Fix inadvertent shadowing of the
5093 len parameter.
5094
Scott James Remnantda100272007-01-06 20:24:18 +00005095 * compat/sysv/telinit.c: Oops, nearly forgot to port this to send
5096 the messages in the new way.
5097 * compat/sysv/shutdown.c (shutdown_now): Likewise, port this too.
5098
Scott James Remnant83a86522007-01-06 19:55:38 +00005099 * TODO: Update.
5100
Scott James Remnant6e941882007-01-06 14:38:57 +00005101 * util/initctl.c (handle_job_status): Output the process argument,
5102 not the pid argument which contains the origin of the message.
5103
Scott James Remnant17d6dca2007-01-06 14:33:30 +00005104 * upstart/message.c (upstart_message_handle): Raise a new unknown
5105 message error if we don't have a handler and a new illegal message
5106 error if the source is illegal.
5107 * upstart/tests/test_message.c (test_handle): Adjust tests to check
5108 for the new errors that we raise.
5109 * upstart/errors.h: Define strings for new errors.
5110
Scott James Remnant66384202007-01-06 14:23:18 +00005111 * util/initctl.c: Yet another makeover for this little program,
5112 port it to the new message/control framework using handler functions
5113 and NihIoMessage. This starts to make each action function look
5114 very similar, so there's method to this madness.
5115
Scott James Remnantb4725d92007-01-05 13:10:21 +000051162007-01-05 Scott James Remnant <scott@netsplit.com>
5117
Scott James Remnant3d6bb792007-01-05 22:33:43 +00005118 * logd/main.c (main): Make sure that we add the SIGTERM handler.
5119
Scott James Remnantefbaafb2007-01-05 18:12:15 +00005120 * init/tests/test_job.c (test_run_script): This test case relies
5121 on there only being one file descriptor watch, which won't be true
5122 if the control socket has been opened because there's a message to
5123 go out. Make sure it's closed first.
5124
Scott James Remnantbe1941f2007-01-05 17:57:59 +00005125 * init/init.supp: Update supressions file now that control_init
5126 has been renamed to notify_init
5127
Scott James Remnant71cc4d82007-01-05 17:53:32 +00005128 * init/Makefile.am: Include notify.o from all tests.
5129 * init/job.c (job_change_state, job_kill_process, job_start)
5130 (job_stop): Use the new notify_job function name.
5131 * init/event.c (event_queue_run): Use the new notify_event function
5132 name.
5133
Scott James Remnantfea6cb62007-01-05 17:49:13 +00005134 * init/control.c (control_error_handler): Handle ECONNREFUSED now
5135 that the process id is available to us.
5136 * init/tests/test_control.c (test_error_handler): Make sure children
5137 going away is handled properly.
5138
Scott James Remnant3dfb2132007-01-05 17:44:48 +00005139 * upstart/message.c (upstart_message_new): Store the process id in
5140 the int_data message field.
5141 * upstart/tests/test_message.c (test_new): Check the int_data field
5142 is filled in.
5143
Scott James Remnant5d702952007-01-05 17:21:34 +00005144 * init/main.c (main): Guard against various things returning an error
5145 that we weren't catching.
5146
Scott James Remnant601a0e32007-01-05 17:06:31 +00005147 * init/tests/test_notify.c: Whitespace fix.
5148
Scott James Remnant15cd0862007-01-05 17:06:20 +00005149 * init/control.c (control_watch_jobs, control_unwatch_jobs)
5150 (control_watch_events, control_unwatch_events): Restore functionality
5151 to subscribe and unsubscribe from job and event notifications.
5152 * init/tests/test_control.c (test_watch_jobs, test_unwatch_jobs)
5153 (test_watch_events, test_unwatch_events): Check that the subscription
5154 and unsubscription messages work.
5155 * init/Makefile.am (test_control_LDADD): Link to notify.o
5156
5157 * init/control.c: Drop unused include of upstart/errors.h
5158
Scott James Remnant58cef572007-01-05 16:18:42 +00005159 * init/notify.c: Move functions that handle subscription and
5160 notification from control.c. Other than changing the names, we're
5161 keeping the API the same for now; expect it to change later when we
5162 add the ability to subscribe to individual jobs or events.
5163 (notify_init): initialise the subscriptions list; we don't have a
5164 separate send queue now that the control I/O is always asynchronous.
5165 * init/notify.h: Moved notification enum, structure and prototypes
5166 from control.h, changing the names so they match notify_* in the
5167 process.
5168 * init/Makefile.am (init_SOURCES): Build and link notify.c using
5169 notify.h
5170 (TESTS): Build the notify test suite binary.
5171 (test_notify_SOURCES, test_notify_LDFLAGS, test_notify_LDADD): Details
5172 for notify test suite binary.
5173 * init/tests/test_notify.c: Rewrite test cases in the manner of
5174 test_control.c so that we have one function for notify_job and
5175 one for notify_event, each of which contains the child process that
5176 receives the notification,
5177
Scott James Remnantb1679c62007-01-05 15:49:54 +00005178 * init/control.c (control_open): Allow this to be called to obtain
5179 the control socket, which means we can make it static.
5180 * init/tests/test_control.c (test_open): Check that it works.
5181
Scott James Remnantf7c6b062007-01-05 15:33:33 +00005182 * init/control.c, init/control.h, init/tests/test_control.c: Move
5183 functions that handle subscription and notification to new notify.c
5184 (control_init): Drop completely, no need to maintain a send queue now
5185 (control_open): Change to return an NihIo that uses the default
5186 control watcher, and our error handler. Split socket opening into
5187 (control_open_sock): which can be called from other functions.
5188 (control_close): Use nih_io_close() to close the socket and free the
5189 structure in one go.
5190 (control_reopen): Close the open control socket and open it again
5191 without destroying the NihIo structure, its queues or state.
5192 (control_close_handler): Handle the control socket going away
5193 (control_error_handler): Handle errors on the control socket,
5194 including the connection refused error that indicates a client went
5195 away.
5196 (control_handle): Split this into a miriad of small functions with
5197 a table to link them to the message type; this will make expanding
5198 each message handler much easier in future.
5199 * init/control.h: Update.
5200 * init/tests/test_control.c: Rewrite test cases to check the new
5201 handler functions; as a side-effect, this gets rid of the evil giant
5202 child/parent functions in favour of one test function per handler
5203 function.
5204
Scott James Remnantb4725d92007-01-05 13:10:21 +00005205 * upstart/message.c (upstart_message_handle_using): Wrapper function
5206 around upstart_message_handle that ensures all messages as passed to
5207 a single function.
5208 * upstart/message.h: Update.
5209 * upstart/tests/test_message.c (test_handle_using): Make sure it
5210 calls the single function.
5211
Scott James Remnantde3666f2007-01-04 23:00:07 +000052122007-01-04 Scott James Remnant <scott@netsplit.com>
5213
5214 * upstart/message.c (upstart_message_reader): Handle any errors
5215 that occurred while handling the message.
5216
Scott James Remnant92feed92007-01-02 15:27:47 +000052172007-01-02 Scott James Remnant <scott@netsplit.com>
5218
Scott James Remnant7833bbf2007-01-02 20:57:23 +00005219 * upstart/message.c (upstart_message_handle): Check that the name
5220 argument is never NULL.
5221 (upstart_message_reader): Simple message reader function that can
5222 be associated with an I/O watch and handles each message received.
5223 * upstart/message.h: Add prototype.
5224 * upstart/tests/test_message.c (test_reader): Test the reader function.
5225
Scott James Remnant0e3b5fe2007-01-02 18:39:03 +00005226 * upstart/control.c: Rename to upstart/message.c
5227 * upstart/control.h: Rename to upstart/message.h
5228 * upstart/tests/test_control.c: Rename to upstart/tests/test_message.c
5229 * upstart/libupstart.h: Update includes.
5230 * upstart/wire.c: Include message.h
5231 * upstart/wire.h: Update includes.
5232 * upstart/tests/test_wire.c: Update includes.
5233 * upstart/errors.h: Rename UPSTART_INVALID_MESSAGE to
5234 UPSTART_MESSAGE_INVALID so that it's prefixed.
5235 * upstart/Makefile.am (libupstart_la_SOURCES)
5236 (upstartinclude_HEADERS, TESTS): Update filenames.
5237
Scott James Remnant2ad9a042007-01-02 18:29:49 +00005238 * upstart/control.c (upstart_message_new): New function that
5239 creates an NihIoMessage directly from its arguments, which are a type
5240 followed by a variable number of args depending on that type.
5241 (upstart_message_handler): Function to find a handler function for
5242 a particular message type and origin process.
5243 (upstart_message_handle): New function that takes an NihIoMessage
5244 and invokes a handler function with a variable number of args
5245 depending on the message type.
5246 (upstart_send_msg, upstart_send_msg_to, upstart_recv_msg): Drop these
5247 functions, leave it up to the caller to decide whether to send and
5248 receive the messages synchronously or asynchronously; now that the
5249 capability is in nih_io_*.
5250 * upstart/control.h (UpstartMsgType): Rename to UpstartMessageType.
5251 (UpstartMessageHandler): Function with variable number of arguments
5252 that handles a message received.
5253 (UpstartMsg): Drop this structure entirely, we'll encode or decode
5254 the wire format directly from or into a function call, rather than
5255 use an intermediate structure to marshal it.
5256 (UpstartMessage): New structure to make a table that can be passed
5257 to upstart_message_handle to determine which handler should be called.
5258 * upstart/tests/test_control.c: Test new behaviour.
5259 * upstart/wire.c (upstart_push_header, upstart_pop_header): Change
5260 structure name for type parameter.
5261 * upstart/wire.h: Update.
5262 * upstart/tests/test_wire.c: Update.
5263
Scott James Remnant92feed92007-01-02 15:27:47 +00005264 * configure.ac (AC_COPYRIGHT): Update copyright to 2007.
5265
Scott James Remnant67546d12006-12-29 13:08:32 +000052662006-12-29 Scott James Remnant <scott@netsplit.com>
5267
5268 * upstart/wire.c (upstart_write_int, upstart_write_unsigned)
5269 (upstart_write_string, upstart_write_header, upstart_write_packv)
5270 (upstart_write_pack): Rename to *_push_*
5271 (upstart_read_int, upstart_read_unsigned, upstart_read_string)
5272 (upstart_read_header, upstart_read_packv, upstart_read_pack): Rename
5273 to *_pop_*.
5274 All of the above modified to modify an NihIoMessage structure,
5275 instead of trying to carry around buffers ourself.
5276 * upstart/wire.h: Update to match above.
5277 * upstart/tests/test_wire.c: Update all tests to match the above
5278 changes.
5279
Scott James Remnantd76e8e32006-12-21 18:34:31 +000052802006-12-21 Scott James Remnant <scott@netsplit.com>
5281
Scott James Remnantf922a982006-12-21 18:45:30 +00005282 * upstart/wire.c (upstart_read_packv, upstart_write_packv): Change
5283 nih_assert_notreached to nih_assert_not_reached.
5284
Scott James Remnantd76e8e32006-12-21 18:34:31 +00005285 * init/job.c (job_run_script): Open the NihIo structure in stream mode.
5286 * logd/main.c (logging_watcher): Open the NihIo structure in
5287 stream mode.
5288 (logging_reader): Need to pass the length of the size_t as a pointer
5289 so that it can be modified if less is read.
5290
Scott James Remnanta0385232006-12-17 15:21:39 +000052912006-12-17 Scott James Remnant <scott@netsplit.com>
5292
Scott James Remnant00cc6882006-12-17 19:54:36 +00005293 * upstart/wire.c (upstart_write_packv, upstart_write_pack)
5294 (upstart_read_packv, upstart_read_pack): Functions to write a pack
5295 of different variables to the stream, or read them from it
5296 * upstart/wire.h: Add prototypes.
5297 * upstart/tests/test_wire.c (test_write_pack, test_read_pack):
5298 Check we can read and write a pack of variables at once.
5299
Scott James Remnant518e1c12006-12-17 18:12:14 +00005300 * upstart/wire.c (upstart_write_header, upstart_read_header): Drop
5301 the version from the header, we'll just keep the protocol always
5302 backwards compatible.
5303 * upstart/wire.h: Update.
5304 * upstart/tests/test_wire.c (test_write_header, test_read_header):
5305 Check that everything works.
5306
Scott James Remnant64e378f2006-12-17 17:24:44 +00005307 * upstart/wire.c (upstart_write_string, upstart_read_string):
5308 Transmit the length as an unsigned, and use 0xffffffff to mean NULL
5309 instead of zero so we can still transmit the empty string.
5310 * upstart/wire.h: Update.
5311 * upstart/tests/test_wire.c (test_write_string, test_read_string):
5312 Tests for the functions to make sure the wire is at it should be.
5313
Scott James Remnantd6dde952006-12-17 17:00:56 +00005314 * upstart/wire.c (upstart_read_str, upstart_write_str): Rename to
5315 upstart_read_string and upstart_write_string.
5316 * upstart/wire.h: Update.
5317
Scott James Remnantc71ab3b2006-12-17 16:58:28 +00005318 * upstart/wire.c (upstart_write_unsigned, upstart_read_unsigned):
5319 Functions to send unsigned values over the wire, which we'll use
5320 to get a bit extra for the string lengths.
5321 * upstart/wire.h: Update.
5322 * upstart/tests/test_wire.c (test_write_unsigned)
5323 (test_read_unsigned): Test the new functions.
5324
Scott James Remnant0218e3a2006-12-17 16:39:33 +00005325 * upstart/wire.c (upstart_write_ints, upstart_read_ints): Drop
5326 these functions, we'll go with something far more generic and
5327 useful.
5328 * upstart/wire.h: Remove prototypes.
5329
Scott James Remnant9ee44302006-12-17 16:37:59 +00005330 * upstart/wire.c (upstart_write_int, upstart_read_int): Transmit
5331 integers as signed 32-bit values in network byte order.
5332 * upstart/tests/test_wire.c (test_write_int, test_read_int): Test
5333 the functions to make sure the wire is at it should be,
5334
Scott James Remnant5cef53e2006-12-17 15:41:13 +00005335 * upstart/control.c (upstart_read_int, upstart_write_int)
5336 (upstart_read_ints, upstart_write_ints, upstart_read_str)
5337 (upstart_write_str, upstart_read_header, upstart_write_header): Move
5338 functions to new wire.c file.
5339 * upstart/wire.c: Source file to hold wire protocol functions.
5340 * upstart/wire.h: Prototypes.
5341 * upstart/tests/test_wire.c: (empty) test suite.
5342 * upstart/libupstart.h: Include wire.h
5343 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link wire.c
5344 (upstartinclude_HEADERS): Install wire.h
5345 (TESTS): Build and run wire test suite.
5346 (test_wire_SOURCES, test_wire_LDFLAGS, test_wire_LDADD): Details for
5347 wire test suite binary.
5348
Scott James Remnanta0385232006-12-17 15:21:39 +00005349 * upstart/control.c (MAGIC): Change to "upstart\n", the final
5350 character was originally \0 and then was a " " for the 0.2 series.
5351 * upstart/tests/test_control.c (test_recv_msg): Change to match.
5352
Scott James Remnantfb9412a2006-12-15 18:03:22 +000053532006-12-15 Scott James Remnant <scott@netsplit.com>
5354
Scott James Remnant2e5fe2b2006-12-15 18:27:58 +00005355 * util/initctl.c, compat/sysv/telinit.c, compat/sysv/shutdown.c:
5356 Update all uses of the UpstartMsg structure to avoid the
5357 intermediate union that no longer exists.
5358
Scott James Remnantfb521462006-12-15 18:24:57 +00005359 * init/control.c, init/tests/test_control.c: Update all uses of
5360 the UpstartMsg structure to avoid the intermediate union that no
5361 longer exists.
5362
Scott James Remnant99b97662006-12-15 18:15:22 +00005363 * upstart/control.h: Combine all the previous message structures
5364 into just one that has all of the fields anyway.
5365 * upstart/control.c, upstart/tests/test_control.c: Update all uses of
5366 the UpstartMsg structure to avoid the intermediate union that no
5367 longer exists.
5368
Scott James Remnantd452ab12006-12-15 18:05:23 +00005369 * upstart/control.h (UPSTART_API_VERSION): Define API version macro
5370 to be public.
5371 * upstart/control.c (MSG_VERSION, upstart_send_msg_to): Replacing the
5372 previous MSG_VERSION macro here.
5373
Scott James Remnantfb9412a2006-12-15 18:03:22 +00005374 * upstart/control.c (upstart_read_int, upstart_write_int)
5375 (upstart_read_ints, upstart_write_ints, upstart_read_str)
5376 (upstart_write_str, upstart_read_header, upstart_write_header):
5377 New functions to replace the old "write a struct" protocol with
5378 something a little more regimented and supportable.
5379 (IOVEC_ADD, IOVEC_READ, WireHdr, WireJobPayload, WireJobStatusPayload)
5380 (WireEventPayload): Remove these structures, use the functions
5381 instead.
5382 (upstart_send_msg_to): Call write functions intead of using macros,
5383 this makes the code somewhat neater.
5384 (upstart_recv_msg): Call read functions instead of using macros,
5385 again making the code somewhat neater.
5386 * upstart/tests/test_control.c (test_recv_msg): Change wire
5387 tests to match new protocol, and thus actually work properly,
5388 previously these were endian sensitive.
5389
Scott James Remnant27ebd792006-12-14 11:37:14 +000053902006-12-14 Scott James Remnant <scott@netsplit.com>
5391
Scott James Remnant136dc6f2006-12-14 12:36:43 +00005392 * compat/sysv/shutdown.c (wall): Construct the wall message so that
5393 we don't put \r into a po file; for some reason, gettext hates that
5394 and bitches about it. Someone's confusing internationalisation with
5395 operating system portability, I expect.
5396
Scott James Remnantf334f842006-12-14 11:46:14 +00005397 * util/man/initctl.8: Drop reference to start(8), as that's just
5398 a symlink to initctl now.
5399
Scott James Remnant88847432006-12-14 11:44:36 +00005400 * init/man/init.8: Link to initctl.
5401
Scott James Remnantf6b237a2006-12-14 11:40:49 +00005402 * compat/sysv/reboot.c (main): Clear up help text a little.
5403
Scott James Remnant3b4b2272006-12-14 11:39:05 +00005404 * HACKING: Correct some typos.
5405
Scott James Remnant27ebd792006-12-14 11:37:14 +00005406 * configure.ac (AC_INIT): Correct bug reporting address.
5407
Scott James Remnant1d8763a2006-12-13 17:49:38 +000054082006-12-13 Scott James Remnant <scott@netsplit.com>
5409
Scott James Remnantecec0fe2006-12-13 21:55:28 +00005410 * configure.ac: Bump version to 0.3.2
5411
Scott James Remnantf642ffa2006-12-13 18:24:22 +00005412 * NEWS: Update.
5413
Scott James Remnant1d8763a2006-12-13 17:49:38 +00005414 * util/initctl.c (print_job_status): Drop the newline from the
5415 output.
5416
Scott James Remnant567cbdc2006-12-13 17:07:58 +000054172006-12-13 Alex Smith <alex@alex-smith.me.uk>
5418
5419 * util/initctl.c (print_job_status): Clean up initctl job status
5420 output, which was badly converted from printf to nih_message.
5421
Scott James Remnante2cf6392006-12-13 17:02:20 +000054222006-12-13 Scott James Remnant <scott@netsplit.com>
5423
5424 * compat/sysv/man/shutdown.8: Add missing documentation on the
5425 format of TIME by copying it from --help output.
5426
Scott James Remnantfec90562006-12-13 17:00:40 +000054272006-12-13 Alex Smith <alex@alex-smith.me.uk>
5428
5429 * init/process.c (process_setup_console): Actually send output to
5430 /dev/null instead of /dev/console, when CONSOLE_NONE.
5431
Scott James Remnantf233c9d2006-12-13 16:45:35 +000054322006-12-13 Scott James Remnant <scott@netsplit.com>
5433
Scott James Remnantfbf7a5c2006-12-13 16:54:42 +00005434 * Makefile.am (EXTRA_DIST): Distribute the nih ChangeLog as well.
5435
Scott James Remnantf233c9d2006-12-13 16:45:35 +00005436 * init/tests/test_job.c: Port to the new test framework.
5437 * init/job.c (job_set_idle_event): Fix a slight memory leak,
5438 repeated setting of the idle event never freed the previous one set.
5439
Scott James Remnant1abced42006-12-12 11:28:49 +000054402006-12-12 Scott James Remnant <scott@netsplit.com>
5441
Scott James Remnantfbad50c2006-12-12 18:47:43 +00005442 * init/tests/test_cfgfile.c: Port to the new test framework.
5443
Scott James Remnantef372232006-12-12 17:23:05 +00005444 * init/tests/test_control.c: Port to the new test framework.
5445 * init/init.supp: Suppress the list head allocated within control_init.
5446
Scott James Remnant2c2e01a2006-12-12 17:22:40 +00005447 * init/control.c (control_watcher): Need to save the pid when we
5448 get ECONNREFUSED, otherwise we lose it when we free the message.
5449
Scott James Remnant40f7d912006-12-12 15:31:35 +00005450 * init/tests/test_process.c: Port to the new test framework.
5451 * init/init.supp: Suppress the list head allocated within job_init.
5452
Scott James Remnantfc456592006-12-12 14:09:45 +00005453 * init/init.supp: Include a valgrind suppressions file.
5454 * init/Makefile.am (EXTRA_DIST): Distribute the suppressions file.
5455
Scott James Remnant96c9b072006-12-12 14:07:30 +00005456 * init/tests/test_event.c: Port to the new test framework.
5457
Scott James Remnant237c7f62006-12-12 13:49:19 +00005458 * logd/Makefile.am, util/Makefile.am, compat/sys/Makefile.am
5459 (AM_CPPFLAGS): Add -I$(srcdir), necessary for testing "programs"
5460 that don't have usual library path semantics.
5461
Scott James Remnant2a35ab92006-12-12 13:23:10 +00005462 * upstart/tests/test_control.c: Port to the new test framework.
5463 * upstart/control.c (upstart_free): Drop this function, while not
5464 exposing libnih is a valiant effort, it already slips out because
5465 of the error handling.
5466
Scott James Remnant905dd272006-12-12 12:38:34 +00005467 * upstart/tests/test_job.c: Add missing include.
5468
Scott James Remnante77567f2006-12-12 12:25:46 +00005469 * upstart/tests/test_job.c: Port to the new test framework.
5470 (test_process_state_name): Check that this returns NULL.
5471
Scott James Remnantb7983062006-12-12 11:34:49 +00005472 * HACKING: Update location of download directory. Document
5473 requirement that all code have test cases.
5474
Scott James Remnant0c577ce2006-12-12 11:31:13 +00005475 * logd/main.c (open_logging): Likewise.
5476
Scott James Remnantc654baf2006-12-12 11:30:44 +00005477 * init/control.c (control_open): No need to set ENOMEM, errno is
5478 always set anyway.
5479
Scott James Remnant1abced42006-12-12 11:28:49 +00005480 * configure.ac (AM_INIT_AUTOMAKE): Include nostdinc so we don't get
5481 Automake's broken default includes.
5482 * upstart/Makefile.am (DEFAULT_INCLUDES): Drop override now that
5483 we don't need it.
5484 (DEFS, INCLUDES): Replace these variables with the combined
5485 (AM_CPPFLAGS): variable that declares everything.
5486 * init/Makefile.am (DEFAULT_INCLUDES): Drop override now that
5487 we don't need it.
5488 (DEFS, INCLUDES): Replace these variables with the combined
5489 (AM_CPPFLAGS): variable that declares everything.
5490 * util/Makefile.am (DEFAULT_INCLUDES): Drop override now that
5491 we don't need it.
5492 (DEFS, INCLUDES): Replace these variables with the combined
5493 (AM_CPPFLAGS): variable that declares everything.
5494 * compat/sysv/Makefile.am (DEFAULT_INCLUDES): Drop override now that
5495 we don't need it.
5496 (DEFS, INCLUDES): Replace these variables with the combined
5497 (AM_CPPFLAGS): variable that declares everything.
5498 * logd/Makefile.am (DEFAULT_INCLUDES): Drop override now that
5499 we don't need it.
5500 (DEFS, INCLUDES): Replace these variables with the combined
5501 (AM_CPPFLAGS): variable that declares everything.
5502
Scott James Remnantacec3b22006-11-02 16:36:53 +000055032006-11-02 Scott James Remnant <scott@netsplit.com>
5504
5505 * util/initctl.c (start_action): Remove break calls which shouldn't
5506 be there.
5507
Scott James Remnantea806b72006-10-18 15:01:00 +010055082006-10-18 Sean E. Russell <ser@ser1.net>
5509
5510 * init/main.c: Include sys/time.h
5511 * init/cfgfile.c: Include sys/time.h and sys/resource.h
5512 * init/job.c: Include sys/time.h and sys/resource.h
5513
Scott James Remnant6702ac12006-10-17 18:55:24 +010055142006-10-17 Scott James Remnant <scott@netsplit.com>
5515
Scott James Remnantd5758f42006-10-17 19:21:25 +01005516 * configure.ac: Bump version to 0.3.1
5517
Scott James Remnantfd029da2006-10-17 19:21:07 +01005518 * NEWS: Update.
5519 * TODO: Update.
5520
Scott James Remnant9f67cb82006-10-17 19:12:28 +01005521 * configure.ac (AM_GNU_GETTEXT_VERSION): Quote version number.
5522
Scott James Remnant4ebe87f2006-10-17 19:04:40 +01005523 * logd/Makefile.am (event.d/logd): Make the event.d sub-directory
5524 in case we're building outside of the source tree.
5525
Scott James Remnant6702ac12006-10-17 18:55:24 +01005526 * compat/sysv/runlevel.c (store): Don't break strict-aliasing rules
5527 by avoiding dereferencing type-punned pointer. Answers on a
5528 postcard, please.
5529
Scott James Remnant7f133012006-10-13 12:00:34 +010055302006-10-13 Scott James Remnant <scott@netsplit.com>
5531
Scott James Remnantecbb2b52006-10-13 15:18:24 +01005532 * util/initctl.c (start_action, emit_action): Add missing \n
5533
Scott James Remnant48622982006-10-13 15:15:50 +01005534 * util/initctl.c: Rewrite using nih_command_parser.
5535 * util/man/initctl.8: Improve.
5536
5537 * util/start.c: Remove, replaced by initctl.
5538 * util/man/start.8: Remove, replaced by initctl.
5539 * util/Makefile.am (sbin_PROGRAMS): Drop start, now just a symlink
5540 to initctl.
5541 (dist_man_MANS): Drop start.8, now a symlink to initctl.8
5542 (install-exec-hook): Make symlinks to initctl, add start
5543 (install-data-hook): Make symlinks to initctl.8, add start.8
5544
Scott James Remnantb1d8a7d2006-10-13 13:57:31 +01005545 * initctl: Rename to util again, I don't want a separate directory
5546 for every single little tool; and we'll be shipping more than just
5547 initctl (e.g. a non-compat reboot).
5548 * configure.ac (AC_CONFIG_FILES): Make util/Makefile instead of
5549 initctl/Makefile.
5550 * Makefile.am (SUBDIRS): Descend into util, not initctl.
5551
Scott James Remnanta48b4fe2006-10-13 13:49:46 +01005552 * compat/sysv/reboot.c: Remove long options where they didn't exist
5553 before. Write help text.
5554 * compat/sysv/man/reboot.8: Update.
5555
Scott James Remnant462734c2006-10-13 13:36:00 +01005556 * init/main.c (main): Formatting.
5557 * logd/main.c (main): Formatting.
5558 * logd/man/logd.8: Formatting.
5559 * compat/sysv/runlevel.c (main): Formatting.
5560 * compat/sysv/telinit.c (main): Formatting.
5561 * compat/sysv/man/shutdown.8: Remove long options.
5562
Scott James Remnanteff01f12006-10-13 13:32:12 +01005563 * compat/sysv/shutdown.c: Remove -e/--event, it has no place in a
5564 compatibility tool. Get rid of long options that never existed
5565 before. Specify help text to describe the options.
5566 * compat/sysv/man/shutdown.8: Spruce up a bit.
5567
Scott James Remnant4a5cd212006-10-13 12:59:15 +01005568 * compat/sysv/telinit.c (main): Set help text to list the valid
5569 runlevels.
5570 * compat/sysv/man/telinit.8: Refine the notes to mention runlevel(8).
5571
Scott James Remnantf7819622006-10-13 12:54:43 +01005572 * compat/sysv/runlevel.c (main): Make the help text describe the
5573 options, rather than the behaviour.
Scott James Remnant4a5cd212006-10-13 12:59:15 +01005574 * compat/sysv/man/runlevel.8: Flesh out a little more.
Scott James Remnantf7819622006-10-13 12:54:43 +01005575
Scott James Remnant930e25a2006-10-13 12:28:05 +01005576 * configure.ac (AC_INIT): Change bug reporting address to the
5577 mailing list, since Launchpad doesn't accept random bugs without
5578 accounts and complicated control messages.
5579 * init/main.c, logd/main.c: Add a period to the synopsis.
5580
Scott James Remnanta6ed7eb2006-10-13 12:14:45 +01005581 * init/main.c (main): Set the synopsis, and direct people to look
5582 at telinit in the --help output.
5583 * init/man/init.8: Flesh this out a little more, still a lot of
5584 explaining to do about jobs and events, but we'll wait until we've
5585 changed that code before documentating the behaviour.
5586
Scott James Remnant7f133012006-10-13 12:00:34 +01005587 * logd/main.c (main): Correct help text to describe the options,
5588 rather than what the program does. As per standard style.
5589 Don't become a daemon until the logging socket is open, and make
5590 that exclusive with waiting for SIGCONT.
5591 * logd/man/logd.8: Write some more extensive documentation,
5592 including describing the startup interlock and the socket protocol.
5593 * TODO: Plan to get rid of the signal interlock from logd.
5594
Scott James Remnant8985dd32006-10-12 15:26:29 +010055952006-10-12 Scott James Remnant <scott@netsplit.com>
5596
5597 * configure.ac: Expand AC_GNU_SOURCE so we get _GNU_SOURCE and so
5598 that gettext doesn't complain.
5599 (AM_GNU_GETTEXT_VERSION): Increase to 0.15
5600 (AC_PREREQ): Increase to 2.60
5601 * HACKING: Update autoconf and gettext requirements.
5602
Scott James Remnantc16a9b42006-10-11 17:08:58 +010056032006-10-11 Scott James Remnant <scott@netsplit.com>
5604
Scott James Remnant74a11442006-10-11 17:58:56 +01005605 * init/control.c (control_init): Pass NULL to nih_list_new.
5606 Clarify list item types.
5607 * init/event.c (event_init): Pass NULL to nih_list_new.
5608 * init/job.c (job_init): Pass NULL to nih_list_new.
5609
Scott James Remnantc34c4be2006-10-11 17:56:34 +01005610 * init/main.c: Change nih_signal_add_callback to nih_signal_add_handler
5611 and NihSignalCb to NihSignalHandler.
5612
Scott James Remnant8b227402006-10-11 17:55:27 +01005613 * init/cfgfile.c, init/cfgfile.h, init/control.c, init/control.h,
5614 init/event.c, init/event.h, init/job.c, init/job.h, init/main.c,
5615 init/process.c: Clean up documentation strings and parent pointer
5616 types.
5617
Scott James Remnantd033c862006-10-11 17:41:22 +01005618 * compat/sysv/shutdown.c: Change nih_signal_add_callback to
5619 nih_signal_add_handler.
5620
Scott James Remnant1ee0f482006-10-11 17:40:41 +01005621 * compat/sysv/reboot.c: Set synopsis text depending on command
5622 used (probably should use nih_command_parser?)
5623 * compat/sysv/runlevel.c: Set synopsis and help text, and correct
5624 usage.
5625 * compat/sysv/shutdown.c: Set synopsis text.
5626 * compat/sysv/telinit.c: Set synopsis text.
5627
Scott James Remnant3b734642006-10-11 17:22:33 +01005628 * compat/sysv/runlevel.c, compat/sysv/shutdown.c: Clean up
5629 documentation strings.
5630
Scott James Remnantc6e4f002006-10-11 17:22:03 +01005631 * logd/main.c: Set synopsis and help text.
5632
Scott James Remnant5e31d742006-10-11 17:16:55 +01005633 * logd/main.c: Clean up documentation strings.
5634 Change nih_signal_add_callback to nih_signal_add_handler.
5635
Scott James Remnant48359382006-10-11 17:13:48 +01005636 * upstart/control.c, upstart/control.h, upstart/job.c: Clean up
5637 documentation strings and correct parent pointer type.
5638
Scott James Remnantc16a9b42006-10-11 17:08:58 +01005639 * HACKING: Detail function documentation requirement and format.
5640
Scott James Remnant59093a82006-10-10 13:09:58 +010056412006-10-10 Scott James Remnant <scott@netsplit.com>
5642
Scott James Remnant335947d2006-10-11 17:08:34 +01005643 * event.d/logd.in: Move to logd/event.d
5644 * event.d/Makefile.am: Remove
5645 * logd/Makefile.am: Create the logd job definition and install
5646 * Makefile.am (SUBDIRS): event.d directory has been removed.
5647 * configure.ac (AC_CONFIG_FILES): No longer make event.d/Makefile
5648
Scott James Remnant59093a82006-10-10 13:09:58 +01005649 * configure.ac: Check for --enable-compat, default to sysv if given
5650 or no compat if not given.
5651 * compat/sysv/Makefile.am: Don't build binaries or install manpages
5652 unless COMPAT_SYSV is defined.
5653
Scott James Remnant45150942006-10-06 16:36:27 +010056542006-10-06 Scott James Remnant <scott@netsplit.com>
5655
5656 * doc/upstart-logo.svg: Include the logo Alexandre designed.
5657 * doc/Makefile.am (EXTRA_DIST): Ship the logo in the tarball.
5658 * Makefile.am (SUBDIRS): Install under doc
5659 * configure.ac: Generate doc/Makefile
5660 * AUTHORS: Ensure he's credited fully.
5661
Scott James Remnant10b8c0e2006-09-27 21:27:38 +010056622006-09-27 Scott James Remnant <scott@netsplit.com>
5663
Scott James Remnant44052a32006-09-28 00:04:32 +01005664 * event.d/Makefile.am (do_subst): Eliminate duplicate /s
5665
Scott James Remnant5222c402006-09-27 22:48:48 +01005666 * man/init.8: Move to init/man
5667 * init/Makefile.am: Update to install man page.
5668 * man/logd.8: Move to logd/man
5669 * logd/Makefile.am: Update to install man page.
5670 * man/initctl.8, man/start.8: Move to initctl/man
5671 * initctl/Makefile.am: Update to install man pages.
5672 * man/reboot.8, man/runlevel.8, man/shutdown.8, man/telinit.8:
5673 Move to compat/sysv/man
5674 * compat/sysv/Makefile.am: Update to install man pages.
5675 * man/Makefile.am: Remove
5676 * configure.ac (AC_CONFIG_FILES): Remove man/Makefile
5677 * Makefile.am (SUBDIRS): Don't build in man
5678
Scott James Remnant545cb8c2006-09-27 21:32:49 +01005679 * util: Rename to initctl
5680 * configure.ac (AC_CONFIG_FILES): Update.
5681 * Makefile.am (SUBDIRS): Update.
5682
Scott James Remnant960c82d2006-09-27 21:30:42 +01005683 * util/reboot.c: Move to compat/sysv
5684 * util/shutdown.c: Move to compat/sysv
5685 * util/Makefile.am: Update.
5686 * compat/sysv/Makefile.am: Update.
5687
Scott James Remnant10b8c0e2006-09-27 21:27:38 +01005688 * configure.ac: Replace macros with single call to NIH_INIT.
5689 Bump version to 0.3.0 to begin new development cycle.
5690
Scott James Remnante5591992006-09-21 05:49:34 +010056912006-09-21 Scott James Remnant <scott@netsplit.com>
5692
5693 * logd/main.c: Revert the change that logged to the console, in
5694 practice this doesn't work so well. I want to get rid of logd
5695 in the long term, or at least just have it as a simple logging
5696 proxy, so giving it features seems wrong.
5697
Scott James Remnant9b58b842006-09-20 05:37:47 +010056982006-09-20 Scott James Remnant <scott@netsplit.com>
5699
Scott James Remnant97f08fa2006-09-20 06:34:12 +01005700 * configure.ac: Bump version to 0.2.8
5701 * NEWS: Updated.
5702
Scott James Remnante59c71e2006-09-20 06:14:32 +01005703 * logd/main.c (main): Check the kernel command-line for "quiet"
5704 (line_reader): Write to console unless silent or a daemon
5705
Scott James Remnant9b58b842006-09-20 05:37:47 +01005706 * man/Makefile.am (dist_man_MANS): Drop sulogin.8
5707 * man/sulogin.8: Drop, we don't include an sulogin
5708
Scott James Remnant0fafba42006-09-20 01:36:29 +010057092006-09-19 Michael Biebl <mbiebl@gmail.com>
5710
5711 * event.d/Makefile.am (logd): Drop $(srcdir)
5712 * init/Makefile.am (init_SOURCES): Distribute paths.h
5713
Scott James Remnant58f165f2006-09-18 19:43:07 +010057142006-09-18 Michael Biebl <mbiebl@gmail.com>
5715
5716 * configure.ac: Check for sys/inotify.h
5717
Scott James Remnante371cab2006-09-18 16:16:00 +010057182006-09-18 Scott James Remnant <scott@netsplit.com>
5719
5720 * util/shutdown.c (warning_message): Adjust method of constructing
5721 the message to not confuse poor translators who think \r and \n are
5722 the same thing!
5723
Scott James Remnantf2b1c052006-09-14 10:34:45 +010057242006-09-14 Scott James Remnant <scott@netsplit.com>
5725
Scott James Remnantb2e03d02006-09-14 11:20:13 +01005726 * init/job.c (job_change_state): Catch runaway respawns when we
5727 enter the running state, so we catch stop/start loops too.
5728 * init/tests/test_job.c (test_change_state): Update test.
5729
Scott James Remnantb7714f72006-09-14 11:07:38 +01005730 * event.d/logd: Rename to logd.in
5731 * event.d/logd.in: Replace /sbin with @sbindir@ so we can transform
5732 * event.d/Makefile.am: Generate logd from logd.in
5733
Scott James Remnant7e6bdb32006-09-14 10:57:03 +01005734 * util/reboot.c: Don't hardcode the location of /sbin/shutdown
5735 * util/Makefile.am (DEFS): Use autoconf to seed it
5736 * util/shutdown.c (sysvinit_shutdown): Don't hardcode the location
5737 of /dev/initctl
5738
Scott James Remnante0d0dd12006-09-14 10:51:05 +01005739 * init/paths.h: Create a new configuration file that can contain
5740 all of the path definitions, and in particular, allow them to be
5741 overidden elsewhere.
5742 * init/Makefile.am (DEFS): Override definitions of CFG_DIR and
5743 TELINIT using autoconf
5744 * init/main.c: Include paths.h. Don't hardcode location of telinit
5745 * init/job.c: Include paths.h
5746 * init/process.c: Include paths.h
5747 * init/process.h: Remove definitions from here.
5748
Scott James Remnantf2b1c052006-09-14 10:34:45 +01005749 * configure.ac: Bump version to 0.2.7
5750
Scott James Remnant0b8f23f2006-09-13 16:51:38 +010057512006-09-13 Scott James Remnant <scott@netsplit.com>
5752
Scott James Remnant948ab872006-09-14 10:34:34 +01005753 * NEWS: Updated.
5754
Scott James Remnant0b8f23f2006-09-13 16:51:38 +01005755 * TODO: More TODO.
5756
Scott James Remnant080dd8d2006-09-10 12:42:03 +010057572006-09-10 Scott James Remnant <scott@netsplit.com>
5758
5759 * util/reboot.c (main): Don't give -H with "halt".
5760
Scott James Remnantd7042862006-09-09 00:50:10 +010057612006-09-09 Scott James Remnant <scott@netsplit.com>
5762
Scott James Remnantedb97902006-09-09 05:48:42 +01005763 * configure.ac: Bump version to 0.2.6
5764
Scott James Remnant760237e2006-09-09 05:38:32 +01005765 * NEWS: Update.
5766 * TODO: Update.
5767
Scott James Remnant5e267a42006-09-09 05:21:28 +01005768 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
5769 the magic to be the package string.
5770 * upstart/tests/test_control.c (test_recv_msg): Update tests.
5771
Scott James Remnant17fec6e2006-09-09 05:05:42 +01005772 * util/initctl.c (main): Set the usage string.
5773 * util/shutdown.c (main): Set the usage string.
5774 * util/start.c (main): Set the usage string.
5775 * compat/sysv/runlevel.c (main): Set the usage string.
5776 * compat/sysv/telinit.c (main): Set the usage string.
5777
Scott James Remnantabede802006-09-09 05:01:45 +01005778 * man/Makefile.am: Use install-data-hook and $(man8dir)
5779 * util/Makefile.am: Also use install-exec-hook
5780
Scott James Remnantc6c20052006-09-09 04:58:11 +01005781 * Makefile.am (SUBDIRS): Install contents of the man directory
5782 * configure.ac (AC_CONFIG_FILES): Generate man/Makefile
5783 * man/Makefile.am: Install manpages in the appropriate places.
5784 * man/init.8, man/logd.8, man/initctl.8, man/reboot.8,
5785 * man/shutdown.8, man/start.8, man/sulogin.8, man/runlevel.8,
5786 * man/telinit.8: Include some basic manpages so we at least have
5787 some level of documentation.
5788
Scott James Remnant33e47112006-09-09 03:45:00 +01005789 * init/job.c (job_child_reaper): Don't check the exit status of
5790 a respawning job if the goal is to stop it.
5791
Scott James Remnant1889aa62006-09-09 03:41:53 +01005792 * compat/sysv/telinit.c (main): Generate events rather than
5793 starting and stopping jobs directly, the events are named
5794 "runlevel-X". 0, 1, 6 and s/S are shutdown events.
5795
Scott James Remnant515b2b92006-09-09 03:41:27 +01005796 * logd/main.c (main): Raise SIGSTOP before entering the main loop.
5797 * init/main.c (main): Interlock with logd.
5798
Scott James Remnant17eb9052006-09-09 03:41:04 +01005799 * event.d/logd: Should not be a console owner, but should stop
5800 on shutdown.
5801
Scott James Remnant34752262006-09-09 01:38:02 +01005802 * init/process.c (process_setup_console): Revert part of the previous
5803 change, should just output to /dev/null if we don't have logd.
5804
Scott James Remnante5533332006-09-09 01:36:07 +01005805 * configure.ac: Bump version to 0.2.5
5806
Scott James Remnantb4a1c2b2006-09-09 01:28:26 +01005807 * init/main.c (main): Start the logd job if it exists.
5808
5809 * init/process.c (process_setup_console): Ignore ECONNREFUSED as
5810 that just means that logd isn't around, handle errors by falling
5811 back to opening the console.
5812
Scott James Remnant9fb20d42006-09-09 01:22:03 +01005813 * init/process.c (process_setup_console): Implement handling for
5814 CONSOLE_LOGGED and generally clean up the other handling.
5815 * init/process.h: Update.
5816 * init/main.c (main): Pass NULL for the job to setup console.
5817 * TODO: Update.
5818
Scott James Remnantd7042862006-09-09 00:50:10 +01005819 * logd/main.c: Implement the logging daemon, it accepts connections
5820 on a unix stream socket with the abstract name
5821 "/com/ubuntu/upstart/logd", expects the length of the name and the
5822 name to follow; then sequences of lines which are logged to
5823 /var/log/boot, or memory until that file can be opened.
5824
Scott James Remnant527b9452006-09-08 17:15:07 +010058252006-09-08 Scott James Remnant <scott@netsplit.com>
5826
Scott James Remnantcb655e72006-09-08 17:49:20 +01005827 * util/shutdown.c (event_setter): Change the event names to
5828 distinguish between "shutdown -h" and "shutdown -h -H".
5829
Scott James Remnant90732d32006-09-08 17:33:19 +01005830 * init/job.c (job_handle_event): Allow jobs to react to their own
5831 events, this is how we'll do respawn eventually.
5832 * init/tests/test_job.c (test_handle_event): Remove test.
5833
Scott James Remnantbb3cc3f2006-09-08 17:17:47 +01005834 * init/main.c (cad_handler, kbd_handler): Generate the new event
5835 names.
5836 * init/event.h (CTRLALTDEL_EVENT, KBDREQUEST_EVENT): Add definitions
5837 of these event names, change the ctrlaltdel event to just that.
5838
Scott James Remnant527b9452006-09-08 17:15:07 +01005839 * logd/main.c (main): Add the code to daemonise, etc.
5840
Scott James Remnanta17917d2006-09-07 00:18:28 +010058412006-09-07 Scott James Remnant <scott@netsplit.com>
5842
Scott James Remnant214ebe82006-09-07 21:48:55 +01005843 * TODO: Long discussion today on #upstart, many improvements to the
5844 job and event model that make it more elegant.
5845 * AUTHORS: Include a list of thanks.
5846
Scott James Remnantb8280072006-09-07 03:19:00 +01005847 * util/shutdown.c (shutdown_now): If we get ECONNREFUSED when we
5848 try and send the shutdown event to init, it probably means we're
5849 still in sysvinit. So try that instead.
5850 (sysvinit_shutdown): Function to send a hand-crafted runlevel
5851 change message across /dev/initctl.
5852
Scott James Remnantae969062006-09-07 00:43:57 +01005853 * util/initctl.c (main): Add a shutdown command that takes an
5854 arbitrary event name to be issued after "shutdown". You'll
5855 nearly always want the /sbin/shutdown tool instead.
5856
Scott James Remnant987bcc42006-09-07 00:38:24 +01005857 * init/job.c (job_detect_idle): Only generate the stalled event
5858 if at least one job handles it in its start_events list.
5859 * init/tests/test_job.c (test_detect_idle): Make sure that works.
5860
Scott James Remnantea204d42006-09-07 00:30:53 +01005861 * init/event.h (STARTUP_EVENT, SHUTDOWN_EVENT, STALLED_EVENT):
5862 Macros to define the standard event names.
5863 * init/main.c (main): Use STARTUP_EVENT macro instead of "startup"
5864 * init/control.c (control_handle): Use SHUTDOWN_EVENT macro
5865 instead of "shutdown".
5866 * init/job.c (job_detect_idle): Use STALLED_EVENT macro instead
5867 of "stalled".
5868
Scott James Remnant84607df2006-09-07 00:27:22 +01005869 * init/job.c (job_detect_idle): Add some log messages for when we
5870 detect the idle or stalled states.
5871 (job_kill_process, job_kill_timer): Increase log verbosity.
5872 * init/event.c (event_queue_run): Log which events we're handling
5873 if --debug is given.
5874
Scott James Remnanta17917d2006-09-07 00:18:28 +01005875 * compat/sysv/telinit.c (main): Send a shutdown command when
5876 requesting to enter runlevel 0 or runlevel 6, likewise for
5877 runlevel 1, s or S which all run "rc1" not "rcS".
5878 * init/main.c (main): When called directory (pid != 1) try and
5879 run telinit before complaining that we're not init. Make sure
5880 errors aren't lost.
5881
Scott James Remnantf5c376c2006-09-04 16:25:04 +010058822006-09-04 Johan Kiviniemi <johan@kiviniemi.name>
Scott James Remnantedcae302006-09-04 07:06:23 +01005883
Scott James Remnantf5c376c2006-09-04 16:25:04 +01005884 * upstart/control.c (upstart_addr): Replace use of __builtin_offsetof
5885 with offsetof.
5886 * upstart/tests/test_control.c (test_recv_msg): Likewise.
5887
58882006-09-04 Scott James Remnant <scott@netsplit.com>
5889
Scott James Remnantedcae302006-09-04 07:06:23 +01005890 * util/shutdown.c (main): Exit normally after sending the warning
5891 message if -k is given.
5892
Scott James Remnante94bd202006-09-01 00:48:36 +010058932006-09-01 Scott James Remnant <scott@netsplit.com>
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01005894
Scott James Remnant294cde72006-09-01 19:58:35 +01005895 * configure.ac: Bump version to 0.2.2
5896
Scott James Remnant7663bfb2006-09-01 19:58:19 +01005897 * NEWS: Update.
5898 * configure.ac: Bump version to 0.2.1
5899
Scott James Remnant67982142006-09-01 19:47:39 +01005900 * init/process.c (process_setup_console): Ensure that the console
5901 is always initialised to at least /dev/null
5902 * init/job.c (job_change_state): Initialise event to NULL.
5903 * init/event.c (event_read_state): Don't mask initialisation of
5904 other variable.
5905 * init/cfgfile.c (cfg_job_stanza, cfg_parse_script, cfg_next_token):
5906 Print lineno using %zi not %d
5907 * compat/sysv/runlevel.c (store): Cast pointer type of timeval.
5908
Scott James Remnant097b2a92006-09-01 19:30:37 +01005909 * init/main.c: Move the kernel headers include beneath the C
5910 library ones, so that compilation doesn't fail on !i386.
5911 * util/reboot.c: Likewise.
5912
Scott James Remnant28fcc922006-09-01 04:15:57 +01005913 * init/main.c (term_handler): Close the control connection if we
5914 re-exec init, otherwise it won't be able to bind. Drop debugging.
5915
Scott James Remnant6f464962006-09-01 04:10:20 +01005916 * init/main.c (term_handler): It always helps if we dup2 the
5917 right file descriptor.
5918
Scott James Remnant1db88042006-09-01 03:14:19 +01005919 * init/main.c: Use the TERM signal instead of USR1, as old init
5920 used that for something else. Also rather than passing across
5921 file descriptor numbers, use a fixed descriptor and just pass
5922 "--restart". When we get that option we need to unmask signals
5923 otherwise we sit there looking like a lemon.
5924
Scott James Remnante7a73262006-09-01 02:32:27 +01005925 * init/job.c (job_change_state): Don't free the event unless we
5926 generate one.
5927
Scott James Remnant12dd7252006-09-01 02:27:04 +01005928 * NEWS: Update.
5929
Scott James Remnant694172a2006-09-01 02:26:45 +01005930 * init/cfgfile.c (cfg_watcher): Ignore any file with '.' or '~'
5931
Scott James Remnantc6e63dd2006-09-01 02:16:43 +01005932 * TODO: Update.
5933
Scott James Remnant3401ab72006-09-01 02:14:47 +01005934 * init/main.c (main): Parse command-line arguments, specifically
5935 look for --state-fd which we'll use for reexec. Don't do a couple
5936 of things if we're passed this.
5937 (read_state): Parse the line-buffered state.
5938 * init/job.c (job_read_state, job_write_state): Job state
5939 serialisation so that we can re-exec ourselves.
5940 * init/job.h: Update.
5941 * init/tests/test_job.c: Test the serialisation.
5942 * init/event.c (event_read_state, event_write_state): And similar
5943 functions for serialising the event queue.
5944 * init/event.h: Update.
5945 * init/tests/test_event.c: Test the serialisation.
5946 * init/cfgfile.c (cfg_read_job): Fix a bug, need to subtract current
5947 time to get due time.
5948
Scott James Remnante94bd202006-09-01 00:48:36 +01005949 * upstart/job.c (job_goal_from_name, job_state_from_name)
5950 (process_state_from_name): Add opposite numbers that convert a
5951 string back into an enumeration.
5952 * upstart/job.h: Update.
5953 * upstart/tests/test_job.c: Test the new functions.
5954
59552006-08-31 Scott James Remnant <scott@netsplit.com>
Scott James Remnant694172a2006-09-01 02:26:45 +01005956
Scott James Remnantb7260a72006-08-31 22:08:56 +01005957 * init/job.h (Job): Add respawn_limit, respawn_interval,
5958 respawn_count and respawn_time members so that we can keep track of
5959 runaway processes.
5960 * init/job.c (job_catch_runaway): Increment the respawn_count
5961 within respawn_interval, or reset it if we go over.
5962 (job_new): Initialise respawn_limit and respawn_interval to sensible
5963 defaults.
5964 * init/tests/test_job.c (test_new): Check the defaults are set.
5965 (test_change_state): Check the respawning code works.
5966 * init/cfgfile.c (cfg_job_stanza): Parse the "respawn limit" stanza.
5967 * init/tests/test_cfgfile.c (test_read_job): Test the new stanza.
5968
Scott James Remnantff0d26a2006-08-31 20:49:43 +01005969 * init/process.c (process_setup_console): Remove the console reset
5970 code, it tends to just crash X and seems to do nothing interesting.
5971 * init/main.c (reset_console): Instead put it here and just do it
5972 on startup.
5973
Scott James Remnant25b263a2006-08-31 18:59:02 +01005974 * configure.ac: Bump version to 0.2.0
5975
Scott James Remnant4b61be92006-08-31 17:08:44 +01005976 * util/Makefile.am (install-exec-local): Create symbolic links,
5977 not hard links.
5978
Scott James Remnantaf1404f2006-08-31 16:04:16 +01005979 * init/main.c: Can't catch STOP.
5980
Scott James Remnant242b50b2006-08-31 15:40:42 +01005981 * util/reboot.c: Pause init while shutting down or rebooting.
5982
Scott James Remnanteabb7802006-08-31 15:39:04 +01005983 * init/main.c (stop_handler): Catch STOP/TSTP and CONT.
5984 * init/event.c (event_queue_run): Don't run the event queue while
5985 paused.
5986 * init/job.c (job_detect_idle): Don't detect idle jobs while paused.
5987
Scott James Remnant1cd8d862006-08-31 15:17:16 +01005988 * util/reboot.c: if we get the -w argument ("only write to wtmp")
5989 we need to exit, and not behave as halt normally would.
5990
Scott James Remnantff63cf72006-08-31 04:39:34 +01005991 * compat/sysv/runlevel.c (main): Add missing newline.
5992 * compat/sysv/telinit.c (main): And here too.
5993
Scott James Remnant32de9222006-08-31 04:34:27 +01005994 * init/main.c (main): Check for idle after the startup event queue
5995 has been run, otherwise we may just sit there.
5996
Scott James Remnant13ffffe2006-08-31 04:33:39 +01005997 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install telinit
5998 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Details for
5999 telinit binary.
6000 * compat/sysv/telinit.c: Trivial telinit program that just runs
6001 the appropriate rcX job.
6002 * compat/sysv/runlevel.c (main): Suggest help on illegal runlevel.
6003
Scott James Remnant40f09012006-08-31 04:21:49 +01006004 * util/Makefile.am: Tidy up.
6005
Scott James Remnant12473562006-08-31 04:21:05 +01006006 * configure.ac (AC_CONFIG_FILES): Create compat/sysv/Makefile
6007 * Makefile.am (SUBDIRS): Build things found in compat/sysv
6008 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install runlevel
6009 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD): Details for
6010 runlevel binary.
6011 * compat/sysv/runlevel.c: Helper to store and retrieve the current
6012 "runlevel" from utmp/wtmp; as well as the reboot time.
6013
Scott James Remnantd909cca2006-08-31 04:20:14 +01006014 * init/main.c (main): Drop debugging set.
6015
Scott James Remnantcedd11a2006-08-31 02:59:29 +01006016 * init/job.c (job_change_state): As well as the job/state events,
6017 send the job event when a service is running or a task is stopping.
6018 * init/tests/test_job.c (test_change_state): Check the events get
6019 sent properly.
6020
Scott James Remnant44b684a2006-08-31 02:58:45 +01006021 * util/start.c: Write a simple utility to start, stop, or query
6022 the status of the named jobs.
6023 * util/Makefile.am (sbin_PROGRAMS): Build and install start
6024 (start_SOURCES, start_LDFLAGS, start_LDADD): Details for start
6025 (install-exec-local): Also install as stop and status.
6026 * util/reboot.c (main): Drop the debugging set.
6027
Scott James Remnantb8ed2d12006-08-31 02:15:48 +01006028 * init/cfgfile.c (cfg_job_stanza): Correct nih_alloc error.
6029
Scott James Remnanta6125ae2006-08-31 02:14:25 +01006030 * init/process.c (process_setup_environment): Guard memory alloc.
6031 * init/job.c (job_set_idle_event): Likewise.
6032 (job_change_state): And here too.
6033 (job_run_command): Likewise.
6034 * init/control.c (control_send): Likewise.
6035 * init/cfgfile.c: And throughout this file.
6036 * upstart/control.c (upstart_recv_msg): And once here too.
6037
Scott James Remnant0b358ab2006-08-31 02:07:32 +01006038 * upstart/control.h: Abolish the separate halt, reboot and poweroff
6039 messages and replace with a single shutdown message that takes
6040 an event name (for the idle event issued afterwards).
6041 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
6042 the new shutdown event type by just treating it as an event.
6043 * upstart/tests/test_control.c (test_messages): Update tests.
6044 * init/job.c (job_set_idle_event): Store a copy of the idle event
6045 name.
6046 * init/control.c (control_send): Copy the shutdown event name.
6047 (control_handle): Replace individual handling with the new
6048 single event.
6049 * init/tests/test_control.c (test_watcher): Update.
6050 * util/initctl.c: Drop handling for things that shutdown does now.
6051 * util/shutdown.c: Send the UPSTART_SHUTDOWN event and let the user
6052 specify anything they want, just give defaults.
6053
Scott James Remnantff5efb92006-08-31 01:45:19 +01006054 This is quite a big change and abolishes level events entirely,
6055 along with the event history. We now just treat events as a
6056 transient queue of strings that go past, may cause things to change,
6057 but are otherwise forgotten. This turns out to be much easier to
6058 understand and has no real loss of power.
6059
6060 * init/event.c: Vastly simplify; gone are the separate notions of
6061 edge and level events, instead we just treat them as one-shot
6062 things that go past and are forgotten about.
6063 * init/event.h (Event): Remove value member.
6064 Update prototypes.
6065 * init/tests/test_event.c: Update.
6066 * init/job.c (job_change_state): Change the event pattern to be
6067 one that includes the job name and a description of the transition
6068 instead of the new state.
6069 (job_detect_idle): Call event_queue rather than event_queue_edge.
6070 * init/tests/test_job.c: Update.
6071 * init/cfgfile.c (cfg_job_stanza): Drop "when" and "while".
6072 * init/tests/test_cfgfile.c (test_read_job): Drop mentions of
6073 "when" and "while".
6074 * init/control.c (control_send, control_handle): Drop cases for
6075 level events.
6076 (control_handle_event): Don't include a level in the event.
6077 * init/tests/test_control.c: Update
6078 * init/main.c: Call event_queue rather than event_queue_edge.
6079 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
6080 event handling so that only a name is read.
6081 * upstart/control.h: Remove value/level event structures.
6082 * upstart/tests/test_control.c (test_messages): Update.
6083 * upstart/job.c (process_state_name): Not used for events, adjust
6084 documentation so it doesn't lie.
6085 * util/initctl.c (main): Drop the set function, simplify trigger.
6086 * util/shutdown.c (shutdown_now): Call UPSTART_EVENT_QUEUE for
6087 shutdown into maintenance mode.
6088
Scott James Remnantfcbee2d2006-08-31 00:49:36 +01006089 * init/control.c (control_handle): Place a message in the syslog
6090 before halting, powering off or rebooting.
6091
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01006092 * util/shutdown.c: Adjust so that the warning message is sent out
6093 if shutdown is immediate, and when it actually happens. Include
6094 the hostname as wall does.
6095
Scott James Remnant255c5f22006-08-30 16:05:01 +010060962006-08-30 Scott James Remnant <scott@netsplit.com>
6097
Scott James Remnant5be55662006-08-30 19:13:25 +01006098 * TODO: Update.
6099
Scott James Remnant4a9245f2006-08-30 19:13:00 +01006100 * util/shutdown.c: Implement shutdown utility along the same lines
6101 as the sysvinit one, but with rather different code.
6102
Scott James Remnant2a71aaa2006-08-30 16:34:06 +01006103 * util/initctl.c (main): Call setuid on the effective user id so
6104 that we can be made setuid root and executable by a special group.
6105 * util/reboot.c (main): Likewise.
6106
Scott James Remnant70cc2292006-08-30 16:06:03 +01006107 * util/initctl.c (main): Check the effective rather than the real
6108 user id, if we're effectively root, that's good enough.
6109
Scott James Remnant255c5f22006-08-30 16:05:01 +01006110 * util/reboot.c: Implement reboot/halt/poweroff utility.
6111 * util/Makefile.am (sbin_PROGRAMS): Build and install reboot
6112 (reboot_SOURCES, reboot_LDFLAGS, reboot_LDADD): Details for reboot
6113 (install-exec-local): Create hardlinks to reboot for halt and poweroff.
6114
Scott James Remnantdc8877d2006-08-29 16:56:48 +010061152006-08-29 Scott James Remnant <scott@netsplit.com>
6116
6117 * init/main.c (main): Actually run the idle-detect function.
6118 * init/job.c (job_detect_idle): Interrupt the main loop, otherwise
6119 we may end up waiting for a signal before we process the event
6120 we just issued.
6121
Scott James Remnantf43bdf32006-08-27 18:20:29 +010061222006-08-27 Scott James Remnant <scott@netsplit.com>
6123
Scott James Remnant47158482006-08-27 22:37:10 +01006124 * util/shutdown.c: Template main function.
6125 * util/Makefile.am (sbin_PROGRAMS): Build and install the
6126 shutdown binary.
6127 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD): Details for
6128 the shutdown binary
6129
Scott James Remnant70a6ec62006-08-27 22:23:50 +01006130 * util/initctl.c (main): Add commands for halt, poweroff and reboot.
6131
Scott James Remnant0c7e72a2006-08-27 22:22:53 +01006132 * init/event.c (event_queue_run): Remove the parameters.
6133 * init/event.h: Update.
6134 * init/main.c (main): Update.
6135 * init/tests/test_control.c (test_watcher): Update.
6136 * init/tests/test_job.c (test_detect_idle): Update.
6137
Scott James Remnant96ae9e42006-08-27 22:15:34 +01006138 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Deal
6139 with halting, rebooting and powering off; or at least the appropriate
6140 messages.
6141 * upstart/control.h: Add control message structures for halting,
6142 powering off and rebooting the machine.
6143 * upstart/tests/test_control.c (test_messages): Run the tests.
6144 * init/control.c (control_handle): Add handling for halt, power off
6145 and reboot that issue the shutdown event and arrange for the halt,
6146 poweroff or reboot to be issued the next time the system is idle.
6147 * init/tests/test_control.c (test_watcher): Test the events.
6148
Scott James Remnant01a37082006-08-27 21:51:00 +01006149 * TODO: Update.
6150
Scott James Remnante02892b2006-08-27 21:49:44 +01006151 * init/job.c (job_detect_idle): Function to detect when the system is
6152 stalled or idle.
6153 * init/job.h: Update
6154 * init/tests/test_job.c (test_detect_idle): Test the new function.
6155
Scott James Remnant6a8508c2006-08-27 19:10:44 +01006156 * util/initctl.c (main): Handle the list command.
6157
Scott James Remnanta9476ad2006-08-27 19:07:23 +01006158 * TODO: Update.
6159
Scott James Remnant4da474d2006-08-27 19:06:35 +01006160 * upstart/control.c (WireJobStatusPayload): add description to the
6161 job status payload.
6162 (upstart_send_msg_to, upstart_recv_msg): Send and receieve the
6163 description over the wire.
6164 * upstart/control.h (UpstartJobStatusMsg): add a description field
6165 * upstart/tests/test_control.c: Update test cases.
6166 * init/control.c (control_handle): Include the job description in
6167 the message.
6168 (control_send): Copy the description when we put the message on
6169 the queue.
6170 (control_handle_job): Copy the description here too
6171 * init/tests/test_control.c: Update test cases.
6172
Scott James Remnant84f5e932006-08-27 18:49:25 +01006173 * init/job.c (job_list): Add a function to return the job list.
6174 * init/job.h: Update.
6175 * init/control.c (control_handle): Handle the JOB_LIST message
6176 by sending back a list of job status messages followed by the
6177 JOB_LIST_END message.
6178 * init/tests/test_control.c (test_watcher_child): Check the
6179 JOB_LIST message works properly.
6180
Scott James Remnantf4ad6d12006-08-27 18:40:01 +01006181 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
6182 the JOB_LIST and JOB_LIST_END messages which have no payload.
6183 * upstart/control.h: Add enums and structures for job list messages.
6184 * upstart/tests/test_control.c (test_messages): Update tests.
6185
Scott James Remnantf4970812006-08-27 18:27:19 +01006186 * init/main.c (main): Check that we're both uid and process #1
6187
Scott James Remnantf43bdf32006-08-27 18:20:29 +01006188 * init/main.c (main): Stop handling SIGTERM, we never want people
6189 to kill init. Handle SIGINT and SIGWINCH through the ordinary
6190 handler and SIGSEGV through a direct handler.
6191 (segv_handler): Write a sensible core dump handler, we use a child
6192 to dump core while we carry on in the parent hopefully stepping over
6193 the bad instruction.
6194 (cad_handler): Generate the control-alt-delete event.
6195 (kbd_handler): Generate the kbdrequest event.
6196
Scott James Remnant33e64d02006-08-25 14:44:32 +020061972006-08-25 Scott James Remnant <scott@netsplit.com>
6198
Scott James Remnant21679252006-08-25 16:22:13 +02006199 * configure.ac: Bump version to 0.1.2
6200 * NEWS: Update.
6201
Scott James Remnantfef12b52006-08-25 16:16:45 +02006202 * TODO: Update.
6203
Scott James Remnant94d00982006-08-25 15:38:22 +02006204 * init/process.c (process_setup_environment): Inherit the PATH
6205 and TERM environment variables from the init process, so the
6206 console works properly.
6207 * init/process.h (PATH): Declare a default value for this variable
6208 * init/main.c (main): Set the value of PATH to the default.
6209 * init/tests/test_process.c (child): Update test case.
6210
Scott James Remnant33e64d02006-08-25 14:44:32 +02006211 * NEWS: Update.
6212 * configure.ac: Bump version to 0.1.1
6213
Scott James Remnant68ccc9e2006-08-24 00:10:41 +020062142006-08-24 Scott James Remnant <scott@netsplit.com>
6215
Scott James Remnant279d4352006-08-24 15:33:19 +02006216 * init/cfgfile.h (CFG_DIR): Change configuration directory to
6217 /etc/event.d -- it's not been used by anyone, but is similar to
6218 other directories that have which is a good precedent.
6219 * event.d/Makefile.am (eventdir, dist_event_DATA): Install files
6220 into the new directory name.
6221 * Makefile.am (SUBDIRS): Rename sub directory
6222 * configure.ac (AC_CONFIG_FILES): Rename generated Makefile
6223
Scott James Remnant937192c2006-08-24 02:57:50 +02006224 * init/Makefile.am (DEFAULT_INCLUDES): Set to include the right
6225 directories so out of tree builds work.
6226 * logd/Makefile.am (DEFAULT_INCLUDES): Set to include the right
6227 directories so out of tree builds work.
6228 * upstart/Makefile.am (DEFAULT_INCLUDES): Set to include the right
6229 directories so out of tree builds work.
6230 (upstartinclude_HEADERS): Install errors.h
6231 * util/Makefile.am (DEFAULT_INCLUDES): Set to include the right
6232 directories so out of tree builds work.
6233
6234 * Makefile.am (SUBDIRS): Add m4 to the list
6235 * configure.ac (AC_CONFIG_FILES): Generate m4/Makefile
6236 * upstart/Makefile.am (upstartinclude_HEADERS): Add errors.h
6237
6238 * upstart/control.c (upstart_open):
6239
Scott James Remnante4c3d552006-08-24 02:34:01 +02006240 * init/control.c (control_open): Raise the error before
6241 performing other actions so errno is not lost.
Scott James Remnant73550092006-08-24 02:27:03 +02006242
Scott James Remnante4c3d552006-08-24 02:34:01 +02006243 * TODO: Update.o
Scott James Remnantf8b776b2006-08-24 00:36:15 +02006244 * init/cfgfile.c (cfg_next_token): Don't count quote characters
6245 unless we're actually planning to dequote the file, otherwise we
6246 end up allocating short.
6247
Scott James Remnant9e17fc02006-08-24 00:28:10 +02006248 * init/control.c (control_close): Free the io_watch using list_free
6249 in case a destructor has been set.
6250 * init/tests/test_control.c: Initialise the type of the message, and
6251 free job correctly.
6252
Scott James Remnant68ccc9e2006-08-24 00:10:41 +02006253 * upstart/tests/test_control.c: Fix overwrite of buffer.
6254 * init/tests/test_job.c: Clean up not-freed job.
6255
Scott James Remnantc961ce32006-08-23 19:46:29 +020062562006-08-23 Scott James Remnant <scott@netsplit.com>
6257
Scott James Remnant013e9722006-08-23 23:00:14 +02006258 * init/tests/test_event.c: free the entry allocated and initialise
6259 the return values.
6260
Scott James Remnantc961ce32006-08-23 19:46:29 +02006261 * init/cfgfile.c (cfg_skip_token): Drop this function; we'll
6262 make sure *pos is pointing at the start of the thing we want
6263 to parse, not the first token. Update the other functions
6264 accordingly.
6265 (cfg_read_job): Implement function to look over a job file and
6266 parse all of the stanzas that are found. Also sanity checks the
6267 job afterwards and deals with reloading existing jobs.
6268 (cfg_job_stanza): Function that parses an individual stanza,
6269 calling out to the other parse functions; this is the main config
6270 file parser!
6271 (cfg_parse_args, cfg_parse_command): Drop requirement that filename
6272 and lineno be passed, so we can be called to reparse arguments after
6273 we've already done so.
6274 (cfg_parse_script): Remove requirement that it be called at the
6275 start of the entire stanza, and instead at the start of the script.
6276 When hitting EOF, return the script so far, not NULL.
6277 (cfg_parse_args): Correct bug where we didn't check sufficient
6278 characters while skipping whitespace.
6279 (cfg_next_token): Correct bug where we didn't copy the character
6280 after a slash into the text, instead of just not copying the slash.
6281 Adjust line numbers to match the fact that it's zero based now.
6282 * init/cfgfile.h: Define prototype.
6283 * init/tests/test_cfgfile.c (test_read_job): Pretty thoroughly
6284 test the config file parser code.
6285
Scott James Remnant0c58ed02006-08-22 11:42:19 +020062862006-08-22 Scott James Remnant <scott@netsplit.com>
6287
Scott James Remnant214168f2006-08-22 18:52:51 +02006288 * init/cfgfile.c (cfg_tokenise): Rename to cfg_next_token.
6289 (cfg_skip_token): Code to skip whitespace, token and whitespace.
6290 (cfg_parse_args): Function to parse an argument list.
6291 (cfg_next_token): Extend to support the removal of quotes and
6292 slashes from the token.
6293
Scott James Remnant21590a22006-08-22 17:40:48 +02006294 * init/cfgfile.c (cfg_parse_script): Pass filename and lineno and
6295 increment the latter as we go.
6296 (cfg_script_end): Pass and increment lineno.
6297
Scott James Remnanteed2e8d2006-08-22 17:31:07 +02006298 * init/cfgfile.c: Correct a missing semi-colon in prototypes.
6299 (cfg_parse_command): Function to parse any stanza that requires
6300 a command and arguments list, e.g. exec/respawn/daemon. We don't
6301 want to require that the list be quoted, etc. and do want to allow
6302 it to be folded over lines.
6303 (cfg_tokenise): Function used by the above to tokenise the file,
6304 handling things like \, quoted strings and newlines, etc. Can be
6305 used both to determine the length of the token and to copy it.
6306
Scott James Remnantfcc98ad2006-08-22 12:28:19 +02006307 * init/cfgfile.c (cfg_read_script): Rename to cfg_parse_script.
6308
Scott James Remnantfd32dd32006-08-22 11:46:01 +02006309 * init/cfgfile.c (cfg_read_script): Function to parse a script
6310 fragment ("foo script\n....end script\n") from the job file, which
6311 is the most complex form we can find. Write it assuming the file is
6312 in a character array which may not be NULL terminated (ie. a mmap'd
6313 file).
6314 (cfg_script_end): Used by the above to detect the end of the
6315 fragment.
6316 * init/cfgfile.h: Empty header file.
6317 * init/Makefile.am (init_SOURCES): Build and link cfgfile.c
6318 using the cfgfile.h header
6319 (TESTS): Build and run the config file test cases.
6320 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
6321 Details for config file test case binary.
6322
Scott James Remnant0c58ed02006-08-22 11:42:19 +02006323 * init/main.c (main): Remove the calls to the unfinished config
6324 file code.
6325
Scott James Remnant6ce44812006-08-21 08:46:32 +020063262006-08-21 Scott James Remnant <scott@netsplit.com>
6327
Scott James Remnant027dd7b2006-08-21 09:01:25 +02006328 * init/main.c: Add missing include for unistd.h
6329 * init/process.c (process_setup_console): Drop use of job.
6330 * util/initctl.c (main): Check that we're run as root.
6331
Scott James Remnant77e8db32006-08-21 08:47:50 +02006332 * init/main.c (main): Write the main function
6333
Scott James Remnant6ecceb82006-08-21 08:47:23 +02006334 * init/event.c (event_queue_cb): Rename to event_queue_run.
6335 * init/event.h: Update.
6336
Scott James Remnant6ce44812006-08-21 08:46:32 +02006337 * init/process.c (process_setup_console): Become an exported
6338 function that includes the code to reset a console.
6339
Scott James Remnant5befd932006-08-19 19:24:54 +010063402006-08-19 Scott James Remnant <scott@netsplit.com>
6341
Scott James Remnantcd39a7c2006-08-19 20:02:17 +01006342 * logd/main.c (main): Write the basic main function.
6343
Scott James Remnant3bcd15e2006-08-19 19:50:12 +01006344 * util/initctl.c (main): Fill in the details to give us a basic
6345 test client.
6346
Scott James Remnant3dc965c2006-08-19 19:25:23 +01006347 * TODO: Update.
6348
Scott James Remnant5befd932006-08-19 19:24:54 +01006349 * util/initctl.c (main): Provide the most basic main function.
6350 * util/Makefile.am (sbin_PROGRAMS): Build the initctl binary
6351 * Makefile.am (SUBDIRS): Build the utilities.
6352 * configure.ac (AC_CONFIG_FILES): Generate the util Makefile.
6353
Scott James Remnant1fe38a82006-08-18 17:06:25 +010063542006-08-18 Scott James Remnant <scott@netsplit.com>
6355
Scott James Remnantc2659612006-08-18 22:19:47 +01006356 * init/Makefile.am (test_job_LDADD): Remove the duplicate link.
6357
Scott James Remnantd5e07052006-08-18 20:39:30 +01006358 * TODO: Update.
6359
Scott James Remnanta060bb72006-08-18 20:16:55 +01006360 * init/job.c (job_handle_child): Rename to job_child_reaper.
6361 * init/job.h: Update.
6362 * init/tests/test_job.c: Update function names.
6363
Scott James Remnant829dc082006-08-18 20:10:02 +01006364 * init/control.c (control_cb): Rename to control_watcher
6365 * init/tests/test_control.c: Update function names.
6366
Scott James Remnantddc3e282006-08-18 18:49:50 +01006367 * TODO: Update.
6368
Scott James Remnantc2cac3f2006-08-18 17:17:57 +01006369 * Makefile.am (SUBDIRS): Install the rc.d files.
6370 * configure.ac (AC_CONFIG_FILES): Generate the rc.d Makefile.
6371 * rc.d/Makefile.am (rcdir): Define rcdir to be /etc/rc.d
6372 (dist_rc_DATA): Install the logd file into that directory.
6373 * rc.d/logd: Write a simple service definition for the log daemon,
6374 this saves us hardcoding any information about it into init; it'll
6375 just need to know the name.
6376
Scott James Remnant1fe38a82006-08-18 17:06:25 +01006377 * Makefile.am (SUBDIRS): Build the logd daemon
6378 * configure.ac (AC_CONFIG_FILES): Generate the logd Makefile.
6379 * logd/Makefile.am (sbin_PROGRAMS): Install the logd binary into
6380 the sbin directory by default.
6381 (logd_SOURCES): Build and link main.c
6382 * logd/main.c (main): Add basic main function for testing purposes.
6383
Scott James Remnantb9814432006-08-16 02:11:51 +010063842006-08-16 Scott James Remnant <scott@netsplit.com>
6385
Scott James Remnantc5da6fd2006-08-16 18:06:49 +01006386 * init/job.c (job_start): Ignore self-dependencies; over-document
6387 why the dependency event prodding has a surprise in its tail.
6388 (job_change_state): Move the job_release_depends call to here.
6389
Scott James Remnant133a7a32006-08-16 17:45:51 +01006390 * init/event.c (event_queue_cb): Add event consumer/dispatcher.
Scott James Remnant13e5dbf2006-08-16 17:48:01 +01006391 * init/event.h: Update.
Scott James Remnant133a7a32006-08-16 17:45:51 +01006392
Scott James Remnant3772bc62006-08-16 17:41:34 +01006393 * init/control.c (control_send): Make the event code clearer.
6394 (control_handle): Handle the changed event semantics.
6395 (control_handle_event): Issue the new event type.
6396 * init/tests/test_control.c: Update tests.
6397
Scott James Remnantcaee5b52006-08-16 17:32:12 +01006398 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Adjust
6399 marshal code to match.
6400 * upstart/control.h: Update all structures appropriately to the
6401 previous changes.
6402 * upstart/tests/test_control.c: Update.
6403
Scott James Remnant4d4389d2006-08-16 17:19:20 +01006404 * init/job.c (job_change_state): Change call to event_trigger_level
6405 to event_queue_level.
6406
Scott James Remnant51664d72006-08-16 17:17:58 +01006407 * init/event.c (event_trigger_edge, event_trigger_level): Place
6408 the event on the event_queue rather than directly triggering it.
6409 Rename to event_queue_edge and event_queue_level respectively.
6410 * init/event.h: Update.
6411 * init/tests/test_event.c: Update test cases.
6412
Scott James Remnant4ddc86e2006-08-16 16:17:48 +01006413 * init/job.c (job_handle_event): Add another sanity check, jobs
6414 should not be able to react to their own events; that's just silly.
6415 * init/tests/test_job.c (test_handle_event): Check that the new
6416 condition does the right thing.
6417
Scott James Remnant930f3e02006-08-16 16:13:03 +01006418 * init/job.c (job_change_state): Make it illegal for a job to exist
6419 without either a command or script or both. This is for sanity
6420 reasons, allowing no primary process makes no sense and can lead
6421 to event loops if someone is feeling nefarious.
6422 * init/tests/test_job.c (test_change_state): Drop test on behaviour
6423 we've just outlawed.
6424
Scott James Remnant7dd047e2006-08-16 13:43:50 +01006425 * init/job.c (job_start): Only announce the change if we're still
6426 in the waiting state, we could have moved on to running already.
6427
Scott James Remnantf9261ba2006-08-16 13:40:05 +01006428 * init/job.c (job_start): If holding the job, at least announce
6429 the goal change to subscribed clients.
6430
Scott James Remnant853cc772006-08-16 13:34:51 +01006431 * TODO: Update.
6432
Scott James Remnantfdb82592006-08-16 13:31:49 +01006433 * init/job.c (job_start): Check for dependencies before starting
6434 the process, if we have any that aren't running we stay in waiting
6435 until they are. Any that aren't even starting get poked with a
6436 dependency event to see whether that wakes them up.
6437 * init/tests/test_job.c (test_start): Test paths through new
6438 dependency code.
6439
Scott James Remnant278150a2006-08-16 12:56:34 +01006440 * init/job.c (job_run_process): Once we've got an active process
6441 in the running state, release our dependencies.
6442
Scott James Remnant6d4104d2006-08-16 12:50:39 +01006443 * init/job.c (job_release_depends): Function to release any waiting
6444 dependencies on the given job.
6445 * init/job.h: Update.
6446 * init/tests/test_job.c (test_release_depends): Test the behaviour
6447 of the function on its own.
6448
Scott James Remnant1da1dad2006-08-16 12:18:50 +01006449 * init/job.h (Job): Add depends list field
6450 (JobName): New structure to hold the name of a job.
6451 * init/job.c (job_new): Initialise the depends list.
6452 * init/tests/test_job.c (test_new): Make sure the depends list is
6453 initialised properly.
6454
Scott James Remnant37eee032006-08-16 12:10:49 +01006455 * init/job.c (job_next_state): Return JOB_STARTING if we're in
6456 JOB_WAITING and the goal is JOB_START. This is only called when
6457 there's some change, and I don't want to hard-code the goal there.
6458 (job_start): Don't hardcode JOB_STARTING, instead just use the next
6459 state.
6460 * init/tests/test_job.c (test_next_state): Adjust test case.
6461
Scott James Remnantc3d3ead2006-08-16 09:00:50 +01006462 * init/control.c (control_subscribe): Allow the current
6463 subscription to be found by passing NOTIFY_NONE.
6464 (control_handle): Don't remove an existing subscription to jobs,
6465 a GUI will probably want a permanent one to keep the status up to
6466 date.
6467
Scott James Remnantb9a568c2006-08-16 08:57:46 +01006468 * init/job.c (job_kill_process, job_kill_timer): Don't hardcode
6469 JOB_STOPPING here, instead move to the next logical state.
6470 (job_kill_process): Notify subscribed processes that we killed
6471 the job.
6472 (job_start, job_stop): Notify subscribed processes of a change of
6473 goal that doesn't result in an immediate state change.
6474
Scott James Remnant8dbc6012006-08-16 08:57:38 +01006475 * init/event.c (event_trigger_edge, event_trigger_level): Swap
6476 order so that events are announced before processed.
6477
Scott James Remnant28161252006-08-16 08:41:48 +01006478 * init/control.c (control_handle): Handle requests to watch and
6479 unwatch jobs and events.
6480 * init/tests/test_control.c (test_cb_child, test_cb): Check that
6481 subscriptions work.
6482
Scott James Remnantb6d55bf2006-08-16 08:24:16 +01006483 * init/tests/test_control.c (test_cb_child): Add a sleep to avoid
6484 a race that upsets gdb, have tried this with a STOP/CONT interlock
6485 but can't seem to find where the child should reach first.
6486
Scott James Remnant5612b232006-08-16 08:21:06 +01006487 * init/job.c (job_change_state): Notify the control handler.
6488 * init/event.c (event_trigger_edge, event_trigger_level): Pass
6489 event to the control handler.
6490 * init/tests/test_control.c (test_cb_child): Expect to receive
6491 job status events as well.
6492 * init/Makefile.am (test_event_LDADD, test_process_LDADD)
6493 (test_job_LDADD): Add control.o to the linkage.
6494
Scott James Remnant9e0626a2006-08-16 08:17:07 +01006495 * init/control.c (control_cb): Don't display an error for
6496 ECONNREFUSED, just remove any subscriptions.
6497 * init/tests/test_control.c (test_handle_job, test_handle_error):
6498 Clean up our subscriptions properly.
6499
Scott James Remnant3c465c82006-08-16 07:40:24 +01006500 * init/control.c (control_handle_job): Function to send out an
6501 UPSTART_JOB_STATUS message to subscribed processes whenever a
6502 job state changes.
6503 (control_handle_event): Function to send out an
6504 UPSTART_EVENT_TRIGGERED message to subscribed processes whenever
6505 an event is triggered.
6506 * init/control.h: Update.
6507 * init/tests/test_control.c (test_handle_job, test_handle_event):
6508 Check that the functions work properly.
6509
Scott James Remnant16dadc52006-08-16 07:27:40 +01006510 * init/control.c (control_handle): Handle messages that trigger
6511 edge and level events; subscribe the process to receive notification
6512 of job changes during the event.
6513 * init/tests/test_control.c (test_cb_child): Check that the messages
6514 are handled properly (without subscription check).
6515
Scott James Remnanta7ba72a2006-08-16 07:11:30 +01006516 * init/control.c (control_cb): Unsubscribe a process if it stops
6517 listening.
6518
Scott James Remnant2c9669c2006-08-16 07:10:05 +01006519 * init/control.c (control_send): Copy the pointers in the new
6520 event messages.
6521 * init/tests/test_control.c (test_send): Check the pointers are
6522 copied across correctly.
6523
Scott James Remnant15d61c62006-08-16 06:55:58 +01006524 * init/control.c (control_subscribe): Add function to handle
6525 processes that want to subscribe to changes.
6526 (control_init): Initialise the subscriptions list.
6527 * init/control.h: Add structures and prototypes.
6528 * init/tests/test_control.c (test_subscribe): Test the function.
6529
Scott James Remnant8692f762006-08-16 06:21:13 +01006530 * upstart/control.h (UpstartMsgType): add messages for triggering
6531 edge and level events, receiving the trigger for an event and for
6532 watching jobs and events.
6533 (UpstartEventTriggerEdgeMsg, UpstartEventTriggerLevelMsg)
6534 (UpstartEventTriggeredMsg, UpstartWatchJobsMsg)
6535 (UpstartUnwatchJobsMsg, UpstartWatchEventsMsg):
6536 (UpstartUnwatchEventsMsg): Add structures for the new messages.
6537 (UpstartMsg): And add them to the union.
6538 * upstart/control.c (WireEventPayload): The event messages can all
6539 share a wire payload type; the watch messages don't need any special
6540 payload.
6541 (upstart_send_msg_to): Add the payloads onto the wire.
6542 (upstart_recv_msg): And take the payloads back off the wire.
6543 * upstart/tests/test_control.c (test_messages): Test the new
6544 message types.
6545
Scott James Remnant8ed97eb2006-08-16 05:46:44 +01006546 * upstart/control.h (UpstartJobStatusMsg): add a process id.
6547 * upstart/control.c (WireJobStatusPayload): and here too.
6548 (upstart_send_msg_to): copy the process id onto the wire.
6549 (upstart_recv_msg): copy the process id from the wire.
6550 * init/control.c (control_handle): Fill in the pid from the job.
6551 * upstart/tests/test_control.c (test_messages): Check the pid gets
6552 passed across the wire properly.
6553
Scott James Remnant7d914312006-08-16 05:37:50 +01006554 * init/control.c (control_cb): Disable the poll for write once the
6555 send queue becomes empty.
6556
Scott James Remnant59707c22006-08-16 05:32:20 +01006557 * upstart/Makefile.am (libupstart_la_SOURCES): Correct ordering.
6558
Scott James Remnanta98c8b82006-08-16 05:32:02 +01006559 * init/control.c (control_handle): Add missing break.
6560
Scott James Remnantb5c7a302006-08-16 05:24:55 +01006561 * upstart/job.c (job_goal_name, process_state_name): For completeness
6562 add these two functions as well.
6563 * upstart/job.h: Update.
6564 * upstart/tests/test_job.c (test_goal_name)
6565 (test_process_state_name): Test the new functions.
6566
Scott James Remnant20b15ad2006-08-16 05:20:02 +01006567 * init/job.c (job_state_name): Move this utility function from here
6568 * upstart/job.c (job_state_name): to here so all clients can use
6569 it.
6570 * init/job.h: Update.
6571 * upstart/job.h: Update.
6572 * init/tests/test_job.c (test_state_name): Move the test case from here
6573 * upstart/tests/test_job.c: to here as well.
6574 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link job.c
6575 (TESTS): Run the job test cases
6576 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for
6577 job test case binary.
6578 * init/Makefile.am (test_job_LDADD, test_process_LDADD)
6579 (test_event_LDADD): Link to libupstart.la
6580
Scott James Remnant7a5c6672006-08-16 05:01:13 +01006581 * init/control.c: Code to handle the server end of the control
6582 socket, a bit more complex than a client as we want to avoid
6583 blocking on malcious clients.
6584 * init/control.h: Prototypes.
6585 * init/tests/test_control.c: Test the control code.
6586 * init/Makefile.am (init_SOURCES): Build and link control.c
6587 using the control.h header
6588 (init_LDADD): Link to libupstart as well
6589 (TESTS): Build and run the control test suite.
6590 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
6591 Details for control test suite binary.
6592
Scott James Remnantb7cbda52006-08-16 04:53:38 +01006593 * upstart/control.c: Add a way to disable the safety checks.
6594 * upstart/tests/test_control.c (test_free): Fix bad test case.
6595
Scott James Remnant71d4d842006-08-16 04:29:21 +01006596 * upstart/control.c (upstart_recv_msg): fixed bogus return type
6597 for recvmsg from size_t to ssize_t so we don't infiniloop on error.
6598
Scott James Remnant2bda3832006-08-16 03:41:10 +01006599 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Avoid
6600 job_start as the short-cut for assigning name, as that might become
6601 a more complex message eventually. Use job_query instead.
6602
Scott James Remnantd154b952006-08-16 03:39:35 +01006603 * upstart/control.c (upstart_free): Add wrapper function around
6604 nih_free so we're a proper library and don't expose libnih too much
6605 (upstart_recv_msg): Stash the sender pid in an argument.
6606 * upstart/control.h: Update.
6607 * upstart/tests/test_control.c (test_recv_msg): Test pid is
6608 returned properly.
6609 (test_free): Test the nih_free wrapper.
6610
Scott James Remnantdc0eb442006-08-16 02:40:29 +01006611 * init/job.c (job_run_script): Document future FIXME.
6612
Scott James Remnant2f558532006-08-16 02:24:55 +01006613 * init/exent.h, init/job.h, init/process.h: Fix up headers.
6614
Scott James Remnant45aab692006-08-16 02:23:27 +01006615 * upstart/control.c, upstart/control.h, upstart/errors.h,
6616 upstart/job.h, upstart/libupstart.h: Fix up headers.
6617
Scott James Remnant8c16cc82006-08-16 02:13:40 +01006618 * upstart/control.c: Write the code to handle the control socket
6619 and communication over it; turns out this was possible to write so
6620 that both ends are handled in the same code.
6621 * upstart/control.h: Structures and prototypes.
6622 * upstart/tests/test_control.c: Test the new code.
6623
Scott James Remnant729d9222006-08-16 02:12:23 +01006624 * upstart/Makefile.am (libupstart_la_LIBADD): Link to libnih
6625
Scott James Remnantb9814432006-08-16 02:11:51 +01006626 * upstart/errors.h: Header file containing errors raised by
6627 libupstart.
6628 * upstart/libupstart.h: Include errors.h
6629
Scott James Remnant342451a2006-08-15 00:08:20 +010066302006-08-15 Scott James Remnant <scott@netsplit.com>
6631
Scott James Remnant0a8e3472006-08-15 23:54:14 +01006632 * init/event.h: Add missing attribute for event_new()
6633
Scott James Remnant6f128872006-08-15 23:54:05 +01006634 * init/job.h (JobGoal, JobState, ProcessState, ConsoleType): Move
6635 the enums from here
6636 * upstart/job.h: into here so that we can use them across the
6637 control socket.
6638
Scott James Remnante5831792006-08-15 21:46:21 +01006639 * Makefile.am (SUBDIRS): Build the libupstart library
6640 * configure.ac (AC_CONFIG_FILES): Generate upstart/Makefile
6641 * upstart/Makefile.am: Makefile for sub-directory
6642 * upstart/libupstart.ver: Linker version script.
6643 * upstart/libupstart.h: "Include everything" header file.
6644
Scott James Remnant26a8eec2006-08-15 05:46:27 +01006645 * TODO: Update.
6646
Scott James Remnant1f8619c2006-08-15 05:45:38 +01006647 * init/job.c (job_handle_child): Warn when processes are killed
6648 or exit with an abnormal status. Warn when respawning.
6649
Scott James Remnanteb5ad272006-08-15 05:43:05 +01006650 * init/job.c (job_handle_child): Respawn processes that were not
6651 supposed to have died.
6652 * init/tests/test_job.c (test_handle_child): Test the respawn code.
6653
Scott James Remnant77c926d2006-08-15 05:22:08 +01006654 * TODO: Update.
6655
Scott James Remnant429cd672006-08-15 05:09:51 +01006656 * init/event.c (event_trigger_edge, event_trigger_level): Call
6657 job_handle_event so that we actually do something useful.
6658 * init/Makefile.am (test_event_LDADD): Link to process.o and job.o
6659 now that event.c calls code from job.
6660
Scott James Remnant355e1b62006-08-15 05:07:24 +01006661 * init/job.c (job_start_event): Function to start a job if an event
6662 matches.
6663 (job_stop_event): Function to stop a job if an event matches.
6664 (job_handle_event): Iterate the job list and dispatch the given event,
6665 causing jobs to be stopped or started using the above two functions.
6666 * init/job.h: Update.
6667 * init/tests/test_job.c: Test the new functions.
6668
Scott James Remnant923400d2006-08-15 04:27:44 +01006669 * init/job.c (job_new): Initialise start_events and stop_events to
6670 an empty list.
6671 * init/job.h (Job): Add start_events and stop_events list heads.
6672 * init/tests/test_job.c (test_new): Check the lists are initialised
6673 correctly to the empty list.
6674
Scott James Remnant865534f2006-08-15 04:22:06 +01006675 * init/event.c (event_match): Function to check events for equality.
6676 * init/event.h: Update.
6677 * init/tests/test_event.c (test_match): Test function.
6678
Scott James Remnant97137a72006-08-15 04:07:08 +01006679 * init/job.c (job_change_state): Trigger the level event with the
6680 same name as the job, with the value taken from the state.
6681 * init/tests/test_job.c (test_change_state): Check the event
6682 gets set to the right values as we go.
6683 * init/Makefile.am (test_job_LDADD, test_process_LDADD): Link to
6684 event.o now that job.c uses code from there.
6685
Scott James Remnant3b35a522006-08-15 04:01:32 +01006686 * init/event.c (event_change_value): Rename event_set_value to this
6687 as we intended in the first place; makes it more consistent with job.
6688 Always change the value.
6689 (event_trigger_edge): Add a high-level function to trigger an edge
6690 event.
6691 (event_trigger_level): And another to trigger a level event with
6692 a given value, this inherits the "don't change it" functionality
6693 that was in event_set_value.
6694 * init/event.h: Update.
6695 * init/tests/test_event.c: Test new behaviours and functions.
6696
Scott James Remnant4fef0732006-08-15 01:45:02 +01006697 * init/event.c: Add simple code to keep track of events, whether
6698 they have been recorded or not and their current value if any.
6699 * init/event.h: Structures and prototypes.
6700 * init/tests/test_event.c: Test cases for event code.
6701 * init/Makefile.am (init_SOURCES): Build and link event.c using event.h
6702 (TESTS): Run the event test suite.
6703 (test_event_SOURCES, test_event_LDFLAGS, test_event_LDADD): Details
6704 for event test suite binary.
6705
Scott James Remnant38fc8ff2006-08-15 00:43:26 +01006706 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
6707 Downgrade error messages to warning as they're not fatal.
6708 (job_change_state): Change info message to be more regular.
6709
Scott James Remnantf033fb02006-08-15 00:37:33 +01006710 * init/job.c (job_start): A very simple, but very necessary, function.
6711 Set the goal of the given job to JOB_START and kick it off.
6712 (job_stop): And its companion, cause a running job to be stopped.
6713 * init/job.h: Update.
6714 * init/tests/test_job.c: Test the functions.
6715
Scott James Remnant342451a2006-08-15 00:08:20 +01006716 * init/job.c (job_handle_child): Child handler to kick jobs into
6717 the next state when their process dies.
6718 * init/job.h: Update.
6719 * init/tests/test_job.c (test_handle_child): Test the handler
6720 directly by just invoking it with various job states.
6721
Scott James Remnant1c463b92006-08-14 14:46:17 +010067222006-08-14 Scott James Remnant <scott@netsplit.com>
6723
Scott James Remnant51c827d2006-08-14 23:06:00 +01006724 * init/tests/test_process.c (test_kill): Use select rather than
6725 poll for consistency with other test cases.
6726
Scott James Remnante6e4a732006-08-14 23:04:53 +01006727 * init/job.c (job_kill_process): Add function to send the active
6728 process of a job the TERM signal, and then set a timer to follow
6729 up with the KILL signal if the job doesn't get cleaned up in time.
6730 (job_kill_timer): Timer callback to send the KILL signal; this
6731 does the same job as the child handler and puts the job into the
6732 next state as there's no point waiting around now.
6733 * init/job.h: Update.
6734 * init/tests/test_job.c (test_kill_process): Test both functions
6735 in one test case (as one is just the bottom half of the other).
6736
Scott James Remnant6868f652006-08-14 21:42:45 +01006737 * init/tests/test_process.c (test_spawn): Use the right thing in
6738 the test case filename and unlink it to make sure.
6739
Scott James Remnant85df9422006-08-14 21:41:39 +01006740 * init/job.c (job_change_state): Write the principal state gate
6741 function, called once a state has been left to enter the given new
6742 state (which one should determine with job_next_state). Spawns
6743 the necessary processes or moves to the next appropriate state.
6744 * init/job.h: Update.
6745 * init/tests/test_job.c: Test the state changes.
6746
Scott James Remnantba44b8b2006-08-14 20:06:28 +01006747 * init/job.c (job_run_process): Internal function to call
6748 process_spawn and update the job structure.
6749 (job_run_command): Simple(ish) wrapper for the above to split
6750 a command by whitespace, or use a shell if it needs more complex
6751 argument processing.
6752 (job_run_script): More complex wrapper that uses a shell to execute
6753 verbatim script, either using -c or a /dev/fd/NN and feeding the
6754 shell down a pipe to it.
6755 * init/job.h: Update.
6756 * init/tests/test_job.c: Test the new functions.
6757
Scott James Remnant156f5482006-08-14 19:09:55 +01006758 * init/Makefile.am (init_SOURCES, TESTS): Reorder so that process.c,
6759 which is arguably lower level, comes first.
6760 (test_job_LDADD): Link the process code.
6761 (test_process_LDADD): Swap the order.
6762
Scott James Remnant00bcc932006-08-14 19:07:28 +01006763 * TODO: Update.
6764
Scott James Remnant1c463b92006-08-14 14:46:17 +01006765 * init/process.c (process_spawn): Correct typo (progress -> process),
6766 thanks Johan.
6767
Scott James Remnant43534ca2006-08-12 14:52:01 +010067682006-08-12 Scott James Remnant <scott@netsplit.com>
6769
Scott James Remnant3030cc22006-08-12 15:18:55 +01006770 * init/process.c (process_spawn): Correct formatting of function.
6771 * init/process.h (SHELL): Define the location of the shell, all in
6772 the spirit of not hard-coding stuff like this.
6773
Scott James Remnant43534ca2006-08-12 14:52:01 +01006774 * init/job.c (job_new): Initialise all structure members to zero
6775 as this doesn't happen automatically.
6776
Scott James Remnant60b03e32006-08-10 00:59:00 +010067772006-08-10 Scott James Remnant <scott@netsplit.com>
6778
6779 * init/job.h (job_state_name): Declare as a const function.
6780
Scott James Remnant143a8572006-08-09 17:37:00 +010067812006-08-09 Scott James Remnant <scott@netsplit.com>
6782
Scott James Remnantd945d2e2006-08-09 23:47:44 +01006783 * init/job.c (job_next_state): State transition logic; this uses
6784 our departure from the specification (the goal) so that the state
6785 can always be currently accurate rather than suggestive.
6786 (job_state_name): Cute function to convert enum into a name.
6787 * init/job.h: Update.
6788 * init/tests/test_job.c (test_next_state): Test the transitions.
6789 (test_state_name): And the return values.
6790
Scott James Remnant5fa15672006-08-09 23:23:17 +01006791 * TODO: Add file to keep track of things.
6792
Scott James Remnantdbc78612006-08-09 23:22:45 +01006793 * init/job.c: Include nih/macros.h and nih/list.h
6794 * init/process.c: Include order fixing, include nih/macros.h
6795 * init/tests/test_job.c: Include nih/macros.h and nih/list.h
6796 * init/tests/test_process.c: Include nih/list.h
6797
Scott James Remnant03853ed2006-08-09 23:11:59 +01006798 * init/job.c: Include order fixing.
6799 (job_find_by_name): Function to find a job by its (unique) name.
6800 (job_find_by_pid): Function to find a job by the pid of its process.
6801 * init/job.h: Update.
6802 * init/tests/test_job.c (test_find_by_name, test_find_by_pid): Test
6803 new functions.
6804
Scott James Remnant143a8572006-08-09 17:37:00 +01006805 * init/process.c (process_spawn): Spawn a process using the job
6806 details to set up the environment, etc.
6807 (process_setup_console): Set up the console according to the job.
6808 (process_setup_limits): Set up the limits according to the job.
6809 (process_setup_environment): Set up the environment according to
6810 the job.
6811 (process_kill): Simple function to send a kill signal or raise an
6812 error; mostly just a wrapper without any particular logic.
6813 * init/process.h: Prototypes and macros.
6814 * init/tests/test_process.c: Test cases.
6815 * init/Makefile.am (init_SOURCES): Build and link process.c and
6816 its header file.
6817 (TESTS): Run the process test suite.
6818 (test_process_SOURCES, test_process_LDFLAGS, test_process_LDADD):
6819 Details for process test sutie binary.
6820
Scott James Remnant29abda02006-08-08 15:01:24 +010068212006-08-08 Scott James Remnant <scott@netsplit.com>
6822
Scott James Remnant31ee2632006-08-08 15:06:02 +01006823 * init/job.c (job_new): nih_list_free is necessary.
6824 * init/tests/test_job.c (test_new): Free job when done.
6825
Scott James Remnant29abda02006-08-08 15:01:24 +01006826 * init/job.h: Header file to contain the definition of the Job
6827 structure and associated typedefs, etc.
6828 (JobGoal): In a divergence from the specification, we introduced a
6829 "goal" for a job which tells us which way round the state machine
6830 we're going (towards start, or towards stop).
6831 (JobState): Which means this always holds the current state, even
6832 if we're trying to get out of this state (ie. if we've sent the TERM
6833 signal to the running process, we're still in the running state until
6834 it's actually been reaped).
6835 (ProcessState): And in another divergence, we keep the state of the
6836 process so we know whether we need to force a state transition or
6837 can just expect one because something transient is happening.
6838 * init/job.c (job_new): Function to allocate a Job structure, set
6839 the pointers to NULL and other important members to sensible
6840 defaults.
6841 (job_init): Initialise the list of jobs.
6842 * init/tests/test_job.c: Test suite.
6843 * init/Makefile.am (init_SOURCES): Compile and link job.c using
6844 its header file.
6845 (TESTS): Run the job test suite.
6846 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for the
6847 job test suite binary.
6848
Scott James Remnantb933bc92006-08-02 02:29:25 +010068492006-08-02 Scott James Remnant <scott@netsplit.com>
6850
Scott James Remnant6c7667a2006-08-02 02:43:12 +01006851 * configure.ac: Check for C99
6852
Scott James Remnantb933bc92006-08-02 02:29:25 +01006853 * HACKING: Document dependency on libnih.
6854
Scott James Remnanta780d6c2006-07-27 18:40:51 +010068552006-07-27 Scott James Remnant <scott@netsplit.com>
6856
6857 * init/Makefile.am (DEFS): Append to the default DEFS list, rather
6858 than overriding, otherwise we lose HAVE_CONFIG_H
6859
Scott James Remnantb6270dd2006-07-13 02:16:38 +010068602006-07-13 Scott James Remnant <scott@netsplit.com>
6861
Scott James Remnant1bb35142006-07-13 02:30:58 +01006862 * HACKING: Correct incorrect Bazaar URL.
6863
Scott James Remnantb6270dd2006-07-13 02:16:38 +01006864 * AUTHORS: Change e-mail address to ubuntu.com.
6865 * HACKING: Update Bazaar and Release URLS.
6866 * configure.ac (AC_COPYRIGHT): Change copyright to Canonical Ltd.
6867 (AC_INIT): Change bug submission address to Launchpad.
6868 * init/main.c: Update header to use Canonical copyright and
6869 credit me as author.
6870
Scott James Remnant50748842006-05-16 21:02:31 +010068712006-05-16 Scott James Remnant <scott@netsplit.com>
6872
6873 * init/main.c: Add the simplest template main.c
6874 * init/Makefile.am: Add template Makefile.am that builds init from
6875 main.c and links to libnih statically
6876 * configure.ac (AC_CONFIG_FILES): Configure nih and init subdirs.
6877 * Makefile.am (SUBDIRS): Recurse into nih and init subdirs.
6878
Scott James Remnant8a0cd072006-05-14 18:28:58 +010068792006-05-14 Scott James Remnant <scott@netsplit.com>
6880
6881 * ChangeLog: Initial project infrastructure created.