blob: e3a3acbe5b89ebd81c997e069b3a72d18c635ca1 [file] [log] [blame]
Scott James Remnantbc1ebc02007-03-01 12:27:09 +000012007-03-01 Scott James Remnant <scott@netsplit.com>
2
Scott James Remnant75914fd2007-03-01 19:05:45 +00003 * util/jobs.c (handle_job_status): Drop the process field from the
4 output for now.
5 * util/events.c (handle_event_job_status): Likewise
6 * util/tests/test_jobs.c (test_start_action, test_list_action)
7 (test_jobs_action): Drop pid from messages we simulate.
8 * util/tests/test_events.c (test_emit_action): Likewise.
9
Scott James Remnant0c68cc12007-03-01 18:53:23 +000010 * upstart/message.c (upstart_message_new, upstart_message_handle):
11 Remove the pid field from the job status and event job status
12 messages.
13 * upstart/message.h: Update description of job status and event
14 job status message to remove the pid field.
15 * upstart/tests/test_message.c (test_new, my_handler)
16 (test_handle): Remove checks using the pid field.
17
Scott James Remnantd134fe82007-03-01 18:46:53 +000018 * init/control.c (control_job_start, control_job_stop)
19 (control_job_query, control_job_list): Remove the pid field from
20 the messages, it'll come back later when we get better message
21 formats.
22 * init/tests/test_control.c (check_job_status, check_job_waiting)
23 (check_job_started, check_job_stopped): Remove checks on the process
24 id, since that field is gone from the message.
25 (test_job_stop): Use the pid field of the main process.
26 (test_job_start): Initialise the main action process.
27
Scott James Remnantdd1a6742007-03-01 18:42:42 +000028 * init/notify.c (notify_job, notify_job_event): Remove the pid field
29 from the message, it'll come back later when we get better message
30 formats.
31 * init/tests/test_notify.c (check_job_status)
32 (check_event_job_status): Remove checks on the pid, since that field
33 is no longer present.
34
Scott James Remnante2ce6372007-03-01 18:37:53 +000035 * init/job.c (job_process_copy): Use job_process_new here, oops.
36
Scott James Remnant8ed70e42007-03-01 18:34:37 +000037 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
38 (cfg_stanza_pre_start, cfg_stanza_post_start)
39 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Use job_process_new
40 to allocate process structures and store in the process array.
41 * init/tests/test_cfgfile.c (test_read_job, test_stanza_exec)
42 (test_stanza_script, test_stanza_pre_start)
43 (test_stanza_post_start, test_stanza_pre_stop)
44 (test_stanza_post_stop): Update test cases to use process array
45 member information.
46
Scott James Remnant42479f92007-03-01 18:12:34 +000047 * init/tests/test_event.c (test_poll): Update to use newer job process
48 array and find the pid under there.
49
Scott James Remnantc8f15ac2007-03-01 18:03:22 +000050 * init/job.h (Job): Remove the pid and aux_pid fields; replace the
51 individual JobProcess pointers with an array of them of a fixed
52 minimum size; replace failed_state with failed_process.
53 (JobProcess): add a pid field here, so now we can obtain the pid on
54 an individual process/action basis rather than global.
55 * init/job.c (job_process_new): Function to create a JobProcess
56 structure, setting the initial values to FALSE/NULL/0.
57 (job_process_copy): Function to copy a JobProcess.
58 (job_new): Don't initialise the pid or aux_pid members, initialise
59 the process array to a fixed initial size and set the members to NULL,
60 initialise the failed_process member to -1.
61 (job_copy): Update to use job_process_copy and copy the process array.
62 (job_find_by_pid): Look through the process structures in the job's
63 process array to find the pid, and optionally return which action it
64 was.
65 (job_change_state): Call job_kill_process in the JOB_KILLED state if
66 we have a main process and that has a pid, pass in the main process.
67 (job_next_state): Check the process id of the main process when
68 deciding what the next state is for running.
69 (job_run_process): Store the process id in the process structure
70 (job_kill_process): Accept a process structure and use that to obtain
71 the process id we need to send TERM too. Remove the code that forced
72 a state change if kill() failed, since we will get a child signal
73 anyway and should do it there.
74 (job_kill_timer): Likewise, accept a process structure and don't
75 forcibly change the state anymore.
76 (job_child_reaper): Rewrite to switch based on the action that died,
77 rather than the state we were in; assert that the state is what we
78 expected.
79 (job_emit_event): The argument to the failed event is now the action
80 name, rather than the state name; an action of -1 indicates that
81 respawn failed.
82 * init/tests/test_job.c (test_process_new, test_process_copy): Make
83 sure the structure is created and copied properly.
84 (test_new, test_copy): Drop checks on the pid and aux_pid members,
85 add checks for the process array and pid members of processes.
86 (test_find_by_pid): Update test case to make sure we can find the pid
87 of any process, returning the action index rather than the process
88 pointer.
89 (test_run_process, test_kill_process, test_change_goal)
90 (test_change_state, test_next_state, test_child_reaper): Update test
91 cases to use pid fields inside process structures rather than the
92 pid or aux_pid members.
93 (test_handle_event, test_handle_event_finished)
94 (test_free_deleted): Update to avoid pid field checks.
95
Scott James Remnant4652e3b2007-03-01 16:25:56 +000096 * upstart/enum.h (JobAction): Enumeration of different actions.
97 * upstart/enum.c (job_action_name, job_action_from_name): Enumeration
98 to string conversion functions.
99 * upstart/tests/test_enum.c (test_action_name)
100 (test_action_from_name): Tests for the new functions.
101
Scott James Remnantdc9d7902007-03-01 12:57:37 +0000102 * init/cfgfile.c (cfg_read_job): Instead of trying to copy over an
103 old job's state and instances into the new one, mark the old job
104 as deleted. This ensures we never end up applying a new post-stop
105 script to a job started with an old pre-start script, etc. It also
106 makes life so much simpler.
107 * init/tests/test_cfgfile.c (test_read_job): Update tests to make
108 sure the old job is marked for deletion, instead of freed.
109 * TODO: Update.
110
Scott James Remnant26a41cf2007-03-01 12:50:10 +0000111 * init/notify.c (notify_job): Split out notification to processes
112 subscribed to the cause event into a new function
113 (notify_job_event): We can call this when we change cause.
114 * init/job.c (job_change_state): Notify anyone subscribed to the
115 job after we've changed the state, rather than before, otherwise
116 we won't know the new pids or anything.
117 (job_change_cause): Call notify_job_event before changing the cause
118 so that subscribers get a final status update.
119 * init/tests/test_notify.c (test_job_event): Check the new function.
120 * TODO: Update.
121
Scott James Remnantbc1ebc02007-03-01 12:27:09 +0000122 * init/cfgfile.c (cfg_stanza_respawn): Remove the shortcut that
123 lets you specify "respawn COMMAND". It was confusing as it hid
124 the common "[when] exec"/"[when] script" syntax, made it non-obvious
125 that "exec" and "respawn" were the same flag, etc.
126 * init/tests/test_cfgfile.c (test_stanza_respawn): Update tests.
127 (test_stanza_service): Fix test case to not use shortcut.
128 * logd/event.d/logd.in: Update to not use respawn shortcut.
129
Scott James Remnantb1f34052007-02-25 09:12:53 +00001302007-02-25 Scott James Remnant <scott@netsplit.com>
131
Scott James Remnant43d8f092007-02-25 12:56:37 +0000132 * init/job.c (job_child_reaper): Shift the signal value into the
133 higher byte to make it easier to detect, and not stamp over exit
134 statuses between 128 and 255.
135 (job_emit_event): Detect the signal stored in the new way.
136 * init/cfgfile.c (cfg_stanza_normal): Store signal in the higher bytes.
137 * init/tests/test_job.c (test_copy, test_change_state)
138 (test_child_reaper): Update test cases.
139 * init/tests/test_cfgfile.c (test_stanza_normal): Update test.
140
Scott James Remnant8a77b5d2007-02-25 11:45:47 +0000141 * TODO: Update.
142
Scott James Remnant2c950692007-02-25 09:13:38 +0000143 * init/event.h (PWRSTATUS_EVENT): Add new power-status-changed event.
144 * init/main.c (pwd_handler): Handle the SIGPWR signal by generating
145 the new event, leave it up to a job to parse the file and do
146 whatever it likes.
147
Scott James Remnantb1f34052007-02-25 09:12:53 +0000148 * TODO: Update.
149
Scott James Remnant7e3ad172007-02-13 15:53:39 +00001502007-02-13 Scott James Remnant <scott@netsplit.com>
151
152 * upstart/tests/test_message.c (test_reader, test_handle_using)
153 (test_handle); Usual fix for gcc optimiser thinking that fixed
154 for loops might not be.
155 * init/tests/test_job.c (test_run_process, test_kill_process):
156 Likewise.
157 * init/tests/test_notify.c (test_subscription_find): I still don't
158 know what a type-punned pointer is, nor why dereferencing such a
159 thing would break strict-aliasing rules.
160 * init/tests/test_cfgfile.c (test_read_job): More type-punning.
161 * util/tests/test_jobs.c (test_start_action): More for-loop action.
162 * util/tests/test_events.c (test_emit_action): And again.
163
Scott James Remnant5c89c502007-02-11 14:08:19 +00001642007-02-11 Scott James Remnant <scott@netsplit.com>
165
Scott James Remnant17305e12007-02-11 18:20:19 +0000166 * init/job.c (job_change_goal): We need to be able to stop a running
167 job without a process, because that's what a job-as-state is! The
168 check was added because job_child_reaper calls job_change_goal and
169 then job_change_state immediately after, we should fix that instead.
170 (job_child_reaper): If we call job_change_goal while in the running
171 state, it will call job_change_state for us; so check for that first
172 and don't change the state!
173 * init/tests/test_job.c (test_change_goal): Update the test to ensure
174 that we can stop a job with no running process.
175
Scott James Remnantddda5f92007-02-11 14:18:00 +0000176 * init/cfgfile.c (cfg_stanza_normalexit): normalexit is inconsistent,
177 change to "normal exit"
178 * init/tests/test_cfgfile.c (test_stanza_normalexit): Update.
179
Scott James Remnant5c89c502007-02-11 14:08:19 +0000180 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
181 (cfg_stanza_pre_start, cfg_stanza_post_start)
182 (cfg_stanza_pre_stop, cfg_stanza_post_stop, cfg_stanza_respawn):
183 We're not going to allow stanza keywords to be quoted, since this
184 gives us an easy way to allow users to make something explicitly
185 not a keyword.
186
Scott James Remnant5dd50e32007-02-10 00:44:44 +00001872007-02-10 Scott James Remnant <scott@netsplit.com>
188
Scott James Remnant9675c072007-02-10 21:36:48 +0000189 * configure.ac: Bump version to 0.3.6
190
Scott James Remnant4e977172007-02-10 21:24:29 +0000191 * configure.ac: Increase version to 0.3.5
192 * NEWS: Update.
193 * TODO: Update.
194
Scott James Remnanta2f0a542007-02-10 18:07:26 +0000195 * TODO: More notes.
196
Scott James Remnant78456a52007-02-10 17:46:21 +0000197 * TODO: Note an issue with using JobProcess->pid
198
Scott James Remnantd11d0fd2007-02-10 17:45:17 +0000199 * init/cfgfile.c (cfg_stanza_pre_start, cfg_stanza_post_start)
200 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Add a needed check
201 for a token when parsing "exec". Correct line number we expect
202 to see the duplicated value on. Correct expected error for missing
203 argument from "Unexpected token" to "Expected token".
204
205 * init/tests/test_cfgfile.c (main): Actually invoke the tests for
206 the scripts.
207
Scott James Remnant2ebe37b2007-02-10 17:35:33 +0000208 * init/cfgfile.c (cfg_read_job): Correct type of lineno in error.
209
Scott James Remnant178f3a62007-02-10 17:34:02 +0000210 * TOOD: Minor notify bug
211
Scott James Remnante72695c2007-02-10 17:11:26 +0000212 * TODO: Big update.
213
Scott James Remnant743c1c12007-02-10 16:49:17 +0000214 * init/tests/test_job.c (test_child_reaper): Make sure that we can
215 reap post-start and pre-stop processes, and have only the aux_pid
216 changed. Also make sure that if the running process dies while
217 in these states, with or without an aux process, that we don't
218 transition badly.
219
Scott James Remnanta54bfd02007-02-10 14:33:32 +0000220 * init/job.c (job_find_by_pid): Check aux_pid as well.
221 * init/tests/test_job.c (test_find_by_pid): Make sure we can find it.
222
Scott James Remnant153e3b52007-02-10 14:15:47 +0000223 * init/job.h (Job): Add an auxiliary pid member.
224 * init/job.c (job_new): Initialise the aux_pid member.
225 (job_change_state): Run the post-start and pre-stop scripts when we
226 enter the state with the same name (assuming they exist).
227 (job_run_process): Store the pid in aux_pid when starting the
228 post-start or pre-stop processes.
229 * init/tests/test_job.c (test_change_state): Add tests for running
230 the new post-start and pre-stop scripts; which get their process ids
231 stored in aux_pid instead of pid.
232 (test_new): Make sure the aux_pid member is initialised properly.
233 (test_copy): Make sure the aux_pid member is not copied.
234
235 * TODO: Update.
236
Scott James Remnantf415d8d2007-02-10 13:55:04 +0000237 * init/tests/test_job.c (test_change_state): Add a check for the
238 daemon stanza holding the job in spawned; we snuck this in a while
239 back and never tested it (there's no support to get it out of
240 spawned yet).
241
Scott James Remnante9332be2007-02-10 13:46:50 +0000242 * init/job.h (Job): Add new post_start and pre_stop scripts.
243 * init/job.c (job_new): Initialise new scripts to NULL.
244 (job_copy): Copy the information from the new scripts over as well.
245 * init/tests/test_job.c (test_new): Check they're initialised.
246 (test_copy): Check that the information is copied properly.
247 * init/cfgfile.c (cfg_stanza_post_start, cfg_stanza_pre_stop): Add
248 new script stanza functions for the additional two scripts that
249 we want.
250 * init/tests/test_cfgfile.c (test_stanza_post_start)
251 (test_stanza_pre_stop): Add tests for the new stanzas.
252
Scott James Remnant5dd50e32007-02-10 00:44:44 +0000253 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script): Rewrite to
254 allocate a JobProcess and parse the command or script into it.
255 (cfg_read_job): Fix the long broken assumption that pid_file and
256 pid_binary are required for respawn, when they're actually required
257 for daemon.
258 (cfg_stanza_start, cfg_stanza_stop): Remove script second-level.
259 (cfg_stanza_respawn): Parse into the job's process.
260 (cfg_stanza_pre_start, cfg_stanza_post_stop): New stanzas for the
261 processes alone.
262 * init/tests/test_cfgfile.c (test_read_job): Update a few test
263 cases to match reality.
264 (test_stanza_start, test_stanza_stop): Remove script-related checks.
265
Scott James Remnante885d552007-02-09 00:01:46 +00002662007-02-09 Scott James Remnant <scott@netsplit.com>
267
Scott James Remnant315a80a2007-02-09 22:50:00 +0000268 * init/tests/test_job.c (test_kill_process): Poll the event queue
269 after each test to get rid of the allocated events and make valgrind
270 happy.
271 * init/tests/test_control.c (test_job_start, test_job_stop)
272 (test_event_emit): Poll the event queue after each test to get rid
273 of the allocated events, as they make valgrind complain.
274 (test_event_emit): Free args and env when done.
275
Scott James Remnant1ada0e22007-02-09 22:40:51 +0000276 * init/job.h (JobName): Drop obsolete structure
277 (JobProcess): Add a new structure to represent a single process
278 within the job, instead of using two variables to pick either the
279 script or command.
280 (Job): Change command and script to a single JobProcess called process;
281 change start_script and stop_script to a JobProcess called pre_start
282 and post_stop respectively.
283 * init/job.c (job_new): Initialise new members to NULL.
284 (job_copy): Copy the process structures across, including contents.
285 (job_change_state): Call job_run_process passing in the structure;
286 rather than fiddling with if statements.
287 (job_run_script, job_run_command, job_run_process): Combine all of
288 these three functions into a single new job_run_process function.
289 * init/tests/test_job.c (test_new, test_copy, test_change_goal)
290 (test_change_state, test_child_reaper)
291 (test_handle_event_finished): Change to using JobProcess for when
292 we need to construct a command.
293 (test_run_script, test_run_command): Merge into single new
294 (test_run_process) function.
295 * init/tests/test_event.c (test_poll): Replace command with process.
296 * init/tests/test_control.c (test_job_start): Change to using
297 JobProcess to specify the command.
298
Scott James Remnantc6740472007-02-09 21:16:28 +0000299 * init/main.c (main): Run job_free_deleted each time through the
300 main loop.
301
Scott James Remnantcb468602007-02-09 21:13:16 +0000302 * init/job.c (job_change_goal): Minor tweak to the logic; we may
303 have just made the job an instance, that should still let us stop
304 the one underneath.
305
Scott James Remnant3fbdda72007-02-09 21:12:10 +0000306 * TODO: Update.
307
Scott James Remnantdde96ff2007-02-09 21:10:45 +0000308 * util/jobs.c (do_job): Always expect a list of replies.
309
Scott James Remnantf9409952007-02-09 21:02:18 +0000310 * init/control.c (control_job_status, control_job_stop)
311 (control_job_query): Reply with information about all instances of
312 the job.
313 * init/tests/test_control.c (test_job_status, test_job_stop)
314 (test_job_query): Make sure we get the list end even for a single job;
315 and make sure we get details of all instances attached to the job.
316
Scott James Remnant6cfc8ab2007-02-09 20:34:37 +0000317 * init/tests/test_job.c (test_change_goal): Check that starting
318 an instance job actually starts a new instance of it.
319
Scott James Remnant87c46472007-02-09 20:05:32 +0000320 * init/cfgfile.c (cfg_stanza_limit): Support the word "unlimited" in
321 limit arguments for both the soft and hard values.
322 * init/tests/test_cfgfile.c (test_stanza_limit): Make sure that we
323 can make limits be unlimited.
324
Scott James Remnant22ac92f2007-02-09 19:39:42 +0000325 * init/event.c (event_copy): Function to copy an event structure.
326 * init/event.h: Add prototype.
327 * init/tests/test_event.c (test_copy): Make sure we copy the event
328 correctly, with or without arguments and/or environment.
329 * init/job.c (job_copy): Function to copy a job structure, leaving
330 the state as it is.
331 * init/job.h: Add prototype.
332 * init/tests/test_job.c (test_copy): Make sure that we copy the
333 job details whether they are NULL or non-NULL, but don't copy the
334 state.
335 * init/init.supp: Update supression.
Scott James Remnant099ece22007-02-09 18:13:51 +0000336 * init/job.c (job_find_by_name): If we get a job that's an instance,
337 return what it's an instance of.
338 * init/tests/test_job.c (test_find_by_name): Restore accidentally
339 deleted test function; test that we get the real job, not an instance.
340
Scott James Remnant99e3ecc2007-02-09 18:08:45 +0000341 * init/job.c (job_new): instance_of is initialised to NULL.
342 * init/job.h: Add a new instance_of pointer, pointing to the parent
343 that we're an instance of.
344 * init/tests/test_job.c (test_new): Check that.
345 * init/tests/test_cfgfile.c (test_read_job): Make sure instance_of
346 pointers are updated.
347
Scott James Remnant4513fae2007-02-09 17:52:32 +0000348 * init/job.c (jobs): Store jobs in a hash table.
349 (job_new): Add to hash table, not to a list.
350 (job_handle_event, job_handle_event_finished, job_detect_stalled)
351 (job_free_deleted): Iterate across the hash table, rather than list.
352 (job_find_by_name): Use nih_hash_lookup, we keep this function because
353 we'll add "is instance or not" smarts soon!
354 (job_find_by_pid): Iterate across the entire hash table.
355 * init/tests/test_job.c (test_find_by_name): Drop test since this
356 function is now gone.
357 (test_free_deleted): Can't assume things are in a line now.
358 * init/control.c (control_job_list): Iterate the hash table.
359
Scott James Remnant3f9624c2007-02-09 17:16:07 +0000360 * init/event.c: Don't hide the events list anymore
361 * init/event.h: Publish it and the init function.
362 * init/job.c: Don't hide the jobs list anymore.
363 (job_list): Since we don't hide it, we can drop this.
364 * init/job.h: Publish it and the init function.
365 * init/notify.c: Don't hide the subscriptions list anymore.
366 * init/notify.h: Publish it and the init function.
367 * init/control.c (control_job_list): Iterate the job list directly
368 * init/tests/test_control.c (test_event_emit): Use the events list
369 available to us.
370 * init/tests/test_event.c (test_poll): Call job_init directly and
371 just use the events list available to us.
372 * init/tests/test_job.c (test_new): Call job_init directly.
373 (test_change_state): Use the events list available to us.
374 * init/tests/test_notify.c (test_unsubscribe): Use the subscriptions
375 list available to us.
376
Scott James Remnant9709a8d2007-02-09 16:08:21 +0000377 * doc/states.dot: Add updated state graph.
378 * doc/Makefile.am (EXTRA_DIST): Ship the states diagram.
379 (states.png): Include rules to build the png, we'll put it in bzr
380 anyway, but this is useful.
381
Scott James Remnant92b01602007-02-09 15:46:55 +0000382 * init/cfgfile.c (cfg_delete_handler): Handle deleted jobs; mark
383 the job as deleted, and if it's dormant, invoke a state change.
384
Scott James Remnant9c0215a2007-02-09 15:42:20 +0000385 * upstart/enum.h: Add a new JOB_DELETED state.
386 * upstart/enum.c (job_state_name, job_state_from_name): Add the new
387 state to the string functions.
388 * upstart/tests/test_enum.c (test_state_name)
389 (test_state_from_name): Check the enum works.
390 * init/job.c (job_change_goal): New decision; we can start a waiting
391 job if it's marked delete (it might be a new instance) -- we'll use
392 the new deleted state to decide that we shouldn't.
393 (job_change_state): Once we reach waiting, if the job is to be deleted,
394 move to the next state.
395 (job_next_state): The next state for a waiting job if the goal is stop
396 is deleted. We should never call job_next_state () for a deleted job.
397 (job_free_deleted): Very simple function, just detects
398 deleted jobs and frees them.
399 * init/job.h: Add prototype for new function.
400 * init/tests/test_job.c (test_change_goal): Update test to use new
401 deleted state; and don't even change the goal.
402 (test_change_state): Add a check to make sure we end up in deleted.
403 (test_next_state): Make sure waiting goes to deleted.
404 (test_free_deleted): Check the function.
405
Scott James Remnant07dd5db2007-02-09 15:20:25 +0000406 * init/job.c (job_change_goal): Don't try and start a job if it's
407 marked to be deleted and is just waiting for cleanup.
408 * init/tests/test_job.c (test_change_state): Make sure that the cause
409 is released when we reach waiting.
410
Scott James Remnanta1ade132007-02-09 15:07:30 +0000411 * init/tests/test_cfgfile.c (test_read_job): Make sure that a deleted
412 job gets resurrected.
413
Scott James Remnant25873b52007-02-09 13:35:43 +0000414 * init/cfgfile.c (cfg_visitor): Correct number of arguments and call
415 to cfg_job_name.
416
Scott James Remnant3b5daf62007-02-09 13:31:01 +0000417 * TODO: Update.
418
Scott James Remnant845c6cb2007-02-09 13:29:27 +0000419 * init/cfgfile.c (cfg_stanza_daemon): Don't allow arguments anymore.
420 * init/tests/test_cfgfile.c (test_stanza_daemon): Update tests.
421
Scott James Remnant1cdc1632007-02-09 13:26:09 +0000422 * init/job.c (job_handle_event_finished): Function to unblock all
423 jobs blocked on a given event emission.
424 (job_new, job_emit_event): Rename blocker to blocked; it's useful for
425 testing for truth.
426 * init/job.h: Add prototype, rename member.
427 * init/tests/test_job.c (test_handle_event_finished): Test it.
428 (test_new, test_change_state): Update name here too.
429 * init/event.c (event_finished): Call job_handle_event_finished
430 function to unblock jobs.
431 * init/tests/test_event.c (test_poll): Make sure the job gets
432 unblocked; a few other tests have to change since running event_poll
433 always unblocks the job if nothing listens to it.
434
Scott James Remnantba5ebb02007-02-09 04:46:39 +0000435 * init/job.c (job_child_reaper): Set failed back to FALSE if
436 we're respawning, since we don't want to be failing.
437 * init/tests/test_job.c (test_child_reaper): cause will be NULL.
438 also free and poll events when done.
439 (test_handle_event): pid can never be -1
440 (test_change_state): poll events when done
441
Scott James Remnantfd0cc552007-02-09 04:39:36 +0000442 * init/tests/test_job.c (test_child_reaper): Process will always
443 be zero on return from reaper.
444
Scott James Remnantef11ca42007-02-09 04:37:24 +0000445 * init/tests/test_job.c (test_child_reaper): Killed doesn't go past
446 stopping; it goes to waiting, which will clear the cause.
447
Scott James Remnanta5034982007-02-09 04:36:12 +0000448 * init/tests/test_job.c (test_child_reaper): Fill in values before
449 we test against them.
450
Scott James Remnantda1ae312007-02-09 04:35:33 +0000451 * init/tests/test_job.c (test_kill_process): Fix violated assertion
452
Scott James Remnant011e4ae2007-02-09 04:35:00 +0000453 * init/tests/test_job.c (test_change_state): This should be failed
454 because nothing cleared it.
455
Scott James Remnant4f4ea832007-02-09 04:33:50 +0000456 * init/tests/test_job.c (test_change_state): Fix a couple of array
457 index problems.
458
Scott James Remnantaf9b63f2007-02-09 04:32:50 +0000459 * init/tests/test_job.c (test_change_state): Why set that which
460 does not change?
461
Scott James Remnantfcc51902007-02-09 04:30:43 +0000462 * init/tests/test_job.c (test_change_state): Add newline to test.
463
Scott James Remnant5f936192007-02-09 04:29:54 +0000464 * init/job.c (job_emit_event): Add the job name as an argument;
465 oops.
466
Scott James Remnantf89b1612007-02-09 04:28:09 +0000467 * init/tests/test_control.c (test_job_stop): Need to kill the process
468 ourselves, as we're blocked on an event.
469 (test_job_query): Fix wrong value in test.
470 (check_job_stopped, test_job_stop, test_unwatch_jobs): Change job
471 name to match the test.
472
Scott James Remnant7178e722007-02-09 04:22:04 +0000473 * init/job.c (job_change_state): Must only not enter some states
474 with no process now; others like killed actually usually want one!
475
Scott James Remnant851a05c2007-02-09 04:18:20 +0000476 * init/tests/test_cfgfile.c (test_read_job): Fix test case.
477
Scott James Remnant6c088782007-02-09 04:13:43 +0000478 * init/tests/test_job.c (test_handle_event): Clean up tests.
479 (test_detect_stalled): Clean up.
480
Scott James Remnantbfcb6162007-02-09 04:08:53 +0000481 * init/job.c (job_child_reaper): Update the reaping of the child
482 processes; there's a much larger state range for the main process
483 now, so that needs to be taken into account.
484 * init/tests/test_job.c (test_child_reaper): New test cases.
485
Scott James Remnantd7ac93f2007-02-09 03:39:00 +0000486 * init/job.c (job_next_state): Encapsulate the slightly odd three
487 exit states of running in this function, otherwise we'll end up
488 special-casing it in places I'd rather not think about.
489 (job_change_goal): Only change the state of a running job if it
490 has a process.
491 * init/tests/test_job.c (test_next_state): Add a test case for the
492 dead running job
493 (test_change_goal): Add test case for the dead running job
494
Scott James Remnantd285b832007-02-09 02:49:06 +0000495 * init/tests/test_job.c (test_change_state): Add test cases for
496 the forgotten stopping to killed transition.
497
Scott James Remnant999fc9a2007-02-09 02:44:25 +0000498 * init/job.c (job_kill_process, job_kill_timer): Just check the pid
499 and state, and no longer any need to notify jobs since we're just
500 called from one state amongst many.
501 (job_change_state): Skip over the killed state if there's no process.
502 * init/tests/test_job.c (test_kill_process): Update test cases.
503
Scott James Remnantad011612007-02-09 02:34:03 +0000504 * init/job.c (job_run_process): Simplify a little bit, no need to
505 do the state assertions here, just make sure there's no already
506 a process running.
507 * init/tests/test_job.c (test_run_command, test_run_script): Run
508 tests in the spawned state, since that's where we run the primary
509 command or script. Drop check for process state since that's no
510 longer set.
511
Scott James Remnant8bd1b042007-02-09 02:27:40 +0000512 * init/job.c (job_change_state, job_next_state): Ok, here's the big
513 one ... rewrite this to use the new state transitions. This has
514 suddenly got a lot simpler and easier to read, this was definitely a
515 good idea.
516 (job_emit_event): Function to make emission of events easier.
517 (job_failed_event): replaces this one which wasn't so easy.
518 * init/tests/test_job.c (test_change_state): I can't say how much I
519 wasn't looking forwards to rewriting these test cases; anyway, it's
520 done now and I hope they're all right;
521 (test_next_state): Make sure the state transitions are correct too.
522
Scott James Remnant6aee3782007-02-09 00:45:29 +0000523 * init/job.h: Rename is_instance to delete and spawns_instance to
524 just instance.
525 * init/job.c (job_new): Update.
526 * init/tests/test_job.c (test_new): Update.
527 * init/cfgfile.c (cfg_stanza_instance): Update.
528 * init/tests/test_cfgfile.c (test_stanza_instance): Update.
529
Scott James Remnant535c6902007-02-09 00:43:03 +0000530 * init/event.h: Correct the event names.
531
Scott James Remnante2edac92007-02-09 00:39:24 +0000532 * init/job.h: Add blocker event member.
533 * init/job.c (job_new): Initialise it to NULL.
534 * init/tests/test_job.c (test_new): Check it.
535
Scott James Remnante885d552007-02-09 00:01:46 +0000536 * init/job.c (job_change_goal): Have a stab at this function with the
537 new state machine; it gets somewhat simpler (until we introduce the
538 second scripts), now we just induce things by a state change.
539 * init/tests/test_job.c (test_change_goal): Made easier (for now)
540 because we don't need to deal with processes and can just wait to
541 be blocked on an event.
542
Scott James Remnant9e13a242007-02-08 00:24:21 +00005432007-02-08 Scott James Remnant <scott@netsplit.com>
544
Scott James Remnant5e469e42007-02-08 23:49:01 +0000545 * init/cfgfile.c (cfg_read_job): Drop check for useless respawn script
546 (cfg_stanza_respawn): Drop handling of "respawn script"
547 * init/tests/test_cfgfile.c (test_stanza_respawn): Drop the checks
548 for "respawn script"
549
Scott James Remnant4fdf7552007-02-08 23:45:34 +0000550 * init/job.h: Move things about a bit more; remove respawn_script
551 since that state is going away.
552 * init/job.c (job_new): Drop initialisation of process_state.
553 * init/tests/test_job.c (test_new): Improve the tests.
554
Scott James Remnant3856c632007-02-08 23:29:17 +0000555 * init/main.c (STATE_FD): Remove this define, not used anymore.
556
Scott James Remnantbc281c32007-02-08 23:25:33 +0000557 * init/tests/test_event.c (test_poll): Update the event checking
558 to match what's likely to happen.
559
Scott James Remnant049b50f2007-02-08 23:23:29 +0000560 * init/event.h: Remove commented out bit.
561
Scott James Remnant1abebfd2007-02-08 23:20:02 +0000562 * init/tests/test_notify.c (check_job_status, test_job): Correct
563 state usage to match a possible state.
564
Scott James Remnant64bc2a82007-02-08 22:59:46 +0000565 * init/control.c (control_job_start, control_job_stop)
566 (control_job_query, control_job_list): Drop process state and
567 description from the job status messages we send back.
568 * init/tests/test_control.c (test_error_handler)
569 (check_job_started, test_job_start, check_job_stopped)
570 (check_job_stopping, test_job_query, check_job_starting)
571 (test_job_list, test_watch_jobs, test_unwatch_jobs): Remove
572 process_state and description, and update usage of job states.
573
Scott James Remnantcb178f82007-02-08 22:47:42 +0000574 * init/notify.c (notify_job): Don't include process state or
575 description in the job status message anymore.
576 * init/tests/test_notify.c (check_job_status, test_job): Update tests
577
Scott James Remnant79cd4bf2007-02-08 22:44:46 +0000578 * init/cfgfile.c (cfg_read_job): Drop the copying of the process_state
579 member, since it doesn't exist anymore.
580 * init/tests/test_cfgfile.c (test_read_job): Drop the check too.
581
Scott James Remnant6f0ff592007-02-08 22:43:04 +0000582 * init/job.h (Job): Drop the process_state member.
583
Scott James Remnant56a1fa82007-02-08 22:40:01 +0000584 * util/jobs.c (handle_job_status): Drop the process_state and
585 description arguments; output a process id only if it's greater
586 than zero.
587 * util/tests/test_jobs.c (test_start_action, test_list_action)
588 (test_jobs_action): Update tests to use newer states and arguments.
589 * util/events.c (handle_event_job_status): Simplify in the same way
590
Scott James Remnantac0c88b2007-02-08 22:31:00 +0000591 * upstart/message.h: Remove process_state and description from the
592 job status event (we already had the foresight to not put them in
593 the event job status event).
594 * upstart/message.c (upstart_message_new, upstart_message_handle):
595 Update handling of the messages to reduce the arguments.
596 * upstart/tests/test_message.c (test_new, my_handler)
597 (test_handle): Update the tests for the new job status message.
598
Scott James Remnante76986a2007-02-08 22:21:22 +0000599 * upstart/enum.h (JobState): Change the job states to the new set
600 of states that we've planned.
601 (ProcessState): Drop process state entirely; this information is now
602 contained in the single JobState field.
603 * upstart/enum.c (job_state_name, job_state_from_name): Update
604 strings to match the new state names.
605 (process_state_name, process_state_from_name): Drop these functions.
606 * upstart/tests/test_enum.c (test_state_name)
607 (test_state_from_name): Update test cases to match new names.
608 (test_process_state_name, test_process_state_from_name): Drop.
609
Scott James Remnant08100e02007-02-08 17:57:21 +0000610 * init/main.c (main): Remove the logd hack for now.
611 * init/job.c (job_new): Change the default console to none for now.
612 * init/tests/test_job.c (test_new): Update test.
613 * init/cfgfile.c (cfg_stanza_console): Can't guard against duplicates
614 for a while.
615 * init/tests/test_cfgfile.c (test_stanza_console): Comment out dup test
616
Scott James Remnantf247adf2007-02-08 15:23:43 +0000617 * init/cfgfile.c (cfg_read_job): Remove the restriction that there
618 must be either an 'exec' or 'script' for a job; jobs without either
619 define states others can use.
620 * init/tests/test_cfgfile.c (test_read_job): Convert the test to
621 a "must work".
622 * init/job.c (job_change_state): Remove restriction that we must
623 have either a script or a command; having neither should just wedge
624 the job at the running rest state. Note that there's no way to get
625 it out yet, because we don't force that particular state change.
626 * init/tests/test_job.c (test_change_state): Make sure that works.
627
Scott James Remnant920d65b2007-02-08 13:49:53 +0000628 * init/job.c (job_change_cause): Put the knowledge about how to
629 change the cause into a separate function, since it's slightly
630 tricky.
631 (job_change_goal, job_change_state): Set the cause using the above
632 function.
633
Scott James Remnanta3bcac12007-02-08 13:40:53 +0000634 * init/job.h (Job): Rename goal_event to cause, also shuffle things
635 around so that the state is mostly together.
636 * init/job.c, init/process.c, init/notify.c, init/cfgfile.c: Update
637 references (and comments) to match the new name.
638 * init/tests/test_job.c, init/tests/test_event.c,
639 init/tests/test_process.c, init/tests/test_cfgfile.c,
640 init/tests/test_notify.c: Likewise.
641
Scott James Remnantef119832007-02-08 13:24:16 +0000642 * init/job.c (job_child_reaper): Don't change the goal event; the
643 state changes will handle this.
644 (job_change_goal): Only dereference/reference the goal event if we're
645 actually changing it.
646 * init/tests/test_job.c (test_change_state, test_child_reaper):
647 Update tests to not assume that the goal event gets changed.
648 (test_kill_process): Eliminate race condition.
649
Scott James Remnant93376ef2007-02-08 12:53:53 +0000650 * init/job.c (job_child_reaper): Correct some problems with job and
651 event failure; we now don't overwrite an existing failure record,
652 and don't record failure if the main process failed and the goal was
653 stop; since we likely caused it.
654 * init/tests/test_job.c (test_child_reaper): More test cases.
655
Scott James Remnantc3db81c2007-02-08 12:38:19 +0000656 * logd/event.d/logd.in: Stop on the new runlevel events, not the
657 shutdown event.
658
Scott James Remnante8d263c2007-02-08 03:20:30 +0000659 * compat/sysv/shutdown.c (shutdown_now): Emit an ordinary runlevel
660 change event now; including the INIT_HALT environment variable
661 * compat/sysv/man/shutdown.8: Update the manual
662
Scott James Remnant52360ea2007-02-08 03:06:40 +0000663 * compat/sysv/telinit.c: Now just sends out a runlevel event with
664 an argument giving the new runlevel.
665 * compat/sysv/man/telinit.8: Update description of the command.
666
Scott James Remnant8662bd02007-02-08 02:57:56 +0000667 * upstart/message.h: Remove the UPSTART_SHUTDOWN message.
668 * upstart/message.c (upstart_message_new, upstart_message_handle):
669 Remove handling for the shutdown message.
670 * upstart/tests/test_message.c (test_new, test_handle): Remove
671 tests against the shutdown message.
672 * init/control.c (control_shutdown): Remove the shutdown command
673 from the server.
674 * init/tests/test_control.c (test_shutdown): Remove tests for it.
675 * init/event.h: Remove the shutdown event.
676 * util/initctl.c: Remove the shutdown command reference.
677 * util/events.c (shutdown_action): Remove the command.
678 * util/events.h: Update.
679 * util/tests/test_events.c (test_shutdown_action): Remove tests.
680
Scott James Remnant65906602007-02-08 02:51:39 +0000681 * init/job.c (job_detect_idle): Rename to job_detect_stalled
682 (job_detect_stalled): Remove the idle state detection
683 (job_set_idle_event): Idle event has been removed.
684 * init/job.h: Update.
685 * init/tests/test_job.c (test_detect_idle): Rename to
686 (test_detect_stalled): and remove idle detection tests.
687 * init/main.c (main): Replace job_detect_idle with job_detect_stalled
688 * init/control.c (control_shutdown): Don't set the idle event.
689 * init/tests/test_control.c (test_shutdown): Don't detect the idle
690 event (and thus the second event)
691
Scott James Remnantb0d99d52007-02-08 02:40:43 +0000692 * init/cfgfile.c (cfg_stanza_service): Parser for service stanza.
693 * init/tests/test_cfgfile.c (test_stanza_service): Test the service
694 stanza.
695 (test_stanza_respawn): Check that respawn implies service.
696 * TODO: Update.
697
698 * init/job.h (Job): Add a new service member.
699 * init/job.c (job_new): Service starts off as false.
700 (job_change_state): Check service instead of respawn.
701 * init/tests/test_job.c (test_change_state): Check with service
702 instead of respawn, since that's what we really mean.
703
Scott James Remnante4ab75c2007-02-08 02:28:19 +0000704 * init/cfgfile.c (cfg_read_job): Copy a whole bunch more state
705 into the newly parsed job.
706 * init/job.c (job_run_process): Only output the first error.
707 * init/tests/test_cfgfile.c (test_read_job): Make sure important
708 things are copied.
709 * TODO: Update.
710
Scott James Remnantdb31c152007-02-08 02:05:38 +0000711 * init/main.c: Restore a much simplified version of the term
712 handler that doesn't try and copy across any state.
713
Scott James Remnant517f5552007-02-08 02:02:52 +0000714 * compat/sysv/telinit.c: Update call to event_emit; we'll revisit
715 this shortly when we get rid of the shutdown event.
716
Scott James Remnant1dc0de52007-02-08 01:57:34 +0000717 * util/events.c (handle_event): Add new id field (but ignore it)
718 Functio
719 (handle_event_job_status): New function to handle the new event.
720 (handle_event_finished): Function to handle the end of the event.
721 (emit_action): Send the newer event, and loop over replies until
722 we get a finished one.
723 * util/tests/test_events.c (test_emit_action): Update tests cases.
724
Scott James Remnantd9520172007-02-08 01:18:24 +0000725 * init/control.c (control_event_emit): New function to handle the
726 new-style emit message.
727 * init/tests/test_control.c (test_event_emit): Make sure the new
728 message function behaves.
729
Scott James Remnantb3e539e2007-02-08 01:10:12 +0000730 * init/event.c, init/job.c, init/main.c, init/tests/test_event.c,
731 init/tests/test_job.c: Completely drop the serialisation code, it's
732 getting out of date and in the way.
733
Scott James Remnant71b91fc2007-02-08 01:07:56 +0000734 * init/event.h: Remove compatibility macros.
735 (EventEmission): Drop the callback function; it was too error prone
736 to try and do it this way, and we only ever wanted to release a job
737 anyway as control requests are better handled through the notify
738 interface.
739 (EventEmissionCb): Drop unused typedef.
740 * init/event.c (event_emit): Drop callback argument.
741 (event_finished): Don't call the callback
742 * init/tests/test_event.c: Update to avoid callbacks.
743 * init/job.c (job_change_state): Convert to using event_emit and
744 EventEmission.
745 (job_detect_idle): Drop extra arguments to event_emit.
746 * init/main.c (main, cad_handler, kbd_handler): Drop extra arguments
747 to event_emit.
748 * init/control.c (control_shutdown): Use event_emit instead of
749 event_queue.
750 * init/tests/test_control.c (test_shutdown): Convert to using
751 EventEmission.
752 (test_watch_events, test_unwatch_events): Drop extra arguments to
753 event_emit.
754 * init/tests/test_notify.c (test_subscribe_event, test_job)
755 (test_event, test_event_finished): Drop extra arguments to event_emit
756 * init/tests/test_job.c (test_change_goal, test_change_state)
757 (test_run_script, test_child_reaper, test_detect_idle): Drop
758 extra arguments to event_emit.
759 * init/tests/test_process.c (test_spawn): Drop extra arguments to
760 event_emit.
761
Scott James Remnantf082fc42007-02-08 00:50:11 +0000762 * TODO: Update.
763
Scott James Remnant716f75c2007-02-08 00:49:40 +0000764 Rewrite the notification subsystem quite significantly; now we
765 have individual functions to subscribe to different types of
766 notification, and can even subscribe to individual jobs or events.
767
768 * init/notify.c (notify_subscribe_job, notify_subscribe_event)
769 (notify_unsubscribe): New subscription and unsubscription functions
770 that assume one record per subscription, not process.
771 (notify_subscription_find): Function to find a subscription.
772 (notify_job): Send a message to anything subscribed to the goal event
773 as well.
774 (notify_event): Use EventEmission and include the id in the event.
775 (notify_event_finished): New function, sends a finished message and
776 includes both the id and whether the event failed.
777 * init/notify.h (NotifySubscribe): New notify structure that is
778 once per subscription, rather than per-process; and allows
779 subscription to individual jobs or events.
780 * init/tests/test_notify.c (test_subscribe_job)
781 (test_subscribe_event, test_unsubscribe): Test the new subscription
782 functions, replacing the old
783 (test_subscribe): tests.
784 (test_subscription_find): Check finding works
785 (check_event, test_event): Update to use emissions, and check that the
786 id is correct.
787 (test_event_finished): Check this one works too
788 (check_event_job_status, test_job): Make sure processes subscribed
789 via the goal event are notified too.
790 * init/event.c (event_pending): Pass the emission directly.
791 (event_finished): Notify subscribers that the event has finished.
792 * init/control.c (control_error_handler): Call notify_unsubscribe
793 (control_watch_jobs, control_unwatch_jobs, control_watch_events)
794 (control_unwatch_events): Update to the new subscription API.
795 * init/tests/test_control.c (test_error_handler): Use new API
796 (test_watch_jobs, test_unwatch_jobs, test_watch_events)
797 (test_unwatch_events): Also update these to the new API; use a
798 destructor to make sure the subscription is freed.
799
Scott James Remnant9e13a242007-02-08 00:24:21 +0000800 * init/tests/test_process.c: Don't use printf, use TEST_FUNCTION
801
Scott James Remnante627ad42007-02-07 00:23:57 +00008022007-02-07 Scott James Remnant <scott@netsplit.com>
803
Scott James Remnant459aee32007-02-07 22:44:08 +0000804 * upstart/message.h: Allocate new grouped event messages.
805 * upstart/message.c (upstart_message_new, upstart_message_handle):
806 Add support for the new grouped event messages.
807 * upstart/tests/test_message.c (test_new, test_handle)
808 (my_handler): Make sure the new messages are passed correctly.
809
Scott James Remnant1d792152007-02-07 20:56:01 +0000810 * init/job.c (job_change_state): Clear the goal event whenever we
811 reach the final rest state of a job (waiting for all jobs, running
812 for services).
813 * init/tests/test_job.c (test_change_state): Check that the goal
814 event goes away at the right times.
815 * TODO: Update.
816
Scott James Remnantab17ab92007-02-07 20:38:01 +0000817 * init/tests/test_job.c (test_child_reaper): Make sure that the
818 event is marked failed properly
819
Scott James Remnant6d007b82007-02-07 20:21:54 +0000820 * init/job.c (job_start_event, job_stop_event): There's no reason
821 for these to exist as seperate functions anymore, especially since
822 we want to eventually have some kind of match table.
823 (job_handle_event): Perform the iterations and match calls here
824 instead, since we just call job_change_goal now.
825 * init/job.h: Remove prototypes.
826 * init/tests/test_job.c (test_start_event, test_stop_event): Fold into
827 (test_handle_event): which now handles all the cases.
828
Scott James Remnant269b7b92007-02-07 20:04:42 +0000829 * init/job.c (job_detect_idle): Call event_emit
830 * init/main.c (main, cad_handler, kbd_handler): Call event_emit
831 instead of event_queue.
832 * init/tests/test_event.c (test_new): Call event_poll
833 * init/tests/test_job.c (test_change_state, test_child_reaper)
834 (test_detect_idle, test_change_state): Update to use newer event API.
835 * TODO: Update.
836
Scott James Remnant80eabbc2007-02-07 19:54:27 +0000837 * init/job.c (job_start, job_stop): Drop these functions; call
838 job_change_goal instead (which is now public).
839 (job_change_state, job_child_reaper): Call job_change_goal instead.
840 * init/job.h: Update.
841 * init/tests/test_job.c (test_start, test_stop): Merge into new
842 (test_change_goal): function.
843 * init/main.c (main): Call job_change_goal instead of job_start.
844 * init/control.c (control_job_start, control_job_stop): Call
845 job_change_goal instead.
846
Scott James Remnant4522f4d2007-02-07 19:38:19 +0000847 * init/tests/test_job.c (test_new, test_change_state)
Scott James Remnant80eabbc2007-02-07 19:54:27 +0000848 (test_run_script, test_start, test_stop, test_start_event):
Scott James Remnant4522f4d2007-02-07 19:38:19 +0000849
850 * init/job.h (Job): goal_event is now an EventEmission, and is
851 a direct pointer to the one in the events queue, rather than a copy.
852 * init/process.c (process_setup_environment): Reference the event
853 name and environment through the goal event, not directly.
854 * init/job.c (job_run_script): Reference the event name and
855 environment through the goal event, not directly.
856 (job_change_state, job_child_reaper): Replace direct setting of the
857 job goal with a call to job_stop; the process state is always
858 PROCESS_NONE in all three cases, so this is completely safe.
859 (_job_start, _job_stop): Merge these two functions together into
860 (job_change_goal): which behaves a lot more like job_change_state,
861 except that it doesn't loop. This handles the changing of the
862 emission.
863 (job_start, job_start_event, job_stop, job_stop_event): Simplify
864 these functions, now they just call job_change_goal passing in
865 the emission pointer (or NULL).
866
Scott James Remnantb1db7a32007-02-07 16:33:27 +0000867 * init/main.c, init/job.c, init/job.h, init/event.c, init/event.h,
868 init/tests/test_job.c, init/tests/test_event.c: Remove state
869 serialisation code for the time being; maintaining it is getting
870 increasingly harder, and it introduces some major bugs. It will
871 get rewritten shortly.
872
Scott James Remnant4216cc82007-02-07 16:22:47 +0000873 * init/event.c (event_pending): Pass the emission directly to
874 job_handle_event now.
875 * init/job.c (job_handle_event, job_start_event, job_stop_event):
876 Deal with event emissions rather than just plain events, the change
877 so far doesn't do anything else other than take the structure change.
878 * init/job.h: Change prototypes.
879 * init/tests/test_job.c (test_start_event, test_stop_event)
880 (test_handle_event): Update tests to use emissions.
881
Scott James Remnantb2d06d42007-02-07 15:55:33 +0000882 * init/tests/test_event.c (test_read_state, test_write_state): Check
883 the passing of the progress information.
884 * init/event.c (event_read_state, event_write_state): Add progress
885 field to the serialisation (oops).
886
Scott James Remnantab132da2007-02-07 15:48:02 +0000887 * init/event.h: Add missing attribute for event_read_state.
888 * init/cfgfile.h: Add missing attributes.
889 * init/main.c (read_state): Don't discard return value.
890 * TODO: Update.
891
Scott James Remnantfcc9a0d2007-02-07 15:41:57 +0000892 * init/main.c (read_state): Handle the Emission keyword; also handle
893 Event really being an EventEmission.
894 * init/event.c (event_emit): Make the next emission id a static global
895 (event_read_state, event_write_state): Serialise event emission
896 structures, not plain events; also send over the last id we used so
897 it appears seamless. This doesn't yet handle the callback/data bit
898 of the serialisation, which turns out to be a little tricky ... oops
899 * init/event.h: Update.
900 * init/tests/test_event.c (test_read_state, test_write_state): Check
901 that serialisation is done with EventEmissions instead, and all the
902 fields are passed (except callback and data which are ... tricky).
903
Scott James Remnanta39da0f2007-02-07 13:52:42 +0000904 * init/main.c (main): Call event_poll instead of event_queue_run.
905
Scott James Remnante47588c2007-02-07 13:50:01 +0000906 * init/event.c (event_poll): Add the new function that replaces
907 event_queue_run(); handles the new-style event emission structures
908 in the list and only returns when there are no non-handling events.
909 (event_pending, event_finished): Handling of particular event states
910 during poll; split out for readability.
911 (event_queue, event_queue_run): Drop these obsolete functions.
912 (event_read_state): Force type from event_queue.
913 * init/event.h: Add event_poll prototype; remove prototypes of old
914 functions, replacing with #defines for now so things still compile.
915 * init/tests/test_event.c (test_queue): Drop tests.
916 (test_read_state, test_write_state): Force type from event_queue
917 Change type we check size of.
918 (test_poll): Pretty thoroughly test the new poll function.
919 * init/job.c (job_change_state): Force type from event_queue
920 * init/control.c (control_event_queue): Force type from event queue
921 * init/tests/test_job.c (test_detect_idle): Force type from event_queue
922 * init/tests/test_control.c (test_event_queue, test_shutdown):
923 Force type from event_queue
924
Scott James Remnant162c2b22007-02-07 11:32:04 +0000925 * init/event.c: Revert to a single list of events with an enum
926 (event_emit): Set the progress to pending initially.
927 (event_emit_find_by_id): Simplify now it just checks one list
928 (event_emit_finished): Function for jobs to call once they've done
929 with an event; just sets the progress to finished for the event
930 queue to pick up.
931 * init/tests/test_event.c (test_emit_finished): Check it.
932
933 * init/event.h: Add prototype.
934 (EventProgress): Add new enum
935 (EventEmission): And add progress member to this structure
936 * init/tests/test_event.c (test_emit): Make sure the event is pending
937
Scott James Remnantd379a602007-02-07 10:58:06 +0000938 * init/event.c (event_emit_find_by_id): Locate an event emission
939 by its id in either the pending or handling queue.
940 * init/event.h: Add prototype
941 * init/tests/test_event.c (test_emit): Make sure that the emission
942 id is unique each time.
943 (test_emit_find_by_id): Test the function.
944
Scott James Remnant7282c9a2007-02-07 03:14:08 +0000945 * init/event.c (event_emit): New function to replace event_queue();
946 returns an EventEmission structure with the details filled in as
947 given.
948 * init/event.h: Add prototype.
949
Scott James Remnant81cc7942007-02-07 02:54:25 +0000950 * init/event.c (event_init): Rename the single events queue to
951 pending and add a new handling list.
952
953 * init/event.h (EventEmission, EventEmissionCb): Add a new emission
954 structure that wraps an event, for use in the queue.
955
Scott James Remnantd82109e2007-02-07 02:15:39 +0000956 * util/tests/test_events.c (test_events_action): Update test now
957 that nih_message is more sensible.
958 * util/tests/test_jobs.c (test_start_action, test_list_action)
959 (test_jobs_action): Update test
960
Scott James Remnante5d3f012007-02-07 01:59:57 +0000961 * util/events.c (emit_action): Actually pass the emit_env array
962 * util/tests/test_events.c (test_emit_action): Make sure it does.
963
964 * util/initctl.c (main): Catch nih_command_parser() returning a
965 negative value to indicate an internal error, and always exit 1.
966
Scott James Remnant2cb93052007-02-07 01:49:43 +0000967 * util/events.c (handle_event): Build up multiple lines to describe
968 the event, including its arguments and environment.
969 * util/tests/test_events.c (test_events_action): Check the new output
970 format is right.
971
Scott James Remnant685644e2007-02-07 01:29:28 +0000972 * init/main.c (main): Take out inadvertantly leaked debugging code;
973 sorry about that.
974
Scott James Remnant5130e6d2007-02-07 01:18:38 +0000975 * init/job.c (job_child_reaper): Rewrite this to make the logic a
976 little easier to follow, and support signals in normalexit. This
977 also now applies to deciding whether the job failed, if it did, we
978 store that information in the job so the stop and stopped events
979 can get it.
980 * init/tests/test_job.c (test_child_reaper): Add new test cases for
981 the setting of the failed flags.
982
Scott James Remnant18935fe2007-02-07 00:38:13 +0000983 * init/cfgfile.c (cfg_stanza_normalexit): Allow signal names in the
984 arguments, which are added to the normalexit array or'd with 0x80
985 * init/tests/test_cfgfile.c (test_stanza_normalexit): Check that we
986 can now parse signal names correctly.
987
Scott James Remnant326c2312007-02-07 00:31:18 +0000988 * init/job.c (job_failed_event): Change add to addp to fix leak.
989
Scott James Remnante627ad42007-02-07 00:23:57 +0000990 * init/job.c (job_failed_event): Function to turn an event into one
991 that includes all the necessary arguments and environment.
992 (job_change_state): Call job_failed_event for the stop and stopped
993 events (bit hacky at the moment, will improve later).
994 * init/tests/test_job.c (test_change_state): Check that the failed
995 events are generated properly.
996
Scott James Remnant2b2b7d12007-02-06 00:07:28 +00009972007-02-06 Scott James Remnant <scott@netsplit.com>
998
Scott James Remnant038ef4d2007-02-06 23:46:53 +0000999 * init/job.c (job_change_state): Reset the failed member when
1000 we enter the starting state.
1001 * init/tests/test_job.c (test_change_state): Make sure that the
1002 failed member is reset when we enter the starting state.
1003
Scott James Remnantbd7ad1a2007-02-06 23:43:59 +00001004 * init/job.h (Job): Add failed, failed_state and exit_status members.
1005 * init/job.c (job_new): Initialise new members.
1006
Scott James Remnantddbf1162007-02-06 23:40:30 +00001007 * init/job.c (job_child_reaper): Convert signals to names when
1008 outputting status messages.
1009 * init/tests/test_job.c (test_child_reaper): Check that the signal
1010 name gets converted over.
1011
Scott James Remnantf11b7dc2007-02-06 23:03:48 +00001012 * init/event.h (CTRLALTDEL_EVENT): Now we've broken the shared
1013 namespace of events and jobs, rename the control-alt-delete event
1014 back to control-alt-delete.
1015
Scott James Remnant0ef0d392007-02-06 23:00:28 +00001016 * init/job.c (job_change_state): Replace the events generated as
1017 part of the job state, named for the job and state, with new state
1018 events that have the job name as an argument.
1019 * init/event.h: Define new job event names.
1020 * init/tests/test_job.c (test_change_state): Make sure the new
1021 events are correct, with the job name as an argument.
1022
Scott James Remnant1416d052007-02-06 22:42:55 +00001023 * init/job.c (job_change_state): Remove the job event; this has
1024 been repeatedly proved to be confusing.
1025 * init/tests/test_job.c (test_change_state): Remove checks for the
1026 job event.
1027
Scott James Remnant08146b92007-02-06 20:45:38 +00001028 * util/events.c (emit_action): Pass in extra arguments.
1029 (env_option): Function to parse an option given an environment
1030 variable.
1031 * util/events.h: Add prototype.
1032 * util/tests/test_events.c (test_emit_action): Make sure that the
1033 emit action works with no arguments and with arguments.
1034 (test_events_action): Send back events with the right number of args.
1035 (test_env_option): Check the env option parser works.
1036 * util/initctl.c: Give shutdown its own command and options, give
1037 emit a new -e option.
Scott James Remnante8f3ef92007-02-06 20:20:33 +00001038
Scott James Remnant7f69c622007-02-06 20:16:50 +00001039 * util/events.c (shutdown_action): Split out from emit, seeing as
1040 these are going to be different from now on.
1041 * util/events.h: Add prototype.
1042 * util/tests/test_events.c (test_shutdown_action): Copy test cases.
1043
Scott James Remnantca2df742007-02-06 20:13:32 +00001044 * init/control.c (control_event_queue): Take the arguments and
1045 environment from the event queue request; and reparent into the
1046 event.
1047 * init/tests/test_control.c (test_event_queue): Check that arguments
1048 and environment are copied across properly.
1049
Scott James Remnanta30a25f2007-02-06 20:08:22 +00001050 * init/notify.c (notify_event): Pass in the arguments and environment
1051 for the event.
1052 * init/tests/test_notify.c (check_event): Check for event arguments
1053 and environment from the notify process.
1054 (test_event): Add arguments and environment to the event we test with
1055
Scott James Remnantce51bfb2007-02-06 20:04:05 +00001056 * upstart/tests/test_message.c (test_new, test_handle): Send
1057 arguments and environment with the UPSTART_EVENT_QUEUE and
1058 UPSTART_EVENT messages.
1059 * upstart/wire.c (upstart_pop_int, upstart_pop_unsigned): Shrink
1060 only once.
1061 (upstart_pop_string): Check the length is at least one first, as
1062 we may just have an 'S'.
1063
1064 * upstart/message.c (upstart_message_new, upstart_message_handle):
1065 The UPSTART_EVENT and UPSTART_EVENT_QUEUE messages gain new array
1066 arguments containing the arguments and environment for the event.
1067 * upstart/message.h: Document the new arguments.
1068
Scott James Remnantd1a65342007-02-06 19:25:38 +00001069 * util/tests/test_events.c, util/tests/test_jobs.c: Update the
1070 message format checks here too.
1071
Scott James Remnantfb45e432007-02-06 19:07:24 +00001072 * upstart/tests/test_wire.c (test_pop_pack): Free the array.
1073
Scott James Remnanta8882032007-02-06 19:06:44 +00001074 * upstart/tests/test_message.c (test_new, test_handle)
1075 (test_handle_using, test_reader): Update tests to include and
1076 expect new type markers between each field.
1077
Scott James Remnantf9663f02007-02-06 18:58:37 +00001078 * upstart/wire.c (upstart_push_int, upstart_push_unsigned):
1079 Take out silly asserts; it must have room!
1080
Scott James Remnantc874a942007-02-06 18:57:34 +00001081 * upstart/wire.c (upstart_push_string, upstart_pop_string): Rewrite
1082 to use a type like the rest of the functions; this removes the strange
1083 length restriction and allows us to make the pop function
1084 non-destructive.
1085 * upstart/tests/test_wire.c (test_push_string): Update.
1086 (test_pop_string): Update, adding in non-destructive, wrong type
1087 and insufficient space for type test cases.
1088 (test_push_array, test_pop_array): These needed updated too,
1089 changing the string format changed the array format.
1090 (test_push_pack, test_pop_pack): And obviously the pack format changed.
1091
Scott James Remnant9ed52092007-02-06 18:36:51 +00001092 * upstart/wire.c (upstart_pop_header): Make the function
1093 non-destructive in the face of errors.
1094 * upstart/tests/test_wire.c (test_pop_header): Make sure that
1095 invalid headers are non-destructive on error.
1096
Scott James Remnantdc4436f2007-02-06 18:33:27 +00001097 * upstart/tests/test_wire.c (test_pop_int, test_pop_unsigned):
1098 Make sure that insufficient space is non-destructive.
1099
Scott James Remnantafc5b8c2007-02-06 18:32:08 +00001100 * upstart/wire.c (upstart_push_int, upstart_pop_int)
1101 (upstart_push_unsigned, upstart_pop_unsigned): Convert to array-style
1102 type first format.
1103 (upstart_push_string, upstart_push_header): Write the length and
1104 type fields out by hand so they don't get an 'i' prefix.
1105 (upstart_pop_string, upstart_pop_header): Read the length and type
1106 fields by hand so they don't get an 'i' prefix.
1107 * upstart/tests/test_wire.c (test_push_int, test_pop_int)
1108 (test_push_unsigned, test_pop_unsigned): Update test cases to match.
1109 (test_push_pack, test_pop_pack): Pack format was changed too.
1110
Scott James Remnanta63d4862007-02-06 18:10:58 +00001111 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add calls
1112 to push and pop array.
1113 * upstart/tests/test_wire.c (test_push_pack, test_pop_pack): Test
1114 support for arrays.
1115
Scott James Remnant5b6a2022007-02-06 18:00:49 +00001116 * upstart/wire.c (upstart_push_array, upstart_pop_array): Implement
1117 new array functions; note that these use a newer format that allows
1118 us to transmit NULL without needing to limit the size of the array.
1119 * upstart/wire.h: Add prototypes.
1120 * upstart/tests/test_wire.c (test_push_array, test_pop_array):
1121 Test the new array functions.
1122
Scott James Remnantf1d51112007-02-06 16:22:48 +00001123 * init/job.c (job_run_script): Build up the argument list, appending
1124 those from the goal event if one is set.
1125 (job_run_command): Use nih_str_array_add to build up the arguments,
1126 but don't append those from the goal event (use script).
1127 * init/tests/test_job.c (test_run_script): Make sure the arguments get
1128 passed to the running shell scripts.
1129
Scott James Remnant2efe5562007-02-06 15:51:19 +00001130 * init/job.c (job_run_script): Only use the /dev/fd trick if we can
1131 actually stat /dev/fd; also don't hardcode that path ...
1132 * init/paths.h (DEV_FD): Add here.
1133
Scott James Remnantefa8c7e2007-02-06 15:02:23 +00001134 * init/process.c (process_setup_environment): Copy environment
1135 variables from the goal event into the job's process.
1136 * init/tests/test_process.c (test_spawn): Make sure the environment
1137 reaches the job, but doesn't override that in the job already.
1138
1139 * init/tests/test_job.c (test_start_event):
1140
Scott James Remnant0071dd32007-02-06 14:57:37 +00001141 * init/job.c (job_start_event, job_stop_event): Copy the arguments
1142 and environment from the event into the goal event.
1143
Scott James Remnantb3d4dee2007-02-06 14:39:35 +00001144 * init/job.c (job_read_state, job_write_state): Read and write
1145 arguments and environment for goal event.
1146 * init/tests/test_job.c (test_read_state, test_write_state): Test
1147 with arguments and environment to the goal event.
1148
Scott James Remnant4bba9702007-02-06 14:28:10 +00001149 * init/event.c (event_read_state, event_write_state): Read and write
1150 the arguments and environment of the event.
1151 * init/tests/test_event.c (test_read_state, test_write_state): Make
1152 sure arguments and environment are correctly serialised.
1153
Scott James Remnant462e7172007-02-06 13:30:24 +00001154 * init/cfgfile.c (cfg_stanza_console): Fix a leak of the console
1155 argument in the case of duplicated options.
1156 (cfg_stanza_env): Drop the counting now nih_str_array_addp does it;
1157 and be sure to use that function.
1158 (cfg_stanza_umask): Fix leak of umask argument
1159 (cfg_stanza_nice): Fix leak of nice argument
1160 * init/tests/test_event.c (test_new): Call event_queue_run so init
1161 is called outside of a TEST_ALLOC_FAIL block.
1162
Scott James Remnantfd196342007-02-06 13:19:03 +00001163 * init/event.c (event_new): Start off with NULL args and env, to
1164 match job (saves a few bytes).
1165 (event_match): Watch for NULL arguments!
1166 * init/tests/test_event.c (test_new): Check for NULL not alloc'd
1167
Scott James Remnantfc9a76e2007-02-06 13:14:46 +00001168 * init/cfgfile.c (cfg_stanza_on, cfg_stanza_start)
1169 (cfg_stanza_stop): Parse arguments to the on stanza and store them
1170 directly in the event.
1171 * init/tests/test_cfgfile.c (test_stanza_on, test_stanza_start)
1172 (test_stanza_stop): Make sure arguments are parsed into the event.
1173
Scott James Remnant5dd1bc92007-02-06 12:57:50 +00001174 * init/event.c (event_new): Use nih_str_array_new.
1175 * init/cfgfile.c (cfg_stanza_env): Rewrite to use nih_str_array.
1176
Scott James Remnant4d0fc0f2007-02-06 11:34:41 +00001177 * init/job.c (job_run_script): Check the error returned from
1178 nih_io_reopen; don't just loop. We only ever expect ENOMEM (the
1179 other error, EBADF, is impossible).
1180
Scott James Remnanteb8cb142007-02-06 11:31:27 +00001181 * init/job.c (job_change_state): Reset the goal_event to NULL when
1182 we catch a run-away job (as it's not stopping for the same event
1183 it started with).
1184 (job_child_reaper): Reset the goal_event to NULL after setting the
1185 goal to STOP.
1186 * init/tests/test_job.c (test_change_state, test_child_reaper):
1187 Check that the goal event gets reset whenever the goal gets changed.
1188
Scott James Remnant62e22f42007-02-06 02:08:19 +00001189 * init/tests/test_event.c: Use TEST_ALLOC_FAIL
1190
Scott James Remnant93cd4d22007-02-06 02:07:45 +00001191 * init/event.c (event_match): Match arguments using fnmatch() and
1192 allow more arguments in event1 than event2 (but not the other way
1193 around).
1194 * init/tests/test_event.c (test_match): Check the new permitted
1195 combinations.
1196
Scott James Remnant34b7c712007-02-06 01:57:45 +00001197 * init/event.h (Event): Add args and env members to Event.
1198 * init/event.c (event_new): Initialise args and env members to
1199 zero-length arrays.
1200 * init/tests/test_event.c (test_new): Use TEST_ALLOC_FAIL and
1201 make sure args and env are both initialised to a list containing
1202 just NULL.
1203
Scott James Remnantb36c1962007-02-06 01:48:09 +00001204 * util/jobs.c (start_action): Get the UPSTART_JOB environment variable
1205 and use that if we don't have any arguments passed to us.
1206 (do_job): Code split from the above function that handles a named job
1207 * util/tests/test_jobs.c (test_start_action): Make sure UPSTART_JOB
1208 is picked up.
1209
Scott James Remnant2a0b0852007-02-06 01:35:56 +00001210 * init/process.h: Add necessary attributes.
1211
Scott James Remnant0b10d502007-02-06 01:28:01 +00001212 * init/process.c (process_setup_environment): Set the UPSTART_JOB
1213 environment variable from the job, and the UPSTART_EVENT environment
1214 variable from the job's goal_event member (if set).
1215 * init/tests/test_process.c (test_spawn): Make sure we get the
1216 environment in the job.
1217
Scott James Remnantafce5282007-02-06 01:22:54 +00001218 * init/job.h: Add attributes to job_new and job_read_state.
1219 * init/tests/test_job.c: Use CHECK_ALLOC_FAIL on the functions we
1220 didn't get around to touching while we were in here.
1221
Scott James Remnant1b9914d2007-02-06 01:01:11 +00001222 * init/job.c (job_start_event, job_stop_event): Set the goal_event
1223 member to a copy of the event we found.
1224 (job_read_state): Use event_new instead of trying to do it by hand.
1225 * init/tests/test_job.c (test_start_event, test_stop_event): Use
1226 CHECK_ALLOC_FAIL; and make sure the goal_event is set properly.
1227 (test_start, test_stop, test_write_new): Use event_new here too
1228
Scott James Remnant9e7d25c2007-02-06 00:42:41 +00001229 * init/job.c (job_write_state): Output a goal_event field containing
1230 the event name or nothing for NULL.
1231 (job_read_state): Parse the goal_event field
1232 * init/tests/test_job.c (test_write_state): Make sure the state is
1233 written out properly.
1234 (test_read_state): Make sure that the state is parsed correctly too.
1235
Scott James Remnant7aa22b62007-02-06 00:32:30 +00001236 * init/job.c (job_start, job_stop): Split all of the code except
1237 the goal_event setting into two new static functions that this calls
1238 (_job_start, _job_stop): New static functions
1239 (job_start_event, job_stop_event): Call _job_start and _job_stop
1240 instead of job_start and job_stop
1241
Scott James Remnante4111be2007-02-06 00:17:27 +00001242 * init/job.c (job_catch_runaway): Move this function up a bit.
1243
Scott James Remnant5761ef02007-02-06 00:15:51 +00001244 * init/job.c (job_start, job_stop): Clear the goal_event member,
1245 these functions are called for a manual start.
1246 * init/tests/test_job.c (test_start, test_stop): Make sure the
1247 goal_event member is freed and set to NULL.
1248
Scott James Remnant2b2b7d12007-02-06 00:07:28 +00001249 * init/job.h (Job): Add a new goal_event member
1250 * init/job.c (job_new): Initialise the goal_event member to NULL.
1251 * init/tests/test_job.c (test_new): Check with TEST_ALLOC_FAIL;
1252 also make sure goal_event is initialised to NULL.
1253
Scott James Remnant506ad092007-02-05 21:09:30 +000012542007-02-05 Scott James Remnant <scott@netsplit.com>
1255
Scott James Remnantee7e5552007-02-05 23:14:10 +00001256 * configure.ac: Bump version to 0.3.3
1257
Scott James Remnantcf64c482007-02-05 23:14:00 +00001258 * NEWS: Update.
1259
Scott James Remnant506ad092007-02-05 21:09:30 +00001260 * init/process.c (process_spawn): Exit with 255 so we don't clash
1261 with anything that uses 1 as a normal exit code. Note why we only
1262 close 0..2 (everything else is FD_CLOEXEC).
1263 * init/cfgfile.c (cfg_watch_dir): Mark the inotify watch descriptor
1264 as FD_CLOEXEC.
1265 * init/control.c (control_open): nih_io_set_cloexec can only ever
1266 return EINVAL, so no point checking it.
1267
Scott James Remnant0b74ff62007-02-04 00:43:20 +000012682007-02-04 Scott James Remnant <scott@netsplit.com>
1269
1270 * init/tests/test_control.c: Remove strange old code.
1271
Scott James Remnant9c44a422007-02-03 12:17:14 +000012722007-02-03 Scott James Remnant <scott@netsplit.com>
1273
Scott James Remnant7b618862007-02-03 23:41:33 +00001274 * init/control.c (control_open_sock, control_reopen)
1275 (control_close_handler): Drop these functions; unconnected datagram
1276 sockets don't close -- so why try dealing with it?
1277 (control_error_handler): Don't reopen the socket on error, just log
1278 it -- the socket should be fine, there's no remote end to be lost,
1279 after all.
1280 * init/tests/test_control.c (test_close_handler): Drop.
1281 (test_error_handler): Drop the reopen tests.
1282
Scott James Remnant88c1aac2007-02-03 23:26:36 +00001283 * init/tests/test_job.c (test_run_script): Control socket doesn't
1284 get unexpectedly opened anymore; so no need to close it.
1285
1286 * init/control.c (control_open): Remove the strange behaviour that
1287 this can be called to get the socket. Instead make control_io
1288 global; we're all adults after all.
1289 * init/tests/test_control.c (test_open): Remove the test for the
1290 silly behaviour.
1291 * init/notify.c (notify_job, notify_event): Use the control_io
1292 pointer directly, and just do nothing if we lost it somehow.
1293
Scott James Remnant2e204b72007-02-03 23:15:28 +00001294 * init/main.c (main): Being unable tp open the control socket, or
1295 parse the configuration, should be a fatal error; stop being so
1296 damned liberal! <g> Don't reset the signal state if we're
1297 being restarted, as this loses any pending signals -- be happy
1298 that our parent left them in a good state. Set SIGCHLD to the
1299 standard handler, otherwise we might lose this before we start
1300 the main loop (which does the same anyway).
1301 (term_handler): Rework so we don't need to close and open the
1302 control socket; instead we just close it in the child that's
1303 going to send the state, and notify the parent that it's safe to
1304 exec (which will cause it to be closed so the new init can open it).
1305
Scott James Remnant3af85462007-02-03 18:31:54 +00001306 * init/tests/test_control.c (test_open): Fix valgrind error
1307 * init/tests/test_notify.c (test_subscribe): Fix valgrind error
1308
Scott James Remnante443b9c2007-02-03 18:24:18 +00001309 * init/notify.c (notify_subscribe): Make safe against ENOMEM.
1310 * init/tests/test_notify.c (test_subscribe): Use TEST_ALLOC_FAIL
1311
Scott James Remnant4b601d12007-02-03 18:20:00 +00001312 * init/control.c: Add needed attributes; tidy up formatting.
1313 (control_open): Don't let ENOMEM fail opening the control socket.
1314 * init/control.h: Add needed attributes.
1315 * init/tests/test_control.c (test_open): Test for failed allocation.
1316 * init/main.c (term_handler): Make sure we catch failure to open
1317 the control socket again.
1318
Scott James Remnantd308b432007-02-03 17:36:41 +00001319 * TODO: Update
1320
Scott James Remnant272938f2007-02-03 17:35:11 +00001321 * init/cfgfile.c (cfg_watch_dir): Clean this up a bit; now we only
1322 output a warning if inotify failed for any reason other than not
1323 being supported AND walking worked.
1324
Scott James Remnantd78d00e2007-02-03 17:27:32 +00001325 * init/cfgfile.c (cfg_watch_dir): Update to even newer watch API;
1326 our create_handler is now always called if inotify is successful,
1327 so we just need to fall back to walking the directory when it
1328 isn't -- if inotify isn't supported, don't even bother complaining.
1329 (cfg_create_modify_handler): Check the stat of the file visited to
1330 make sure it's a regular file.
1331 (cfg_visitor): Check the stat of the file visited to make sure it's
1332 a regular file.
1333
Scott James Remnantbcbb1122007-02-03 17:11:21 +00001334 * init/cfgfile.c: Update include to upstart/enum.h
1335 * init/job.c: Update include to upstart/enum.h
1336 * init/job.h: Update include to upstart/enum.h
1337
Scott James Remnant801f9e12007-02-03 17:10:06 +00001338 * logd/main.c: Add attribute to open_logging
1339
Scott James Remnantcbd0cf82007-02-03 17:05:39 +00001340 * util/initctl.c: Split out the command functions into new files;
1341 * util/jobs.c: This gets the job-related commands
1342 * util/events.h: This gets the event-related commands
1343 * util/initctl.h, util/jobs.h, util/events.h: Headers
1344 * util/tests/test_jobs.c: Test suite for job-related commands.
1345 * util/tests/test_events.c: Test suite for event-related commands.
1346 * util/Makefile.am (initctl_SOURCES): Add new files.
1347 (TESTS): Build new test suites.
1348 (test_jobs_SOURCES, test_jobs_LDFLAGS, test_jobs_LDADD):
1349 Details for job-related commands test suite binary.
1350 (test_events_SOURCES, test_events_LDFLAGS, test_events_LDADD):
1351 Details for event-related commands test suite binary.
1352 * TODO: Remove item about splitting initctl now we've done it.
1353
Scott James Remnantadfcc3f2007-02-03 12:24:07 +00001354 * TODO: Big update; strip anything we have a spec for.
1355
Scott James Remnant1157bbf2007-02-03 12:17:55 +00001356 * upstart/message.c (upstart_message_handle): Make sure that if we
1357 fail to parse a message, we don't leave strings around in memory.
1358 * upstart/tests/test_message.c (test_open): Check that we get a
1359 raised EADDRINUSE if we try an open a socket twice.
1360 (test_handle): Add lots of checks for things like NULL names and
1361 incomplete messages; as well as the obvious unknown message.
1362 (test_reader): Make sure that errors while handling messages are
1363 dealt with by logging it.
1364
Scott James Remnant9c44a422007-02-03 12:17:14 +00001365 * upstart/job.c, upstart/job.h, upstart/tests/test_job.c: Rename to
1366 enum.c, enum.h and tests/test_enum.c; since this just includes enums
1367 and convert functions really.
1368 * upstart/Makefile.am: Update.
1369 * upstart/libupstart.h: Update include.
1370 * upstart/tests/test_message.c: Update include.
1371
Scott James Remnant1e57ab22007-02-01 16:51:28 +000013722007-02-01 Scott James Remnant <scott@netsplit.com>
1373
Scott James Remnant0f1d9b62007-02-01 18:20:00 +00001374 * logd/main.c (main): Ensure we error if daemonise fails.
1375
Scott James Remnant36911572007-02-01 18:18:27 +00001376 * compat/sysv/shutdown.c (main): Ensure that signals and timers
1377 are added, even if we run out of memory.
1378
Scott James Remnant9b705ee2007-02-01 17:34:39 +00001379 * upstart/tests/test_message.c: Change from assert to assert0
1380 * upstart/tests/test_wire.c: Change from assert to assert0
1381 * init/tests/test_notify.c: Change from assert to assert0
1382 * init/tests/test_control.c: nih_io_message_send should always return
1383 a value greater than zero.
1384
Scott James Remnant91c6eb72007-02-01 17:19:32 +00001385 * upstart/tests/test_wire.c: Change to use assert instead of NIH_ZERO;
1386 the rationale here is that in test cases we just want to fail, not
1387 try again repeatedly.
1388 * upstart/tests/test_message.c: Likewise.
1389
Scott James Remnant9caf2822007-02-01 17:04:34 +00001390 * init/tests/test_control.c: Use assert to ensure we get the expected
1391 return values of functions that raise errors.
1392 * init/tests/test_notify.c: Use assert to ensure we get the expected
1393 return values of functions that raise errors.
1394
Scott James Remnant1e57ab22007-02-01 16:51:28 +00001395 * init/cfgfile.c (cfg_watch_dir): Port to the new NihWatch API and
1396 use nih_dir_walk(). This also fixes the long-standing bug where we
1397 wouldn't watch the configuration directory if inotify was disabled.
1398 Drop both the parent and prefix members for now, until we clean this
1399 up later.
1400 (cfg_create_modify_handler): Wrap cfg_read_job after figuring out
1401 the job name.
1402 (cfg_job_name): Function to figure out the job name from a path.
1403 (cfg_visitor): Visitor function to handle initial parsing, figuring
1404 out the job name; otherwise identical to the standard handler.
1405 * init/cfgfile.h: Update prototype for cfg_watch_dir.
1406 * init/main.c (main): Update call to cfg_watch_dir.
1407
Scott James Remnantbfd712d2007-01-31 12:13:25 +000014082007-01-31 Scott James Remnant <scott@netsplit.com>
1409
1410 * upstart/tests/test_message.c: Use TEST_ALLOC_FAIL to make sure
1411 allocations are handled properly.
1412
Scott James Remnant44828472007-01-30 11:53:33 +000014132007-01-30 Scott James Remnant <scott@netsplit.com>
1414
Scott James Remnant2cc36542007-01-30 17:12:34 +00001415 * upstart/wire.c: Note that if any of the push functions fail, the
1416 entire buffer should be discarded.
1417 * upstart/tests/test_wire.c (test_push_int, test_push_unsigned)
1418 (test_push_string, test_push_header, test_push_pack): Us
1419 TEST_ALLOC_FAIL to ensure that failing to allocate memory is caught.
1420
Scott James Remnant1084c682007-01-30 15:17:41 +00001421 * upstart/tests/test_message.c (my_handler): Free the name and
1422 description after checking; they aren't otherwise.
1423
Scott James Remnantdc8b3292007-01-30 15:01:30 +00001424 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Consume
1425 a copy of the va_list, so these can be called multiple times on the
1426 same list without ill effect.
1427
Scott James Remnant92d87442007-01-30 15:01:21 +00001428 * upstart/message.h: Add warn_unused_result attributes to
1429 upstart_message_handle and upstart_message_handle_using as they raise
1430 errors.
1431
Scott James Remnant2de25012007-01-30 14:57:27 +00001432 * upstart/wire.c: push functions return negative values to indicate
1433 insufficient memory.
1434 * upstart/wire.h: Add warn_unused_result attributes to push functions
1435
Scott James Remnant4ccebcf2007-01-30 14:51:17 +00001436 * upstart/tests/test_message.c: Guard calls to nih_io_buffer_push and
1437 nih_io_message_add_control with NIH_ZERO to ensure they succeed.
1438 * upstart/tests/test_wire.c: Guard calls to nih_io_buffer_push
1439
Scott James Remnant44828472007-01-30 11:53:33 +00001440 * HACKING: Update from libnih with new Documentation,
1441 Function Attributes and Test Cases sections.
1442
Scott James Remnant16a286f2007-01-10 15:38:33 +000014432007-01-10 Scott James Remnant <scott@netsplit.com>
1444
Scott James Remnantde443012007-01-10 18:45:40 +00001445 * init/main.c (crash_handler): s/SEGV/SIGSEGV/
1446
Scott James Remnant505f9282007-01-10 18:44:38 +00001447 * init/main.c (main): Rename variable
1448
Scott James Remnant56a4d062007-01-10 17:33:39 +00001449 * TODO: Update.
1450
Scott James Remnant78626fb2007-01-10 16:48:10 +00001451 * init/main.c (main): Change the way we clear the arguments; by
1452 deleting just the final NULL terminator, we fool the kernel into
1453 only returning one argument in cmdline.
1454
Scott James Remnant16a286f2007-01-10 15:38:33 +00001455 * init/main.c (segv_handler): Rename to crash_handler and handle
1456 SIGABRT as well, so we can catch assertion errors. Of course, in
1457 theory, with our high test converage this should never happen in
1458 practice <chortle>
1459
Scott James Remnant39ec35b2007-01-09 08:16:01 +000014602007-01-09 Scott James Remnant <scott@netsplit.com>
1461
Scott James Remnant7f4db422007-01-09 20:51:08 +00001462 * init/main.c (main): Clear arguments so that upstart only ever
1463 appears as /sbin/init in ps, top, etc.
1464
Scott James Remnant8fd06de2007-01-09 20:38:27 +00001465 * TODO: Update.
1466
Scott James Remnant4d0481d2007-01-09 20:38:07 +00001467 * util/initctl.c: Add data pointer to functions and handle calls.
1468
Scott James Remnantbcf9e972007-01-09 20:34:47 +00001469 * init/control.c: Add data pointer to all functions.
1470 * init/tests/test_control.c: Pass data pointer to
1471 upstart_message_handle_using()
1472 * init/tests/test_notify.c: Pass data pointer to
1473 upstart_message_handle_using()
1474
Scott James Remnant6aa008c2007-01-09 20:26:44 +00001475 * upstart/message.c (upstart_message_handle)
1476 (upstart_message_handle_using): Add a data pointer argument to these
1477 functions and pass it to the handler.
1478 (upstart_message_reader): Pass the io structure's data pointer.
1479 * upstart/message.h (UpstartMessageHandler): Add a data pointer to
1480 the message handler.
1481 * upstart/tests/test_message.c (test_handle, test_handle_using):
1482 Pass a data pointer to the function call and check it's passed
1483 to the handler correctly.
1484 (test_reader): Check that the io data pointer gets passed.
1485
Scott James Remnantc7017d32007-01-09 18:44:58 +00001486 * init/tests/test_cfgfile.c (test_stanza_console, test_stanza_env)
1487 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Finish off
1488 the newer style test cases.
1489
Scott James Remnante63ef802007-01-09 17:54:56 +00001490 * init/cfgfile.c (cfg_stanza_console, cfg_stanza_umask)
1491 (cfg_stanza_nice, cfg_stanza_limit, cfg_stanza_chroot)
1492 (cfg_stanza_chdir): Guard against duplicate uses of the stanzas.
1493 * init/tests/test_cfgfile.c (test_stanza_daemon)
1494 (test_stanza_respawn): Check that neither daemon or respawn override
1495 exec if they have no arguments.
1496 (test_stanza_script): Add missing function
1497 (test_stanza_chroot, test_stanza_chdir): Add tests for these simple
1498 stanzas.
1499
Scott James Remnant0cd393d2007-01-09 17:36:34 +00001500 * init/cfgfile.c: Change remaining uses of nih_error_raise and
1501 return to just nih_return_error.
1502
Scott James Remnantc352b632007-01-09 17:31:41 +00001503 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_daemon)
1504 (cfg_stanza_respawn, cfg_stanza_script): Disallow duplicates,
1505 both of command strings, scripts, limits and of just the flags.
1506 * init/tests/test_cfgfile.c (test_stanza_exec)
1507 (test_stanza_daemon, test_stanza_respawn, test_stanza_instance):
1508 Check the behaviour of these stanzas.
1509
Scott James Remnant94188d42007-01-09 16:43:58 +00001510 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop): Disallow
1511 duplicate values for the script.
1512 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop):
1513 Test cases for those two functions.
1514
Scott James Remnant474a6ff2007-01-09 16:17:49 +00001515 * init/cfgfile.c (cfg_stanza_description, cfg_stanza_author)
1516 (cfg_stanza_version): Don't allow stanza to be duplicated anymore.
1517 * init/tests/test_cfgfile.c (test_stanza_description)
1518 (test_stanza_author, test_stanza_version): Test cases for these
1519 simple stanza; making sure duplication is not permitted.
1520 (test_stanza_on): Add a test case for this stanza too.
1521
Scott James Remnant49e8bb82007-01-09 15:57:59 +00001522 * init/cfgfile.c (cfg_stanza_kill): Guard against duplicate uses
1523 of the kill timeout stanza.
1524 * init/tests/test_cfgfile.c (test_stanza_kill): Test the complex
1525 kill stanza.
1526 (test_stanza_pid): Check duplicate usage results in an error.
1527
Scott James Remnant443ef2e2007-01-09 15:47:24 +00001528 * init/job.h (Job): Rename pidfile to pid_file and binary to pid_binary
1529 * init/job.c (job_new): Update names here too.
1530 * init/errors.h: Add a new "duplicate value" error.
1531 * init/cfgfile.c (cfg_read_job): Change name of variables, and catch
1532 the duplicate value error to add the line number.
1533 (cfg_stanza_pid): Change variable names, and clean this function up
1534 a little. Make it an error to use a stanza more than once.
1535 * init/tests/test_cfgfile.c (test_stanza_pid): Write a newer test
1536 case function for the pid stanza.
1537
Scott James Remnant34ff87d2007-01-09 09:00:30 +00001538 * init/cfgfile.c (cfg_stanza_normalexit): Use do/while instead of
1539 while, that we don't have to test has_token first as next_arg does
1540 that for us.
1541
Scott James Remnanta7354692007-01-09 08:56:02 +00001542 * init/cfgfile.c (cfg_stanza_normalexit): Change to peek at the next
1543 token to see whether it's missing or not, and then just fetch each
1544 next argument at a time. This is more efficient than parsing them
1545 all in one go, and also means we can report the error in the right
1546 place!
1547 * init/tests/test_cfgfile.c (test_stanza_normalexit): Since we've
1548 changed the function that parses the stanza, add a proper test case
1549 function for it, covering all the behaviours.
1550
Scott James Remnant92e7fda2007-01-09 08:40:13 +00001551 * init/job.c (job_new): Initialise the emits member to an empty list.
1552 * init/job.h (Job): Add the emits member as a list.
1553 * init/tests/test_job.c (test_new): Check the emits list starts off
1554 empty.
1555 * init/tests/test_cfgfile.c (test_stanza_emits): Test the new emits
1556 stanza; this function will also serve as a prototype for cleaning up
1557 the config tests.
1558
1559 * init/cfgfile.c (cfg_stanza_emits): Add function to parse the new
1560 emits stanza.
1561
Scott James Remnant39ec35b2007-01-09 08:16:01 +00001562 * init/cfgfile.c (cfg_stanza_depends): Remove the depends stanza
1563 from the configuration file. Dependency support has never been used,
1564 and is to be replaced by a more flexible event/state configuration
1565 and blocking on the starting/stopping events.
1566 * init/tests/test_cfgfile.c: Remove references and tests for the
1567 depends stanza.
1568 * init/job.h: Remove the depends list from the job structure.
1569 * init/job.c (job_new): No depends list to initialise.
1570 (job_change_state): No dependencies to release
1571 (job_start): No dependencies to iterate; this removes a particularly
1572 hairy and complex interaction between state changes. Remove the
1573 dependency event.
1574 (job_release_depends): Drop this function.
1575 * init/tests/test_job.c (test_start, test_stop): Massively simplify
1576 these tests cases now we don't have dependencies to worry about.
1577 (test_release_depends): Drop tests
1578
Scott James Remnantd4f5fb82007-01-08 23:25:23 +000015792007-01-08 Scott James Remnant <scott@netsplit.com>
1580
1581 * init/cfgfile.c: Rewrite using the nih_config API, rather than one
1582 huge function we now just have seperate handler functions for each
1583 stanza. We can also use more fine-grained parsing than slurping
1584 all args in and counting them.
1585 (cfg_read_job): Catch exceptions from the configuration parser and
1586 add the line number where the problem occurred to an output message.
1587 Parser errors are now fatal, and not ignored.
1588 * init/errors.h: Add a file containing errors raised within the init
1589 daemon codebase.
1590 * init/Makefile.am (init_SOURCES): Build with errors.h
1591 * init/tests/test_cfgfile.c: Update test cases now we don't expect
1592 a job to be returned if there's a parser error.
1593
1594 * TODO: Update
1595
Scott James Remnant66384202007-01-06 14:23:18 +000015962007-01-06 Scott James Remnant <scott@netsplit.com>
1597
Scott James Remnant4f968192007-01-06 20:31:13 +00001598 * logd/main.c (logging_reader): Fix inadvertent shadowing of the
1599 len parameter.
1600
Scott James Remnantda100272007-01-06 20:24:18 +00001601 * compat/sysv/telinit.c: Oops, nearly forgot to port this to send
1602 the messages in the new way.
1603 * compat/sysv/shutdown.c (shutdown_now): Likewise, port this too.
1604
Scott James Remnant83a86522007-01-06 19:55:38 +00001605 * TODO: Update.
1606
Scott James Remnant6e941882007-01-06 14:38:57 +00001607 * util/initctl.c (handle_job_status): Output the process argument,
1608 not the pid argument which contains the origin of the message.
1609
Scott James Remnant17d6dca2007-01-06 14:33:30 +00001610 * upstart/message.c (upstart_message_handle): Raise a new unknown
1611 message error if we don't have a handler and a new illegal message
1612 error if the source is illegal.
1613 * upstart/tests/test_message.c (test_handle): Adjust tests to check
1614 for the new errors that we raise.
1615 * upstart/errors.h: Define strings for new errors.
1616
Scott James Remnant66384202007-01-06 14:23:18 +00001617 * util/initctl.c: Yet another makeover for this little program,
1618 port it to the new message/control framework using handler functions
1619 and NihIoMessage. This starts to make each action function look
1620 very similar, so there's method to this madness.
1621
Scott James Remnantb4725d92007-01-05 13:10:21 +000016222007-01-05 Scott James Remnant <scott@netsplit.com>
1623
Scott James Remnant3d6bb792007-01-05 22:33:43 +00001624 * logd/main.c (main): Make sure that we add the SIGTERM handler.
1625
Scott James Remnantefbaafb2007-01-05 18:12:15 +00001626 * init/tests/test_job.c (test_run_script): This test case relies
1627 on there only being one file descriptor watch, which won't be true
1628 if the control socket has been opened because there's a message to
1629 go out. Make sure it's closed first.
1630
Scott James Remnantbe1941f2007-01-05 17:57:59 +00001631 * init/init.supp: Update supressions file now that control_init
1632 has been renamed to notify_init
1633
Scott James Remnant71cc4d82007-01-05 17:53:32 +00001634 * init/Makefile.am: Include notify.o from all tests.
1635 * init/job.c (job_change_state, job_kill_process, job_start)
1636 (job_stop): Use the new notify_job function name.
1637 * init/event.c (event_queue_run): Use the new notify_event function
1638 name.
1639
Scott James Remnantfea6cb62007-01-05 17:49:13 +00001640 * init/control.c (control_error_handler): Handle ECONNREFUSED now
1641 that the process id is available to us.
1642 * init/tests/test_control.c (test_error_handler): Make sure children
1643 going away is handled properly.
1644
Scott James Remnant3dfb2132007-01-05 17:44:48 +00001645 * upstart/message.c (upstart_message_new): Store the process id in
1646 the int_data message field.
1647 * upstart/tests/test_message.c (test_new): Check the int_data field
1648 is filled in.
1649
Scott James Remnant5d702952007-01-05 17:21:34 +00001650 * init/main.c (main): Guard against various things returning an error
1651 that we weren't catching.
1652
Scott James Remnant601a0e32007-01-05 17:06:31 +00001653 * init/tests/test_notify.c: Whitespace fix.
1654
Scott James Remnant15cd0862007-01-05 17:06:20 +00001655 * init/control.c (control_watch_jobs, control_unwatch_jobs)
1656 (control_watch_events, control_unwatch_events): Restore functionality
1657 to subscribe and unsubscribe from job and event notifications.
1658 * init/tests/test_control.c (test_watch_jobs, test_unwatch_jobs)
1659 (test_watch_events, test_unwatch_events): Check that the subscription
1660 and unsubscription messages work.
1661 * init/Makefile.am (test_control_LDADD): Link to notify.o
1662
1663 * init/control.c: Drop unused include of upstart/errors.h
1664
Scott James Remnant58cef572007-01-05 16:18:42 +00001665 * init/notify.c: Move functions that handle subscription and
1666 notification from control.c. Other than changing the names, we're
1667 keeping the API the same for now; expect it to change later when we
1668 add the ability to subscribe to individual jobs or events.
1669 (notify_init): initialise the subscriptions list; we don't have a
1670 separate send queue now that the control I/O is always asynchronous.
1671 * init/notify.h: Moved notification enum, structure and prototypes
1672 from control.h, changing the names so they match notify_* in the
1673 process.
1674 * init/Makefile.am (init_SOURCES): Build and link notify.c using
1675 notify.h
1676 (TESTS): Build the notify test suite binary.
1677 (test_notify_SOURCES, test_notify_LDFLAGS, test_notify_LDADD): Details
1678 for notify test suite binary.
1679 * init/tests/test_notify.c: Rewrite test cases in the manner of
1680 test_control.c so that we have one function for notify_job and
1681 one for notify_event, each of which contains the child process that
1682 receives the notification,
1683
Scott James Remnantb1679c62007-01-05 15:49:54 +00001684 * init/control.c (control_open): Allow this to be called to obtain
1685 the control socket, which means we can make it static.
1686 * init/tests/test_control.c (test_open): Check that it works.
1687
Scott James Remnantf7c6b062007-01-05 15:33:33 +00001688 * init/control.c, init/control.h, init/tests/test_control.c: Move
1689 functions that handle subscription and notification to new notify.c
1690 (control_init): Drop completely, no need to maintain a send queue now
1691 (control_open): Change to return an NihIo that uses the default
1692 control watcher, and our error handler. Split socket opening into
1693 (control_open_sock): which can be called from other functions.
1694 (control_close): Use nih_io_close() to close the socket and free the
1695 structure in one go.
1696 (control_reopen): Close the open control socket and open it again
1697 without destroying the NihIo structure, its queues or state.
1698 (control_close_handler): Handle the control socket going away
1699 (control_error_handler): Handle errors on the control socket,
1700 including the connection refused error that indicates a client went
1701 away.
1702 (control_handle): Split this into a miriad of small functions with
1703 a table to link them to the message type; this will make expanding
1704 each message handler much easier in future.
1705 * init/control.h: Update.
1706 * init/tests/test_control.c: Rewrite test cases to check the new
1707 handler functions; as a side-effect, this gets rid of the evil giant
1708 child/parent functions in favour of one test function per handler
1709 function.
1710
Scott James Remnantb4725d92007-01-05 13:10:21 +00001711 * upstart/message.c (upstart_message_handle_using): Wrapper function
1712 around upstart_message_handle that ensures all messages as passed to
1713 a single function.
1714 * upstart/message.h: Update.
1715 * upstart/tests/test_message.c (test_handle_using): Make sure it
1716 calls the single function.
1717
Scott James Remnantde3666f2007-01-04 23:00:07 +000017182007-01-04 Scott James Remnant <scott@netsplit.com>
1719
1720 * upstart/message.c (upstart_message_reader): Handle any errors
1721 that occurred while handling the message.
1722
Scott James Remnant92feed92007-01-02 15:27:47 +000017232007-01-02 Scott James Remnant <scott@netsplit.com>
1724
Scott James Remnant7833bbf2007-01-02 20:57:23 +00001725 * upstart/message.c (upstart_message_handle): Check that the name
1726 argument is never NULL.
1727 (upstart_message_reader): Simple message reader function that can
1728 be associated with an I/O watch and handles each message received.
1729 * upstart/message.h: Add prototype.
1730 * upstart/tests/test_message.c (test_reader): Test the reader function.
1731
Scott James Remnant0e3b5fe2007-01-02 18:39:03 +00001732 * upstart/control.c: Rename to upstart/message.c
1733 * upstart/control.h: Rename to upstart/message.h
1734 * upstart/tests/test_control.c: Rename to upstart/tests/test_message.c
1735 * upstart/libupstart.h: Update includes.
1736 * upstart/wire.c: Include message.h
1737 * upstart/wire.h: Update includes.
1738 * upstart/tests/test_wire.c: Update includes.
1739 * upstart/errors.h: Rename UPSTART_INVALID_MESSAGE to
1740 UPSTART_MESSAGE_INVALID so that it's prefixed.
1741 * upstart/Makefile.am (libupstart_la_SOURCES)
1742 (upstartinclude_HEADERS, TESTS): Update filenames.
1743
Scott James Remnant2ad9a042007-01-02 18:29:49 +00001744 * upstart/control.c (upstart_message_new): New function that
1745 creates an NihIoMessage directly from its arguments, which are a type
1746 followed by a variable number of args depending on that type.
1747 (upstart_message_handler): Function to find a handler function for
1748 a particular message type and origin process.
1749 (upstart_message_handle): New function that takes an NihIoMessage
1750 and invokes a handler function with a variable number of args
1751 depending on the message type.
1752 (upstart_send_msg, upstart_send_msg_to, upstart_recv_msg): Drop these
1753 functions, leave it up to the caller to decide whether to send and
1754 receive the messages synchronously or asynchronously; now that the
1755 capability is in nih_io_*.
1756 * upstart/control.h (UpstartMsgType): Rename to UpstartMessageType.
1757 (UpstartMessageHandler): Function with variable number of arguments
1758 that handles a message received.
1759 (UpstartMsg): Drop this structure entirely, we'll encode or decode
1760 the wire format directly from or into a function call, rather than
1761 use an intermediate structure to marshal it.
1762 (UpstartMessage): New structure to make a table that can be passed
1763 to upstart_message_handle to determine which handler should be called.
1764 * upstart/tests/test_control.c: Test new behaviour.
1765 * upstart/wire.c (upstart_push_header, upstart_pop_header): Change
1766 structure name for type parameter.
1767 * upstart/wire.h: Update.
1768 * upstart/tests/test_wire.c: Update.
1769
Scott James Remnant92feed92007-01-02 15:27:47 +00001770 * configure.ac (AC_COPYRIGHT): Update copyright to 2007.
1771
Scott James Remnant67546d12006-12-29 13:08:32 +000017722006-12-29 Scott James Remnant <scott@netsplit.com>
1773
1774 * upstart/wire.c (upstart_write_int, upstart_write_unsigned)
1775 (upstart_write_string, upstart_write_header, upstart_write_packv)
1776 (upstart_write_pack): Rename to *_push_*
1777 (upstart_read_int, upstart_read_unsigned, upstart_read_string)
1778 (upstart_read_header, upstart_read_packv, upstart_read_pack): Rename
1779 to *_pop_*.
1780 All of the above modified to modify an NihIoMessage structure,
1781 instead of trying to carry around buffers ourself.
1782 * upstart/wire.h: Update to match above.
1783 * upstart/tests/test_wire.c: Update all tests to match the above
1784 changes.
1785
Scott James Remnantd76e8e32006-12-21 18:34:31 +000017862006-12-21 Scott James Remnant <scott@netsplit.com>
1787
Scott James Remnantf922a982006-12-21 18:45:30 +00001788 * upstart/wire.c (upstart_read_packv, upstart_write_packv): Change
1789 nih_assert_notreached to nih_assert_not_reached.
1790
Scott James Remnantd76e8e32006-12-21 18:34:31 +00001791 * init/job.c (job_run_script): Open the NihIo structure in stream mode.
1792 * logd/main.c (logging_watcher): Open the NihIo structure in
1793 stream mode.
1794 (logging_reader): Need to pass the length of the size_t as a pointer
1795 so that it can be modified if less is read.
1796
Scott James Remnanta0385232006-12-17 15:21:39 +000017972006-12-17 Scott James Remnant <scott@netsplit.com>
1798
Scott James Remnant00cc6882006-12-17 19:54:36 +00001799 * upstart/wire.c (upstart_write_packv, upstart_write_pack)
1800 (upstart_read_packv, upstart_read_pack): Functions to write a pack
1801 of different variables to the stream, or read them from it
1802 * upstart/wire.h: Add prototypes.
1803 * upstart/tests/test_wire.c (test_write_pack, test_read_pack):
1804 Check we can read and write a pack of variables at once.
1805
Scott James Remnant518e1c12006-12-17 18:12:14 +00001806 * upstart/wire.c (upstart_write_header, upstart_read_header): Drop
1807 the version from the header, we'll just keep the protocol always
1808 backwards compatible.
1809 * upstart/wire.h: Update.
1810 * upstart/tests/test_wire.c (test_write_header, test_read_header):
1811 Check that everything works.
1812
Scott James Remnant64e378f2006-12-17 17:24:44 +00001813 * upstart/wire.c (upstart_write_string, upstart_read_string):
1814 Transmit the length as an unsigned, and use 0xffffffff to mean NULL
1815 instead of zero so we can still transmit the empty string.
1816 * upstart/wire.h: Update.
1817 * upstart/tests/test_wire.c (test_write_string, test_read_string):
1818 Tests for the functions to make sure the wire is at it should be.
1819
Scott James Remnantd6dde952006-12-17 17:00:56 +00001820 * upstart/wire.c (upstart_read_str, upstart_write_str): Rename to
1821 upstart_read_string and upstart_write_string.
1822 * upstart/wire.h: Update.
1823
Scott James Remnantc71ab3b2006-12-17 16:58:28 +00001824 * upstart/wire.c (upstart_write_unsigned, upstart_read_unsigned):
1825 Functions to send unsigned values over the wire, which we'll use
1826 to get a bit extra for the string lengths.
1827 * upstart/wire.h: Update.
1828 * upstart/tests/test_wire.c (test_write_unsigned)
1829 (test_read_unsigned): Test the new functions.
1830
Scott James Remnant0218e3a2006-12-17 16:39:33 +00001831 * upstart/wire.c (upstart_write_ints, upstart_read_ints): Drop
1832 these functions, we'll go with something far more generic and
1833 useful.
1834 * upstart/wire.h: Remove prototypes.
1835
Scott James Remnant9ee44302006-12-17 16:37:59 +00001836 * upstart/wire.c (upstart_write_int, upstart_read_int): Transmit
1837 integers as signed 32-bit values in network byte order.
1838 * upstart/tests/test_wire.c (test_write_int, test_read_int): Test
1839 the functions to make sure the wire is at it should be,
1840
Scott James Remnant5cef53e2006-12-17 15:41:13 +00001841 * upstart/control.c (upstart_read_int, upstart_write_int)
1842 (upstart_read_ints, upstart_write_ints, upstart_read_str)
1843 (upstart_write_str, upstart_read_header, upstart_write_header): Move
1844 functions to new wire.c file.
1845 * upstart/wire.c: Source file to hold wire protocol functions.
1846 * upstart/wire.h: Prototypes.
1847 * upstart/tests/test_wire.c: (empty) test suite.
1848 * upstart/libupstart.h: Include wire.h
1849 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link wire.c
1850 (upstartinclude_HEADERS): Install wire.h
1851 (TESTS): Build and run wire test suite.
1852 (test_wire_SOURCES, test_wire_LDFLAGS, test_wire_LDADD): Details for
1853 wire test suite binary.
1854
Scott James Remnanta0385232006-12-17 15:21:39 +00001855 * upstart/control.c (MAGIC): Change to "upstart\n", the final
1856 character was originally \0 and then was a " " for the 0.2 series.
1857 * upstart/tests/test_control.c (test_recv_msg): Change to match.
1858
Scott James Remnantfb9412a2006-12-15 18:03:22 +000018592006-12-15 Scott James Remnant <scott@netsplit.com>
1860
Scott James Remnant2e5fe2b2006-12-15 18:27:58 +00001861 * util/initctl.c, compat/sysv/telinit.c, compat/sysv/shutdown.c:
1862 Update all uses of the UpstartMsg structure to avoid the
1863 intermediate union that no longer exists.
1864
Scott James Remnantfb521462006-12-15 18:24:57 +00001865 * init/control.c, init/tests/test_control.c: Update all uses of
1866 the UpstartMsg structure to avoid the intermediate union that no
1867 longer exists.
1868
Scott James Remnant99b97662006-12-15 18:15:22 +00001869 * upstart/control.h: Combine all the previous message structures
1870 into just one that has all of the fields anyway.
1871 * upstart/control.c, upstart/tests/test_control.c: Update all uses of
1872 the UpstartMsg structure to avoid the intermediate union that no
1873 longer exists.
1874
Scott James Remnantd452ab12006-12-15 18:05:23 +00001875 * upstart/control.h (UPSTART_API_VERSION): Define API version macro
1876 to be public.
1877 * upstart/control.c (MSG_VERSION, upstart_send_msg_to): Replacing the
1878 previous MSG_VERSION macro here.
1879
Scott James Remnantfb9412a2006-12-15 18:03:22 +00001880 * upstart/control.c (upstart_read_int, upstart_write_int)
1881 (upstart_read_ints, upstart_write_ints, upstart_read_str)
1882 (upstart_write_str, upstart_read_header, upstart_write_header):
1883 New functions to replace the old "write a struct" protocol with
1884 something a little more regimented and supportable.
1885 (IOVEC_ADD, IOVEC_READ, WireHdr, WireJobPayload, WireJobStatusPayload)
1886 (WireEventPayload): Remove these structures, use the functions
1887 instead.
1888 (upstart_send_msg_to): Call write functions intead of using macros,
1889 this makes the code somewhat neater.
1890 (upstart_recv_msg): Call read functions instead of using macros,
1891 again making the code somewhat neater.
1892 * upstart/tests/test_control.c (test_recv_msg): Change wire
1893 tests to match new protocol, and thus actually work properly,
1894 previously these were endian sensitive.
1895
Scott James Remnant27ebd792006-12-14 11:37:14 +000018962006-12-14 Scott James Remnant <scott@netsplit.com>
1897
Scott James Remnant136dc6f2006-12-14 12:36:43 +00001898 * compat/sysv/shutdown.c (wall): Construct the wall message so that
1899 we don't put \r into a po file; for some reason, gettext hates that
1900 and bitches about it. Someone's confusing internationalisation with
1901 operating system portability, I expect.
1902
Scott James Remnantf334f842006-12-14 11:46:14 +00001903 * util/man/initctl.8: Drop reference to start(8), as that's just
1904 a symlink to initctl now.
1905
Scott James Remnant88847432006-12-14 11:44:36 +00001906 * init/man/init.8: Link to initctl.
1907
Scott James Remnantf6b237a2006-12-14 11:40:49 +00001908 * compat/sysv/reboot.c (main): Clear up help text a little.
1909
Scott James Remnant3b4b2272006-12-14 11:39:05 +00001910 * HACKING: Correct some typos.
1911
Scott James Remnant27ebd792006-12-14 11:37:14 +00001912 * configure.ac (AC_INIT): Correct bug reporting address.
1913
Scott James Remnant1d8763a2006-12-13 17:49:38 +000019142006-12-13 Scott James Remnant <scott@netsplit.com>
1915
Scott James Remnantecec0fe2006-12-13 21:55:28 +00001916 * configure.ac: Bump version to 0.3.2
1917
Scott James Remnantf642ffa2006-12-13 18:24:22 +00001918 * NEWS: Update.
1919
Scott James Remnant1d8763a2006-12-13 17:49:38 +00001920 * util/initctl.c (print_job_status): Drop the newline from the
1921 output.
1922
Scott James Remnant567cbdc2006-12-13 17:07:58 +000019232006-12-13 Alex Smith <alex@alex-smith.me.uk>
1924
1925 * util/initctl.c (print_job_status): Clean up initctl job status
1926 output, which was badly converted from printf to nih_message.
1927
Scott James Remnante2cf6392006-12-13 17:02:20 +000019282006-12-13 Scott James Remnant <scott@netsplit.com>
1929
1930 * compat/sysv/man/shutdown.8: Add missing documentation on the
1931 format of TIME by copying it from --help output.
1932
Scott James Remnantfec90562006-12-13 17:00:40 +000019332006-12-13 Alex Smith <alex@alex-smith.me.uk>
1934
1935 * init/process.c (process_setup_console): Actually send output to
1936 /dev/null instead of /dev/console, when CONSOLE_NONE.
1937
Scott James Remnantf233c9d2006-12-13 16:45:35 +000019382006-12-13 Scott James Remnant <scott@netsplit.com>
1939
Scott James Remnantfbf7a5c2006-12-13 16:54:42 +00001940 * Makefile.am (EXTRA_DIST): Distribute the nih ChangeLog as well.
1941
Scott James Remnantf233c9d2006-12-13 16:45:35 +00001942 * init/tests/test_job.c: Port to the new test framework.
1943 * init/job.c (job_set_idle_event): Fix a slight memory leak,
1944 repeated setting of the idle event never freed the previous one set.
1945
Scott James Remnant1abced42006-12-12 11:28:49 +000019462006-12-12 Scott James Remnant <scott@netsplit.com>
1947
Scott James Remnantfbad50c2006-12-12 18:47:43 +00001948 * init/tests/test_cfgfile.c: Port to the new test framework.
1949
Scott James Remnantef372232006-12-12 17:23:05 +00001950 * init/tests/test_control.c: Port to the new test framework.
1951 * init/init.supp: Suppress the list head allocated within control_init.
1952
Scott James Remnant2c2e01a2006-12-12 17:22:40 +00001953 * init/control.c (control_watcher): Need to save the pid when we
1954 get ECONNREFUSED, otherwise we lose it when we free the message.
1955
Scott James Remnant40f7d912006-12-12 15:31:35 +00001956 * init/tests/test_process.c: Port to the new test framework.
1957 * init/init.supp: Suppress the list head allocated within job_init.
1958
Scott James Remnantfc456592006-12-12 14:09:45 +00001959 * init/init.supp: Include a valgrind suppressions file.
1960 * init/Makefile.am (EXTRA_DIST): Distribute the suppressions file.
1961
Scott James Remnant96c9b072006-12-12 14:07:30 +00001962 * init/tests/test_event.c: Port to the new test framework.
1963
Scott James Remnant237c7f62006-12-12 13:49:19 +00001964 * logd/Makefile.am, util/Makefile.am, compat/sys/Makefile.am
1965 (AM_CPPFLAGS): Add -I$(srcdir), necessary for testing "programs"
1966 that don't have usual library path semantics.
1967
Scott James Remnant2a35ab92006-12-12 13:23:10 +00001968 * upstart/tests/test_control.c: Port to the new test framework.
1969 * upstart/control.c (upstart_free): Drop this function, while not
1970 exposing libnih is a valiant effort, it already slips out because
1971 of the error handling.
1972
Scott James Remnant905dd272006-12-12 12:38:34 +00001973 * upstart/tests/test_job.c: Add missing include.
1974
Scott James Remnante77567f2006-12-12 12:25:46 +00001975 * upstart/tests/test_job.c: Port to the new test framework.
1976 (test_process_state_name): Check that this returns NULL.
1977
Scott James Remnantb7983062006-12-12 11:34:49 +00001978 * HACKING: Update location of download directory. Document
1979 requirement that all code have test cases.
1980
Scott James Remnant0c577ce2006-12-12 11:31:13 +00001981 * logd/main.c (open_logging): Likewise.
1982
Scott James Remnantc654baf2006-12-12 11:30:44 +00001983 * init/control.c (control_open): No need to set ENOMEM, errno is
1984 always set anyway.
1985
Scott James Remnant1abced42006-12-12 11:28:49 +00001986 * configure.ac (AM_INIT_AUTOMAKE): Include nostdinc so we don't get
1987 Automake's broken default includes.
1988 * upstart/Makefile.am (DEFAULT_INCLUDES): Drop override now that
1989 we don't need it.
1990 (DEFS, INCLUDES): Replace these variables with the combined
1991 (AM_CPPFLAGS): variable that declares everything.
1992 * init/Makefile.am (DEFAULT_INCLUDES): Drop override now that
1993 we don't need it.
1994 (DEFS, INCLUDES): Replace these variables with the combined
1995 (AM_CPPFLAGS): variable that declares everything.
1996 * util/Makefile.am (DEFAULT_INCLUDES): Drop override now that
1997 we don't need it.
1998 (DEFS, INCLUDES): Replace these variables with the combined
1999 (AM_CPPFLAGS): variable that declares everything.
2000 * compat/sysv/Makefile.am (DEFAULT_INCLUDES): Drop override now that
2001 we don't need it.
2002 (DEFS, INCLUDES): Replace these variables with the combined
2003 (AM_CPPFLAGS): variable that declares everything.
2004 * logd/Makefile.am (DEFAULT_INCLUDES): Drop override now that
2005 we don't need it.
2006 (DEFS, INCLUDES): Replace these variables with the combined
2007 (AM_CPPFLAGS): variable that declares everything.
2008
Scott James Remnantacec3b22006-11-02 16:36:53 +000020092006-11-02 Scott James Remnant <scott@netsplit.com>
2010
2011 * util/initctl.c (start_action): Remove break calls which shouldn't
2012 be there.
2013
Scott James Remnantea806b72006-10-18 15:01:00 +010020142006-10-18 Sean E. Russell <ser@ser1.net>
2015
2016 * init/main.c: Include sys/time.h
2017 * init/cfgfile.c: Include sys/time.h and sys/resource.h
2018 * init/job.c: Include sys/time.h and sys/resource.h
2019
Scott James Remnant6702ac12006-10-17 18:55:24 +010020202006-10-17 Scott James Remnant <scott@netsplit.com>
2021
Scott James Remnantd5758f42006-10-17 19:21:25 +01002022 * configure.ac: Bump version to 0.3.1
2023
Scott James Remnantfd029da2006-10-17 19:21:07 +01002024 * NEWS: Update.
2025 * TODO: Update.
2026
Scott James Remnant9f67cb82006-10-17 19:12:28 +01002027 * configure.ac (AM_GNU_GETTEXT_VERSION): Quote version number.
2028
Scott James Remnant4ebe87f2006-10-17 19:04:40 +01002029 * logd/Makefile.am (event.d/logd): Make the event.d sub-directory
2030 in case we're building outside of the source tree.
2031
Scott James Remnant6702ac12006-10-17 18:55:24 +01002032 * compat/sysv/runlevel.c (store): Don't break strict-aliasing rules
2033 by avoiding dereferencing type-punned pointer. Answers on a
2034 postcard, please.
2035
Scott James Remnant7f133012006-10-13 12:00:34 +010020362006-10-13 Scott James Remnant <scott@netsplit.com>
2037
Scott James Remnantecbb2b52006-10-13 15:18:24 +01002038 * util/initctl.c (start_action, emit_action): Add missing \n
2039
Scott James Remnant48622982006-10-13 15:15:50 +01002040 * util/initctl.c: Rewrite using nih_command_parser.
2041 * util/man/initctl.8: Improve.
2042
2043 * util/start.c: Remove, replaced by initctl.
2044 * util/man/start.8: Remove, replaced by initctl.
2045 * util/Makefile.am (sbin_PROGRAMS): Drop start, now just a symlink
2046 to initctl.
2047 (dist_man_MANS): Drop start.8, now a symlink to initctl.8
2048 (install-exec-hook): Make symlinks to initctl, add start
2049 (install-data-hook): Make symlinks to initctl.8, add start.8
2050
Scott James Remnantb1d8a7d2006-10-13 13:57:31 +01002051 * initctl: Rename to util again, I don't want a separate directory
2052 for every single little tool; and we'll be shipping more than just
2053 initctl (e.g. a non-compat reboot).
2054 * configure.ac (AC_CONFIG_FILES): Make util/Makefile instead of
2055 initctl/Makefile.
2056 * Makefile.am (SUBDIRS): Descend into util, not initctl.
2057
Scott James Remnanta48b4fe2006-10-13 13:49:46 +01002058 * compat/sysv/reboot.c: Remove long options where they didn't exist
2059 before. Write help text.
2060 * compat/sysv/man/reboot.8: Update.
2061
Scott James Remnant462734c2006-10-13 13:36:00 +01002062 * init/main.c (main): Formatting.
2063 * logd/main.c (main): Formatting.
2064 * logd/man/logd.8: Formatting.
2065 * compat/sysv/runlevel.c (main): Formatting.
2066 * compat/sysv/telinit.c (main): Formatting.
2067 * compat/sysv/man/shutdown.8: Remove long options.
2068
Scott James Remnanteff01f12006-10-13 13:32:12 +01002069 * compat/sysv/shutdown.c: Remove -e/--event, it has no place in a
2070 compatibility tool. Get rid of long options that never existed
2071 before. Specify help text to describe the options.
2072 * compat/sysv/man/shutdown.8: Spruce up a bit.
2073
Scott James Remnant4a5cd212006-10-13 12:59:15 +01002074 * compat/sysv/telinit.c (main): Set help text to list the valid
2075 runlevels.
2076 * compat/sysv/man/telinit.8: Refine the notes to mention runlevel(8).
2077
Scott James Remnantf7819622006-10-13 12:54:43 +01002078 * compat/sysv/runlevel.c (main): Make the help text describe the
2079 options, rather than the behaviour.
Scott James Remnant4a5cd212006-10-13 12:59:15 +01002080 * compat/sysv/man/runlevel.8: Flesh out a little more.
Scott James Remnantf7819622006-10-13 12:54:43 +01002081
Scott James Remnant930e25a2006-10-13 12:28:05 +01002082 * configure.ac (AC_INIT): Change bug reporting address to the
2083 mailing list, since Launchpad doesn't accept random bugs without
2084 accounts and complicated control messages.
2085 * init/main.c, logd/main.c: Add a period to the synopsis.
2086
Scott James Remnanta6ed7eb2006-10-13 12:14:45 +01002087 * init/main.c (main): Set the synopsis, and direct people to look
2088 at telinit in the --help output.
2089 * init/man/init.8: Flesh this out a little more, still a lot of
2090 explaining to do about jobs and events, but we'll wait until we've
2091 changed that code before documentating the behaviour.
2092
Scott James Remnant7f133012006-10-13 12:00:34 +01002093 * logd/main.c (main): Correct help text to describe the options,
2094 rather than what the program does. As per standard style.
2095 Don't become a daemon until the logging socket is open, and make
2096 that exclusive with waiting for SIGCONT.
2097 * logd/man/logd.8: Write some more extensive documentation,
2098 including describing the startup interlock and the socket protocol.
2099 * TODO: Plan to get rid of the signal interlock from logd.
2100
Scott James Remnant8985dd32006-10-12 15:26:29 +010021012006-10-12 Scott James Remnant <scott@netsplit.com>
2102
2103 * configure.ac: Expand AC_GNU_SOURCE so we get _GNU_SOURCE and so
2104 that gettext doesn't complain.
2105 (AM_GNU_GETTEXT_VERSION): Increase to 0.15
2106 (AC_PREREQ): Increase to 2.60
2107 * HACKING: Update autoconf and gettext requirements.
2108
Scott James Remnantc16a9b42006-10-11 17:08:58 +010021092006-10-11 Scott James Remnant <scott@netsplit.com>
2110
Scott James Remnant74a11442006-10-11 17:58:56 +01002111 * init/control.c (control_init): Pass NULL to nih_list_new.
2112 Clarify list item types.
2113 * init/event.c (event_init): Pass NULL to nih_list_new.
2114 * init/job.c (job_init): Pass NULL to nih_list_new.
2115
Scott James Remnantc34c4be2006-10-11 17:56:34 +01002116 * init/main.c: Change nih_signal_add_callback to nih_signal_add_handler
2117 and NihSignalCb to NihSignalHandler.
2118
Scott James Remnant8b227402006-10-11 17:55:27 +01002119 * init/cfgfile.c, init/cfgfile.h, init/control.c, init/control.h,
2120 init/event.c, init/event.h, init/job.c, init/job.h, init/main.c,
2121 init/process.c: Clean up documentation strings and parent pointer
2122 types.
2123
Scott James Remnantd033c862006-10-11 17:41:22 +01002124 * compat/sysv/shutdown.c: Change nih_signal_add_callback to
2125 nih_signal_add_handler.
2126
Scott James Remnant1ee0f482006-10-11 17:40:41 +01002127 * compat/sysv/reboot.c: Set synopsis text depending on command
2128 used (probably should use nih_command_parser?)
2129 * compat/sysv/runlevel.c: Set synopsis and help text, and correct
2130 usage.
2131 * compat/sysv/shutdown.c: Set synopsis text.
2132 * compat/sysv/telinit.c: Set synopsis text.
2133
Scott James Remnant3b734642006-10-11 17:22:33 +01002134 * compat/sysv/runlevel.c, compat/sysv/shutdown.c: Clean up
2135 documentation strings.
2136
Scott James Remnantc6e4f002006-10-11 17:22:03 +01002137 * logd/main.c: Set synopsis and help text.
2138
Scott James Remnant5e31d742006-10-11 17:16:55 +01002139 * logd/main.c: Clean up documentation strings.
2140 Change nih_signal_add_callback to nih_signal_add_handler.
2141
Scott James Remnant48359382006-10-11 17:13:48 +01002142 * upstart/control.c, upstart/control.h, upstart/job.c: Clean up
2143 documentation strings and correct parent pointer type.
2144
Scott James Remnantc16a9b42006-10-11 17:08:58 +01002145 * HACKING: Detail function documentation requirement and format.
2146
Scott James Remnant59093a82006-10-10 13:09:58 +010021472006-10-10 Scott James Remnant <scott@netsplit.com>
2148
Scott James Remnant335947d2006-10-11 17:08:34 +01002149 * event.d/logd.in: Move to logd/event.d
2150 * event.d/Makefile.am: Remove
2151 * logd/Makefile.am: Create the logd job definition and install
2152 * Makefile.am (SUBDIRS): event.d directory has been removed.
2153 * configure.ac (AC_CONFIG_FILES): No longer make event.d/Makefile
2154
Scott James Remnant59093a82006-10-10 13:09:58 +01002155 * configure.ac: Check for --enable-compat, default to sysv if given
2156 or no compat if not given.
2157 * compat/sysv/Makefile.am: Don't build binaries or install manpages
2158 unless COMPAT_SYSV is defined.
2159
Scott James Remnant45150942006-10-06 16:36:27 +010021602006-10-06 Scott James Remnant <scott@netsplit.com>
2161
2162 * doc/upstart-logo.svg: Include the logo Alexandre designed.
2163 * doc/Makefile.am (EXTRA_DIST): Ship the logo in the tarball.
2164 * Makefile.am (SUBDIRS): Install under doc
2165 * configure.ac: Generate doc/Makefile
2166 * AUTHORS: Ensure he's credited fully.
2167
Scott James Remnant10b8c0e2006-09-27 21:27:38 +010021682006-09-27 Scott James Remnant <scott@netsplit.com>
2169
Scott James Remnant44052a32006-09-28 00:04:32 +01002170 * event.d/Makefile.am (do_subst): Eliminate duplicate /s
2171
Scott James Remnant5222c402006-09-27 22:48:48 +01002172 * man/init.8: Move to init/man
2173 * init/Makefile.am: Update to install man page.
2174 * man/logd.8: Move to logd/man
2175 * logd/Makefile.am: Update to install man page.
2176 * man/initctl.8, man/start.8: Move to initctl/man
2177 * initctl/Makefile.am: Update to install man pages.
2178 * man/reboot.8, man/runlevel.8, man/shutdown.8, man/telinit.8:
2179 Move to compat/sysv/man
2180 * compat/sysv/Makefile.am: Update to install man pages.
2181 * man/Makefile.am: Remove
2182 * configure.ac (AC_CONFIG_FILES): Remove man/Makefile
2183 * Makefile.am (SUBDIRS): Don't build in man
2184
Scott James Remnant545cb8c2006-09-27 21:32:49 +01002185 * util: Rename to initctl
2186 * configure.ac (AC_CONFIG_FILES): Update.
2187 * Makefile.am (SUBDIRS): Update.
2188
Scott James Remnant960c82d2006-09-27 21:30:42 +01002189 * util/reboot.c: Move to compat/sysv
2190 * util/shutdown.c: Move to compat/sysv
2191 * util/Makefile.am: Update.
2192 * compat/sysv/Makefile.am: Update.
2193
Scott James Remnant10b8c0e2006-09-27 21:27:38 +01002194 * configure.ac: Replace macros with single call to NIH_INIT.
2195 Bump version to 0.3.0 to begin new development cycle.
2196
Scott James Remnante5591992006-09-21 05:49:34 +010021972006-09-21 Scott James Remnant <scott@netsplit.com>
2198
2199 * logd/main.c: Revert the change that logged to the console, in
2200 practice this doesn't work so well. I want to get rid of logd
2201 in the long term, or at least just have it as a simple logging
2202 proxy, so giving it features seems wrong.
2203
Scott James Remnant9b58b842006-09-20 05:37:47 +010022042006-09-20 Scott James Remnant <scott@netsplit.com>
2205
Scott James Remnant97f08fa2006-09-20 06:34:12 +01002206 * configure.ac: Bump version to 0.2.8
2207 * NEWS: Updated.
2208
Scott James Remnante59c71e2006-09-20 06:14:32 +01002209 * logd/main.c (main): Check the kernel command-line for "quiet"
2210 (line_reader): Write to console unless silent or a daemon
2211
Scott James Remnant9b58b842006-09-20 05:37:47 +01002212 * man/Makefile.am (dist_man_MANS): Drop sulogin.8
2213 * man/sulogin.8: Drop, we don't include an sulogin
2214
Scott James Remnant0fafba42006-09-20 01:36:29 +010022152006-09-19 Michael Biebl <mbiebl@gmail.com>
2216
2217 * event.d/Makefile.am (logd): Drop $(srcdir)
2218 * init/Makefile.am (init_SOURCES): Distribute paths.h
2219
Scott James Remnant58f165f2006-09-18 19:43:07 +010022202006-09-18 Michael Biebl <mbiebl@gmail.com>
2221
2222 * configure.ac: Check for sys/inotify.h
2223
Scott James Remnante371cab2006-09-18 16:16:00 +010022242006-09-18 Scott James Remnant <scott@netsplit.com>
2225
2226 * util/shutdown.c (warning_message): Adjust method of constructing
2227 the message to not confuse poor translators who think \r and \n are
2228 the same thing!
2229
Scott James Remnantf2b1c052006-09-14 10:34:45 +010022302006-09-14 Scott James Remnant <scott@netsplit.com>
2231
Scott James Remnantb2e03d02006-09-14 11:20:13 +01002232 * init/job.c (job_change_state): Catch runaway respawns when we
2233 enter the running state, so we catch stop/start loops too.
2234 * init/tests/test_job.c (test_change_state): Update test.
2235
Scott James Remnantb7714f72006-09-14 11:07:38 +01002236 * event.d/logd: Rename to logd.in
2237 * event.d/logd.in: Replace /sbin with @sbindir@ so we can transform
2238 * event.d/Makefile.am: Generate logd from logd.in
2239
Scott James Remnant7e6bdb32006-09-14 10:57:03 +01002240 * util/reboot.c: Don't hardcode the location of /sbin/shutdown
2241 * util/Makefile.am (DEFS): Use autoconf to seed it
2242 * util/shutdown.c (sysvinit_shutdown): Don't hardcode the location
2243 of /dev/initctl
2244
Scott James Remnante0d0dd12006-09-14 10:51:05 +01002245 * init/paths.h: Create a new configuration file that can contain
2246 all of the path definitions, and in particular, allow them to be
2247 overidden elsewhere.
2248 * init/Makefile.am (DEFS): Override definitions of CFG_DIR and
2249 TELINIT using autoconf
2250 * init/main.c: Include paths.h. Don't hardcode location of telinit
2251 * init/job.c: Include paths.h
2252 * init/process.c: Include paths.h
2253 * init/process.h: Remove definitions from here.
2254
Scott James Remnantf2b1c052006-09-14 10:34:45 +01002255 * configure.ac: Bump version to 0.2.7
2256
Scott James Remnant0b8f23f2006-09-13 16:51:38 +010022572006-09-13 Scott James Remnant <scott@netsplit.com>
2258
Scott James Remnant948ab872006-09-14 10:34:34 +01002259 * NEWS: Updated.
2260
Scott James Remnant0b8f23f2006-09-13 16:51:38 +01002261 * TODO: More TODO.
2262
Scott James Remnant080dd8d2006-09-10 12:42:03 +010022632006-09-10 Scott James Remnant <scott@netsplit.com>
2264
2265 * util/reboot.c (main): Don't give -H with "halt".
2266
Scott James Remnantd7042862006-09-09 00:50:10 +010022672006-09-09 Scott James Remnant <scott@netsplit.com>
2268
Scott James Remnantedb97902006-09-09 05:48:42 +01002269 * configure.ac: Bump version to 0.2.6
2270
Scott James Remnant760237e2006-09-09 05:38:32 +01002271 * NEWS: Update.
2272 * TODO: Update.
2273
Scott James Remnant5e267a42006-09-09 05:21:28 +01002274 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
2275 the magic to be the package string.
2276 * upstart/tests/test_control.c (test_recv_msg): Update tests.
2277
Scott James Remnant17fec6e2006-09-09 05:05:42 +01002278 * util/initctl.c (main): Set the usage string.
2279 * util/shutdown.c (main): Set the usage string.
2280 * util/start.c (main): Set the usage string.
2281 * compat/sysv/runlevel.c (main): Set the usage string.
2282 * compat/sysv/telinit.c (main): Set the usage string.
2283
Scott James Remnantabede802006-09-09 05:01:45 +01002284 * man/Makefile.am: Use install-data-hook and $(man8dir)
2285 * util/Makefile.am: Also use install-exec-hook
2286
Scott James Remnantc6c20052006-09-09 04:58:11 +01002287 * Makefile.am (SUBDIRS): Install contents of the man directory
2288 * configure.ac (AC_CONFIG_FILES): Generate man/Makefile
2289 * man/Makefile.am: Install manpages in the appropriate places.
2290 * man/init.8, man/logd.8, man/initctl.8, man/reboot.8,
2291 * man/shutdown.8, man/start.8, man/sulogin.8, man/runlevel.8,
2292 * man/telinit.8: Include some basic manpages so we at least have
2293 some level of documentation.
2294
Scott James Remnant33e47112006-09-09 03:45:00 +01002295 * init/job.c (job_child_reaper): Don't check the exit status of
2296 a respawning job if the goal is to stop it.
2297
Scott James Remnant1889aa62006-09-09 03:41:53 +01002298 * compat/sysv/telinit.c (main): Generate events rather than
2299 starting and stopping jobs directly, the events are named
2300 "runlevel-X". 0, 1, 6 and s/S are shutdown events.
2301
Scott James Remnant515b2b92006-09-09 03:41:27 +01002302 * logd/main.c (main): Raise SIGSTOP before entering the main loop.
2303 * init/main.c (main): Interlock with logd.
2304
Scott James Remnant17eb9052006-09-09 03:41:04 +01002305 * event.d/logd: Should not be a console owner, but should stop
2306 on shutdown.
2307
Scott James Remnant34752262006-09-09 01:38:02 +01002308 * init/process.c (process_setup_console): Revert part of the previous
2309 change, should just output to /dev/null if we don't have logd.
2310
Scott James Remnante5533332006-09-09 01:36:07 +01002311 * configure.ac: Bump version to 0.2.5
2312
Scott James Remnantb4a1c2b2006-09-09 01:28:26 +01002313 * init/main.c (main): Start the logd job if it exists.
2314
2315 * init/process.c (process_setup_console): Ignore ECONNREFUSED as
2316 that just means that logd isn't around, handle errors by falling
2317 back to opening the console.
2318
Scott James Remnant9fb20d42006-09-09 01:22:03 +01002319 * init/process.c (process_setup_console): Implement handling for
2320 CONSOLE_LOGGED and generally clean up the other handling.
2321 * init/process.h: Update.
2322 * init/main.c (main): Pass NULL for the job to setup console.
2323 * TODO: Update.
2324
Scott James Remnantd7042862006-09-09 00:50:10 +01002325 * logd/main.c: Implement the logging daemon, it accepts connections
2326 on a unix stream socket with the abstract name
2327 "/com/ubuntu/upstart/logd", expects the length of the name and the
2328 name to follow; then sequences of lines which are logged to
2329 /var/log/boot, or memory until that file can be opened.
2330
Scott James Remnant527b9452006-09-08 17:15:07 +010023312006-09-08 Scott James Remnant <scott@netsplit.com>
2332
Scott James Remnantcb655e72006-09-08 17:49:20 +01002333 * util/shutdown.c (event_setter): Change the event names to
2334 distinguish between "shutdown -h" and "shutdown -h -H".
2335
Scott James Remnant90732d32006-09-08 17:33:19 +01002336 * init/job.c (job_handle_event): Allow jobs to react to their own
2337 events, this is how we'll do respawn eventually.
2338 * init/tests/test_job.c (test_handle_event): Remove test.
2339
Scott James Remnantbb3cc3f2006-09-08 17:17:47 +01002340 * init/main.c (cad_handler, kbd_handler): Generate the new event
2341 names.
2342 * init/event.h (CTRLALTDEL_EVENT, KBDREQUEST_EVENT): Add definitions
2343 of these event names, change the ctrlaltdel event to just that.
2344
Scott James Remnant527b9452006-09-08 17:15:07 +01002345 * logd/main.c (main): Add the code to daemonise, etc.
2346
Scott James Remnanta17917d2006-09-07 00:18:28 +010023472006-09-07 Scott James Remnant <scott@netsplit.com>
2348
Scott James Remnant214ebe82006-09-07 21:48:55 +01002349 * TODO: Long discussion today on #upstart, many improvements to the
2350 job and event model that make it more elegant.
2351 * AUTHORS: Include a list of thanks.
2352
Scott James Remnantb8280072006-09-07 03:19:00 +01002353 * util/shutdown.c (shutdown_now): If we get ECONNREFUSED when we
2354 try and send the shutdown event to init, it probably means we're
2355 still in sysvinit. So try that instead.
2356 (sysvinit_shutdown): Function to send a hand-crafted runlevel
2357 change message across /dev/initctl.
2358
Scott James Remnantae969062006-09-07 00:43:57 +01002359 * util/initctl.c (main): Add a shutdown command that takes an
2360 arbitrary event name to be issued after "shutdown". You'll
2361 nearly always want the /sbin/shutdown tool instead.
2362
Scott James Remnant987bcc42006-09-07 00:38:24 +01002363 * init/job.c (job_detect_idle): Only generate the stalled event
2364 if at least one job handles it in its start_events list.
2365 * init/tests/test_job.c (test_detect_idle): Make sure that works.
2366
Scott James Remnantea204d42006-09-07 00:30:53 +01002367 * init/event.h (STARTUP_EVENT, SHUTDOWN_EVENT, STALLED_EVENT):
2368 Macros to define the standard event names.
2369 * init/main.c (main): Use STARTUP_EVENT macro instead of "startup"
2370 * init/control.c (control_handle): Use SHUTDOWN_EVENT macro
2371 instead of "shutdown".
2372 * init/job.c (job_detect_idle): Use STALLED_EVENT macro instead
2373 of "stalled".
2374
Scott James Remnant84607df2006-09-07 00:27:22 +01002375 * init/job.c (job_detect_idle): Add some log messages for when we
2376 detect the idle or stalled states.
2377 (job_kill_process, job_kill_timer): Increase log verbosity.
2378 * init/event.c (event_queue_run): Log which events we're handling
2379 if --debug is given.
2380
Scott James Remnanta17917d2006-09-07 00:18:28 +01002381 * compat/sysv/telinit.c (main): Send a shutdown command when
2382 requesting to enter runlevel 0 or runlevel 6, likewise for
2383 runlevel 1, s or S which all run "rc1" not "rcS".
2384 * init/main.c (main): When called directory (pid != 1) try and
2385 run telinit before complaining that we're not init. Make sure
2386 errors aren't lost.
2387
Scott James Remnantf5c376c2006-09-04 16:25:04 +010023882006-09-04 Johan Kiviniemi <johan@kiviniemi.name>
Scott James Remnantedcae302006-09-04 07:06:23 +01002389
Scott James Remnantf5c376c2006-09-04 16:25:04 +01002390 * upstart/control.c (upstart_addr): Replace use of __builtin_offsetof
2391 with offsetof.
2392 * upstart/tests/test_control.c (test_recv_msg): Likewise.
2393
23942006-09-04 Scott James Remnant <scott@netsplit.com>
2395
Scott James Remnantedcae302006-09-04 07:06:23 +01002396 * util/shutdown.c (main): Exit normally after sending the warning
2397 message if -k is given.
2398
Scott James Remnante94bd202006-09-01 00:48:36 +010023992006-09-01 Scott James Remnant <scott@netsplit.com>
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01002400
Scott James Remnant294cde72006-09-01 19:58:35 +01002401 * configure.ac: Bump version to 0.2.2
2402
Scott James Remnant7663bfb2006-09-01 19:58:19 +01002403 * NEWS: Update.
2404 * configure.ac: Bump version to 0.2.1
2405
Scott James Remnant67982142006-09-01 19:47:39 +01002406 * init/process.c (process_setup_console): Ensure that the console
2407 is always initialised to at least /dev/null
2408 * init/job.c (job_change_state): Initialise event to NULL.
2409 * init/event.c (event_read_state): Don't mask initialisation of
2410 other variable.
2411 * init/cfgfile.c (cfg_job_stanza, cfg_parse_script, cfg_next_token):
2412 Print lineno using %zi not %d
2413 * compat/sysv/runlevel.c (store): Cast pointer type of timeval.
2414
Scott James Remnant097b2a92006-09-01 19:30:37 +01002415 * init/main.c: Move the kernel headers include beneath the C
2416 library ones, so that compilation doesn't fail on !i386.
2417 * util/reboot.c: Likewise.
2418
Scott James Remnant28fcc922006-09-01 04:15:57 +01002419 * init/main.c (term_handler): Close the control connection if we
2420 re-exec init, otherwise it won't be able to bind. Drop debugging.
2421
Scott James Remnant6f464962006-09-01 04:10:20 +01002422 * init/main.c (term_handler): It always helps if we dup2 the
2423 right file descriptor.
2424
Scott James Remnant1db88042006-09-01 03:14:19 +01002425 * init/main.c: Use the TERM signal instead of USR1, as old init
2426 used that for something else. Also rather than passing across
2427 file descriptor numbers, use a fixed descriptor and just pass
2428 "--restart". When we get that option we need to unmask signals
2429 otherwise we sit there looking like a lemon.
2430
Scott James Remnante7a73262006-09-01 02:32:27 +01002431 * init/job.c (job_change_state): Don't free the event unless we
2432 generate one.
2433
Scott James Remnant12dd7252006-09-01 02:27:04 +01002434 * NEWS: Update.
2435
Scott James Remnant694172a2006-09-01 02:26:45 +01002436 * init/cfgfile.c (cfg_watcher): Ignore any file with '.' or '~'
2437
Scott James Remnantc6e63dd2006-09-01 02:16:43 +01002438 * TODO: Update.
2439
Scott James Remnant3401ab72006-09-01 02:14:47 +01002440 * init/main.c (main): Parse command-line arguments, specifically
2441 look for --state-fd which we'll use for reexec. Don't do a couple
2442 of things if we're passed this.
2443 (read_state): Parse the line-buffered state.
2444 * init/job.c (job_read_state, job_write_state): Job state
2445 serialisation so that we can re-exec ourselves.
2446 * init/job.h: Update.
2447 * init/tests/test_job.c: Test the serialisation.
2448 * init/event.c (event_read_state, event_write_state): And similar
2449 functions for serialising the event queue.
2450 * init/event.h: Update.
2451 * init/tests/test_event.c: Test the serialisation.
2452 * init/cfgfile.c (cfg_read_job): Fix a bug, need to subtract current
2453 time to get due time.
2454
Scott James Remnante94bd202006-09-01 00:48:36 +01002455 * upstart/job.c (job_goal_from_name, job_state_from_name)
2456 (process_state_from_name): Add opposite numbers that convert a
2457 string back into an enumeration.
2458 * upstart/job.h: Update.
2459 * upstart/tests/test_job.c: Test the new functions.
2460
24612006-08-31 Scott James Remnant <scott@netsplit.com>
Scott James Remnant694172a2006-09-01 02:26:45 +01002462
Scott James Remnantb7260a72006-08-31 22:08:56 +01002463 * init/job.h (Job): Add respawn_limit, respawn_interval,
2464 respawn_count and respawn_time members so that we can keep track of
2465 runaway processes.
2466 * init/job.c (job_catch_runaway): Increment the respawn_count
2467 within respawn_interval, or reset it if we go over.
2468 (job_new): Initialise respawn_limit and respawn_interval to sensible
2469 defaults.
2470 * init/tests/test_job.c (test_new): Check the defaults are set.
2471 (test_change_state): Check the respawning code works.
2472 * init/cfgfile.c (cfg_job_stanza): Parse the "respawn limit" stanza.
2473 * init/tests/test_cfgfile.c (test_read_job): Test the new stanza.
2474
Scott James Remnantff0d26a2006-08-31 20:49:43 +01002475 * init/process.c (process_setup_console): Remove the console reset
2476 code, it tends to just crash X and seems to do nothing interesting.
2477 * init/main.c (reset_console): Instead put it here and just do it
2478 on startup.
2479
Scott James Remnant25b263a2006-08-31 18:59:02 +01002480 * configure.ac: Bump version to 0.2.0
2481
Scott James Remnant4b61be92006-08-31 17:08:44 +01002482 * util/Makefile.am (install-exec-local): Create symbolic links,
2483 not hard links.
2484
Scott James Remnantaf1404f2006-08-31 16:04:16 +01002485 * init/main.c: Can't catch STOP.
2486
Scott James Remnant242b50b2006-08-31 15:40:42 +01002487 * util/reboot.c: Pause init while shutting down or rebooting.
2488
Scott James Remnanteabb7802006-08-31 15:39:04 +01002489 * init/main.c (stop_handler): Catch STOP/TSTP and CONT.
2490 * init/event.c (event_queue_run): Don't run the event queue while
2491 paused.
2492 * init/job.c (job_detect_idle): Don't detect idle jobs while paused.
2493
Scott James Remnant1cd8d862006-08-31 15:17:16 +01002494 * util/reboot.c: if we get the -w argument ("only write to wtmp")
2495 we need to exit, and not behave as halt normally would.
2496
Scott James Remnantff63cf72006-08-31 04:39:34 +01002497 * compat/sysv/runlevel.c (main): Add missing newline.
2498 * compat/sysv/telinit.c (main): And here too.
2499
Scott James Remnant32de9222006-08-31 04:34:27 +01002500 * init/main.c (main): Check for idle after the startup event queue
2501 has been run, otherwise we may just sit there.
2502
Scott James Remnant13ffffe2006-08-31 04:33:39 +01002503 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install telinit
2504 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Details for
2505 telinit binary.
2506 * compat/sysv/telinit.c: Trivial telinit program that just runs
2507 the appropriate rcX job.
2508 * compat/sysv/runlevel.c (main): Suggest help on illegal runlevel.
2509
Scott James Remnant40f09012006-08-31 04:21:49 +01002510 * util/Makefile.am: Tidy up.
2511
Scott James Remnant12473562006-08-31 04:21:05 +01002512 * configure.ac (AC_CONFIG_FILES): Create compat/sysv/Makefile
2513 * Makefile.am (SUBDIRS): Build things found in compat/sysv
2514 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install runlevel
2515 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD): Details for
2516 runlevel binary.
2517 * compat/sysv/runlevel.c: Helper to store and retrieve the current
2518 "runlevel" from utmp/wtmp; as well as the reboot time.
2519
Scott James Remnantd909cca2006-08-31 04:20:14 +01002520 * init/main.c (main): Drop debugging set.
2521
Scott James Remnantcedd11a2006-08-31 02:59:29 +01002522 * init/job.c (job_change_state): As well as the job/state events,
2523 send the job event when a service is running or a task is stopping.
2524 * init/tests/test_job.c (test_change_state): Check the events get
2525 sent properly.
2526
Scott James Remnant44b684a2006-08-31 02:58:45 +01002527 * util/start.c: Write a simple utility to start, stop, or query
2528 the status of the named jobs.
2529 * util/Makefile.am (sbin_PROGRAMS): Build and install start
2530 (start_SOURCES, start_LDFLAGS, start_LDADD): Details for start
2531 (install-exec-local): Also install as stop and status.
2532 * util/reboot.c (main): Drop the debugging set.
2533
Scott James Remnantb8ed2d12006-08-31 02:15:48 +01002534 * init/cfgfile.c (cfg_job_stanza): Correct nih_alloc error.
2535
Scott James Remnanta6125ae2006-08-31 02:14:25 +01002536 * init/process.c (process_setup_environment): Guard memory alloc.
2537 * init/job.c (job_set_idle_event): Likewise.
2538 (job_change_state): And here too.
2539 (job_run_command): Likewise.
2540 * init/control.c (control_send): Likewise.
2541 * init/cfgfile.c: And throughout this file.
2542 * upstart/control.c (upstart_recv_msg): And once here too.
2543
Scott James Remnant0b358ab2006-08-31 02:07:32 +01002544 * upstart/control.h: Abolish the separate halt, reboot and poweroff
2545 messages and replace with a single shutdown message that takes
2546 an event name (for the idle event issued afterwards).
2547 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
2548 the new shutdown event type by just treating it as an event.
2549 * upstart/tests/test_control.c (test_messages): Update tests.
2550 * init/job.c (job_set_idle_event): Store a copy of the idle event
2551 name.
2552 * init/control.c (control_send): Copy the shutdown event name.
2553 (control_handle): Replace individual handling with the new
2554 single event.
2555 * init/tests/test_control.c (test_watcher): Update.
2556 * util/initctl.c: Drop handling for things that shutdown does now.
2557 * util/shutdown.c: Send the UPSTART_SHUTDOWN event and let the user
2558 specify anything they want, just give defaults.
2559
Scott James Remnantff5efb92006-08-31 01:45:19 +01002560 This is quite a big change and abolishes level events entirely,
2561 along with the event history. We now just treat events as a
2562 transient queue of strings that go past, may cause things to change,
2563 but are otherwise forgotten. This turns out to be much easier to
2564 understand and has no real loss of power.
2565
2566 * init/event.c: Vastly simplify; gone are the separate notions of
2567 edge and level events, instead we just treat them as one-shot
2568 things that go past and are forgotten about.
2569 * init/event.h (Event): Remove value member.
2570 Update prototypes.
2571 * init/tests/test_event.c: Update.
2572 * init/job.c (job_change_state): Change the event pattern to be
2573 one that includes the job name and a description of the transition
2574 instead of the new state.
2575 (job_detect_idle): Call event_queue rather than event_queue_edge.
2576 * init/tests/test_job.c: Update.
2577 * init/cfgfile.c (cfg_job_stanza): Drop "when" and "while".
2578 * init/tests/test_cfgfile.c (test_read_job): Drop mentions of
2579 "when" and "while".
2580 * init/control.c (control_send, control_handle): Drop cases for
2581 level events.
2582 (control_handle_event): Don't include a level in the event.
2583 * init/tests/test_control.c: Update
2584 * init/main.c: Call event_queue rather than event_queue_edge.
2585 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
2586 event handling so that only a name is read.
2587 * upstart/control.h: Remove value/level event structures.
2588 * upstart/tests/test_control.c (test_messages): Update.
2589 * upstart/job.c (process_state_name): Not used for events, adjust
2590 documentation so it doesn't lie.
2591 * util/initctl.c (main): Drop the set function, simplify trigger.
2592 * util/shutdown.c (shutdown_now): Call UPSTART_EVENT_QUEUE for
2593 shutdown into maintenance mode.
2594
Scott James Remnantfcbee2d2006-08-31 00:49:36 +01002595 * init/control.c (control_handle): Place a message in the syslog
2596 before halting, powering off or rebooting.
2597
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01002598 * util/shutdown.c: Adjust so that the warning message is sent out
2599 if shutdown is immediate, and when it actually happens. Include
2600 the hostname as wall does.
2601
Scott James Remnant255c5f22006-08-30 16:05:01 +010026022006-08-30 Scott James Remnant <scott@netsplit.com>
2603
Scott James Remnant5be55662006-08-30 19:13:25 +01002604 * TODO: Update.
2605
Scott James Remnant4a9245f2006-08-30 19:13:00 +01002606 * util/shutdown.c: Implement shutdown utility along the same lines
2607 as the sysvinit one, but with rather different code.
2608
Scott James Remnant2a71aaa2006-08-30 16:34:06 +01002609 * util/initctl.c (main): Call setuid on the effective user id so
2610 that we can be made setuid root and executable by a special group.
2611 * util/reboot.c (main): Likewise.
2612
Scott James Remnant70cc2292006-08-30 16:06:03 +01002613 * util/initctl.c (main): Check the effective rather than the real
2614 user id, if we're effectively root, that's good enough.
2615
Scott James Remnant255c5f22006-08-30 16:05:01 +01002616 * util/reboot.c: Implement reboot/halt/poweroff utility.
2617 * util/Makefile.am (sbin_PROGRAMS): Build and install reboot
2618 (reboot_SOURCES, reboot_LDFLAGS, reboot_LDADD): Details for reboot
2619 (install-exec-local): Create hardlinks to reboot for halt and poweroff.
2620
Scott James Remnantdc8877d2006-08-29 16:56:48 +010026212006-08-29 Scott James Remnant <scott@netsplit.com>
2622
2623 * init/main.c (main): Actually run the idle-detect function.
2624 * init/job.c (job_detect_idle): Interrupt the main loop, otherwise
2625 we may end up waiting for a signal before we process the event
2626 we just issued.
2627
Scott James Remnantf43bdf32006-08-27 18:20:29 +010026282006-08-27 Scott James Remnant <scott@netsplit.com>
2629
Scott James Remnant47158482006-08-27 22:37:10 +01002630 * util/shutdown.c: Template main function.
2631 * util/Makefile.am (sbin_PROGRAMS): Build and install the
2632 shutdown binary.
2633 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD): Details for
2634 the shutdown binary
2635
Scott James Remnant70a6ec62006-08-27 22:23:50 +01002636 * util/initctl.c (main): Add commands for halt, poweroff and reboot.
2637
Scott James Remnant0c7e72a2006-08-27 22:22:53 +01002638 * init/event.c (event_queue_run): Remove the parameters.
2639 * init/event.h: Update.
2640 * init/main.c (main): Update.
2641 * init/tests/test_control.c (test_watcher): Update.
2642 * init/tests/test_job.c (test_detect_idle): Update.
2643
Scott James Remnant96ae9e42006-08-27 22:15:34 +01002644 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Deal
2645 with halting, rebooting and powering off; or at least the appropriate
2646 messages.
2647 * upstart/control.h: Add control message structures for halting,
2648 powering off and rebooting the machine.
2649 * upstart/tests/test_control.c (test_messages): Run the tests.
2650 * init/control.c (control_handle): Add handling for halt, power off
2651 and reboot that issue the shutdown event and arrange for the halt,
2652 poweroff or reboot to be issued the next time the system is idle.
2653 * init/tests/test_control.c (test_watcher): Test the events.
2654
Scott James Remnant01a37082006-08-27 21:51:00 +01002655 * TODO: Update.
2656
Scott James Remnante02892b2006-08-27 21:49:44 +01002657 * init/job.c (job_detect_idle): Function to detect when the system is
2658 stalled or idle.
2659 * init/job.h: Update
2660 * init/tests/test_job.c (test_detect_idle): Test the new function.
2661
Scott James Remnant6a8508c2006-08-27 19:10:44 +01002662 * util/initctl.c (main): Handle the list command.
2663
Scott James Remnanta9476ad2006-08-27 19:07:23 +01002664 * TODO: Update.
2665
Scott James Remnant4da474d2006-08-27 19:06:35 +01002666 * upstart/control.c (WireJobStatusPayload): add description to the
2667 job status payload.
2668 (upstart_send_msg_to, upstart_recv_msg): Send and receieve the
2669 description over the wire.
2670 * upstart/control.h (UpstartJobStatusMsg): add a description field
2671 * upstart/tests/test_control.c: Update test cases.
2672 * init/control.c (control_handle): Include the job description in
2673 the message.
2674 (control_send): Copy the description when we put the message on
2675 the queue.
2676 (control_handle_job): Copy the description here too
2677 * init/tests/test_control.c: Update test cases.
2678
Scott James Remnant84f5e932006-08-27 18:49:25 +01002679 * init/job.c (job_list): Add a function to return the job list.
2680 * init/job.h: Update.
2681 * init/control.c (control_handle): Handle the JOB_LIST message
2682 by sending back a list of job status messages followed by the
2683 JOB_LIST_END message.
2684 * init/tests/test_control.c (test_watcher_child): Check the
2685 JOB_LIST message works properly.
2686
Scott James Remnantf4ad6d12006-08-27 18:40:01 +01002687 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
2688 the JOB_LIST and JOB_LIST_END messages which have no payload.
2689 * upstart/control.h: Add enums and structures for job list messages.
2690 * upstart/tests/test_control.c (test_messages): Update tests.
2691
Scott James Remnantf4970812006-08-27 18:27:19 +01002692 * init/main.c (main): Check that we're both uid and process #1
2693
Scott James Remnantf43bdf32006-08-27 18:20:29 +01002694 * init/main.c (main): Stop handling SIGTERM, we never want people
2695 to kill init. Handle SIGINT and SIGWINCH through the ordinary
2696 handler and SIGSEGV through a direct handler.
2697 (segv_handler): Write a sensible core dump handler, we use a child
2698 to dump core while we carry on in the parent hopefully stepping over
2699 the bad instruction.
2700 (cad_handler): Generate the control-alt-delete event.
2701 (kbd_handler): Generate the kbdrequest event.
2702
Scott James Remnant33e64d02006-08-25 14:44:32 +020027032006-08-25 Scott James Remnant <scott@netsplit.com>
2704
Scott James Remnant21679252006-08-25 16:22:13 +02002705 * configure.ac: Bump version to 0.1.2
2706 * NEWS: Update.
2707
Scott James Remnantfef12b52006-08-25 16:16:45 +02002708 * TODO: Update.
2709
Scott James Remnant94d00982006-08-25 15:38:22 +02002710 * init/process.c (process_setup_environment): Inherit the PATH
2711 and TERM environment variables from the init process, so the
2712 console works properly.
2713 * init/process.h (PATH): Declare a default value for this variable
2714 * init/main.c (main): Set the value of PATH to the default.
2715 * init/tests/test_process.c (child): Update test case.
2716
Scott James Remnant33e64d02006-08-25 14:44:32 +02002717 * NEWS: Update.
2718 * configure.ac: Bump version to 0.1.1
2719
Scott James Remnant68ccc9e2006-08-24 00:10:41 +020027202006-08-24 Scott James Remnant <scott@netsplit.com>
2721
Scott James Remnant279d4352006-08-24 15:33:19 +02002722 * init/cfgfile.h (CFG_DIR): Change configuration directory to
2723 /etc/event.d -- it's not been used by anyone, but is similar to
2724 other directories that have which is a good precedent.
2725 * event.d/Makefile.am (eventdir, dist_event_DATA): Install files
2726 into the new directory name.
2727 * Makefile.am (SUBDIRS): Rename sub directory
2728 * configure.ac (AC_CONFIG_FILES): Rename generated Makefile
2729
Scott James Remnant937192c2006-08-24 02:57:50 +02002730 * init/Makefile.am (DEFAULT_INCLUDES): Set to include the right
2731 directories so out of tree builds work.
2732 * logd/Makefile.am (DEFAULT_INCLUDES): Set to include the right
2733 directories so out of tree builds work.
2734 * upstart/Makefile.am (DEFAULT_INCLUDES): Set to include the right
2735 directories so out of tree builds work.
2736 (upstartinclude_HEADERS): Install errors.h
2737 * util/Makefile.am (DEFAULT_INCLUDES): Set to include the right
2738 directories so out of tree builds work.
2739
2740 * Makefile.am (SUBDIRS): Add m4 to the list
2741 * configure.ac (AC_CONFIG_FILES): Generate m4/Makefile
2742 * upstart/Makefile.am (upstartinclude_HEADERS): Add errors.h
2743
2744 * upstart/control.c (upstart_open):
2745
Scott James Remnante4c3d552006-08-24 02:34:01 +02002746 * init/control.c (control_open): Raise the error before
2747 performing other actions so errno is not lost.
Scott James Remnant73550092006-08-24 02:27:03 +02002748
Scott James Remnante4c3d552006-08-24 02:34:01 +02002749 * TODO: Update.o
Scott James Remnantf8b776b2006-08-24 00:36:15 +02002750 * init/cfgfile.c (cfg_next_token): Don't count quote characters
2751 unless we're actually planning to dequote the file, otherwise we
2752 end up allocating short.
2753
Scott James Remnant9e17fc02006-08-24 00:28:10 +02002754 * init/control.c (control_close): Free the io_watch using list_free
2755 in case a destructor has been set.
2756 * init/tests/test_control.c: Initialise the type of the message, and
2757 free job correctly.
2758
Scott James Remnant68ccc9e2006-08-24 00:10:41 +02002759 * upstart/tests/test_control.c: Fix overwrite of buffer.
2760 * init/tests/test_job.c: Clean up not-freed job.
2761
Scott James Remnantc961ce32006-08-23 19:46:29 +020027622006-08-23 Scott James Remnant <scott@netsplit.com>
2763
Scott James Remnant013e9722006-08-23 23:00:14 +02002764 * init/tests/test_event.c: free the entry allocated and initialise
2765 the return values.
2766
Scott James Remnantc961ce32006-08-23 19:46:29 +02002767 * init/cfgfile.c (cfg_skip_token): Drop this function; we'll
2768 make sure *pos is pointing at the start of the thing we want
2769 to parse, not the first token. Update the other functions
2770 accordingly.
2771 (cfg_read_job): Implement function to look over a job file and
2772 parse all of the stanzas that are found. Also sanity checks the
2773 job afterwards and deals with reloading existing jobs.
2774 (cfg_job_stanza): Function that parses an individual stanza,
2775 calling out to the other parse functions; this is the main config
2776 file parser!
2777 (cfg_parse_args, cfg_parse_command): Drop requirement that filename
2778 and lineno be passed, so we can be called to reparse arguments after
2779 we've already done so.
2780 (cfg_parse_script): Remove requirement that it be called at the
2781 start of the entire stanza, and instead at the start of the script.
2782 When hitting EOF, return the script so far, not NULL.
2783 (cfg_parse_args): Correct bug where we didn't check sufficient
2784 characters while skipping whitespace.
2785 (cfg_next_token): Correct bug where we didn't copy the character
2786 after a slash into the text, instead of just not copying the slash.
2787 Adjust line numbers to match the fact that it's zero based now.
2788 * init/cfgfile.h: Define prototype.
2789 * init/tests/test_cfgfile.c (test_read_job): Pretty thoroughly
2790 test the config file parser code.
2791
Scott James Remnant0c58ed02006-08-22 11:42:19 +020027922006-08-22 Scott James Remnant <scott@netsplit.com>
2793
Scott James Remnant214168f2006-08-22 18:52:51 +02002794 * init/cfgfile.c (cfg_tokenise): Rename to cfg_next_token.
2795 (cfg_skip_token): Code to skip whitespace, token and whitespace.
2796 (cfg_parse_args): Function to parse an argument list.
2797 (cfg_next_token): Extend to support the removal of quotes and
2798 slashes from the token.
2799
Scott James Remnant21590a22006-08-22 17:40:48 +02002800 * init/cfgfile.c (cfg_parse_script): Pass filename and lineno and
2801 increment the latter as we go.
2802 (cfg_script_end): Pass and increment lineno.
2803
Scott James Remnanteed2e8d2006-08-22 17:31:07 +02002804 * init/cfgfile.c: Correct a missing semi-colon in prototypes.
2805 (cfg_parse_command): Function to parse any stanza that requires
2806 a command and arguments list, e.g. exec/respawn/daemon. We don't
2807 want to require that the list be quoted, etc. and do want to allow
2808 it to be folded over lines.
2809 (cfg_tokenise): Function used by the above to tokenise the file,
2810 handling things like \, quoted strings and newlines, etc. Can be
2811 used both to determine the length of the token and to copy it.
2812
Scott James Remnantfcc98ad2006-08-22 12:28:19 +02002813 * init/cfgfile.c (cfg_read_script): Rename to cfg_parse_script.
2814
Scott James Remnantfd32dd32006-08-22 11:46:01 +02002815 * init/cfgfile.c (cfg_read_script): Function to parse a script
2816 fragment ("foo script\n....end script\n") from the job file, which
2817 is the most complex form we can find. Write it assuming the file is
2818 in a character array which may not be NULL terminated (ie. a mmap'd
2819 file).
2820 (cfg_script_end): Used by the above to detect the end of the
2821 fragment.
2822 * init/cfgfile.h: Empty header file.
2823 * init/Makefile.am (init_SOURCES): Build and link cfgfile.c
2824 using the cfgfile.h header
2825 (TESTS): Build and run the config file test cases.
2826 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
2827 Details for config file test case binary.
2828
Scott James Remnant0c58ed02006-08-22 11:42:19 +02002829 * init/main.c (main): Remove the calls to the unfinished config
2830 file code.
2831
Scott James Remnant6ce44812006-08-21 08:46:32 +020028322006-08-21 Scott James Remnant <scott@netsplit.com>
2833
Scott James Remnant027dd7b2006-08-21 09:01:25 +02002834 * init/main.c: Add missing include for unistd.h
2835 * init/process.c (process_setup_console): Drop use of job.
2836 * util/initctl.c (main): Check that we're run as root.
2837
Scott James Remnant77e8db32006-08-21 08:47:50 +02002838 * init/main.c (main): Write the main function
2839
Scott James Remnant6ecceb82006-08-21 08:47:23 +02002840 * init/event.c (event_queue_cb): Rename to event_queue_run.
2841 * init/event.h: Update.
2842
Scott James Remnant6ce44812006-08-21 08:46:32 +02002843 * init/process.c (process_setup_console): Become an exported
2844 function that includes the code to reset a console.
2845
Scott James Remnant5befd932006-08-19 19:24:54 +010028462006-08-19 Scott James Remnant <scott@netsplit.com>
2847
Scott James Remnantcd39a7c2006-08-19 20:02:17 +01002848 * logd/main.c (main): Write the basic main function.
2849
Scott James Remnant3bcd15e2006-08-19 19:50:12 +01002850 * util/initctl.c (main): Fill in the details to give us a basic
2851 test client.
2852
Scott James Remnant3dc965c2006-08-19 19:25:23 +01002853 * TODO: Update.
2854
Scott James Remnant5befd932006-08-19 19:24:54 +01002855 * util/initctl.c (main): Provide the most basic main function.
2856 * util/Makefile.am (sbin_PROGRAMS): Build the initctl binary
2857 * Makefile.am (SUBDIRS): Build the utilities.
2858 * configure.ac (AC_CONFIG_FILES): Generate the util Makefile.
2859
Scott James Remnant1fe38a82006-08-18 17:06:25 +010028602006-08-18 Scott James Remnant <scott@netsplit.com>
2861
Scott James Remnantc2659612006-08-18 22:19:47 +01002862 * init/Makefile.am (test_job_LDADD): Remove the duplicate link.
2863
Scott James Remnantd5e07052006-08-18 20:39:30 +01002864 * TODO: Update.
2865
Scott James Remnanta060bb72006-08-18 20:16:55 +01002866 * init/job.c (job_handle_child): Rename to job_child_reaper.
2867 * init/job.h: Update.
2868 * init/tests/test_job.c: Update function names.
2869
Scott James Remnant829dc082006-08-18 20:10:02 +01002870 * init/control.c (control_cb): Rename to control_watcher
2871 * init/tests/test_control.c: Update function names.
2872
Scott James Remnantddc3e282006-08-18 18:49:50 +01002873 * TODO: Update.
2874
Scott James Remnantc2cac3f2006-08-18 17:17:57 +01002875 * Makefile.am (SUBDIRS): Install the rc.d files.
2876 * configure.ac (AC_CONFIG_FILES): Generate the rc.d Makefile.
2877 * rc.d/Makefile.am (rcdir): Define rcdir to be /etc/rc.d
2878 (dist_rc_DATA): Install the logd file into that directory.
2879 * rc.d/logd: Write a simple service definition for the log daemon,
2880 this saves us hardcoding any information about it into init; it'll
2881 just need to know the name.
2882
Scott James Remnant1fe38a82006-08-18 17:06:25 +01002883 * Makefile.am (SUBDIRS): Build the logd daemon
2884 * configure.ac (AC_CONFIG_FILES): Generate the logd Makefile.
2885 * logd/Makefile.am (sbin_PROGRAMS): Install the logd binary into
2886 the sbin directory by default.
2887 (logd_SOURCES): Build and link main.c
2888 * logd/main.c (main): Add basic main function for testing purposes.
2889
Scott James Remnantb9814432006-08-16 02:11:51 +010028902006-08-16 Scott James Remnant <scott@netsplit.com>
2891
Scott James Remnantc5da6fd2006-08-16 18:06:49 +01002892 * init/job.c (job_start): Ignore self-dependencies; over-document
2893 why the dependency event prodding has a surprise in its tail.
2894 (job_change_state): Move the job_release_depends call to here.
2895
Scott James Remnant133a7a32006-08-16 17:45:51 +01002896 * init/event.c (event_queue_cb): Add event consumer/dispatcher.
Scott James Remnant13e5dbf2006-08-16 17:48:01 +01002897 * init/event.h: Update.
Scott James Remnant133a7a32006-08-16 17:45:51 +01002898
Scott James Remnant3772bc62006-08-16 17:41:34 +01002899 * init/control.c (control_send): Make the event code clearer.
2900 (control_handle): Handle the changed event semantics.
2901 (control_handle_event): Issue the new event type.
2902 * init/tests/test_control.c: Update tests.
2903
Scott James Remnantcaee5b52006-08-16 17:32:12 +01002904 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Adjust
2905 marshal code to match.
2906 * upstart/control.h: Update all structures appropriately to the
2907 previous changes.
2908 * upstart/tests/test_control.c: Update.
2909
Scott James Remnant4d4389d2006-08-16 17:19:20 +01002910 * init/job.c (job_change_state): Change call to event_trigger_level
2911 to event_queue_level.
2912
Scott James Remnant51664d72006-08-16 17:17:58 +01002913 * init/event.c (event_trigger_edge, event_trigger_level): Place
2914 the event on the event_queue rather than directly triggering it.
2915 Rename to event_queue_edge and event_queue_level respectively.
2916 * init/event.h: Update.
2917 * init/tests/test_event.c: Update test cases.
2918
Scott James Remnant4ddc86e2006-08-16 16:17:48 +01002919 * init/job.c (job_handle_event): Add another sanity check, jobs
2920 should not be able to react to their own events; that's just silly.
2921 * init/tests/test_job.c (test_handle_event): Check that the new
2922 condition does the right thing.
2923
Scott James Remnant930f3e02006-08-16 16:13:03 +01002924 * init/job.c (job_change_state): Make it illegal for a job to exist
2925 without either a command or script or both. This is for sanity
2926 reasons, allowing no primary process makes no sense and can lead
2927 to event loops if someone is feeling nefarious.
2928 * init/tests/test_job.c (test_change_state): Drop test on behaviour
2929 we've just outlawed.
2930
Scott James Remnant7dd047e2006-08-16 13:43:50 +01002931 * init/job.c (job_start): Only announce the change if we're still
2932 in the waiting state, we could have moved on to running already.
2933
Scott James Remnantf9261ba2006-08-16 13:40:05 +01002934 * init/job.c (job_start): If holding the job, at least announce
2935 the goal change to subscribed clients.
2936
Scott James Remnant853cc772006-08-16 13:34:51 +01002937 * TODO: Update.
2938
Scott James Remnantfdb82592006-08-16 13:31:49 +01002939 * init/job.c (job_start): Check for dependencies before starting
2940 the process, if we have any that aren't running we stay in waiting
2941 until they are. Any that aren't even starting get poked with a
2942 dependency event to see whether that wakes them up.
2943 * init/tests/test_job.c (test_start): Test paths through new
2944 dependency code.
2945
Scott James Remnant278150a2006-08-16 12:56:34 +01002946 * init/job.c (job_run_process): Once we've got an active process
2947 in the running state, release our dependencies.
2948
Scott James Remnant6d4104d2006-08-16 12:50:39 +01002949 * init/job.c (job_release_depends): Function to release any waiting
2950 dependencies on the given job.
2951 * init/job.h: Update.
2952 * init/tests/test_job.c (test_release_depends): Test the behaviour
2953 of the function on its own.
2954
Scott James Remnant1da1dad2006-08-16 12:18:50 +01002955 * init/job.h (Job): Add depends list field
2956 (JobName): New structure to hold the name of a job.
2957 * init/job.c (job_new): Initialise the depends list.
2958 * init/tests/test_job.c (test_new): Make sure the depends list is
2959 initialised properly.
2960
Scott James Remnant37eee032006-08-16 12:10:49 +01002961 * init/job.c (job_next_state): Return JOB_STARTING if we're in
2962 JOB_WAITING and the goal is JOB_START. This is only called when
2963 there's some change, and I don't want to hard-code the goal there.
2964 (job_start): Don't hardcode JOB_STARTING, instead just use the next
2965 state.
2966 * init/tests/test_job.c (test_next_state): Adjust test case.
2967
Scott James Remnantc3d3ead2006-08-16 09:00:50 +01002968 * init/control.c (control_subscribe): Allow the current
2969 subscription to be found by passing NOTIFY_NONE.
2970 (control_handle): Don't remove an existing subscription to jobs,
2971 a GUI will probably want a permanent one to keep the status up to
2972 date.
2973
Scott James Remnantb9a568c2006-08-16 08:57:46 +01002974 * init/job.c (job_kill_process, job_kill_timer): Don't hardcode
2975 JOB_STOPPING here, instead move to the next logical state.
2976 (job_kill_process): Notify subscribed processes that we killed
2977 the job.
2978 (job_start, job_stop): Notify subscribed processes of a change of
2979 goal that doesn't result in an immediate state change.
2980
Scott James Remnant8dbc6012006-08-16 08:57:38 +01002981 * init/event.c (event_trigger_edge, event_trigger_level): Swap
2982 order so that events are announced before processed.
2983
Scott James Remnant28161252006-08-16 08:41:48 +01002984 * init/control.c (control_handle): Handle requests to watch and
2985 unwatch jobs and events.
2986 * init/tests/test_control.c (test_cb_child, test_cb): Check that
2987 subscriptions work.
2988
Scott James Remnantb6d55bf2006-08-16 08:24:16 +01002989 * init/tests/test_control.c (test_cb_child): Add a sleep to avoid
2990 a race that upsets gdb, have tried this with a STOP/CONT interlock
2991 but can't seem to find where the child should reach first.
2992
Scott James Remnant5612b232006-08-16 08:21:06 +01002993 * init/job.c (job_change_state): Notify the control handler.
2994 * init/event.c (event_trigger_edge, event_trigger_level): Pass
2995 event to the control handler.
2996 * init/tests/test_control.c (test_cb_child): Expect to receive
2997 job status events as well.
2998 * init/Makefile.am (test_event_LDADD, test_process_LDADD)
2999 (test_job_LDADD): Add control.o to the linkage.
3000
Scott James Remnant9e0626a2006-08-16 08:17:07 +01003001 * init/control.c (control_cb): Don't display an error for
3002 ECONNREFUSED, just remove any subscriptions.
3003 * init/tests/test_control.c (test_handle_job, test_handle_error):
3004 Clean up our subscriptions properly.
3005
Scott James Remnant3c465c82006-08-16 07:40:24 +01003006 * init/control.c (control_handle_job): Function to send out an
3007 UPSTART_JOB_STATUS message to subscribed processes whenever a
3008 job state changes.
3009 (control_handle_event): Function to send out an
3010 UPSTART_EVENT_TRIGGERED message to subscribed processes whenever
3011 an event is triggered.
3012 * init/control.h: Update.
3013 * init/tests/test_control.c (test_handle_job, test_handle_event):
3014 Check that the functions work properly.
3015
Scott James Remnant16dadc52006-08-16 07:27:40 +01003016 * init/control.c (control_handle): Handle messages that trigger
3017 edge and level events; subscribe the process to receive notification
3018 of job changes during the event.
3019 * init/tests/test_control.c (test_cb_child): Check that the messages
3020 are handled properly (without subscription check).
3021
Scott James Remnanta7ba72a2006-08-16 07:11:30 +01003022 * init/control.c (control_cb): Unsubscribe a process if it stops
3023 listening.
3024
Scott James Remnant2c9669c2006-08-16 07:10:05 +01003025 * init/control.c (control_send): Copy the pointers in the new
3026 event messages.
3027 * init/tests/test_control.c (test_send): Check the pointers are
3028 copied across correctly.
3029
Scott James Remnant15d61c62006-08-16 06:55:58 +01003030 * init/control.c (control_subscribe): Add function to handle
3031 processes that want to subscribe to changes.
3032 (control_init): Initialise the subscriptions list.
3033 * init/control.h: Add structures and prototypes.
3034 * init/tests/test_control.c (test_subscribe): Test the function.
3035
Scott James Remnant8692f762006-08-16 06:21:13 +01003036 * upstart/control.h (UpstartMsgType): add messages for triggering
3037 edge and level events, receiving the trigger for an event and for
3038 watching jobs and events.
3039 (UpstartEventTriggerEdgeMsg, UpstartEventTriggerLevelMsg)
3040 (UpstartEventTriggeredMsg, UpstartWatchJobsMsg)
3041 (UpstartUnwatchJobsMsg, UpstartWatchEventsMsg):
3042 (UpstartUnwatchEventsMsg): Add structures for the new messages.
3043 (UpstartMsg): And add them to the union.
3044 * upstart/control.c (WireEventPayload): The event messages can all
3045 share a wire payload type; the watch messages don't need any special
3046 payload.
3047 (upstart_send_msg_to): Add the payloads onto the wire.
3048 (upstart_recv_msg): And take the payloads back off the wire.
3049 * upstart/tests/test_control.c (test_messages): Test the new
3050 message types.
3051
Scott James Remnant8ed97eb2006-08-16 05:46:44 +01003052 * upstart/control.h (UpstartJobStatusMsg): add a process id.
3053 * upstart/control.c (WireJobStatusPayload): and here too.
3054 (upstart_send_msg_to): copy the process id onto the wire.
3055 (upstart_recv_msg): copy the process id from the wire.
3056 * init/control.c (control_handle): Fill in the pid from the job.
3057 * upstart/tests/test_control.c (test_messages): Check the pid gets
3058 passed across the wire properly.
3059
Scott James Remnant7d914312006-08-16 05:37:50 +01003060 * init/control.c (control_cb): Disable the poll for write once the
3061 send queue becomes empty.
3062
Scott James Remnant59707c22006-08-16 05:32:20 +01003063 * upstart/Makefile.am (libupstart_la_SOURCES): Correct ordering.
3064
Scott James Remnanta98c8b82006-08-16 05:32:02 +01003065 * init/control.c (control_handle): Add missing break.
3066
Scott James Remnantb5c7a302006-08-16 05:24:55 +01003067 * upstart/job.c (job_goal_name, process_state_name): For completeness
3068 add these two functions as well.
3069 * upstart/job.h: Update.
3070 * upstart/tests/test_job.c (test_goal_name)
3071 (test_process_state_name): Test the new functions.
3072
Scott James Remnant20b15ad2006-08-16 05:20:02 +01003073 * init/job.c (job_state_name): Move this utility function from here
3074 * upstart/job.c (job_state_name): to here so all clients can use
3075 it.
3076 * init/job.h: Update.
3077 * upstart/job.h: Update.
3078 * init/tests/test_job.c (test_state_name): Move the test case from here
3079 * upstart/tests/test_job.c: to here as well.
3080 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link job.c
3081 (TESTS): Run the job test cases
3082 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for
3083 job test case binary.
3084 * init/Makefile.am (test_job_LDADD, test_process_LDADD)
3085 (test_event_LDADD): Link to libupstart.la
3086
Scott James Remnant7a5c6672006-08-16 05:01:13 +01003087 * init/control.c: Code to handle the server end of the control
3088 socket, a bit more complex than a client as we want to avoid
3089 blocking on malcious clients.
3090 * init/control.h: Prototypes.
3091 * init/tests/test_control.c: Test the control code.
3092 * init/Makefile.am (init_SOURCES): Build and link control.c
3093 using the control.h header
3094 (init_LDADD): Link to libupstart as well
3095 (TESTS): Build and run the control test suite.
3096 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
3097 Details for control test suite binary.
3098
Scott James Remnantb7cbda52006-08-16 04:53:38 +01003099 * upstart/control.c: Add a way to disable the safety checks.
3100 * upstart/tests/test_control.c (test_free): Fix bad test case.
3101
Scott James Remnant71d4d842006-08-16 04:29:21 +01003102 * upstart/control.c (upstart_recv_msg): fixed bogus return type
3103 for recvmsg from size_t to ssize_t so we don't infiniloop on error.
3104
Scott James Remnant2bda3832006-08-16 03:41:10 +01003105 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Avoid
3106 job_start as the short-cut for assigning name, as that might become
3107 a more complex message eventually. Use job_query instead.
3108
Scott James Remnantd154b952006-08-16 03:39:35 +01003109 * upstart/control.c (upstart_free): Add wrapper function around
3110 nih_free so we're a proper library and don't expose libnih too much
3111 (upstart_recv_msg): Stash the sender pid in an argument.
3112 * upstart/control.h: Update.
3113 * upstart/tests/test_control.c (test_recv_msg): Test pid is
3114 returned properly.
3115 (test_free): Test the nih_free wrapper.
3116
Scott James Remnantdc0eb442006-08-16 02:40:29 +01003117 * init/job.c (job_run_script): Document future FIXME.
3118
Scott James Remnant2f558532006-08-16 02:24:55 +01003119 * init/exent.h, init/job.h, init/process.h: Fix up headers.
3120
Scott James Remnant45aab692006-08-16 02:23:27 +01003121 * upstart/control.c, upstart/control.h, upstart/errors.h,
3122 upstart/job.h, upstart/libupstart.h: Fix up headers.
3123
Scott James Remnant8c16cc82006-08-16 02:13:40 +01003124 * upstart/control.c: Write the code to handle the control socket
3125 and communication over it; turns out this was possible to write so
3126 that both ends are handled in the same code.
3127 * upstart/control.h: Structures and prototypes.
3128 * upstart/tests/test_control.c: Test the new code.
3129
Scott James Remnant729d9222006-08-16 02:12:23 +01003130 * upstart/Makefile.am (libupstart_la_LIBADD): Link to libnih
3131
Scott James Remnantb9814432006-08-16 02:11:51 +01003132 * upstart/errors.h: Header file containing errors raised by
3133 libupstart.
3134 * upstart/libupstart.h: Include errors.h
3135
Scott James Remnant342451a2006-08-15 00:08:20 +010031362006-08-15 Scott James Remnant <scott@netsplit.com>
3137
Scott James Remnant0a8e3472006-08-15 23:54:14 +01003138 * init/event.h: Add missing attribute for event_new()
3139
Scott James Remnant6f128872006-08-15 23:54:05 +01003140 * init/job.h (JobGoal, JobState, ProcessState, ConsoleType): Move
3141 the enums from here
3142 * upstart/job.h: into here so that we can use them across the
3143 control socket.
3144
Scott James Remnante5831792006-08-15 21:46:21 +01003145 * Makefile.am (SUBDIRS): Build the libupstart library
3146 * configure.ac (AC_CONFIG_FILES): Generate upstart/Makefile
3147 * upstart/Makefile.am: Makefile for sub-directory
3148 * upstart/libupstart.ver: Linker version script.
3149 * upstart/libupstart.h: "Include everything" header file.
3150
Scott James Remnant26a8eec2006-08-15 05:46:27 +01003151 * TODO: Update.
3152
Scott James Remnant1f8619c2006-08-15 05:45:38 +01003153 * init/job.c (job_handle_child): Warn when processes are killed
3154 or exit with an abnormal status. Warn when respawning.
3155
Scott James Remnanteb5ad272006-08-15 05:43:05 +01003156 * init/job.c (job_handle_child): Respawn processes that were not
3157 supposed to have died.
3158 * init/tests/test_job.c (test_handle_child): Test the respawn code.
3159
Scott James Remnant77c926d2006-08-15 05:22:08 +01003160 * TODO: Update.
3161
Scott James Remnant429cd672006-08-15 05:09:51 +01003162 * init/event.c (event_trigger_edge, event_trigger_level): Call
3163 job_handle_event so that we actually do something useful.
3164 * init/Makefile.am (test_event_LDADD): Link to process.o and job.o
3165 now that event.c calls code from job.
3166
Scott James Remnant355e1b62006-08-15 05:07:24 +01003167 * init/job.c (job_start_event): Function to start a job if an event
3168 matches.
3169 (job_stop_event): Function to stop a job if an event matches.
3170 (job_handle_event): Iterate the job list and dispatch the given event,
3171 causing jobs to be stopped or started using the above two functions.
3172 * init/job.h: Update.
3173 * init/tests/test_job.c: Test the new functions.
3174
Scott James Remnant923400d2006-08-15 04:27:44 +01003175 * init/job.c (job_new): Initialise start_events and stop_events to
3176 an empty list.
3177 * init/job.h (Job): Add start_events and stop_events list heads.
3178 * init/tests/test_job.c (test_new): Check the lists are initialised
3179 correctly to the empty list.
3180
Scott James Remnant865534f2006-08-15 04:22:06 +01003181 * init/event.c (event_match): Function to check events for equality.
3182 * init/event.h: Update.
3183 * init/tests/test_event.c (test_match): Test function.
3184
Scott James Remnant97137a72006-08-15 04:07:08 +01003185 * init/job.c (job_change_state): Trigger the level event with the
3186 same name as the job, with the value taken from the state.
3187 * init/tests/test_job.c (test_change_state): Check the event
3188 gets set to the right values as we go.
3189 * init/Makefile.am (test_job_LDADD, test_process_LDADD): Link to
3190 event.o now that job.c uses code from there.
3191
Scott James Remnant3b35a522006-08-15 04:01:32 +01003192 * init/event.c (event_change_value): Rename event_set_value to this
3193 as we intended in the first place; makes it more consistent with job.
3194 Always change the value.
3195 (event_trigger_edge): Add a high-level function to trigger an edge
3196 event.
3197 (event_trigger_level): And another to trigger a level event with
3198 a given value, this inherits the "don't change it" functionality
3199 that was in event_set_value.
3200 * init/event.h: Update.
3201 * init/tests/test_event.c: Test new behaviours and functions.
3202
Scott James Remnant4fef0732006-08-15 01:45:02 +01003203 * init/event.c: Add simple code to keep track of events, whether
3204 they have been recorded or not and their current value if any.
3205 * init/event.h: Structures and prototypes.
3206 * init/tests/test_event.c: Test cases for event code.
3207 * init/Makefile.am (init_SOURCES): Build and link event.c using event.h
3208 (TESTS): Run the event test suite.
3209 (test_event_SOURCES, test_event_LDFLAGS, test_event_LDADD): Details
3210 for event test suite binary.
3211
Scott James Remnant38fc8ff2006-08-15 00:43:26 +01003212 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
3213 Downgrade error messages to warning as they're not fatal.
3214 (job_change_state): Change info message to be more regular.
3215
Scott James Remnantf033fb02006-08-15 00:37:33 +01003216 * init/job.c (job_start): A very simple, but very necessary, function.
3217 Set the goal of the given job to JOB_START and kick it off.
3218 (job_stop): And its companion, cause a running job to be stopped.
3219 * init/job.h: Update.
3220 * init/tests/test_job.c: Test the functions.
3221
Scott James Remnant342451a2006-08-15 00:08:20 +01003222 * init/job.c (job_handle_child): Child handler to kick jobs into
3223 the next state when their process dies.
3224 * init/job.h: Update.
3225 * init/tests/test_job.c (test_handle_child): Test the handler
3226 directly by just invoking it with various job states.
3227
Scott James Remnant1c463b92006-08-14 14:46:17 +010032282006-08-14 Scott James Remnant <scott@netsplit.com>
3229
Scott James Remnant51c827d2006-08-14 23:06:00 +01003230 * init/tests/test_process.c (test_kill): Use select rather than
3231 poll for consistency with other test cases.
3232
Scott James Remnante6e4a732006-08-14 23:04:53 +01003233 * init/job.c (job_kill_process): Add function to send the active
3234 process of a job the TERM signal, and then set a timer to follow
3235 up with the KILL signal if the job doesn't get cleaned up in time.
3236 (job_kill_timer): Timer callback to send the KILL signal; this
3237 does the same job as the child handler and puts the job into the
3238 next state as there's no point waiting around now.
3239 * init/job.h: Update.
3240 * init/tests/test_job.c (test_kill_process): Test both functions
3241 in one test case (as one is just the bottom half of the other).
3242
Scott James Remnant6868f652006-08-14 21:42:45 +01003243 * init/tests/test_process.c (test_spawn): Use the right thing in
3244 the test case filename and unlink it to make sure.
3245
Scott James Remnant85df9422006-08-14 21:41:39 +01003246 * init/job.c (job_change_state): Write the principal state gate
3247 function, called once a state has been left to enter the given new
3248 state (which one should determine with job_next_state). Spawns
3249 the necessary processes or moves to the next appropriate state.
3250 * init/job.h: Update.
3251 * init/tests/test_job.c: Test the state changes.
3252
Scott James Remnantba44b8b2006-08-14 20:06:28 +01003253 * init/job.c (job_run_process): Internal function to call
3254 process_spawn and update the job structure.
3255 (job_run_command): Simple(ish) wrapper for the above to split
3256 a command by whitespace, or use a shell if it needs more complex
3257 argument processing.
3258 (job_run_script): More complex wrapper that uses a shell to execute
3259 verbatim script, either using -c or a /dev/fd/NN and feeding the
3260 shell down a pipe to it.
3261 * init/job.h: Update.
3262 * init/tests/test_job.c: Test the new functions.
3263
Scott James Remnant156f5482006-08-14 19:09:55 +01003264 * init/Makefile.am (init_SOURCES, TESTS): Reorder so that process.c,
3265 which is arguably lower level, comes first.
3266 (test_job_LDADD): Link the process code.
3267 (test_process_LDADD): Swap the order.
3268
Scott James Remnant00bcc932006-08-14 19:07:28 +01003269 * TODO: Update.
3270
Scott James Remnant1c463b92006-08-14 14:46:17 +01003271 * init/process.c (process_spawn): Correct typo (progress -> process),
3272 thanks Johan.
3273
Scott James Remnant43534ca2006-08-12 14:52:01 +010032742006-08-12 Scott James Remnant <scott@netsplit.com>
3275
Scott James Remnant3030cc22006-08-12 15:18:55 +01003276 * init/process.c (process_spawn): Correct formatting of function.
3277 * init/process.h (SHELL): Define the location of the shell, all in
3278 the spirit of not hard-coding stuff like this.
3279
Scott James Remnant43534ca2006-08-12 14:52:01 +01003280 * init/job.c (job_new): Initialise all structure members to zero
3281 as this doesn't happen automatically.
3282
Scott James Remnant60b03e32006-08-10 00:59:00 +010032832006-08-10 Scott James Remnant <scott@netsplit.com>
3284
3285 * init/job.h (job_state_name): Declare as a const function.
3286
Scott James Remnant143a8572006-08-09 17:37:00 +010032872006-08-09 Scott James Remnant <scott@netsplit.com>
3288
Scott James Remnantd945d2e2006-08-09 23:47:44 +01003289 * init/job.c (job_next_state): State transition logic; this uses
3290 our departure from the specification (the goal) so that the state
3291 can always be currently accurate rather than suggestive.
3292 (job_state_name): Cute function to convert enum into a name.
3293 * init/job.h: Update.
3294 * init/tests/test_job.c (test_next_state): Test the transitions.
3295 (test_state_name): And the return values.
3296
Scott James Remnant5fa15672006-08-09 23:23:17 +01003297 * TODO: Add file to keep track of things.
3298
Scott James Remnantdbc78612006-08-09 23:22:45 +01003299 * init/job.c: Include nih/macros.h and nih/list.h
3300 * init/process.c: Include order fixing, include nih/macros.h
3301 * init/tests/test_job.c: Include nih/macros.h and nih/list.h
3302 * init/tests/test_process.c: Include nih/list.h
3303
Scott James Remnant03853ed2006-08-09 23:11:59 +01003304 * init/job.c: Include order fixing.
3305 (job_find_by_name): Function to find a job by its (unique) name.
3306 (job_find_by_pid): Function to find a job by the pid of its process.
3307 * init/job.h: Update.
3308 * init/tests/test_job.c (test_find_by_name, test_find_by_pid): Test
3309 new functions.
3310
Scott James Remnant143a8572006-08-09 17:37:00 +01003311 * init/process.c (process_spawn): Spawn a process using the job
3312 details to set up the environment, etc.
3313 (process_setup_console): Set up the console according to the job.
3314 (process_setup_limits): Set up the limits according to the job.
3315 (process_setup_environment): Set up the environment according to
3316 the job.
3317 (process_kill): Simple function to send a kill signal or raise an
3318 error; mostly just a wrapper without any particular logic.
3319 * init/process.h: Prototypes and macros.
3320 * init/tests/test_process.c: Test cases.
3321 * init/Makefile.am (init_SOURCES): Build and link process.c and
3322 its header file.
3323 (TESTS): Run the process test suite.
3324 (test_process_SOURCES, test_process_LDFLAGS, test_process_LDADD):
3325 Details for process test sutie binary.
3326
Scott James Remnant29abda02006-08-08 15:01:24 +010033272006-08-08 Scott James Remnant <scott@netsplit.com>
3328
Scott James Remnant31ee2632006-08-08 15:06:02 +01003329 * init/job.c (job_new): nih_list_free is necessary.
3330 * init/tests/test_job.c (test_new): Free job when done.
3331
Scott James Remnant29abda02006-08-08 15:01:24 +01003332 * init/job.h: Header file to contain the definition of the Job
3333 structure and associated typedefs, etc.
3334 (JobGoal): In a divergence from the specification, we introduced a
3335 "goal" for a job which tells us which way round the state machine
3336 we're going (towards start, or towards stop).
3337 (JobState): Which means this always holds the current state, even
3338 if we're trying to get out of this state (ie. if we've sent the TERM
3339 signal to the running process, we're still in the running state until
3340 it's actually been reaped).
3341 (ProcessState): And in another divergence, we keep the state of the
3342 process so we know whether we need to force a state transition or
3343 can just expect one because something transient is happening.
3344 * init/job.c (job_new): Function to allocate a Job structure, set
3345 the pointers to NULL and other important members to sensible
3346 defaults.
3347 (job_init): Initialise the list of jobs.
3348 * init/tests/test_job.c: Test suite.
3349 * init/Makefile.am (init_SOURCES): Compile and link job.c using
3350 its header file.
3351 (TESTS): Run the job test suite.
3352 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for the
3353 job test suite binary.
3354
Scott James Remnantb933bc92006-08-02 02:29:25 +010033552006-08-02 Scott James Remnant <scott@netsplit.com>
3356
Scott James Remnant6c7667a2006-08-02 02:43:12 +01003357 * configure.ac: Check for C99
3358
Scott James Remnantb933bc92006-08-02 02:29:25 +01003359 * HACKING: Document dependency on libnih.
3360
Scott James Remnanta780d6c2006-07-27 18:40:51 +010033612006-07-27 Scott James Remnant <scott@netsplit.com>
3362
3363 * init/Makefile.am (DEFS): Append to the default DEFS list, rather
3364 than overriding, otherwise we lose HAVE_CONFIG_H
3365
Scott James Remnantb6270dd2006-07-13 02:16:38 +010033662006-07-13 Scott James Remnant <scott@netsplit.com>
3367
Scott James Remnant1bb35142006-07-13 02:30:58 +01003368 * HACKING: Correct incorrect Bazaar URL.
3369
Scott James Remnantb6270dd2006-07-13 02:16:38 +01003370 * AUTHORS: Change e-mail address to ubuntu.com.
3371 * HACKING: Update Bazaar and Release URLS.
3372 * configure.ac (AC_COPYRIGHT): Change copyright to Canonical Ltd.
3373 (AC_INIT): Change bug submission address to Launchpad.
3374 * init/main.c: Update header to use Canonical copyright and
3375 credit me as author.
3376
Scott James Remnant50748842006-05-16 21:02:31 +010033772006-05-16 Scott James Remnant <scott@netsplit.com>
3378
3379 * init/main.c: Add the simplest template main.c
3380 * init/Makefile.am: Add template Makefile.am that builds init from
3381 main.c and links to libnih statically
3382 * configure.ac (AC_CONFIG_FILES): Configure nih and init subdirs.
3383 * Makefile.am (SUBDIRS): Recurse into nih and init subdirs.
3384
Scott James Remnant8a0cd072006-05-14 18:28:58 +010033852006-05-14 Scott James Remnant <scott@netsplit.com>
3386
3387 * ChangeLog: Initial project infrastructure created.