blob: 3c1454924df43ebd8def99c55e11c8a6d46fc50a [file] [log] [blame]
Scott James Remnant0ea658f2011-03-22 10:46:46 -070012011-3-22 Scott James Remnant <scott@netsplit.com>
2
Scott James Remnant8c89a7b2011-03-22 10:52:25 -07003 * NEWS: Release 1.2
4
Scott James Remnant0ea658f2011-03-22 10:46:46 -07005 * init/job_process.c (job_process_run): Correct shell redirection;
6 the form we used dosen't work with at least pdksh
7
Scott James Remnant74c6f022011-03-16 14:55:03 -070082011-03-16 Scott James Remnant <scott@netsplit.com>
9
Scott James Remnantde6c4eb2011-03-16 18:03:52 -070010 * configure.ac: Bump version to 1.2
11 * NEWS: Begin new release
12
Scott James Remnantcef00b82011-03-16 18:03:01 -070013 * NEWS: Release 1.1
14
15 * configure.ac (NIH_COPYRIGHT): Update
16
Scott James Remnant540dcfd2011-03-16 15:54:56 -070017 * init/main.c: Don't close the console until initialization is
18 complete.
19
Scott James Remnantc7095772011-03-16 15:49:20 -070020 * util/Makefile.am (uninstall-hook): Clean up symlinks on uninstall
21
Scott James Remnant5e32d582011-03-16 15:42:48 -070022 * init/environ.c (environ_all_valid): Only verify that an = is present
23 (environ_valid): Drop this function, the part of POSIX I read about
24 valid environment variable names only applies to other things defined
25 by POSIX, elsewhere it explicitly says Applications may do whatever
26 they like (and even encourages to avoid conflict)
27 (environ_expand_until): Remove validity check for name.
28 * init/environ.h: Update header.
29 * init/tests/test_environ.c (test_valid): Drop tests.
30 (test_all_valid): Drop name tests.
31 (test_expand): Remove illegal expansion test.
32 * init/tests/test_control.c (test_emit_event): Remove the test case for
33 an invalid name in the environment.
34 * init/tests/test_job_class.c (test_start, test_stop)
35 (test_restart): Change the invalid argument tests to use an entry
36 without an = as the invalid test.
37
Scott James Remnant2e055262011-03-16 15:15:58 -070038 * util/reboot.c: pass '-H' to shutdown when called as 'halt'
39
Scott James Remnant36fa1162011-03-16 15:11:24 -070040 * init/job_process.c (job_process_handler): Check the job's normal exit
41 list, decrease log priority of messages from warning to information if
42 the exit status or signal is in the list.
43 * init/tests/test_job_process.c (test_handler): Change the normal exit
44 test cases to not expect the warning
45
Scott James Remnant74c6f022011-03-16 14:55:03 -070046 * init/job_process.c (job_process_run): Prepend a shell command to the
47 pasted script to force the shell to close the file descriptor being
48 used to paste the script. The shell will already have a new copy when
49 it opened the path.
50
James Hunt38130732011-03-15 11:44:09 -0700512011-03-15 James Hunt <james.hunt@ubuntu.com>
52
53 * init/conf.c (conf_source_reload, conf_source_reload_dir): Fix typos
54 in doc-strings
55 * init/job_process.c (job_process_run): Fix typo in doc-string
56 * init/parse_job.c (stanza_env): Fix typo in doc-string
57
Patty Langasek77be9362011-03-15 11:36:57 -0700582011-03-15 Patty Langasek <harmoney@dodds.net>
59
60 * init/man/init.5: Grammar fixes
61
Jacek Konieczny2dbfe532011-03-15 11:30:57 -0700622011-03-15 Jacek Konieczny <jajcus@jajcus.net>
63
64 * contrib/vim/syntax/upstart.vim: Further improve syntax hilighting
65
Scott James Remnant410a0352011-03-01 20:56:51 -0800662011-03-01 Scott James Remnant <scott@netsplit.com>
67
Scott James Remnantf1d57772011-03-01 21:15:33 -080068 * configure.ac: Bump version to 1.1
69 * NEWS: Begin new release
70
Scott James Remnant410a0352011-03-01 20:56:51 -080071 * NEWS: Release 1.0
72
Scott James Remnant02977f82011-02-17 15:33:04 -0800732011-02-17 Scott James Remnant <scott@netsplit.com>
74
Scott James Remnant6b667b12011-02-17 15:38:40 -080075 * configure.ac, NEWS: Bump version to 1.0
76 * TODO: Update.
77
Scott James Remnant02977f82011-02-17 15:33:04 -080078 * init/tests/test_conf.c (test_source_reload_job_dir): Add tests for
79 a crasher bug when a file is created called ".conf"
80 * init/conf.c (conf_dir_filter): Apply fix for the crasher; check that
81 the character before the ".conf" extension is not "/"
82 * NEWS: Update.
83
Petr Lautrbacha87b18b2011-01-06 07:37:59 +0000842011-01-06 Petr Lautrbach <plautrba@redhat.com>
85
86 * init/job_process.c (job_process_termianted): Don't rewind the
87 utmp file between updates.
88 * init/tests/test_job_process.c (test_utmp): Add test case for
89 newer mingetty behaviour.
90
Scott James Remnant9c6a2032010-12-21 13:54:49 +0000912010-12-21 James Hunt <james.hunt@ubuntu.com>
92
93 * contrib/bash_completion/upstart: Add bash completion script.
94 * contrib/Makefile.am (EXTRA_DIST): Include in tarball.
95 * NEWS: Update.
96
Scott James Remnante5e20692010-12-20 09:57:55 +0000972010-12-20 Scott James Remnant <scott@netsplit.com>
98
99 * NEWS: update.
100
Petr Lautrbach18ff78d2010-12-20 09:46:30 +00001012010-12-20 Petr Lautrbach <plautrba@redhat.com>
102
Petr Lautrbach0fa3d322010-12-20 09:50:06 +0000103 * init/job_process.c (job_process_terminated): On termination of
104 a job, update the utmp file replacing any existing entry for that
105 pid with a DEAD_PROCESS entry; likewise append an entry to wtmp.
106 * init/tests/test_job_process.c (test_utmp): Test utmp handling.
107
Petr Lautrbach18ff78d2010-12-20 09:46:30 +0000108 * util/shutdown.c: Exit non-zero if unable to shutdown the system.
109
Scott James Remnant8d4c7372010-12-14 15:30:06 +00001102010-12-14 Scott James Remnant <scott@netsplit.com>
111
Scott James Remnant42fb11b2010-12-14 16:41:18 +0000112 * configure.ac: Bump version to 0.6.8
113 * NEWS: Begin new release
114
Scott James Remnant5f66d4d2010-12-14 16:40:26 +0000115 * NEWS: Release 0.6.7
116
Scott James Remnant8d4c7372010-12-14 15:30:06 +0000117 * dbus/com.ubuntu.Upstart.Job.xml (start_on, stop_on, emits): Add new
118 properties to return the job's relationship to events.
119 * init/job_class.c (job_class_get_start_on)
120 (job_class_get_stop_on, job_class_get_emits): Implement the properties
121 * init/job_class.h: Add prototypes.
122 * init/tests/test_job_class.c (test_get_start_on)
123 (test_get_stop_on, test_get_emits): Test the new properties too
124
Scott James Remnant3cf46382010-12-14 12:20:28 +00001252010-12-14 James Hunt <james.hunt@ubuntu.com>
James Huntb75bd612010-12-14 11:40:13 +0000126
James Huntf5ee6b92010-12-14 16:15:46 +0000127 * init/parse_job.c (stanza_manual): New function to handle manual
128 stanza.
129 * init/tests/test_parse_job.c (test_stanza_manual): New function to
130 test manual stanza.
131 * init/man/init.5: Update for manual stanza.
132
1332010-12-14 James Hunt <james.hunt@ubuntu.com>
134
James Huntb75bd612010-12-14 11:40:13 +0000135 * init/job_class.h: Added debug member.
136 * init/job_class.c: Initialized debug member.
137 * init/job_process.c: Pause child using raise(3).
138 * init/main.c: Display PID+PPID for debug builds.
139 * init/parse_job.c: Added new function stanza_debug.
140 * init/tests/test_job_process.c (test_spawn): Added test for debug stanza.
141
Scott James Remnanta6c05362010-12-10 04:04:51 +00001422010-12-10 Scott James Remnant <scott@netsplit.com>
143
144 * dbus/upstart.h (DBUS_SERVICE_UPSTART, DBUS_ADDRESS_UPSTART):
145 For debugging purposes, when -DDEBUG is given, change the values of
146 these constants. You'll need to modify your own D-Bus configuration
147 of course.
148
Scott James Remnant89258142010-12-09 21:10:38 +00001492010-12-09 Scott James Remnant <scott@netsplit.com>
150
151 * init/tests/test_job.c (test_change_state): Add missing
152 DBUS_TYPE_INVALID to dbus_message_get_args() call.
153
Scott James Remnant48ac0882010-12-09 21:04:03 +00001542010-12-08 Colin Watson <cjwatson@debian.org>
Colin Watsone2d8fac2010-11-13 02:44:08 +0000155
Scott James Remnant48ac0882010-12-09 21:04:03 +0000156 * dbus/com.ubuntu.Upstart.Instance.xml (GoalChanged, StateChanged)
157 (Failed): New signals.
Colin Watsone2d8fac2010-11-13 02:44:08 +0000158 * init/job.c (job_change_goal): Emit GoalChanged signal after
Scott James Remnant48ac0882010-12-09 21:04:03 +0000159 (job_change_state): Emit StateChanged signal after changing state.
Colin Watson874aab12010-11-13 01:47:34 +0000160 (job_failed): Emit Failed signal after marking job as failed.
Scott James Remnant48ac0882010-12-09 21:04:03 +0000161 * init/tests/test_job.c (test_change_goal): Test for this.
162 (test_change_state): Test for this.
Colin Watson8ed1c1e2010-11-10 23:23:22 +0000163 * NEWS: Update.
164
Scott James Remnant3cf46382010-12-14 12:20:28 +00001652010-12-08 James Hunt <james.hunt@ubuntu.com>
Scott James Remnant87796f62010-12-08 18:40:25 +0000166
167 * init/event.c, init/event_operator.c: Fix grammar and factual errors
168 in comments.
169 * init/man/init.5: Fix grammar errors and clarify export behaviour.
170
Scott James Remnantda55fa12010-12-08 18:33:41 +00001712010-12-08 Clint Byrum <clint@ubuntu.com>
172
173 * init/man/init.5: Typo existing -> exiting
174
Scott James Remnantdcf52cf2010-08-12 09:49:45 -04001752010-08-12 Scott James Remnant <scott@netsplit.com>
176
177 * init/job_process.c (job_process_spawn): We can fail to open the
178 system console for various reasons, sometimes because there isn't
179 a console (ENXIO or ENODEV) but worse due to kernel race conditions
180 on SMP/multi-core systems (EIO). If "console output" is used, and
181 these happen, fall back to /dev/null.
182
Scott James Remnantbc23b122010-04-27 10:10:19 -07001832010-04-27 Scott James Remnant <scott@netsplit.com>
184
Scott James Remnant319bde12010-04-27 12:48:44 -0700185 * configure.ac: Bump version to 0.6.7
186 * NEWS: Begin new release
187
Scott James Remnant98c65a62010-04-27 12:29:17 -0700188 * NEWS: Release 0.6.6
189
Scott James Remnantbc23b122010-04-27 10:10:19 -0700190 * configure.ac: Bump the requirement of libnih to 1.0.2 after
191 verifying that building using --with-local-libnih and an earlier
192 version installed still works.
193
Scott James Remnantef971542010-04-24 23:18:56 -07001942010-04-24 Scott James Remnant <scott@netsplit.com>
195
196 * configure.ac: Replace the --with-local-libnih code with an
197 expansion of the NIH_WITH_LOCAL_LIBNIH macro that now contains it.
198 * README: Bump libnih version.
199
Colin Watsone9633c92010-03-31 18:29:24 +01002002010-03-31 Colin Watson <cjwatson@ubuntu.com>
201
202 * init/man/init.5 (env): Document behaviour when the environment
203 variable's value is omitted.
204 * init/parse_job.c (stanza_env): Document that arguments may be
205 simply VAR as well as VAR=VALUE.
206
Michael Biebl862fe182010-03-02 00:03:37 +00002072010-03-02 Michael Biebl <mbiebl@gmail.com>
208
209 * configure.ac: Remove double-quoting from NIH_CFLAGS and
210 NIH_DBUS_CFLAGS when using --with-local-libnih
211
Scott James Remnant5ac18352010-02-26 15:27:14 +00002122010-02-26 Scott James Remnant <scott@netsplit.com>
213
Scott James Remnant51d109b2010-02-26 15:33:12 +0000214 * NEWS: Update.
215
Scott James Remnant65ea7a62010-02-26 15:31:13 +0000216 * init/job_process.c (job_process_run): Since /proc is always mounted,
217 guaranteed because we mount it ourselves if it isn't, we don't need
218 to check for it and can always use /proc/self/fd/NNN when we want.
219 * init/tests/test_job_process.c (test_run): Since /proc is always
220 mounted, we don't need to check for it and skip tests.
221
Scott James Remnantd69c1da2010-02-26 15:29:07 +0000222 * init/system.c (system_mount): Add function to mount a kernel
223 filesystem (ie. /proc and /sys)
224 * init/system.h: Add header.
225 * init/main.c: Mount /proc and /sys on initialisation.
226
Scott James Remnant5ac18352010-02-26 15:27:14 +0000227 * init/paths.h (DEV_FD): Drop this definition, it's needless.
228 * init/job_process.c (job_process_run): Rather than using /dev/fd,
229 use /proc/self/fd which is more Linuxish and is always guaranteed to
230 exist when /proc is mounted - needing no symlinks.
231 * init/tests/test_job_process.c (test_run): Adjust test to match.
232
Scott James Remnantb90310b2010-02-09 16:06:55 +00002332010-02-09 Scott James Remnant <scott@netsplit.com>
234
235 * configure.ac: Use NIH_COPYRIGHT instead of AC_COPYRIGHT
236
Scott James Remnant866bfd92010-02-04 00:39:08 -08002372010-02-04 Scott James Remnant <scott@netsplit.com>
238
Scott James Remnantaca75642010-02-04 16:40:04 -0800239 * configure.ac: Bump version to 0.6.6
240 * NEWS: Begin new release
241
Scott James Remnantbfae97b2010-02-04 15:06:41 -0800242 * NEWS: Release 0.6.5
243
Scott James Remnant43af8c62010-02-04 12:43:33 -0800244 * util/tests/test_initctl.c (test_reload_action): Don't send
245 SIGHUP to the server process, it'll be terminated anyway since
246 reload doesn't loop.
247
Scott James Remnant9f236472010-02-04 12:08:59 -0800248 * init/event_operator.c (event_operator_match): Support operator
249 negation using !=
250 * init/tests/test_event_operator.c (test_operator_update): Add
251 test cases for negation.
252 * init/man/init.5: Add negation to documentation
253
Scott James Remnantd5890b32010-02-04 11:26:17 -0800254 * init/man/init.8: Improve reference to init(5) to make it more
255 obvious that this is where documentation can be found.
256 * init/man/init.5: Add Upstart to the title to make it show up
257 with man -k upstart
258
Scott James Remnant7b50f2b2010-02-04 11:24:25 -0800259 * init/man/init.8: Add missing OPTIONS section, documenting the
260 --verbose option.
261
Scott James Remnantf99ea0c2010-02-04 11:14:30 -0800262 * init/main.c (main): After resetting the system console, close it
263 again and reopen /dev/null for ourselves so we don't hold the
264 system console open.
265
Scott James Remnant34940012010-02-04 11:09:55 -0800266 * init/job_process.c (job_process_error_abort): Free the error
267 before exiting.
268
Scott James Remnant004d8c02010-02-04 11:08:07 -0800269 * util/initctl.c (reload_action): Add a reload command, this obtains
270 the pid of the main process of the given job instance and sends
271 SIGHUP to it. It might not be in its final form, but it's damned
272 useful for now.
273 * util/tests/test_initctl.c (test_reload_action): Add test cases.
274 * util/man/initctl.8: Add documentation for the reload command,
275 and missing documentation for restart.
276 * util/Makefile.am (install-data-hook, install-exec-hook): Create
277 additional reload symlinks.
278
Scott James Remnant61626292010-02-04 00:43:56 -0800279 * util/reboot.c (main): Restore the sync() system call before
280 calling reboot(); the Linux kernel says we have to do this, and I
281 suspect that ext4 is no longer forcing this before power off.
282
Scott James Remnante7138052010-02-04 00:41:25 -0800283 * init/main.c (hup_handler): Move call to reconnect to D-Bus system
284 bus into new function
285 (usr1_handler): This is because a config reload "forgets" existing
286 state, such as events that were pending.
287 (main): Add SIGUSR1 signal handler.
288
Scott James Remnant866bfd92010-02-04 00:39:08 -0800289 * init/job_process.c (job_process_handler): Reduce priority of the
290 stopped/continued by signal messages to informational.
291
Scott James Remnant6d610662010-02-03 20:00:11 -08002922010-02-03 Scott James Remnant <scott@netsplit.com>
293
294 * util/shutdown.c (shutdown_now): Free error before exiting.
295
Johan Kiviniemi7ea666f2010-02-03 19:59:06 -08002962010-02-03 Johan Kiviniemi <johan@kiviniemi.name>
297
298 * conf/rc-sysinit.conf: Don't replace DEFAULT_RUNLEVEL with an
299 empty string when there is no "initdefault" line in /etc/inittab
300
Scott James Remnantb3918a62010-02-03 16:39:50 -08003012010-02-03 Scott James Remnant <scott@netsplit.com>
302
Scott James Remnant8003b882010-02-03 19:56:40 -0800303 Update code to work with libnih 1.0.1
304
305 * init/tests/test_event.c (test_new): Replace TEST_ALLOC_ORPHAN(env)
306 with TEST_ALLOC_PARENT(env, NULL); discard environment after creating
307 event from it
308 * init/tests/test_event_operator.c (test_operator_new): Replace
309 TEST_ALLOC_ORPHAN(env) with TEST_ALLOC_PARENT(env, NULL); discard
310 environment after creating event from it
311 * init/tests/test_control.c (test_emit_event): Discard event
312 environment after emission
313 * init/init.supp: Add nih_alloc_ref_new() to init functions
314
Scott James Remnantd2350362010-02-03 19:42:29 -0800315 libnih is now released as its own project, so rather than expecting
316 to include it with the source we depend on it being outside of it.
317
318 * Makefile.am (SUBDIRS): Remove m4 directory along with the nih bits.
319 (EXTRA_DIST): Remove ChangeLog.nih
320 * configure.ac (AM_INIT_AUTOMAKE): Remove dist-bzip2, since we don't
321 actually use it; add color-tests and silent-rules.
322 (AM_SILENT_RULES): Use silent rules by default
323 (AM_MAINTAINER_MODE): Enable maintainer mode by default (as before),
324 but allow it to be disabled
325 (AM_GNU_GETTEXT_VERSION): Bump to 0.17
326 (NIH_INIT): Replace with the expanded out calls that we actually need.
327 (AC_CONFIG_FILES): Remove nih directories
328 Add magic to allow use of a local libnih source tree.
329 * init/Makefile.am (AM_CFLAGS): Add NIH_CFLAGS and NIH_DBUS_CFLAGS
330 (init_LDADD, test_system_LDADD, test_environ_LDADD, test_process_LDADD)
331 (test_job_class_LDADD, test_job_process_LDADD, test_job_LDADD)
332 (test_event_LDADD, test_event_operator_LDADD)
333 (test_blocked_LDADD, test_parse_job_LDADD)
334 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD):
335 Replace library paths with NIH_LIBS and NIH_DBUS_LIBS
336 ($(com_ubuntu_Upstart_OUTPUTS)),
337 ($(com_ubuntu_Upstart_Job_OUTPUTS)),
338 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Use external nih-dbus-tool
339 and obey silent rules.
340 (test_system_LDFLAGS, test_environ_LDFLAGS)
341 (test_process_LDFLAGS, test_job_class_LDFLAGS)
342 (test_job_process_LDFLAGS, test_job_LDFLAGS, test_event_LDFLAGS)
343 (test_event_operator_LDFLAGS, test_blocked_LDFLAGS)
344 (test_parse_job_LDFLAGS, test_parse_conf_LDFLAGS)
345 (test_conf_LDFLAGS, test_control_LDFLAGS): Drop -static
346 * util/Makefile.am (AM_CFLAGS): Add NIH_CFLAGS and NIH_DBUS_CFLAGS
347 (initctl_LDADD, reboot_LDADD, runlevel_LDADD, shutdown_LDADD)
348 (test_initctl_LDADD, test_utmp_LDADD, test_sysv_LDADD)
349 (test_telinit_LDADD): Replace library paths with NIH_LIBS and
350 NIH_DBUS_LIBS
351 ($(com_ubuntu_Upstart_OUTPUTS)):
352 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
353 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Use external nih-dbus-tool
354 and obey silent rules.
355 (initctl_LDFLAGS, reboot_LDFLAGS, runlevel_LDFLAGS)
356 (shutdown_LDFLAGS, telinit_LDFLAGS, test_initctl_LDFLAGS)
357 (test_utmp_LDFLAGS, test_sysv_LDFLAGS, test_telinit_LDFLAGS): Drop
358 -static
359 * README: Add libnih to the dependencies.
360 * HACKING: Remove the instructions for checking out libnih, replace
361 with a description about how to use a libnih source tree instead of
362 the installed one.
363
Scott James Remnantb3918a62010-02-03 16:39:50 -0800364 * configure.ac: Bump version to 0.6.5, bump copyright year to 2010.
365 * NEWS: Begin new release.
366
Scott James Remnantfacdb672009-08-02 20:01:34 +01003672009-08-02 Scott James Remnant <scott@netsplit.com>
368
369 * NEWS: Release 0.6.3
370
Scott James Remnant826b8762009-08-01 19:08:50 +01003712009-08-01 Scott James Remnant <scott@netsplit.com>
372
373 * init/tests/test_job_process.c (test_handler): Add a missing test
374 case for the running process exiting while we're in the stopping
375 state.
376 * init/job_process.c (job_process_terminated): Don't change the
377 state or record failure information if we're in the stopping state
378 when the main process dies, otherwise we hit an assertion later;
379 just wait for the stopping event to finish and carry on as before.
380
Scott James Remnant1eb81432009-07-31 12:34:43 +01003812009-07-31 Scott James Remnant <scott@netsplit.com>
382
383 * dbus/upstart.h: Allow the service name and address to be overriden
384
Michael Biebl5e2f15b2009-07-29 11:18:47 +01003852009-07-29 Michael Biebl <mbiebl@gmail.com>
386
387 * init/tests/test_job_process.c: Add missing sys/ptrace.h include
388
Scott James Remnantbeae7f22009-07-21 12:27:55 +01003892009-07-21 Scott James Remnant <scott@netsplit.com>
390
Scott James Remnant726290a2009-07-21 18:31:35 +0100391 * configure.ac: Bump version to 0.6.3
392 * NEWS: Begin new release
393
Scott James Remnant73e8fd32009-07-21 18:30:51 +0100394 * NEWS: Release 0.6.2
395
Scott James Remnant9d736bb2009-07-21 18:15:20 +0100396 * init/main.c (crash_handler): Restore missing chdir ("/") call.
397
Scott James Remnant0a0c47d2009-07-21 13:03:23 +0100398 * init/tests/test_job_process.c (test_handler): We should allow
399 a job to exec() before it calls fork() to allow shell scripts to
400 exec daemons.
401 * init/job_process.c (job_process_trace_exec): Continue the traced
402 process instead of detaching if it has not yet forked.
403
Scott James Remnantbeae7f22009-07-21 12:27:55 +0100404 * init/job.c (job_change_state): Obvious bug fix; the set of states
405 into which we can enter JOB_STOPPING includes JOB_STARTING because
406 we can get the "stop" event or command there.
407
Scott James Remnante6de0452009-07-16 17:26:00 +01004082009-07-16 Scott James Remnant <scott@netsplit.com>
409
Scott James Remnant9c372302009-07-16 18:08:52 +0100410 * configure.ac: Bump version to 0.6.2
411 * NEWS: Begin new release
412
Scott James Remnantb52deb12009-07-16 18:05:31 +0100413 * NEWS: Release 0.6.1
414
Scott James Remnant3ef8fac2009-07-16 17:39:04 +0100415 * util/runlevel.c: Output the path before the error message,
416 to make it clear that it's the utmp file missing not runlevel.
417
Scott James Remnante6de0452009-07-16 17:26:00 +0100418 * util/runlevel.c: If there is no current runlevel because the
419 environment variable is empty, output "unknown" instead of "N N".
420
Scott James Remnant0acfdc52009-07-15 11:13:46 +01004212009-07-15 Scott James Remnant <scott@netsplit.com>
422
423 * README: Now that D-Bus 1.2.16 proper has been released, update
424 our requirements.
425
Scott James Remnant6ca3c752009-07-14 11:40:08 +01004262009-07-14 Scott James Remnant <scott@netsplit.com>
427
Scott James Remnant9f175212009-07-14 18:45:47 +0100428 * TODO: Update
429
Scott James Remnantcf9f3ce2009-07-14 14:55:47 +0100430 * init/tests/test_job_process.c (test_handler): Rework the existing
431 ptrace fork handler test case to make sure we test the case where
432 we get the fork event before the stopped child. Add a second test
433 case for the opposite (stopped child before the fork event) which
434 we don't currently handle.
435 * init/job_process.c (job_process_trace_fork): Test for the missed
436 child event using ptrace(), if it succeeds the child is ready so
437 we can just assume we had the event.
438
Scott James Remnant5de1bfe2009-07-14 12:34:49 +0100439 * util/Makefile.am (EXTRA_DIST): Distribute the valgrind suppressions
440 file
441
Scott James Remnant92ac1ce2009-07-14 12:04:34 +0100442 * util/tests/test_utmp.c (test_write_shutdown): Additional instance
443 of the same test.
444
Scott James Remnant6ca3c752009-07-14 11:40:08 +0100445 * util/tests/test_utmp.c (test_write_runlevel): Looks like glibc
446 is fixed to return the right error code.
447
Scott James Remnantce95ce22009-07-11 12:46:57 +01004482009-07-11 Scott James Remnant <scott@netsplit.com>
449
Scott James Remnantde9cacb2009-07-11 12:47:12 +0100450 * init/control.c (control_server_open): Don't hardcode the server
451 address, otherwise the test suite can't test this function.
452 * init/tests/test_control.c (test_server_open)
453 (test_server_connect, test_server_close): Change the server
454 address in the tests.
455
Scott James Remnantce95ce22009-07-11 12:46:57 +0100456 * configure.ac: Bump version to 0.6.1
457 * NEWS: Begin new release
458
Scott James Remnant6e177852009-07-09 00:09:09 +01004592009-07-09 Scott James Remnant <scott@netsplit.com>
460
Scott James Remnant11caefc2009-07-09 17:18:26 +0100461 * NEWS: Release 0.6.0
462
Scott James Remnant057a8692009-07-09 16:40:34 +0100463 * README: Note that we need D-Bus GIT HEAD.
464 * NEWS: Update.
465
Scott James Remnant6e568432009-07-09 16:01:07 +0100466 * init/man/inittab.5: People keep trying "man inittab", so explain
467 that it's gone.
468 * init/Makefile.am (dist_man_MANS): Install it
469
Scott James Remnant7c23b1f2009-07-09 15:56:49 +0100470 * NEWS: Declare the "lacks documentation" bug fixed
471
Scott James Remnant8bdf0712009-07-09 15:54:28 +0100472 * init/man/init.8: Refresh and turn it into more of an overview
473 of Upstart now that we have lots of other pages to refer to.
474 * init/man/upstart.7: Since it's an overview, people might go
475 "man upstart" so redirect to it.
476 * init/man/init.5: Actually document the configuration format.
477 * init/Makefile.am (dist_man_MANS): Install the configuration
478 documentation, and the redirect.
479
Scott James Remnanta5b683a2009-07-09 14:21:16 +0100480 * util/man/runlevel.8, util/man/telinit.8, util/man/shutdown.8,
481 * util/man/reboot.8: Add environment and files sections.
482
Scott James Remnant8a50b2c2009-07-09 13:26:11 +0100483 * init/man/startup.7, init/man/starting.7, init/man/started.7,
484 * init/man/stopping.7, init/man/stopped.7
485 * init/man/control-alt-delete.7, init/man/keyboard-request.7,
486 * init/man/power-status-changed.7: Write manual pages for each
487 of the events generated by the init daemon by default.
488 * init/Makefile.am (dist_man_MANS): Distribute and install the
489 new manpages.
490 * util/man/runlevel.7: Indent the example, don't boldface
491
Scott James Remnantb175de82009-07-09 12:50:19 +0100492 * init/job.c (job_start, job_stop, job_restart): Restructure
493 slightly to avoid gcc warning
494 * init/job_class.c (job_class_start, job_class_restart): Make the
495 same change to these too
496 * util/shutdown.c: Warn if we can't change directory
497 * util/telinit.c: Assert that we don't fall out of the switch
498 * init/tests/test_job_class.c (test_get_version)
499 (test_get_author, test_get_description, test_get_name): Initialise
500 alloc-safe variables to NULL to avoid gcc warning
501 * util/tests/test_initctl.c (test_job_status, test_start_action)
502 (test_stop_action, test_restart_action, test_status_action)
503 (test_list_action, test_emit_action)
504 (test_reload_configuration_action, test_version_action)
505 (test_log_priority_action, test_upstart_open): Initialise alloc-safe
506 variables to NULL and diverted return values to 0 to avoid gcc
507 warnings.
508 (test_start_action, test_stop_action, test_restart_action):
509 Replace sigsetjmp/siglongjmp with a call to _exit() in the handler
510 * util/tests/test_sysv.c (test_change_runlevel): Initialise alloc-safe
511 variables to NULL to avoid gcc warnings
512
Scott James Remnante5cadae2009-07-09 12:02:06 +0100513 * util/man/runlevel.7: Formatting fixes, and mention that rcS
514 runs rc-sysinit again.
515 * util/man/runlevel.8: s/utilities/tools/
516 * util/man/telinit.8: s/utilities/tools/
517 * util/man/shutdown.8: s/utilities/tools/
518 * util/man/reboot.8: s/utilities/programs/
519 * util/man/initctl.8: s/utility/tool/
520
Scott James Remnant60d91ea2009-07-09 12:01:53 +0100521 * init/job_class.h (JobClass): Drop the leader option; at the time
522 it seemed to make sense that Upstart would provide a "daemon"-like
523 environment, but it really doesn't in practice. Software should
524 feel safe to daemonise on its own, and I'd rather fix supervision
525 of those; freeing up Upstart jobs to run as new sessions by default
526 again. This is also the only real option that would change the
527 behaviour between 0.6 and 0.10 in an awkwardly compatible way.
528 * init/job_class.c (job_class_new): Remove leader initialisation
529 * init/tests/test_job_class.c (test_new): Drop the initialisation
530 check for leader
531 * init/parse_job.c (stanza_session): Drop the stanza
532 * init/tests/test_parse_job.c (test_stanza_session): Drop the
533 stanza test cases.
534 * init/job_process.c (job_process_spawn): Drop the double-fork.
535 This means we don't need to read the pid of our extra child either.
536 (job_process_error_read): we no longer need a fork error.
537 * init/job_process.h (JobProcessErrorType): Drop the fork error.
538 * init/tests/test_job_process.c (test_spawn): Replace the simple job
539 test case with the session leader test case, now that's the default.
540 (test_run, test_spawn, test_kill, test_handler): Remove all the
541 class->leader = TRUE from the tests, we only ever really tested
542 session leaders anyway since that's all the test suite could follow
543 * init/tests/test_job.c (test_change_goal, test_change_state):
544 Remove the leader flag from test jobs
545 * init/tests/test_event.c (test_pending, test_finished): Remove
546 the leader flag from test jobs.
547
Scott James Remnant1e812b52009-07-09 10:10:37 +0100548 * init/job_process.c (job_process_catch_runaway): Use a monotonic
549 clock, not the realtime clock, for respawn interval detection.
550 * init/tests/test_job_process.c (test_kill, test_handler): Use the
551 monotonic clock in test cases too
552 * init/Makefile.am (init_LDADD): Link with librt
553 * NEWS: Update.
554
Scott James Remnantfbff5df2009-07-09 09:43:17 +0100555 * util/utmp.c (utmp_write_runlevel): Don't write 'N' to utmp or
556 wtmp for the previous runlevel, this will force writing reboot
557 records if prevlevel='N'/0 since read_runlevel will always return
558 'N' in that case.
559 * util/tests/test_utmp.c (test_write_runlevel): Add test case for
560 passing 'N' and having it treated as zero
561 (test_read_runlevel): Add a couple of test cases for the problems
562 we found last night where shutdown and corrupt utmp records result
563 in the wrong data being returned.
564 * util/tests/test_sysv.c (test_change_runlevel): Add a test case
565 for switching from sysinit to the first runlevel
566
Scott James Remnant8e354982009-07-09 09:36:52 +0100567 * init/conf.h,
568 * init/control.h,
569 * init/event.h,
570 * init/job_class.h: Variable declarations in header files need to
571 be prefixed with "extern", the NIH_BEGIN_EXTERN stuff only applies
572 to C++.
573
Scott James Remnant5619fdc2009-07-09 00:57:10 +0100574 * util/reboot.c: Reboot can't write the shutdown time before
575 calling shutdown, otherwise shutdown won't be able to get the
576 current runlevel anymore.
577 * util/man/reboot.8: Update, we don't write the shutdown time
578 before calling shutdown - it's up to the shutdown scripts to
579 call reboot -w before remounting the root filesystem.
580
Scott James Remnant9c95b102009-07-09 00:39:55 +0100581 * util/tests/test_utmp.c (test_get_runlevel): Replace test case
582 with one that expects 'N' rather than fall-through.
583 * util/tests/test_sysv.c (test_change_runlevel): Expect N when
584 there is no previous runlevel
585
Scott James Remnanta849b0a2009-07-09 00:36:46 +0100586 * util/utmp.c (utmp_read_runlevel): Also catch a zero runlevel from
587 utmp, replacing with 'N' - these functions should never return 0
588 * util/sysv.c (sysv_change_runlevel): Should set prevlevel to N
589 when we don't find one
590
Scott James Remnant5091edc2009-07-09 00:34:53 +0100591 * util/utmp.c (utmp_read_runlevel): Catch a negative runlevel from
592 corrupt utmp data, convert to 'N'
593 (utmp_get_runlevel): Return N when RUNLEVEL is set but empty,
594 rather than falling through
595
Scott James Remnant98af00b2009-07-09 00:22:25 +0100596 * util/telinit.c: Catch a missing argument separately so we don't
597 output "(null)"
598
Scott James Remnantbf7399d2009-07-09 00:14:49 +0100599 * README: Update requirements.
600 * TODO: Update.
601
Scott James Remnant6e177852009-07-09 00:09:09 +0100602 * conf/rc-sysinit.conf: Fix typo.
603
Scott James Remnant63473d72009-07-08 21:03:50 +01006042009-07-08 Scott James Remnant <scott@netsplit.com>
605
Scott James Remnant5094d2e2009-07-08 23:04:13 +0100606 * conf/rc-sysinit.conf: Michael Biebl pointed out that by setting
607 the runlevel to "S" during sysinit, we end up with the runlevel
608 after boot being "S 2" - and that means scripts in rc2.d that
609 are also in rcS.d won't get started. The way we had it before
610 ("N 2") was correct. This happily fixes the one corner case our
611 reboot handling didn't cover - crashing in single user mode and
612 rebooting.
613
Scott James Remnantc80b09f2009-07-08 22:48:03 +0100614 * util/telinit.c: Fix missing ret = from kill
615
Scott James Remnantdf7d14a2009-07-08 22:46:26 +0100616 * conf/rc-sysinit.conf: Ignore -s/single if we're already coming
617 from single-user-mode.
618
Scott James Remnantc2ebba92009-07-08 22:43:49 +0100619 * util/telinit.c (options): Unignore the -t option
620 * NEWS: Update.
621
Scott James Remnant911cb2e2009-07-08 22:40:50 +0100622 * init/main.c (hup_handler): Also try and reconnect to the message
623 bus if we've lost the connection.
624
Scott James Remnant545bbe32009-07-08 22:05:59 +0100625 * init/conf.c (conf_source_reload_dir): Don't blacklist certain
626 patterns from the configuration directory, instead just filter
627 to whitelist.
628 (conf_dir_filter): Whitelist filter, only accept files ending
629 in .conf
630 (conf_reload_path): Strip .conf from the filename to generate
631 the job name.
632 (conf_file_filter): Add the extra is_dir argument.
633 * init/tests/test_conf.c (test_source_reload_job_dir)
634 (test_source_reload_conf_dir, test_source_reload_file)
635 (test_source_reload): Append .conf to all our filenames
636 * init/tests/test_control.c (test_reload_configuration): Append
637 .conf to filenames here too
638 * NEWS: Update.
639
Scott James Remnant63473d72009-07-08 21:03:50 +0100640 * init/job_process.c (job_process_run): Stop being stingy, the
641 post-stop script can have the stop environment too
642 * init/tests/test_job_process.c (test_run): Add a test case to
643 make sure it is.
644
Scott James Remnantd3a6ca72009-07-08 20:59:21 +01006452009-07-08 Michael Biebl <mbiebl@gmail.com>
646
647 * contrib/vim/syntax/upstart.vim: Upstart job syntax highlighting
648 * contrib/vim/ftdetect/upstart.vim: Use for the /etc/init directory
649 * contrib/Makefile.am: Include the vim syntax files in the
650 distribution
651 * configure.ac (AC_CONFIG_FILES): Create contrib/Makefile
652 * Makefile.am (SUBDIRS): Recurse into the contrib sub-directory
653
Scott James Remnant9f322cb2009-07-08 15:42:15 +01006542009-07-08 Scott James Remnant <scott@netsplit.com>
655
Scott James Remnant0a046c62009-07-08 20:55:15 +0100656 * conf/rc.conf: This doesn't need to be an instance job, Upstart
657 will do the right thing and stop the task before starting it again
658 with the new environment (I spent so much time on that, you'd think
659 I'd remember :p)
660
Scott James Remnantedb382a2009-07-08 20:43:16 +0100661 * conf/control-alt-delete.conf: Default job for Control-Alt-Delete
662 * conf/rc-sysinit.conf: Default job for system initialisation
663 * conf/rc.conf: A fully wacky instance job that runs the rc script
664 for runlevel changes
665 * conf/rcS.conf: And a job for single-user-mode, which calls back
666 to rc-sysinit
667 * conf/Makefile.am (dist_init_DATA): Install the default files
668 into the /etc/init directory
669 * configure.ac (AC_CONFIG_FILES): Create conf/Makefile
670 * Makefile.am (SUBDIRS): Recurse into the conf directory.
671
Scott James Remnant10a35f22009-07-08 20:05:46 +0100672 * util/initctl.c (upstart_open, start_action, stop_action)
673 (restart_action, status_action, list_action): Don't auto-start
674 the init daemon, it makes no sense.
675 (upstart_open): When not running from the test suite, and not as
676 root, it makes sense to default to using the system bus daemon.
677 * util/tests/test_initctl.c (test_upstart_open): Make sure that
678 auto-start is FALSE, not TRUE.
679 * NEWS: Update.
680
Scott James Remnant3b61f512009-07-08 19:59:00 +0100681 * util/Makefile.am (dist_man_MANS): Oops, had the wrong name for
682 the runlevel(7) manpage.
683
Scott James Remnantf24e55d2009-07-08 19:58:37 +0100684 * util/shutdown.c: Gets a bit of a redress, but not much of rewrite
685 since this is largely just compatibility madness.
686 (shutdown_now): Port to use sysv_change_runlevel()
687 (warning_message): Construct plural forms a little better.
688 (wall): use utmpx, rather than utmp
689 * util/man/shutdown.8: Minor tweaks and improvements
690 * NEWS: Update.
691
Scott James Remnant461578a2009-07-08 19:30:12 +0100692 * util/reboot.c: Following the pattern of the previous, remove much
693 of the reboot code, but in the process adding support for reboot
694 implying --force in runlevel 0 or 6, and writing the shutdown
695 wtmp record.
696 * util/man/reboot.8: Minor updates.
697 * NEWS: Update.
698
Scott James Remnant3aac7132009-07-08 19:02:56 +0100699 * util/telinit.c: Drop quite a bit of the code of telinit too,
700 just becoming a wrapper about sysv_change_runlevel() - also support
701 Qq/Uu by using kill()
702 * util/tests/test_telinit.c (test_env_option): Since we have an
703 env option, we should test it.
704 * util/man/telinit.8: Update the manual page.
705 * util/man/runlevel.8: Typo (/var/run/wtmp -> /var/log/wtmp)
706 * util/Makefile.am (TESTS): Run the new test
707 (test_telinit_SOURCES, test_telinit_CFLAGS)
708 (test_telinit_LDFLAGS, test_telinit_LDADD): Details for the
709 test suite binary
710 * NEWS: Update.
711
Scott James Remnantff87eaf2009-07-08 18:38:25 +0100712 * util/runlevel.c: Drop about 90% of the code, this just becomes
713 a wrapper around utmp_get_runlevel()
714 * util/man/runlevel.8: Update the runlevel manpage.
715 * util/man/runlevel.7: Also put together a manual page that
716 describes the runlevel event, as well as the implementation in
717 Upstart.
718 * util/Makefile.am (dist_man_MANS): Install the new manpage.
719 * NEWS: Update.
720
Scott James Remnant054c5c42009-07-08 17:07:14 +0100721 * util/Makefile.am (reboot_SOURCES, runlevel_SOURCES): Compile and
722 link the utmp handling source, depending on the header.
723 (reboot_LDADD, runlevel_LDADD): Drop dependency on libupstart
724 (shutdown_SOURCES, telinit_SOURCES): Compile and link both the
725 utmp handling and sysv compat source, depending on the headers
726 (nodist_shutdown_SOURCES, nodist_telinit_SOURCES): Also link in
727 the auto-generated bindings
728 (shutdown_LDADD, telinit_LDADD): Drop dependencies on libupstart,
729 replacing with dependencies on libnih-dbus and the D-Bus libs.
730 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD)
731 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD)
732 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Remove duplicate
733 entries mistakenly copied from compat/sysv
734
Scott James Remnantd5a366e2009-07-08 17:03:05 +0100735 * util/sysv.c (sysv_change_runlevel): Pretty much the core compat
736 function for System V, generate a runlevel event and store the
737 appropriate things in utmp and wtmp.
738 * util/sysv.h: Prototype.
739 * util/tests/test_sysv.c: Test cases for the new function.
740 * util/Makefile.am (TESTS): Run the sysv test cases
741 (test_sysv_SOURCES, nodist_test_sysv_SOURCES, test_sysv_LDFLAGS)
742 (test_sysv_LDADD): Details for the sysv test cases, which obviously
743 depend on the auto-generated bindings code.
744
Scott James Remnant27c0c762009-07-08 16:56:53 +0100745 * util/utmp.c (utmp_write_runlevel): Make sure that it's ok to
746 have no previous runlevel.
747 * util/tests/test_utmp.c (test_write_runlevel): Add no previous
748 runlevel test.
749
Scott James Remnant591ab472009-07-08 15:52:55 +0100750 * util/utmp.c (utmp_read_runlevel): Don't call utmpxname() if we
751 don't pass a utmp_file, letting glibc pick the default.
752 * util/tests/test_utmp.c (test_read_runlevel): Add a test case for
753 no filename.
754
Scott James Remnant98025662009-07-08 15:42:41 +0100755 * util/util.supp: utmpname leaks memory, so suppress it from valgrind
756
Scott James Remnant9f322cb2009-07-08 15:42:15 +0100757 * util/utmp.c: Set of functions for dealing with utmp and wtmp
758 (utmp_read_runlevel): Read the current runlevel from the file
759 (utmp_get_runlevel): Obtain the current runlevel from the
760 environment, or the file if not set
761 (utmp_write_runlevel): Write a runlevel change record, and also
762 deal with the reboot record if the utmp or wtmp files don't quite
763 match.
764 (utmp_write_shutdown): Write a shutdown time record
765 (utmp_entry, utmp_write, wtmp_write): utility functions for creating
766 and writing utmp and wtmp records.
767 * util/utmp.h: Prototypes for new functions.
768 * util/tests/test_utmp.c: Test cases.
769 * util/Makefile.am (test_utmp_SOURCES, test_utmp_LDFLAGS)
770 (test_utmp_LDADD): Details for utmp test cases
771 (tests): Move to the bottom of the file and make PHONY
772
Scott James Remnant07b32242009-07-07 10:49:43 +01007732009-07-07 Scott James Remnant <scott@netsplit.com>
774
775 * util/man/initctl.8: Improve the manpage.
776
Scott James Remnantcf2e8332009-07-06 20:32:07 +01007772009-07-06 Scott James Remnant <scott@netsplit.com>
778
779 * util/initctl.c: Rewrite from scratch, utilising the current
780 D-Bus API and auto-generated method functions for it.
781 * util/tests/test_initctl.c: Rewrite from scratch to test all
782 of the new methods.
783 * util/Makefile.am (test_initctl_CFLAGS): Include AM_CFLAGS
784 (install-data-hook, install-exec-hook): Install a symlink for
785 "restart" as well.
786 * NEWS: Update.
787
Scott James Remnantb95895c2009-07-03 12:35:48 +01007882009-07-03 Scott James Remnant <scott@netsplit.com>
789
Scott James Remnant54179122009-07-03 17:38:02 +0100790 * dbus/com.ubuntu.Upstart.Instance.xml (Start, Stop, Restart): add
791 wait arguments to the instance commands as well.
792 * init/job.c (job_start, job_stop, job_restart): Add wait arguments,
793 when TRUE the functions behave as before; when FALSE the methods
794 return after changing the goal and no blocked entries are created.
795 * init/job.h: Amend prototypes.
796 * init/tests/test_job.c (test_start, test_stop, test_restart):
797 Pass TRUE for wait and check for a blocking entry in existing tests,
798 add tests for passing FALSE and making sure that there's no blocking
799 but we still get the reply.
800
Scott James Remnantf2926f02009-07-03 17:28:21 +0100801 * dbus/com.ubuntu.Upstart.Job.xml (Start, Stop, Restart): Add wait
802 arguments to these too
803 * init/job_class.c (job_class_start, job_class_stop)
804 (job_class_restart): Add wait arguments, when TRUE the functions
805 behave as before; when FALSE the methods return after changing
806 the goal and no blocked entries are created.
807 * init/job_class.h: Amend prototypes.
808 * init/tests/test_job_class.c (test_start, test_stop, test_restart):
809 Pass TRUE for wait and check for a blocking entry in existing tests,
810 add tests for passing FALSE and making sure that there's no blocking
811 but we still get the reply.
812 (test_get_name, test_get_description, test_get_author)
813 (test_get_version): Add missing code to free the class on enomem
814
Scott James Remnantfb8242d2009-07-03 17:08:10 +0100815 * dbus/com.ubuntu.Upstart.xml (EmitEvent): Add wait argument
816 * init/control.c (control_emit_event): Add wait argument, when TRUE
817 this behaves as before; when FALSE the method returns after queuing
818 the event and no blocked entry is created for it.
819 * init/control.h: Amend prototype.
820 * init/tests/test_control.c (test_emit_event): Pass TRUE for wait
821 and check for a blocking entry in existing tests, add a test for
822 passing FALSE and making sure that there's no blocking but we
823 still get the reply.
824
Scott James Remnantb9f5ee82009-07-03 16:03:25 +0100825 * dbus/com.ubuntu.Upstart.Instance.xml: Add a "processes" property
826 to obtain the list of current job processes, both their type and
827 their pid.
828 * init/job.c (job_get_processes): Implement the new property accessor
829 * init/job.h: Add prototype
830 * init/tests/test_job.c (test_get_processes): Add test cases for
831 returning process arrays.
832 (test_get_name, test_get_goal, test_get_state): Add missing free
833 for job class.
834
Scott James Remnantde5a1662009-07-03 12:51:34 +0100835 * init/tests/test_control.c (test_emit_event): Directly acess
836 the number from an NihDBusError
837
Scott James Remnantb95895c2009-07-03 12:35:48 +0100838 * dbus/com.ubuntu.Upstart.xml: Add a "version" property to obtain
839 the version of the init daemon, and a "log_priority" property to
840 get and set the daemon's log priority.
841 * init/control.c (control_get_version, control_get_log_priority)
842 (control_set_log_priority): Methods to support the new properties
843 * init/control.h: Prototypes.
844 * init/tests/test_control.c (test_get_version)
845 (test_get_log_priority, test_set_log_priority): Add tests for the
846 property accessor functions.
847
Scott James Remnant02606132009-07-02 18:31:25 +01008482009-07-02 Scott James Remnant <scott@netsplit.com>
849
Scott James Remnant0cbb06c2009-07-02 18:46:41 +0100850 * dbus/Upstart.conf: Need to adjust the security configuration
851 * dbus/upstart.h: And the constants as well.
852
Scott James Remnant02bdd772009-07-02 18:41:52 +0100853 * dbus/com.ubuntu.Upstart.xml,
854 * dbus/com.ubuntu.Upstart.Job.xml,
855 * dbus/com.ubuntu.Upstart.Instance.xml: Now we don't hardcode the
856 interface name anywhere, we can version it properly.
857 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
858 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
859 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update default interface
860 names.
861 * util/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
862 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
863 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update here too.
864
Scott James Remnant02606132009-07-02 18:31:25 +0100865 * dbus/Makefile.am (EXTRA_DIST): Make sure we distribute it
866 * dbus/upstart.h: Add a header file with the usual D-Bus constants.
867 * init/control.h: Drop CONTROL_ROOT, replace with DBUS_PATH_UPSTART
868 * init/control.c (control_server_open, control_bus_open)
869 (control_register_all): Replace CONTROL_* constants with the new ones
870 (control_get_job_by_name): Use DBUS_INTERFACE_UPSTART when constructing
871 error names.
872 * init/job_class.c (job_class_new, job_class_register)
873 (job_class_unregister): Construct paths using DBUS_PATH_UPSTART
874 (job_class_get_instance)
875 (job_class_get_instance_by_name, job_class_start)
876 (job_class_stop, job_class_restart): Use DBUS_INTERFACE_UPSTART to
877 construct error names
878 * init/job.c (job_new): Construct path using DBUS_PATH_UPSTART
879 (job_finished, job_start, job_stop, job_restart): Use
880 DBUS_INTERFACE_UPSTART to construct error names.
881 * init/event.c (event_finished): Use DBUS_INTERFACE_UPSTART to
882 construct error name.
883 * init/tests/test_control.c (test_server_open): Don't hardcode
884 the address, extract the abstract path from the constant.
885 (test_server_connect, test_bus_open, test_emit_event): Don't
886 harcode addresses, paths or interfaces - use the constants
887 * init/tests/test_job_class.c (test_consider, test_reconsider)
888 (test_register, test_unregister, test_start, test_stop)
889 (test_restart, test_get_instance, test_get_instance_by_name):
890 Use the constants instead of harcoding.
891 (test_new): Derive the expected path from the constant
892 * init/tests/test_job.c (test_new): Derive the paths from the
893 constant, check for jobs by that interface constant.
894 (test_change_state): Use DBUS_INTERFACE_UPSTART_JOB
895 (test_start, test_stop, test_restart): Use DBUS_INTERFACE_UPSTART_INSTANCE,
896 and generate errors from DBUS_INTERFACE_UPSTART
897
898 * dbus/com.ubuntu.Upstart.xml,
899 * dbus/com.ubuntu.Upstart.Job.xml,
900 * dbus/com.ubuntu.Upstart.Instance.xml: Remove the empty symbol
901 annotation for the interfaces.
902 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
903 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
904 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Define the default
905 interface and build-time instead.
906 * util/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
907 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
908 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Likewise for util
909
Scott James Remnantdcf67712009-06-30 13:20:25 +01009102009-06-30 Scott James Remnant <scott@netsplit.com>
911
912 * dbus/Upstart.conf: It doesn't make much sense to restrict getting
913 the values of properties, or looking up jobs or interfaces, so make
914 these public.
915
Scott James Remnantb3338202009-06-23 01:02:58 +01009162009-06-23 Scott James Remnant <scott@netsplit.com>
917
Scott James Remnant047b94f2009-06-23 13:45:12 +0100918 * Makefile.am (SUBDIRS): Add util to the list of sub-directories
919 again.
920 * configure.ac (AC_CONFIG_FILES): Generate util/Makefile
921 * util/Makefile.am (AM_CFLAGS): Append D-Bus CFLAGS
922 (AM_CPPFLAGS): Make sure the build directory is also in the quoted
923 include path
924 (nodist_initctl_SOURCES): Build and link the generated D-Bus
925 bindings, but don't distribute them
926 (initctl_LDADD): Drop the libupstart dependency, instead put
927 libnih-dbus and DBUS_LIBS in there.
928 (com_ubuntu_Upstart_OUTPUTS, com_ubuntu_Upstart_XML)
929 ($(com_ubuntu_Upstart_OUTPUTS)): Auto-generate D-Bus binding code
930 to proxy the manager object
931 (com_ubuntu_Upstart_Job_OUTPUTS, com_ubuntu_Upstart_Job_XML)
932 ($(com_ubuntu_Upstart_Job_OUTPUTS)): Auto-generate D-Bus binding
933 code to proxy job class objects
934 (com_ubuntu_Upstart_Instance_OUTPUTS)
935 (com_ubuntu_Upstart_Instance_XML)
936 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Auto-generate D-Bus
937 binding code to proxy job instance objects
938 (BUILT_SOURCES, CLEANFILES): Built sources have to come first
939 and be cleaned up
940 (test_initctl_LDADD): Tests need to be linked to libnih-dbus
941 and the D-Bus libraries, as well as the auto-generated output
942 * init/Makefile.am (EXTRA_DIST): Drop the EXTRA_DIST for the
943 sources, already handled since they're in a different directory
944
Scott James Remnant0c0c5a52009-06-23 10:29:35 +0100945 * COPYING: Change licence to version 2 of the GNU GPL.
946 All files have been updated to reflect this.
947
Scott James Remnant854fda22009-06-23 01:21:55 +0100948 * init/paths.h (CONFFILE): Add new macro
949 * init/Makefile.am (AM_CPPFLAGS): Add CONFFILE definition
950 (install-data-local): No need to make conf.d or jobs.d
951 * init/main.c: Only parse CONFFILE (/etc/init.conf) as a
952 configuration file source and CONFDIR (/etc/init) as a job
953 configuration source.
954
Scott James Remnantb3338202009-06-23 01:02:58 +0100955 * configure.ac: Bump version to 0.6.0
956 * NEWS: Copy in news from 0.5.3; that release doesn't appear in
957 this ChangeLog since it was made on a separate branch. Begin
958 new release.
959
Scott James Remnanta25cc902009-06-18 18:44:15 +01009602009-06-18 Casey Dahlin <cdahlin@redhat.com>
961
962 * util/man/initctl.8: Fix formatting of SYNOPSIS
963
Scott James Remnant11a21582009-06-18 11:29:39 +01009642009-06-18 Scott James Remnant <scott@netsplit.com>
965
966 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
967 dbus/com.ubuntu.Upstart.Instance.xml: Add a comment to these files
968 to clarify that you may communicate and interact with Upstart
969 through these interfaces without restriction. It also makes sense
970 that these files be copied into software that does so to turn into
971 their own bindings, so use the FSF permissive licence for them.
972
Scott James Remnant2ec8b042009-06-17 16:49:13 +01009732009-06-17 Scott James Remnant <scott@netsplit.com>
974
Scott James Remnantebbbb0d2009-06-17 19:03:24 +0100975 * configure.ac: Bump version to 0.5.3
976
Scott James Remnant4ef6e282009-06-17 19:02:13 +0100977 * NEWS: Copy in news from 0.5.2; that release doesn't appear in
978 this ChangeLog since it was made on a separate branch.
979
Scott James Remnantfff115a2009-06-17 18:47:22 +0100980 * NEWS: Include 0.3.10 release, which happened from a separate branch.
981
Scott James Remnante22f81e2009-06-17 18:28:24 +0100982 * init/parse_job.c (stanza_kill, stanza_respawn, stanza_nice)
983 (stanza_oom): Check errno after using strtol() to avoid overflows.
984 (stanza_normal, stanza_umask, stanza_limit): Also check with
985 strtoul() too
986 * init/tests/test_parse_job.c (test_stanza_kill)
987 (test_stanza_respawn): Add test cases for the two that don't
988 check for overflow already.
989 (test_stanza_limit): Add test for the too large case where we don't
990 already cope.
991
Scott James Remnant180b5442009-06-17 17:52:18 +0100992 * dbus/Upstart.conf: Allow root to obtain properties
993
Scott James Remnant6684a9a2009-06-17 17:49:58 +0100994 * dbus/com.ubuntu.Upstart.Instance.xml: Add name, goal and state
995 properties to the instance
996 * init/job.c (job_get_name, job_get_goal, job_get_state): Add methods
997 to return the property values
998 * init/job.h: Add prototypes.
999 * init/tests/test_job.c (test_get_name, test_get_goal)
1000 (test_get_state): Test cases.
1001
Scott James Remnant6f49af02009-06-17 17:41:09 +01001002 * dbus/com.ubuntu.Upstart.Job.xml: Add name, description, author
1003 and version properties to the job
1004 * init/job_class.c (job_class_get_name)
1005 (job_class_get_description, job_class_get_author)
1006 (job_class_get_version): Add methods to return the property values.
1007 * init/job_class.h: Add prototypes
1008
Scott James Remnantd9bbe972009-06-17 17:09:49 +01001009 * init/job_process.c (job_process_error_abort): Don't abort() from
1010 a child process, it confuses people; just exit with an interesting
1011 error code (which we ignore anyway).
1012
Scott James Remnant2ec8b042009-06-17 16:49:13 +01001013 * dbus/Upstart.conf: Update the D-Bus configuration based on newer
1014 D-Bus recommended practice with a proper deny-by-default D-Bus,
1015 making sure to not use send_interface without send_destination.
1016 Allow introspection as well.
1017
Scott James Remnant25c96942009-06-17 16:41:34 +010010182009-06-17 Jeff Oliver <Jeffrey.Oliver@panasonic.aero>
1019
1020 * init/job_process.c (job_process_spawn): Only attempt to set
1021 the OOM adjustment if set in the class, avoiding issue where /proc
1022 is not mounted for the first job.
1023
Scott James Remnanta5efa6c2009-06-17 14:30:45 +010010242009-06-17 Scott James Remnant <scott@netsplit.com>
1025
Scott James Remnant1b91df42009-06-17 16:24:11 +01001026 * init/tests/test_job_process.c (test_handler): Add test cases for a
1027 respawning job failing while it's post-start or pre-stop processes
1028 are still running while making sure that it still respawns afterwards.
1029 * init/job_process.c (job_process_terminated): To fix it, check for
1030 a running post-start or pre-stop process before checking for a the
1031 respawn. That's not enough because then we won't respawn when the
1032 existing process finishes, so use the goal as a hint.
1033 * init/job.c (job_next_state): Use that hint goal here, remembering
1034 to set the goal back to JOB_START afterwards.
1035 (job_change_goal): Nothing to do in the respawn case
1036 (job_goal_name, job_goal_from_name): Add the new values
1037 * init/job.h (job_goal): Add the respawn goal
1038 * init/tests/test_job.c (test_next_state): Add tests for the respawn
1039 goal
1040 (test_goal_name, test_goal_from_name): Tests for the new values
1041
Scott James Remnantf7271672009-06-17 14:59:38 +01001042 * configure.ac (AC_CONFIG_FILES): dbus goes before init just in case
1043 we ever do anything to them later
1044
Scott James Remnant0a8bd922009-06-17 14:37:23 +01001045 * init/job_class.c (job_class_register, job_class_unregister): Update
1046 name of signal functions that we call.
1047 (job_class_interfaces): No need to declare this separately
1048 * init/job.c (job_register, job_change_state): Update name of signal
1049 functions.
1050 (job_interfaces): Drop, it comes from the generated header now
1051 * init/control.c (manager_interfaces): Drop, comes from the header
1052 as control_interfaces
1053 (control_register_all): Change array name
1054 * init/tests/test_job_class.c,
1055 * init/tests/test_job.c,
1056 * init/tests/test_control.c,
1057 * init/tests/test_blocked.c: Rename conn member of NihDBusMessage
1058 to connection
1059
Scott James Remnanta5efa6c2009-06-17 14:30:45 +01001060 * dbus/com.ubuntu.Upstart.xml,
1061 * dbus/com.ubuntu.Upstart.Job.xml,
1062 * dbus/com.ubuntu.Upstart.Instance.xml: Use annotation to mark the
1063 methods as async, rather than a namespaced attribute. Omit the
1064 interface symbol.
1065 * init/Makefile.am (AM_CPPFLAGS): Add builddir to the quoted includes
1066 (init_SOURCES): Don't distribute the auto-generated outputs
1067 ($(com_ubuntu_Upstart_OUTPUTS))
1068 ($(com_ubuntu_Upstart_Job_OUTPUTS))
1069 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Generate using the new
1070 binary tool.
1071 (BUILT_SOURCES): Remind myself why these are BUILT_SOURCES
1072 (MAINTAINERCLEANFILES): Change to ordinary CLEANFILES
1073 (EXTRA_DIST): outputs aren't distributed
1074
Scott James Remnant75123022009-05-22 13:27:56 +020010752009-05-22 Scott James Remnant <scott@netsplit.com>
1076
Scott James Remnant5c102eb2009-05-22 15:18:30 +02001077 * init/tests/test_conf.c: Remove nih/inotify.h include
1078
Scott James Remnant75123022009-05-22 13:27:56 +02001079 * COPYING: Change licence from GPL-2+ to GPL-3 only.
1080
Scott James Remnanta6a82532009-05-17 14:43:54 +010010812009-05-17 Scott James Remnant <scott@netsplit.com>
1082
1083 * init/tests/test_job.c,
1084 * init/tests/test_job_class.c,
1085 * init/tests/test_control.c: Include nih-dbus/errors.h
1086
Scott James Remnantdbd3b152009-05-09 16:30:35 +010010872009-05-09 Scott James Remnant <scott@netsplit.com>
1088
Scott James Remnant3306e262009-05-13 11:49:51 +01001089 * init/init.supp: setenv on tls/i686/cmov
1090
Scott James Remnant0ff734e2009-05-09 16:56:08 +01001091 * init/job_class.c (job_class_get_instance, job_class_start)
1092 (job_class_stop, job_class_restart): Clean up the code by using
1093 nih_error_steal()
1094
Scott James Remnant7f590ac2009-05-09 16:52:54 +01001095 * init/conf.c (conf_source_reload_file, conf_source_reload_dir):
1096 Steal the error that we stash instead of getting it, otherwise we'll
1097 fail if another one occurs.
1098
Scott James Remnant3d7483b2009-05-09 16:36:03 +01001099 * init/conf.c (conf_reload_path): Simply return, no need to re-raise
1100 the error.
1101 * init/job_class.c (job_class_get_instance, job_class_start)
1102 (job_class_stop, job_class_restart): If not ENOMEM, we need to
1103 re-raise the error as a D-Bus one, that means we now have to free
1104 the old error first (saving the msssage)
1105 * init/job_process.c (job_process_error_read): Replace call to
1106 nih_error_raise_again() with nih_error_raise_error()
1107
Scott James Remnantdbd3b152009-05-09 16:30:35 +01001108 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
1109 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
1110 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Use the Python variant
1111 of nih-dbus-tool for now
1112
Scott James Remnantddee7aa2009-03-27 14:28:51 +000011132009-03-27 Scott James Remnant <scott@netsplit.com>
1114
Scott James Remnant58278d62009-03-27 15:22:07 +00001115 * init/tests/test_process.c (test_from_name): Cast -1 to ProcessType
1116 * init/tests/test_job_process.c (test_kill, test_handler): Cast -1
1117 to ProcessType
1118 * init/tests/test_job.c (test_new, test_change_state): Cast -1
1119 to ProcessType
1120 (test_goal_from_name): Cast -1 to JobGoal
1121 (test_state_from_name): Cast -1 to JobState
1122 * init/tests/test_control.c (test_bus_open): Add braces
1123
Scott James Remnant58f873a2009-03-27 15:22:00 +00001124 * init/Makefile.am (tests): Add rule to build test cases
1125 * util/Makefile.am (tests): Likewise
1126
Scott James Remnant267e61c2009-03-27 15:16:06 +00001127 * init/job.c (job_interfaces): Put static first
1128 (job_emit_event): Cast -1 to ProcessType
1129 (job_emit_event): Cast -1 to ProcessType
1130 * init/job_class.c (job_class_interfaces): Put static first.
1131 * init/job_process.c (job_process_kill_timer): Cast -1 to ProcessType
1132 * init/control.c (manager_interfaces): Put static first
1133
Scott James Remnantddee7aa2009-03-27 14:28:51 +00001134 * init/Makefile.am (AM_CPPFLAGS): Use -iquote$(srcdir) instead of -I
1135 since we only need it to pick those paths up.
1136 * util/Makefile.am (AM_CPPFLAGS): Likewise.
1137
Scott James Remnant0ad2d9a2009-02-20 22:08:20 +000011382009-02-20 Scott James Remnant <scott@netsplit.com>
1139
Scott James Remnant7d59ed22009-02-20 22:28:03 +00001140 * util/initctl.c (handle_job_instance_end, handle_job_process)
1141 (handle_job_status_end, handle_event),
1142 * util/shutdown.c (main): No need for new_* temporary variable when
1143 looping over nih_realloc with NIH_MUST.
1144
Scott James Remnantc5d3e1b2009-02-20 22:22:48 +00001145 * util/initctl.c (job_info_output, output_name, handle_job_list)
1146 (handle_job_instance, handle_job_instance_end)
1147 (handle_job_status, handle_job_process, handle_job_status_end)
1148 (handle_event, env_option),
1149 * util/telinit.c (main),
1150 * util/shutdown.c (main, shutdown_now, timer_callback, wall):
1151
Scott James Remnant56954112009-02-20 22:18:57 +00001152 * init/event.c (event_init, event_pending_handle_jobs, event_finished),
1153 * init/event_operator.c (event_operator_events),
1154 * init/job.c (job_emit_event, job_name),
1155 * init/job_class.c (job_class_init, job_class_start)
1156 (job_class_stop, job_class_restart),
1157 * init/job_process.c (job_process_run, job_process_error_read)
1158 (job_process_kill),
1159 * init/conf.c (conf_init, conf_source_reload_file)
1160 (conf_reload_path),
1161 * init/control.c (control_init, control_server_connect)
1162 (control_bus_open): Set variable outside of NIH_MUST macro.
1163
Scott James Remnant69132b72009-02-20 22:10:06 +00001164 * init/event.c (event_pending_handle_jobs): Set variable outside
1165 of NIH_SHOULD macro.
1166
Scott James Remnant0ad2d9a2009-02-20 22:08:20 +00001167 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
1168 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
1169 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update expected path
1170 of nih-dbus-tool
1171
1172 * configure.ac: Create nih-dbus-tool Makefile
1173 * Makefile.am (SUBDIRS): Build in nih-dbus-tool
1174
Scott James Remnantda7d2d42009-01-29 01:55:15 +000011752009-01-29 Scott James Remnant <scott@netsplit.com>
1176
Scott James Remnant619905b2009-01-29 06:23:08 +00001177 * configure.ac: Bump version to 0.5.2
1178 * NEWS: Begin 0.5.2
1179
1180 * NEWS: Copy in news from 0.5.1; that release doesn't appear in
1181 this ChangeLog since it was made on a separate branch.
1182
Scott James Remnant593c8ea2009-01-29 05:29:17 +00001183 * init/tests/test_blocked.c (test_new),
1184 * init/tests/test_control.c (test_get_job_by_name)
1185 (test_get_all_jobs, test_emit_event),
1186 * init/tests/test_event.c (test_finished),
1187 * init/tests/test_job.c (test_change_state),
1188 * init/tests/test_job_class.c (test_get_instance)
1189 (test_get_instance_by_name, test_get_all_instances): Continue the
1190 battle with the gcc optimiser which declares variables first used
1191 inside TEST_ALLOC_FAIL as used uninitialized.
1192
Scott James Remnant88abb652009-01-29 04:23:21 +00001193 * init/parse_job.c (parse_exec, parse_script, stanza_instance)
1194 (stanza_description, stanza_author, stanza_version)
1195 (stanza_start, stanza_stop, stanza_chroot, stanza_chdir):
1196 Unreference members when replacing them instead of freeing; not
1197 strictly necessary but the style is the thing.
1198
Scott James Remnant57a64d32009-01-29 04:21:07 +00001199 * init/job_process.c (job_process_terminated): Unreference the
1200 kill timer instead of freeing
1201
Scott James Remnantd3df7ee2009-01-29 04:20:42 +00001202 * init/job_class.c (job_class_get_instance): Use nih_local for
1203 instance environment and name
1204 (job_class_start, job_class_stop, job_class_restart):
1205 Unreference job environment instead of freeing
1206
Scott James Remnant636d37f2009-01-29 04:18:35 +00001207 * init/job.c (job_change_state, job_start, job_stop, job_restart):
1208 Unreference job environment instead of freeing
1209 (job_name): Discard job name in case a reference was taken.
1210
Scott James Remnant248b40e2009-01-29 04:16:14 +00001211 * init/event.c (event_pending_handle_jobs): Unreference the job
1212 environment instead of freeing
1213
Scott James Remnant06d95a12009-01-29 04:15:05 +00001214 * init/environ.c (environ_add): should unreference the old environment
1215 string in case anyone took a ref elsewhere
1216 (environ_set): use nih_local for str
1217 (environ_expand_until): Should set *str to NULL if we free it,
1218 just in case.
1219
Scott James Remnantd3667ed2009-01-29 04:11:24 +00001220 * init/conf.c (conf_source_reload): File should be unreferenced,
1221 not freed.
1222 (conf_source_reload_file): Use nih_local for dpath
1223 (conf_delete_handler): Watch and file should be unreferenced,
1224 not freed.
1225 (conf_reload_path): File should be unreferenced, not freed;
1226 use nih_local for file buffer
1227
Scott James Remnant750c0b12009-01-29 02:24:21 +00001228 * init/blocked.c (blocked_new),
1229 * init/conf.c (conf_source_new, conf_file_new),
1230 * init/event.c (event_new),
1231 * init/event_operator.c (event_operator_new),
1232 * init/job.c (job_new),
1233 * init/job_class.c (job_class_new): No need to cast function
1234 argument to nih_alloc_set_destructor()
1235
Scott James Remnant85ef5352009-01-29 02:15:34 +00001236 * init/tests/test_job_process.c (test_handler): We can't just
1237 assume that our child is sitting at the signal otherwise we might
1238 end up sending the CONT signal before it's even stopped. Use
1239 waitid() to wait for the child to stop first.
1240
Scott James Remnant79bd8612009-01-29 02:02:36 +00001241 * init/init.supp: More expressions for environment memory which
1242 valgrind can't deal with
1243
Scott James Remnantda7d2d42009-01-29 01:55:15 +00001244 * init/conf.c (conf_source_reload): The ConfFile destructor has
1245 side-effects that involve the iteration of the sources and their
1246 files, so we can't simply call it while iterating because of the
1247 cursor. Move the sources into a deleted list first, and delete
1248 them from there.
1249 * init/conf.h: Fix prototype.
1250 * init/tests/test_conf.c (test_source_reload_job_dir): Test pointers
1251 with TEST_EQ_P not TEST_EQ
1252
Scott James Remnant57982222009-01-28 01:22:31 +000012532009-01-28 Scott James Remnant <scott@netsplit.com>
1254
Scott James Remnant75fb8382009-01-29 00:01:08 +00001255 * init/job_class.c (job_class_start): We can't create the blocked
1256 until we know we're going to block, otherwise we could ref and unref
1257 the message (freeing it). Wait until the job is created, which
1258 means we can't fail to create the blocked item (we'll already have
1259 announced the new instance).
1260 (job_class_stop, job_class_restart): For consistency, don't fail
1261 if OOM when making blocked.
1262
Scott James Remnant78a9bb02009-01-28 23:42:24 +00001263 * init/tests/test_job.c (test_new): Initialise a bunch of subsystems
1264 outside of TEST_ALLOC_FAIL
1265
Scott James Remnant10cb7012009-01-28 23:39:29 +00001266 * init/environ.c (environ_add): We can't allocate nih_local with
1267 a context, it won't be freed; so don't, but then remember to
1268 reference it when we do just use it.
1269
Scott James Remnant6edea722009-01-28 23:32:32 +00001270 * init/event.c (event_pending_handle_jobs): Must reset the start_on
1271 operator in case of error.
1272
Scott James Remnant64b9b7a2009-01-28 22:00:12 +00001273 * init/job_process.c (job_process_kill_timer): Oops, move the
1274 assert that we have a process pid to after we know which process
1275 we have.
1276 * init/tests/test_job_process.c (test_run): Initialise the
1277 error context and NihIo outside of TEST_ALLOC_FAIL
1278 (test_kill): Initialise timers and the event system.
1279 * init/init.supp: Reference from the jobs hash to the bins is
1280 still reachable, obviously; as is the string inside job_name()
1281 either way it is allocated
1282
Scott James Remnant5eac8f12009-01-28 21:33:13 +00001283 * init/tests/test_parse_job.c (test_parse_job): Initialise the
1284 error context outside of TEST_ALLOC_FAIL
1285
Scott James Remnant514f1d02009-01-28 21:32:16 +00001286 * init/init.supp: Update suppressions for new nih_alloc()
1287
Scott James Remnant4f1e0b72009-01-28 08:30:50 +00001288 * init/job_process.c (job_process_run): Had the shell variable
1289 setting round the wrong way, now it should be ok.
1290
Scott James Remnant01830df2009-01-28 08:30:23 +00001291 * init/tests/test_blocked.c (test_new): in the case of allocation
1292 failure, the message should not be referenced; which we test by
1293 trying to discard it and seeing whether that works.
1294
Scott James Remnant44f60952009-01-28 04:04:15 +00001295 * init/job.c (job_emit_event): event_new() only references the
1296 environment now, so use nih_local to make sure we clean it up
1297 if that doesn't happen
1298
Scott James Remnant885879b2009-01-28 04:01:55 +00001299 * init/job.h (Job): Add kill_process member
1300 * init/job.c (job_new): Initialise to -1
1301 * init/job_process.c (job_process_kill): Store the process to be
1302 killed in the kill_process member for the timer, since we can't
1303 pass two sets of data. Assert that it's not set to anything, this
1304 all needs fixing, obviously.
1305 (job_process_kill_timer): Take the job as the data argument,
1306 eliminating the need for nih_alloc_parent(). Sanity check the job
1307 and reset kill_timer and kill_process when done.
1308 (job_process_terminated): Clear the kill_process field too.
1309 * init/tests/test_job.c (test_new): Check it's -1
1310 (test_change_state): Check kill_process is set to PROCESS_MAIN
1311 when active, or -1 when not.
1312 * init/tests/test_job_process.c (test_kill): Make sure the
1313 kill_process member is set and cleared.
1314 (test_handler): Set the kill_process member for the timer and make
1315 sure it's cleared when appropriate.
1316
Scott James Remnant50643372009-01-28 03:49:56 +00001317 * init/job_class.c (job_class_start, job_class_stop)
1318 (job_class_restart): Use nih_local to eliminate nih_alloc_reparent,
1319 and to clean up some of the code too.
1320
Scott James Remnant041e7cd2009-01-28 03:41:47 +00001321 * init/job_class.c: Update documentation to match new nih_alloc()
1322
Scott James Remnantda7839b2009-01-28 03:40:23 +00001323 * init/parse_job.c (parse_on_operator, parse_on_collect):
1324 Use an nih_ref/nih_unref pair instead of nih_alloc_reparent; this
1325 is not ideal, but then this code is rather messy and leaves a lot
1326 of allocated data attached to the object on the assumption that
1327 it will be thrown away.
1328
Scott James Remnantee5b4202009-01-28 03:34:42 +00001329 * init/event_operator.c: Update documentation to match new nih_alloc()
1330 (event_operator_match): Use nih_local on expanded value.
1331 (event_operator_environment): Make evlist nih_local, it will be
1332 referenced by the environment array on success
1333
Scott James Remnantad9468a2009-01-28 03:27:51 +00001334 * init/event_operator.c (event_operator_new): Reference the
1335 event instead of reparenting it.
1336
Scott James Remnantcf14eeb2009-01-28 03:26:36 +00001337 * init/event.c: Update documentation to match new nih_alloc()
1338 (event_finished): Use nih_local to tidy up a slight bit.
1339
Scott James Remnantdec386b2009-01-28 03:24:22 +00001340 * init/event.c (event_new): Reference the event, don't reparent
1341 (event_pending_handle_jobs): Use nih_local for environment array
1342 and for the job name, damn I love this thing. Reference the array
1343 into the job to avoid freeing.
1344
Scott James Remnant5c540052009-01-28 03:17:04 +00001345 * init/parse_job.c (parse_job): Update documentation to match
1346 new nih_alloc()
1347 (parse_process, parse_on_operator, stanza_start, stanza_stop)
1348 (stanza_expect, stanza_kill, stanza_respawn, stanza_normal)
1349 (stanza_session, stanza_console, stanza_nice, stanza_umask)
1350 (stanza_oom, stanza_limit): Use nih_local for all the temporary
1351 arguments where we can.
1352
Scott James Remnant1bff7d62009-01-28 03:00:00 +00001353 * init/parse_job.c (parse_on_operand, stanza_env, stanza_export)
1354 (stanza_emits): Make temporary string variables use nih_local,
1355 this gives us a massive code clean-up and makes nih_str_array_addp
1356 safe to take a reference.
1357
Scott James Remnantc54150c2009-01-28 02:50:06 +00001358 * init/job_process.c (job_process_run): Make argv, env, script and
1359 cmd all use nih_local, this cleans up the code a little and makes
1360 nih_str_array_addp safe to take a reference.
1361
Scott James Remnantc4c2af92009-01-28 02:45:04 +00001362 * init/environ.c: Update documentation to match new nih_alloc()
1363
Scott James Remnant07a93482009-01-28 02:30:00 +00001364 * init/tests/test_job_process.c (test_run): Check that trailing
1365 newlines are ignored when running a script (can verify r1025 is
1366 fixed with gdb)
1367
Scott James Remnantbfc98512009-01-28 02:13:23 +00001368 * init/tests/test_environ.c (test_expand): Add a test case for the
1369 bug fixed in r1027, the implicit case of the gap in the environment
1370 string being the same size as the value replacing it.
1371
Scott James Remnant23b59822009-01-28 02:09:12 +00001372 * init/environ.c (environ_add): Use nih_local for new_str, making
1373 the code paths a little simpler and ensuring we pass something that
1374 can be referenced to nih_str_array_addp()
1375
Scott James Remnant4d34eb22009-01-28 02:07:32 +00001376 * init/tests/test_event.c (test_new): Make sure that env is an
1377 orphan with TEST_ALLOC_ORPHAN.
1378 * init/tests/test_event_operator.c (test_operator_new): Make sure
1379 that env is an orphan with TEST_ALLOC_ORPHAN.
1380 (test_operator_copy): Drop pointless NULL parent check.
1381
Scott James Remnantf6becd42009-01-28 02:02:06 +00001382 * init/tests/test_control.c: Include limits.h
1383
Scott James Remnant754a8752009-01-28 02:00:35 +00001384 * init/blocked.c (blocked_new): Take a reference to the message,
1385 otherwise it will be freed; we free the Blocked structure when we're
1386 done, so will automatically unref the message.
1387 * init/tests/test_blocked.c (test_new): Add tests to make sure the
1388 reference is taken.
1389 * init/tests/test_job.c (test_start, test_stop, test_restart):
1390 Make sure the message is referenced when an error is not returned
1391 but not referenced when one is.
1392 * init/tests/test_job_class.c (test_start, test_stop)
1393 (test_restart): Make sure the message is referenced when an error
1394 is not returned but not referenced when one is.
1395 * init/tests/test_control.c (test_emit_event): Make sure that
1396 the message is referenced.
1397
Scott James Remnant4cccfff2009-01-28 01:35:25 +00001398 * init/tests/test_blocked.c: Change nih/dbus.h include to
1399 nih-dbus/dbus_message.h
1400 * init/tests/test_control.c: Change nih/dbus.h include to error,
1401 connection and object; include D-Bus test macros.
1402 * init/tests/test_job.c: Change nih/dbus.h include to error, message
1403 and object; include D-Bus test macros
1404 * init/tests/test_job_class.c: Change nih/dbus.h include to error,
1405 message and object; include D-Bus test macros
1406
Scott James Remnant8269cac2009-01-28 01:31:02 +00001407 * init/job_class.h: Change nih/dbus.h include to
1408 nih-dbus/dbus_message.h and include the actual D-Bus header
1409 * init/job_class.c: Change nih/dbus.h include to error, message,
1410 object and util.
1411
Scott James Remnant1e78bc22009-01-28 01:30:56 +00001412 * init/job.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1413 and include the actual D-Bus header
1414 * init/job.c: Change nih/dbus.h include to error, message, object
1415 and util.
1416
Scott James Remnante8c03862009-01-28 01:25:44 +00001417 * init/control.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1418 and include the actual D-Bus header
1419 * init/control.c: Change nih/dbus.h include to error, connection,
1420 message and object includes.
1421
Scott James Remnant57982222009-01-28 01:22:31 +00001422 * init/blocked.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1423 * init/blocked.c: Change nih/dbus.h include to nih-dbus/dbus_message.h
1424
Scott James Remnant961ad212009-01-27 00:54:13 +000014252009-01-27 Scott James Remnant <scott@netsplit.com>
1426
1427 * init/Makefile.am: Update paths to libnih-dbus dependencies.
1428
Scott James Remnant2e8760b2009-01-26 01:15:21 +000014292009-01-26 Scott James Remnant <scott@netsplit.com>
1430
Scott James Remnant9b25c8d2009-01-26 15:35:51 +00001431 * configure.ac (AC_CONFIG_FILES): Add nih-dbus sub-directory
1432 * Makefile.am (SUBDIRS): Add nih-dbus sub-directory
1433
Scott James Remnantfcb81e62009-01-26 15:26:29 +00001434 * configure.ac: Bump copyright to 2009
1435
Scott James Remnant32804e82009-01-26 15:25:57 +00001436 * configure.ac: Matching libnih, we now mandate libtool 2.2.x
1437 * HACKING: Update dependency requirement to 2.2.4
1438
Scott James Remnantfc2b4f42009-01-26 01:18:12 +00001439 * init/init.supp: Adjust suppression for glibc 2.8
1440
Scott James Remnant4b2dcc62009-01-26 01:17:59 +00001441 * init/tests/test_event.c (test_finished): Remove erroneous test
1442 of free'd memory.
1443
Scott James Remnante32ab4f2009-01-26 01:17:21 +00001444 * configure.ac: Bump version to 0.5.1
1445
Scott James Remnantde22f422009-01-26 01:16:17 +00001446 * init/tests/test_event_operator.c (test_operator_handle): Add a
1447 test for duplicate events when already matched.
1448 * init/event_operator.c (event_operator_handle): Skip if already
1449 matched.
1450
Scott James Remnant2e8760b2009-01-26 01:15:21 +00001451 * README: Update features and requirements.
1452 * NEWS: Copy in news from 0.5.0; that release doesn't appear in
1453 this ChangeLog since it was made on a separate branch.
1454
Scott James Remnante4bbac02009-01-26 01:12:16 +000014552009-01-26 Casey Dahlin <cdahlin@redhat.com>
1456
1457 * init/environ.c (environ_expand_until): Handle the implicit case
1458 of the gap in the string being the same size of the value.
Scott James Remnant571b0702009-01-26 01:05:50 +00001459
1460 * init/job_process.c (job_process_handler): Handle the case of a
1461 child being continued by a signal, otherwise we'll assert.
Scott James Remnant07b2bc72009-01-26 01:03:35 +00001462
1463 * init/job_process.c (job_process_run): Double-check that the
1464 newline(s) we see are at the end of the script before stripping,
1465 since we can fall through if the newline is mid-script but /dev/fd
1466 isn't mounted.
1467
Scott James Remnantfd8a0432008-07-05 17:30:04 +010014682008-07-05 Scott James Remnant <scott@netsplit.com>
1469
1470 * TODO: Update.
1471
Scott James Remnantdd8abca2008-07-01 19:36:44 +010014722008-07-01 Scott James Remnant <scott@netsplit.com>
1473
1474 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
1475 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
1476 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Must be newer than the
1477 source for the dbus tool, and ensure the dbus tool is built
1478
Scott James Remnant55f3c7c2008-06-30 17:37:27 +010014792008-06-30 Scott James Remnant <scott@netsplit.com>
1480
1481 * init/Makefile.am: Update along with libnih so that we leave the
1482 D-Bus bindings in the dist tarball, meaning Python is no longer a
1483 build-dependency.
1484
Scott James Remnantce2b3b22008-06-11 08:21:35 +010014852008-06-11 Scott James Remnant <scott@netsplit.com>
1486
Scott James Remnant9a140952008-06-11 08:22:03 +01001487 * Makefile.am (SUBDIRS): List dbus before init in case we need to
1488 generate anything in that directory later on.
1489
Scott James Remnantce2b3b22008-06-11 08:21:35 +01001490 * Makefile.am (SUBDIRS): List po last so that update-po is run after
1491 generating any sources.
1492
Scott James Remnant3fb48382008-06-08 02:03:40 +010014932008-06-08 Scott James Remnant <scott@netsplit.com>
1494
Scott James Remnant94d75a12008-06-08 04:08:56 +01001495 * init/Makefile.am (EXTRA_DIST): Ship the built sources, don't
1496 clean them.
1497 (maintainer-clean-local): Well, not unless maintainer-clean anyway
1498
1499 * init/job.c, init/job_class.c: Add missing errno.h include
1500
Scott James Remnantb40e4dd2008-06-08 03:26:36 +01001501 * dbus/com.ubuntu.Upstart.Job.xml (GetInstance): Add method to get
1502 an instance name in the same basic manner as start and stop would,
1503 though this one's synchronous.
1504 * init/job_class.c (job_class_get_instance): Implementing by copying
1505 the relevant bit of Stop.
1506 * init/job_class.h: Add prototype.
1507 * init/tests/test_job_class.c (test_get_instance): Add tests.
1508 * TODO: Continue to document the C&P madness.
1509
Scott James Remnant39a8a0c2008-06-08 03:08:55 +01001510 * init/conf.c (conf_reload_path): Read file directly into memory,
1511 not using mmap.
1512
Scott James Remnant6591fef2008-06-08 03:08:39 +01001513 * compat/sysv/reboot.c, compat/sysv/runlevel.c, compat/sysv/shutdown.c,
1514 * compat/sysv/telinit.c: Move into the util directory; we're going
1515 to support limited SysV-a-like commands without full compatibility
1516 which is what we always did, and I'm not going to worry about adding
1517 others.
1518 * compat/sysv/man/reboot.8, compat/sysv/runlevel.8,
1519 * compat/sysv/man/shutdown.8, compat/sysv/telinit.8: Move as well.
1520 * compat/sysv/Makefile.am, util/Makefile.am: Merge.
1521 * configure.ac: Remove the (commented out) compat/sysv and logd
1522 Remove the --enable-compat option.
1523 * Makefile.am (SUBDIRS): Remove (commented out) compat/sysv and logd
1524
Scott James Remnant3e205a42008-06-08 02:13:33 +01001525 * logd/Makefile.am, logd/main.c, logd/man/logd.8, logd/jobs.d/logd.in:
1526 Consign logd to oblivion. We haven't supported it for ages, it has
1527 non-working issues, and there's got to be a better way to do this.
1528
Scott James Remnantd25ffae2008-06-08 02:12:10 +01001529 * TODO: Update.
1530
Scott James Remnantb3a1e7b2008-06-08 02:09:31 +01001531 * init/job.c (job_change_goal): Adjust the documentation. After
1532 careful thought, there's no way this can return after freeing the
1533 job, since it'll either block on an event, a process or do nothing.
1534
Scott James Remnant1d0a1e72008-06-08 02:05:49 +01001535 * init/job.c (job_start, job_stop, job_restart): Clear the start
1536 and stop environment, shouldn't necessarily make a difference, but
1537 it pays to be consistent.
1538
Scott James Remnant3fb48382008-06-08 02:03:40 +01001539 * dbus/com.ubuntu.Upstart.Job.xml (Start, Stop, Restart): Add methods
1540 to control jobs, all take an environment array and both Start and
1541 Restart return an instance path so properties, etc. can be obtained
1542 afterwards.
1543 * init/job_class.c (job_class_start, job_class_stop)
1544 (job_class_restart): Add the code for the top halves of the methods
1545 * init/job_class.h: Add prototypes for the new methods.
1546 * init/job.c (job_finished): And the bottom halves go here.
1547 * init/tests/test_job_class.c (test_start, test_stop)
1548 (test_restart): Add test cases for the methods.
1549 * init/blocked.h (blocked_type): Add enums for the new methods.
1550 * init/blocked.c (blocked_new): Handle the new methods here.
1551 * init/tests/test_blocked.c (test_new): Add add tests for handling.
1552
Scott James Remnantb7673b02008-06-07 01:28:39 +010015532008-06-07 Scott James Remnant <scott@netsplit.com>
1554
Scott James Remnanta4d83142008-06-07 22:59:56 +01001555 * init/job_process.c (job_process_terminated): Don't check the goal
1556 to see whether the main process was allowed to terminate, check the
1557 state. A termination is only not a failure if we're on the KILLED
1558 state (ie. we killed it), otherwise it can still be a failure even
1559 if it was going to stop anyway.
1560 * init/tests/test_job_process.c (test_handler): Add a test case.
1561
Scott James Remnante8762cb2008-06-07 21:11:20 +01001562 * init/control.c (control_emit_event): Use environ_all_valid here(),
1563 also reorder the blocking stuff to be less strange, it's ok to free
1564 environment.
1565 * init/tests/test_control.c (test_emit_event): The event array should
1566 be a child of message, which means it doesn't matter if the function
1567 we call frees it.
1568
Scott James Remnanta5e8e942008-06-07 21:06:56 +01001569 * init/environ.c (environ_all_valid): Add a validation function for
1570 external input.
1571 * init/environ.h: Add prototype.
1572 * init/tests/test_environ.c (test_all_valid): Test function.
1573
Scott James Remnant1a129922008-06-07 20:56:13 +01001574 * init/environ.c: Note that we can call this in a loop with OOM,
1575 since the resulting table will always be the same.
1576
Scott James Remnant44978b62008-06-07 20:54:49 +01001577 * init/event_operator.c (event_operator_environment): Use
1578 environ_append(), and while we're at it, there's no reason this should
1579 use NIH_MUST.
1580 * init/event_operator.h: Adjust prototype.
1581 * init/tests/test_event_operator.c (test_operator_environment): Allow
1582 for failure.
1583 * init/event.c (event_pending_handle_jobs): Call with NIH_MUST,
1584 which is actually safe.
1585
Scott James Remnanta175f3b2008-06-07 20:20:11 +01001586 * init/job_class.c (job_class_environment): Use environ_append()
1587
Scott James Remnant90b6f3f2008-06-07 20:17:29 +01001588 * init/environ.c (environ_append): There are multiple cases where we
1589 append one environment table onto another, so we should have a
1590 function to do that.
1591 * init/environ.h: Prototype for it.
1592 * init/tests/test_environ.c (test_append): Test the new function.
1593
Scott James Remnantfd364982008-06-07 03:40:29 +01001594 * init/job_process.c (job_process_run): Invert the logic; we nearly
1595 always want to pass the script with /dev/fd/NNN. The only times we
1596 don't are if it doesn't exist, or if we're dealing with a single-line
1597 shell script.
1598 * init/tests/test_job_process.c (test_run): Update test cases to
1599 only expect an argv-execution for single-line scripts.
1600
Scott James Remnant345fc022008-06-07 01:40:32 +01001601 * init/job.c (job_restart): Wrote the blocking bit slightly weirdly
1602 without neededing to, so leave it as it should be.
1603
Scott James Remnante22f7a22008-06-07 01:36:43 +01001604 * TODO: Update.
1605
Scott James Remnantb7673b02008-06-07 01:28:39 +01001606 * dbus/com.ubuntu.Upstart.Instance.xml (Start, Stop, Restart): Add
1607 simple instance control methods, these only change the goal of an
1608 existing instance - thus cannot pass environment.
1609 * init/job.c (job_start, job_stop, job_restart): Add methods, which
1610 look spookily similar to each other, except for the subtle yet
1611 important differences.
1612 (job_finished): Implement bottom halves.
1613 * init/job.h: Add prototypes.
1614 * init/tests/test_job.c (test_start, test_stop, test_restart): Add
1615 tests for the new methods.
1616 * init/blocked.h (blocked_type): Add enums for methods.
1617 * init/blocked.c (blocked_new): Handle methods here too
1618 * init/tests/test_blocked.c (test_new): Add tests for them.
1619
Scott James Remnantd0258e02008-06-06 02:09:38 +010016202008-06-06 Scott James Remnant <scott@netsplit.com>
1621
Scott James Remnant088f59a2008-06-06 23:00:35 +01001622 * init/blocked.h (blocked_type): Having a single message type won't
1623 work for the job cases, so expand to have many.
1624 * init/blocked.c (blocked_new): We'll just have to list them all here.
1625 * init/control.c (control_emit_event): Happily we create them
1626 individually anyway.
1627 * init/event.c (event_finished): And since we have to handle them
1628 individually, it'll actually protect us replying to the wrong one.
1629
Scott James Remnanta78145a2008-06-06 03:57:54 +01001630 * init/tests/test_conf.c (test_source_reload): Clean up the temporary
1631 directory.
1632 * init/tests/test_control.c (test_reload_configuration): That goes
1633 for this one too.
1634
Scott James Remnant6921caa2008-06-06 03:52:15 +01001635 * init/tests/test_control.c (my_connect_handler): Use TEST_DBUS_MESSAGE
1636 instead of a pop/read/write loop.
1637 (test_emit_event): Renamed TEST_DBUS_CONN to TEST_DBUS_OPEN.
1638 * init/tests/test_job.c (test_new, test_register)
1639 (test_change_state): Use TEST_DBUS_OPEN and TEST_DBUS_CLOSE to setup
1640 and tear down D-Bus connections and TEST_DBUS_MESSAGE instead of
1641 a loop.
1642 * init/tests/test_job_class.c (test_consider, test_reconsider)
1643 (test_register, test_unregister): Likewise.
1644
Scott James Remnantdf8435e2008-06-06 03:39:17 +01001645 * init/control.c (control_get_job_by_name): Sanity check the name
1646 of a job in the same way; we don't need to sanity check the instance
1647 name because "" is valid (and the default for singletons).
1648 * init/tests/test_control.c (test_get_job_by_name): Test.
1649
Scott James Remnantb36155b2008-06-06 03:34:16 +01001650 * dbus/com.ubuntu.Upstart.xml (EmitEvent): Add an asynchronous
1651 method to emit an event, providing the name and accompanying
1652 environment. No return value, it either works or you get an
1653 error.
1654 * init/control.c (control_emit_event): Implement top half of the
1655 method, blocking the message in the event.
1656 * init/control.h: Add prototype.
1657 * init/event.c (event_finished): Implement the bottom half which
1658 sends the reply or error, these are actually tested along with
1659 the top for sanity reasons.
1660 * init/tests/test_control.c (test_emit_event): Test the various
1661 ways the method may be used and abused; the async nature means
1662 we actually need a real D-Bus server to do this.
1663 * TODO: Update.
1664
Scott James Remnantd0258e02008-06-06 02:09:38 +01001665 * init/event.c (event_new): There's no reason this shouldn't be
1666 allowed to return insufficient memory, so do so.
1667 (event_finished): Wrap call.
1668 * init/tests/test_event.c (test_new): Add alloc failed test.
1669 * init/job.c (job_emit_event): Must create the event.
1670 * init/main.c (main, cad_handler, kbd_handler, pwr_handler): Wrap
1671 with NIH_MUST
1672
Scott James Remnant01735c02008-06-05 00:38:56 +010016732008-06-05 Scott James Remnant <scott@netsplit.com>
1674
Scott James Remnant02ee2002008-06-05 22:07:43 +01001675 * TODO: Update.
1676
Scott James Remnantad4afe22008-06-05 22:05:21 +01001677 * init/job.c (job_unblock): Rename to job_finished, since this
1678 does not behave like event_unblock but more like event_finished
1679 (job_change_state, job_failed): Change name in call.
1680 * init/job.h: Update prototype.
1681 * init/tests/test_job.c (test_unblock): Rename to test_finished
1682 * init/event.c (event_pending_handle_jobs): Update calls here.
1683
Scott James Remnant81e74e02008-06-05 22:00:56 +01001684 * init/job.h (Job): Rename blocked to blocker to match event, since
1685 it has the same use as event->blockers except it's a toggle
1686 * init/job.c (job_new, job_change_state): Rename where used
1687 * init/event.c (event_finished): Rename here also since its reset
1688 * init/tests/test_job.c, init/tests/test_job_process.c,
1689 * init/tests/test_event.c: Rename in test cases too.
1690
Scott James Remnant4ff5c7c2008-06-05 21:57:44 +01001691 * init/job.c (job_emit_event): Add a Blocked record to the event's
1692 blocking list for the starting and stopping events.
1693 * init/tests/test_job.c (test_emit_event): Add tests for the record
1694 being added to the list with the right details.
1695 (test_change_goal): Make sure that a Blocked record is added
1696 (test_change_state): Make sure that Blocked records are added
1697 * init/tests/test_job_process.c (test_handler): Also make sure
1698 that Blocked records are added.
1699
Scott James Remnant2ef01a92008-06-05 21:31:25 +01001700 * init/event.c (event_finished): Clear jobs referenced in the
1701 blocking list, rather than iterating the entire jobs hash.
1702 (event_finished_handle_jobs): Drop this function.
1703 * init/tests/test_event.c (test_finished, test_finished_handle_jobs):
1704 Merge tests again and test using both the blocking list and job's
1705 blocked member.
1706
Scott James Remnantdb7e92b2008-06-05 21:15:54 +01001707 * init/event.h (event): Add blocking member.
1708 * init/event.c (event_new): Initialising blocking list.
1709 * init/tests/test_event.c (test_new): Make sure it's initialised
1710 to an empty list.
1711
Scott James Remnant9e919ba2008-06-05 21:01:42 +01001712 * init/tests/test_job_process.c (test_handler): Update tests to use
1713 Blocked.
1714
Scott James Remnantea489282008-06-05 20:52:45 +01001715 * init/event.c (event_pending_handle_jobs): Collect environment
1716 and events independantly, which means we don't have to worry about
1717 the list contents or freeing them up in case of error.
1718 * init/event_operator.c (event_operator_events): Fix parent.
1719 * init/tests/test_event.c (test_pending_handle_jobs): Update tests.
1720 * init/init.supp: Update collect suppression.
1721
Scott James Remnant3aa31c82008-06-05 20:18:17 +01001722 * init/event_operator.c (event_operator_collect): Break in two.
1723 (event_operator_environment): Collect the environment from the event,
1724 appending the list of event names if necessary.
1725 (event_operator_events): Block events and pass them to the
1726 given list.
1727 * init/event_operator.h: Update prototypes.
1728 * init/tests/test_event_operator.c (test_operator_collect): Also
1729 split into two new functions
1730 (test_operator_environment, test_operator_events): Adjust
1731
Scott James Remnant56a1da62008-06-05 19:47:45 +01001732 * init/event_operator.c (event_operator_collect): Placed Blocked
1733 structures in the list, rather than ordinary entries; I strongly
1734 suspect that while it's nice to iterate the operator tree only once,
1735 this needs to be three functions really.
1736 * init/tests/test_event_operator.c (test_operator_collect): Update
1737 test suite.
1738
Scott James Remnantc33e1332008-06-05 19:33:17 +01001739 * init/job.h (Job): Make blocking a statically defined list.
1740 * init/job.c (job_new): Initialise rather than setting to NULL.
1741 (job_unblock): Assume that blocking members are Blocked structures
1742 and that the list itself is always iterable.
1743 * init/tests/test_job.c (test_new): Check the list is empty, rather
1744 than NULL.
1745 (test_change_state, test_failed, test_unblock): Change tests cases
1746 to expect blocking to always be present, and create members as Blocked
1747 structures.
1748
Scott James Remnantfa5ccfe2008-06-05 19:32:14 +01001749 * init/blocked.c (blocked_new): Set destructor (forgotten)
1750
Scott James Remnant5b2115f2008-06-05 19:31:58 +01001751 * init/init.supp: Add setenv, which has crept in
1752
Scott James Remnant0fb7dac2008-06-05 18:39:21 +01001753 * init/blocked.h: Header containing enum, struct and prototype.
1754 * init/blocked.c (blocked_new): Function to allocate the structure
1755 with the right details.
1756 * init/tests/test_blocked.c (test_new): Tests for the new function.
1757 * init/Makefile.am (init_SOURCES): Compile using blocked.c and header
1758 (TESTS): Build blocked test suite
1759 (test_process_LDADD, test_job_class_LDADD)
1760 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
1761 (test_event_operator_LDADD, test_parse_job_LDADD)
1762 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD):
1763 Link blocked.o to most test suites.
1764 (test_blocked_SOURCES, test_blocked_LDFLAGS, test_blocked_LDADD):
1765 Details for test suite.
1766
Scott James Remnantf3ef5112008-06-05 01:26:10 +01001767 * init/main.c: Also remove SIGTERM handling, we don't re-exec
1768 properly and this is a dangerous signal to use anyway.
1769 (term_handler): Drop function.
1770
Scott James Remnant6d271af2008-06-05 01:22:53 +01001771 * init/main.c: Remove handling for stop/cont; there's no reason
1772 a user should be able to pause the event queue.
1773 (stop_handler): Drop function.
1774 * init/event.c (event_poll): Remove paused handling.
1775
Scott James Remnant3d703792008-06-05 01:20:35 +01001776 * init/control.c: Fix doc string.
1777
Scott James Remnant8523ba72008-06-05 01:14:33 +01001778 * dbus/com.ubuntu.Upstart.xml (ReloadConfiguration): Add method
1779 that's effectively the same as the HUP signal.
1780 * init/control.c (control_reload_configuration): Unsurprisingly,
1781 the implementation is identical.
1782 * init/control.h: Add prototype.
1783 * init/tests/test_control.c (test_reload_configuration): Make sure
1784 the method works as expected.
1785 (test_get_job_by_name, test_get_all_jobs): Add missing free calls for
1786 message in cases of out of memory.
1787
Scott James Remnant01735c02008-06-05 00:38:56 +01001788 * dbus/com.ubuntu.Upstart.xml (JobAdded, JobRemoved): Add signals
1789 for when new jobs are added to the known list and when existing jobs
1790 are removed, this allows GUIs to always show an up-to-date list.
1791 * dbus/com.ubuntu.Upstart.Job.xml (InstanceAdded, InstanceRemoved):
1792 Also add matching signals for when instances are added to the list
1793 for a job and when they're removed again.
1794 * init/job_class.c (job_class_register): Emit the JobAdded signal
1795 for this job when registering if the new signal argument is TRUE;
1796 pass on the signal argument to job_register()
1797 (job_class_add): Emit signals when registering jobs with existing
1798 connections.
1799 (job_class_unregister): Emit signals when unregistering a job.
1800 * init/job.c (job_register): Likewise, emit the InstanceAdded signal
1801 for the job class if the new signal argument is TRUE.
1802 (job_new): Emit signals when registering instances with existing
1803 connections.
1804 (job_change_state): Emit the instance removed signal when destroying
1805 an inactive instance.
1806 * init/job_class.h, init/job.h: Add signal argument to prototypes
1807 * init/control.c (control_register_all): When registering job classes
1808 on a new connection, do not emit a signal since they will already
1809 exist at the point when the name appears on the bus or the connection
1810 is complete.
1811 * init/tests/test_control.c (test_bus_open): Add comment that we
1812 are testing for signal non-emission already with the fake server,
1813 since it was this test that actually made me realise we had to
1814 not emit them :p
1815 * init/tests/test_job_class.c (test_register): Test that the signal
1816 is emitted when signal is TRUE and not emitted when signal is FALSE
1817 (test_unregister): Test that the JobRemoved signal is emitted
1818 (test_get_instance_by_name, test_get_all_instances): Free message
1819 if allocation failed.
1820 (test_consider, test_reconsider): Test that the JobAdded and
1821 JobRemoved signals are emitted (or not) when appropriate.
1822 * init/tests/test_job.c (test_register): Make sure that the
1823 InstanceAdded signal is emitted when TRUE is passed, and not when
1824 FALSE is passed.
1825 (test_new): Make sure the InstanceAdded signal is emitted when the
1826 job is registered on the bus.
1827 (test_change_state): Make sure the InstanceRemoved signal is sent
1828 when deleting an instance.
1829
Scott James Remnantbd3504a2008-06-02 16:00:27 +010018302008-06-02 Scott James Remnant <scott@netsplit.com>
1831
Scott James Remnante49832c2008-06-02 16:12:22 +01001832 * init/tests/test_job.c (test_new, test_register): Also use a private
1833 dbus server to avoid session bus problems.
1834
Scott James Remnantf18c5ae2008-06-02 16:10:23 +01001835 * init/tests/test_job_class.c (test_consider, test_reconsider)
1836 (test_register, test_unregister): Use a private dbus server instead
1837 of connecting to the session bus, which might not be there.
1838
Scott James Remnant77446ca2008-06-02 16:05:28 +01001839 * init/tests/test_control.c (test_disconnected): Simplify using a
1840 private dbus server rather than faking one.
1841
Scott James Remnantbd3504a2008-06-02 16:00:27 +01001842 * init/tests/test_control.c (test_bus_close): Don't rely on being
1843 able to connect to the various buses, instead use a special private
1844 one.
1845
Scott James Remnant51980bc2008-06-01 19:22:11 +010018462008-06-01 Scott James Remnant <scott@netsplit.com>
1847
Scott James Remnant92f2cc42008-06-01 20:42:30 +01001848 * dbus/com.ubuntu.Upstart.Job.xml (GetAllInstances): And also add
1849 a similar method to return the object path of all instances of a
1850 particular job.
1851 * init/job_class.c (job_class_get_all_instances): Implement the
1852 method, pretty much the same as the other.
1853 * init/job_class.h: Add prototype.
1854 * init/control.c: Fix comment.
1855 * init/tests/test_control.c (test_get_all_jobs): Ensure that the
1856 individual paths are children of the array.
1857
Scott James Remnant30abe7c2008-06-01 20:31:09 +01001858 * dbus/com.ubuntu.Upstart.xml (GetAllJobs): Add method to return
1859 the object path of all known jobs.
1860 * init/control.c (control_get_all_jobs): Implement the method,
1861 somewhat simple happily.
1862 * init/control.h: Add prototype for the method.
1863 * init/tests/test_control.c (test_get_all_jobs): Test that the
1864 right data is returned.
1865
Scott James Remnante9876b72008-06-01 19:49:39 +01001866 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
1867 * dbus/com.ubuntu.Upstart.Instance.xml: Add libnih XML NS to the
1868 files so that we can tag methods as sync or async later.
1869
Scott James Remnant9c221382008-06-01 19:43:48 +01001870 * init/control.c (control_get_job_by_name): Remove const from
1871 return parameter.
1872 * init/control.h: Update prototype.
1873 * init/tests/test_control.c (test_get_job_by_name): Remove const
1874 from path type.
1875
Scott James Remnant8c69f7b2008-06-01 19:40:33 +01001876 * init/job_class.c (job_class_get_instance_by_name): Remove wrong
1877 const from parameter now that we've fixed the bindings generator.
1878 * init/job_class.h: Update prototype to match.
1879 * init/tests/test_job_class.c (test_get_instance_by_name): Change
1880 type of path to match.
1881
Scott James Remnant00c8b992008-06-01 19:27:04 +01001882 * HACKING (Dependencies): clarify that autoreconf and configure need
1883 to be run for libnih first.
1884
Scott James Remnant51980bc2008-06-01 19:22:11 +01001885 * init/Makefile.am (test_process_LDADD, test_job_class_LDADD)
1886 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
1887 (test_event_operator_LDADD, test_parse_job_LDADD)
1888 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD): Link
1889 the auto-generated D-Bus code in, otherwise the tests won't be
1890 complete.
1891
Scott James Remnant50677e02008-05-24 13:09:50 +020018922008-05-24 Scott James Remnant <scott@netsplit.com>
1893
1894 * HACKING: Changed branch location again, of both upstart and
1895 libnih.
1896
Scott James Remnant9a7282e2008-05-16 00:04:52 +020018972008-05-16 Scott James Remnant <scott@netsplit.com>
1898
1899 * init/job_class.c (job_class_consider, job_class_reconsider): Find
1900 the best class first and compare against the current class before
1901 acting, this avoids the re-register jump every time a job stops.
1902 (job_class_select): Rename to job_class_add() since this is takes
1903 a class and is the direct opposite to job_class_remove().
1904
Scott James Remnant88345b82008-05-15 23:58:05 +020019052008-05-15 Scott James Remnant <scott@netsplit.com>
1906
1907 * init/event.c (event_new): We can't rely on the event poll function
1908 being the last in the main loop, it's often the first, so after
1909 adding an event to the queue ensure the loop is iterated at least
1910 once so that the event poll occurs for it.
1911
Scott James Remnanta645a992008-05-09 00:15:49 +010019122008-05-09 Scott James Remnant <scott@netsplit.com>
1913
Scott James Remnant6308bb12008-05-09 03:05:47 +01001914 * TODO (Anytime): Update.
1915
Scott James Remnant54ef7512008-05-09 03:04:49 +01001916 * dbus/com.ubuntu.Upstart.Instance.xml: format to match others
1917
Scott James Remnantb0ce81e2008-05-09 03:04:29 +01001918 * dbus/com.ubuntu.Upstart.Job.xml (GetInstanceByName): Add method
1919 * init/job_class.c (job_class_get_instance_by_name): Implementation.
1920 * init/job_class.h: Add prototype.
1921 * init/tests/test_job_class.c (test_get_instance_by_name): Tests
1922 for new method.
1923
Scott James Remnant6fa0b492008-05-09 02:58:41 +01001924 * init/job_class.h (JobClass): Make instances a hash table.
1925 * init/job_class.c (job_class_new): Initialise instances as a hash
1926 table now.
1927 (job_class_register): Iterate instances as hash table.
1928 (job_class_remove): Slightly odd construct needed to return FALSE
1929 if there's anything in the hash table.
1930 (job_class_unregister): Likewise to assert on no instances.
1931 * init/tests/test_job_class.c (test_new): Check that instances is
1932 now a hash table.
1933 * init/job.h (Job): Make name the first member.
1934 * init/job.c (job_new): Add to instances as hash table.
1935 (job_instance): Drop entirely, replaced by a hash lookup.
1936 * init/tests/test_job.c (test_instance): Drop.
1937 * init/job_process.c (job_process_find): Iterate instances as a
1938 hash table.
1939 * init/event.c (event_pending_handle_jobs)
1940 (event_finished_handle_jobs): Iterate instances as hash table.
1941 (event_pending_handle_jobs): Replace job_instance call with an
1942 ordinary hash lookup.
1943 * init/tests/test_event.c: Update to use hash table.
1944 * init/tests/test_conf.c: Update instances stealing for hash table
1945
Scott James Remnant27d71f12008-05-09 02:35:26 +01001946 * init/job_class.c (job_class_new): initialise instance to the
1947 empty string.
1948 * init/tests/test_job_class.c: Update job_new() calls.
1949 (test_new): Check instance against the empty string.
1950 * init/job.c (job_new): name may no longer be NULL.
1951 * init/tests/test_job.c: Update job_new() calls.
1952 (test_instance): Reset back to "" when done.
1953 * init/event.c (event_pending_handle_jobs): Always expand the
1954 name, since the class->instance is always non-NULL.
1955 * init/tests/test_event.c: Update job_new calls.
1956 * init/tests/test_conf.c: Update job_new calls.
1957 * init/tests/test_job_process.c: Update job_new calls.
1958
Scott James Remnant07bdd4c2008-05-09 02:26:15 +01001959 * init/job.c (job_new): Singleton jobs have a fixed name of "",
1960 rather than a NULL name, and a D-Bus name of "_".
1961 (job_instance): Which rather simplifies this function (in fact,
1962 it makes this function look like a common one).
1963 (job_emit_event): Always set INSTANCE variable.
1964 (job_name): Still distinguish in output, to avoid ugly "()" but
1965 check character rather than NULL.
1966 * init/tests/test_job.c (test_new): Check name is set to ""
1967 and path to ".../_"
1968 (test_change_state, test_emit_event): Update test cases to assume
1969 an empty INSTANCE variable
1970 (test_instance): Update to pass "" instead of NULL.
1971 * init/job_process.c (job_process_run): Always set UPSTART_INSTANCE
1972 * init/tests/test_job_process.c (test_run): Always assume an
1973 UPSTART_INSTANCE variable, it may just be empty.
1974 * init/tests/test_event.c (test_pending_handle_jobs): Expect
1975 the name to be set to the empty string.
1976
Scott James Remnanta1fb6862008-05-09 00:30:14 +01001977 * init/Makefile.am (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
1978 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
1979 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
1980 Drop setting of data-type, turns out it doesn't work anyway.
1981
Scott James Remnant31253ca2008-05-09 00:19:07 +01001982 * dbus/Upstart.conf: Add configuration file.
1983 * dbus/Makefile.am (dbussystemdir, dist_dbussystem_DATA): Install
1984 the configuration file into the right place.
1985
Scott James Remnanta645a992008-05-09 00:15:49 +01001986 * dbus/com.ubuntu.Upstart.xml (GetJobByName): Add method
1987 * init/control.c (control_get_job_by_name): Implementation.
1988 * init/control.h: Prototype.
1989 * init/tests/test_control.c (test_get_job_by_name): Test the
1990 method using a fake message.
1991
Scott James Remnant327c7df2008-05-08 10:18:27 +010019922008-05-08 Scott James Remnant <scott@netsplit.com>
1993
Scott James Remnant8eb8dd22008-05-08 23:35:31 +01001994 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
1995 * dbus/com.ubuntu.Upstart.Instance.xml: Add DTDs.
1996
Scott James Remnant8877f442008-05-08 23:30:40 +01001997 * init/control.c (manager_interfaces): Export the general
1998 com.ubuntu.Upstart interface
1999 * init/job_class.c (job_class_interfaces): Export the
2000 com.ubuntu.Upstart.Job interface
2001 * init/job.c (job_interfaces): Export the
2002 com.ubuntu.Upstart.Instance interface
2003
Scott James Remnante1640612008-05-08 23:27:51 +01002004 * init/Makefile.am (BUILT_SOURCES)
2005 (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
2006 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
2007 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
2008 Generate C code and header files from the XML files which produce
2009 object bindings.
2010 (init_SOURCES): Link the built sources.
2011 (CLEANFILES): Clean them up afterwards
2012
Scott James Remnant08169c12008-05-08 23:14:22 +01002013 * dbus/com.ubuntu.Upstart.xml: Initially empty description for
2014 manager object interface(s).
2015 * dbus/com.ubuntu.Upstart.Job.xml: Initially empty description
2016 for job class object interface(s).
2017 * dbus/com.ubuntu.Upstart.Instance.xml: Initially empty
2018 description for job instance object interface(s).
2019 * dbus/Makefile.am: Distribute the three interface files,
2020 they're used as sources elsewhere.
2021 * configure.ac (AC_CONFIG_FILES): Generate dbus/Makefile
2022 * Makefile.am (SUBDIRS): Descend into the dbus sub-directory.
2023
Scott James Remnant0464dc12008-05-08 19:21:54 +01002024 * init/job_class.c (job_class_consider, job_class_reconsider):
2025 Separate out the actual meat of the functions, since it's largely
2026 duplicated between the two. This makes the difference between
2027 the two functions clearer, consider always stages an election
2028 no matter which is registered, reconsider only stages an election
2029 if the current class is registered.
2030 (job_class_select, job_class_remove): Functions containing the
2031 common code, which now also handle registering and unregistering
2032 the class with D-Bus. Here is the right place, not in new, since
2033 we only export the current best class of a given name.
2034 (job_class_register, job_class_unregister): Function to register
2035 a job and its instances, and to unregister a job (we assert that
2036 there must be no instances for us to do this).
2037 * init/job_class.h: Add prototypes.
2038 * init/tests/test_job_class.c (test_consider, test_reconsider):
2039 Check that D-Bus registration and unregistration happens as
2040 expected.
2041 (test_register, test_unregister): test on their own.
2042 * init/job.c (job_new): Register instances with D-Bus, since
2043 instances can only ever exist for active classes, all instances
2044 are always registered on the bus.
2045 (job_register): Function to register an instance on the bus.
2046 * init/job.h: Add prototype.
2047 * init/tests/test_job.c (test_new): Test creating a job with an
2048 active d-bus connection, which should have it registered.
2049 (test_register): Test registration on its own.
2050 * init/control.c (control_register_all): Make this always succeed,
2051 and register existing jobs on the new connection.
2052 (control_server_connect, control_bus_open): registration is
2053 always successful.
2054 * init/tests/test_control.c (test_server_connect, test_bus_open):
2055 Test with existing jobs when we get a connection or create the
2056 bus connection, ensure that the jobs and instances are registered.
2057
Scott James Remnant327c7df2008-05-08 10:18:27 +01002058 * init/tests/test_job.c (test_change_state): Check for a bug where
2059 a job with multiple instances will be freed when one instance is
2060 deleted rather than the last instance.
2061 * init/job.c (job_change_state): Add debugging messages when we
2062 destroy a job that's no longer the current one or an instance
2063 that's no longer active; also ensure that we never destroy a job
2064 that's the current one.
2065 * init/event.c (event_pending_handle_jobs): Add a debugging message
2066 when we create a new instance of a job.
2067 * init/conf.c (conf_file_destroy): Add a debugging message when
2068 we destroy a job that's no longer the current one.
2069
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +010020702008-05-07 Scott James Remnant <scott@netsplit.com>
2071
Scott James Remnant1ba7f7a2008-05-07 23:52:11 +01002072 * init/control.c (control_server_open, control_server_close)
2073 (control_server_connect): Create and manage a listening d-bus server
2074 that is used for private direct connections to Upstart for when the
2075 d-bus daemon is not available. Each new connection has the same
2076 objects as the d-bus system bus, they only differ in their method.
2077 (control_conns, control_init): Cache the open connections, including
2078 the bus daemon and any private connections; we'll iterate this list
2079 when sending signals.
2080 (control_bus_open): Store connection in the list, don't worry about
2081 setting close-on-exec, we check that by test case and rely on d-bus
2082 to do it.
2083 (control_bus_disconnected): Rename to control_disconnected
2084 (control_disconnected): Work for system bus and private connections,
2085 remove from the connections list.
2086 * init/control.h: Add prototypes, remove global definition of bus
2087 name to just being private again.
2088 * init/tests/test_control.c (test_server_open, test_server_close)
2089 (test_server_connect): Test the new functions.
2090 (test_bus_open): add check for list entry
2091 (test_bus_disconnected): rename to test_disconnected
2092 * init/main.c: Open the listening server, warning if we're unable
2093 to do so (but we won't treat it as a hard error since there's the
2094 d-bus daemon as the default anyway).
2095 * init/init.supp: suppress the fact that the control connections
2096 list stays around.
2097
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +01002098 * init/job_process.c (job_process_run): Use NIH_ZERO instead of
2099 NIH_MUST and == 0
2100
Scott James Remnant5635e072008-05-06 23:22:58 +010021012008-05-06 Scott James Remnant <scott@netsplit.com>
2102
Scott James Remnantd1799d22008-05-06 23:34:56 +01002103 * init/environ.c (environ_expand_until): Odd gcc optimiser warning,
2104 it reckons arg_start and end may be used uninitialised, but I don't
2105 see how they can be.
2106
Scott James Remnant5635e072008-05-06 23:22:58 +01002107 * init/main.c (main): Warn if we can't set the root directory.
2108 * init/job_process.c (job_process_spawn)
2109 (job_process_error_abort): loop on the return of write()
2110 * init/tests/test_job_process.c (child, main): assert getcwd() works
2111 (test_handler): initialise list and entry for gcc's blind spot.
2112 (test_run): initialise ret for gcc's blind spot
2113 * init/tests/test_job.c (test_name): jump through hoops for gcc
2114 (test_change_state): list and entry.
2115 * init/tests/test_event.c (test_finished_handle_jobs, test_finished)
2116 (test_pending_handle_jobs, test_poll, test_pending): initialise to
2117 NULL and buy gcc glasses
2118 * init/tests/test_event_operator.c (test_operator_collect): another
2119 NULL to make gcc happy.
2120
Scott James Remnant70a8c8a2008-05-01 01:06:22 +010021212008-05-01 Scott James Remnant <scott@netsplit.com>
2122
Scott James Remnant75f6fae2008-05-01 01:39:27 +01002123 * TODO: Update.
2124
Scott James Remnant8d68b132008-05-01 01:21:07 +01002125 * init/init.supp: Suppress a few test case artefacts caused by
2126 valgrind hating reachable memory at exec() time.
2127
Scott James Remnant41f44aa2008-05-01 01:20:33 +01002128 * init/tests/test_job_process.c: Fix a few cases where we were
2129 still dup'ing the name argument to job_new().
2130 * init/tests/test_parse_job.c: Include missing signal.h
2131
Scott James Remnant70a8c8a2008-05-01 01:06:22 +01002132 * init/event.c (event_pending_handle_jobs)
2133 (event_finished_handle_jobs): Land the old job event handling
2134 functions here as static functions, right now they're immense but
2135 we'll actually move much of the code back out again as we go.
2136 * init/tests/test_event.c (test_pending_handle_jobs)
2137 (test_finished_handle_jobs): Also land the test cases in renamed
2138 and somewhat restructued functions, since we now have to do the
2139 testing through event_poll().
2140 (test_poll, test_pending, test_finished): It never hurts to improve
2141 test cases while you're in there.
2142
Scott James Remnantb98ac992008-04-30 00:03:00 +010021432008-04-30 Scott James Remnant <scott@netsplit.com>
2144
Scott James Remnant63fd5c72008-04-30 21:34:31 +01002145 * init/job.c (job_change_state): Change calls to job_process_run
2146 and job_process_kill.
2147 * init/main.c: Change to job_process_handler
2148
Scott James Remnantf2d78e62008-04-30 21:33:38 +01002149 * init/job_process.c, init/job_process.h: Land the code from job.c
2150 and defs from job.h that deal specifically with a job's processes,
2151 rename the functions to job_process_*() in the process.
2152 * init/tests/test_job_process.c: And land the test cases as well.
2153
Scott James Remnanted255912008-04-30 21:09:48 +01002154 * init/job.c: Strip of everything not related to creation and finding
2155 of instances and the core state machine; process stuff will move to
2156 job_process.c and event handling to event.c, class (nee config) stuff
2157 is already moved to job_class.c
2158 (job_new): Don't reparent the name, it doesn't help anything, just
2159 take a copy.
2160 (job_name, job_failed, job_unblock, job_emit_event): Make extern since
2161 we need to use these outside or just want to test them.
2162 * init/job.h: Clean out also.
2163 * init/tests/test_job.c: Also clean out.
2164 (test_name, test_failed, test_unblock, test_emit_event): Add test cases
2165 for newly extern functions.
2166
Scott James Remnant5d82d902008-04-30 00:03:29 +01002167 * init/main.c: Include events.h to get the ones we need.
2168
Scott James Remnantb98ac992008-04-30 00:03:00 +01002169 * init/control.c (control_job_config_path, control_job_path)
2170 (control_path_append): Drop these functions (replaced by the more
2171 generic nih_dbus_path() function)
2172 * init/control.h: Make CONTROL_ROOT public, and drop other prototypes.
2173 * init/tests/test_control.c (test_job_config_path)
2174 (test_job_path): Drop tests.
2175
Scott James Remnant07336532008-04-29 19:45:51 +010021762008-04-29 Scott James Remnant <scott@netsplit.com>
2177
Scott James Remnante1725e82008-04-29 23:59:51 +01002178 * init/event.c, init/event.h, init/tests/test_event.c: Strip out the
2179 event operator code and events list.
2180
Scott James Remnant6f02f542008-04-29 23:59:12 +01002181 * init/job_class.c, init/job_class.h: We only need the event operator
2182 code here now.
2183
Scott James Remnantddbbaa62008-04-29 23:58:36 +01002184 * init/events.h, init/event_operator.c, init/event_operator.h,
2185 init/tests/test_event_operator.c: Separate out the event operator
2186 code and the list of events into separate source files.
2187 * init/Makefile.am (init_SOURCES): Build and link event operator code
2188 and use the lists of events.
2189 (TESTS): Build and run the event operator test suite.
2190 (test_event_operator_SOURCES, test_event_operator_LDFLAGS)
2191 (test_event_operator_LDADD): Details for the event operator test
2192 suite.
2193 (test_process_LDADD, test_job_class_LDADD)
2194 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
2195 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
2196 (test_control_LDADD): Link the event operator code.
2197
Scott James Remnantf2f69d02008-04-29 23:38:23 +01002198 * init/job_class.c, init/main.c: Correct includes and some function
2199 names.
2200
Scott James Remnant9de968e2008-04-29 23:37:25 +01002201 * init/process.c, init/process.h, init/tests/test_process.c: Land
2202 original Process code (used by job class and similar).
2203
Scott James Remnant8092e792008-04-29 23:36:16 +01002204 * init/process.c, init/process.h, init/tests/test_process.c: Break
2205 into two pieces, one part becomes job_process which requires both
2206 job information and process information, the other becomes system
2207 which requires no job information.
2208 * init/errors.h: Update error name.
2209 * init/Makefile.am (init_SOURCES): Build and link job process code
2210 and header along with system code and header.
2211 (TESTS): Build and run job process and system test suites.
2212 (test_job_process_SOURCES, test_job_process_LDFLAGS)
2213 (test_job_process_LDADD): Details for job process test suite.
2214 (test_system_SOURCES, test_system_LDFLAGS, test_system_LDADD):
2215 Details for system test suite.
2216 (test_process_LDADD, test_job_class_LDADD, test_job_LDADD)
2217 (test_event_LDADD, test_parse_job_LDADD, test_parse_conf_LDADD)
2218 (test_conf_LDADD, test_control_LDADD): Link job process and system
2219 code.
2220
Scott James Remnant783a79d2008-04-29 20:00:52 +01002221 * init/parse_conf.c: Remove parse_job include.
2222
Scott James Remnantc2791dd2008-04-29 19:59:41 +01002223 * init/init.supp: Update leak check for class init; remove
2224 valgrind workaround since it's gone away with the change of that
2225 function.
2226
Scott James Remnant710c5152008-04-29 19:58:44 +01002227 * init/conf.h (ConfFile): Change type of job member, but leave name.
2228 Add prototype for new function.
2229 * init/conf.c (conf_reload_path): Somewhat simplify the case of
2230 having parsed a job, we only need to call job_class_consider() now
2231 to have it dealt with.
2232 (conf_file_destroy): Likewise after removing the ConfFile from the
2233 source (so it won't get considered) and marking the job class as
2234 deleted, we only need to call job_class_reconsider() and check the
2235 return value to see whether we've been replaced.
2236 (conf_select_job): In return we provide the function to decide which
2237 of the available job sources is the best one.
2238 * init/tests/test_conf.c: Update types in tests.
2239 (test_select_job): Test the new function.
2240
Scott James Remnant11168f32008-04-29 19:46:03 +01002241 * init/parse_job.h: Update to include job_class.h and update prototype
2242 to return JobClass, we'll keep the name though since we'll never
2243 parse jobs and otherwise things get annoying.
2244 * init/parse_job.c: Update to work on job classes.
2245 * init/tests/test_parse_job.c: Update to match.
2246
Scott James Remnant07336532008-04-29 19:45:51 +01002247 * init/job_class.h (JobClass): Factor out old JobConfig object into
2248 a new JobClass object with the same properties, but in its own source
2249 file.
2250 (ExpectType): Rename old JobExpect to this to match other enums.
2251 (ConsoleType): Move along with the object that uses it.
2252 * init/job_class.c (job_class_init, job_class_new)
2253 (job_class_environment): Bring along methods that only operate on
2254 a JobClass, cleaning them up in the process.
2255 (job_class_consider, job_class_reconsider): Replace job_config_replace
2256 with these two functions that may be used for a new job class and
2257 when discarding or finishing with an old one respectively.
2258 * init/tests/test_job_class.c: Tests for the functions.
2259 * init/Makefile.am (init_SOURCES): Build and link job class source
2260 and header.
2261 (TESTS): Build and run job class test suite.
2262 (test_job_class_SOURCES, test_job_class_LDFLAGS)
2263 (test_job_class_LDADD): Details for job class test suite.
2264 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2265 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
2266 (test_control_LDADD): Link job class code to other tests too.
2267
Scott James Remnantf92d4832008-04-28 20:32:35 +010022682008-04-28 Scott James Remnant <scott@netsplit.com>
2269
Scott James Remnantbee70f52008-04-28 22:09:23 +01002270 * init/control.c (control_job_config_path, control_job_path): Add
2271 functions to generate D-Bus object paths for jobs and instances
2272 (control_path_append): and a static function used by both to append
2273 escaped path elements.
2274 * init/control.h: Add prototypes.
2275 * init/tests/test_control.c (test_job_config_path)
2276 (test_job_path): Add test cases for the new functions.
2277 * init/job.h (JobConfig, Job): Add path member to both structures.
2278 * init/job.c (job_config_new, job_new): Initialise the path members.
2279 * init/tests/test_job.c (test_config_new, test_new): Make sure
2280 the path members are initialised to something sensible.
2281 * init/init.supp: Valgrind whines, I do not know why.
2282
Scott James Remnantf92d4832008-04-28 20:32:35 +01002283 * init/control.c (control_bus_open): Call out to register objects
2284 on the new bus connection.
2285 (control_register_all): Start off by registering the connection
2286 manager object, no methods/signals for now.
2287 * init/tests/test_control.c (test_bus_open): Make sure the manager
2288 object is registered.
2289
Scott James Remnant00c71a02008-04-27 23:04:17 +010022902008-04-27 Scott James Remnant <scott@netsplit.com>
2291
Scott James Remnanta6cb3542008-04-27 23:10:55 +01002292 * init/tests/test_control.c (test_bus_open): Correct name of
2293 error macro.
2294
Scott James Remnant00c71a02008-04-27 23:04:17 +01002295 * init/job.c (job_emit_event): Make INSTANCE the second variable.
2296 * init/tests/test_job.c (test_next_state): Update tests.
2297
Scott James Remnant7fbefc12008-04-25 00:51:18 +010022982008-04-25 Scott James Remnant <scott@netsplit.com>
2299
2300 * init/tests/test_control.c (test_bus_open): Use D-bus macros for
2301 error strings instead of naming them by hand.
2302
Scott James Remnantaec48692008-04-22 07:44:48 +010023032008-04-22 Scott James Remnant <scott@netsplit.com>
2304
2305 * init/tests/test_control.c (test_bus_close): Add another missing
2306 call to dbus_shutdown.
2307
Scott James Remnant7e965822008-04-21 22:41:11 +010023082008-04-21 Scott James Remnant <scott@netsplit.com>
2309
2310 * init/tests/test_control.c (test_bus_open): Under valgrind we seem
2311 to get NoReply instead of Disconnected which is a wee bit odd.
2312 Add missing call
2313 (test_bus_disconnected): Add missing call to dbus_shutdown.
2314
Scott James Remnant30555d52008-04-19 11:52:04 +010023152008-04-19 Scott James Remnant <scott@netsplit.com>
2316
Scott James Remnantfbdd3cd2008-04-19 19:42:31 +01002317 * init/process.c: Add missing limits.h include
2318
Scott James Remnant15a1eea2008-04-19 16:47:32 +01002319 * init/job.h (JobConfig): Merge instance and instance_name; if
2320 instance is set, the job is multi-instance with the name derived
2321 from that; if unset the job is singleton. We will not support
2322 unlimited instances.
2323 * init/job.c (job_config_new): Initialise instance to NULL.
2324 (job_new): Assert that name is set for instance jobs.
2325 (job_instance): Alter to only deal with singleton and instance
2326 jobs, the unlimited instances case is gone.
2327 (job_handle_event): Use instance instead of instance_name
2328 * init/tests/test_job.c (test_config_new): Check instance is NULL
2329 (test_find_by_pid): Adjust the way instance jobs are made, which
2330 means we have to pass a name to job_config_new now.
2331 (test_instance): Adjust tests to remove unlmited-instance tests
2332 and pass name to job_config_new
2333 (test_change_state, test_run_process): Pass instance name to
2334 job_new as an allocated argument rather than waiting to set it
2335 until afterwards.
2336 (test_handle_event): Set instance instead of instance_name
2337 * init/parse_job.c (stanza_instance): Make the argument mandatory.
2338 * init/tests/test_parse_job.c (test_stanza_instance): Remove the
2339 checks for without argument, and make sure that without argument
2340 is an error.
2341
Scott James Remnantc75e8242008-04-19 13:01:43 +01002342 * init/parse_job.c (stanza_oom): Oops, forgot to free never arg.
2343
Scott James Remnant4e3365d2008-04-19 13:00:42 +01002344 * init/job.h (JobConfig): NihList is rather overkill for emits,
2345 which is static configuration; turn into a NULL-terminated array
2346 which'll make it easier to turn into a D-Bus property later.
2347 * init/job.c (job_config_new): Initialise to NULL now.
2348 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
2349 * init/parse_job.c (stanza_emits): Store in an array instead.
2350 * init/tests/test_parse_job.c (test_stanza_emits): Redo tests.
2351
Scott James Remnant264f7e92008-04-19 12:55:58 +01002352 * init/job.c (job_emit_event): Append exported variables to the
2353 job event without overwriting the builtins.
2354 * init/tests/test_job.c (test_change_state): Check that exported
2355 environment is added to the job events.
2356
Scott James Remnant4b7b9d72008-04-19 12:39:52 +01002357 * init/parse_job.c (stanza_export): Parse a new export stanza,
2358 which takes one or more environment variable names.
2359 * init/tests/test_parse_job.c (test_stanza_export): Test the new
2360 stanza.
2361
Scott James Remnant65da8662008-04-19 12:28:44 +01002362 * init/job.h (JobConfig): Add new export member.
2363 * init/job.c (job_config_new): Initialise to NULL.
2364 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
2365
Scott James Remnantf2f53652008-04-19 12:15:47 +01002366 * init/environ.c (environ_add, environ_set): Add a replace argument
2367 which when FALSE does not replace existing entries in the environment
2368 table.
2369 * init/environ.h: Adjust prototypes.
2370 * init/tests/test_environ.c (test_add): Add tests for non-replacement
2371 mode, including corner cases.
2372 (test_set): Replace should be TRUE in this test.
2373 * init/event.c (event_operator_collect): Always replace existing
2374 environment members.
2375 * init/job.c (job_config_environment, job_run_process): Always replace
2376 existing environment members.
2377 (job_emit_event): Always replace existing environment members, and
2378 rework this function to get rid of the confusing gotos.
2379
Scott James Remnant30555d52008-04-19 11:52:04 +01002380 * init/tests/test_job.c (test_change_state): Add tests to make sure
2381 we include the INSTANCE variable in the event environment.
2382
Scott James Remnant9fab4e92008-04-18 13:19:06 +010023832008-04-18 Scott James Remnant <scott@netsplit.com>
2384
Scott James Remnantd8fe7022008-04-18 18:24:43 +01002385 * init/process.c (process_kill): Make sure we do send the signal to
2386 the process group; in practice this makes no difference, but it pays
2387 to be explicit in such things.
2388 * init/tests/test_process.c (test_kill): Add a test case for when
2389 the session leader is no more.
2390
Scott James Remnantac3d4ea2008-04-18 18:11:47 +01002391 * init/job.h (JobConfig): Another day, another obscure job config
2392 detail. This one is for adjusting how likely you are to be killed
2393 by the OOM Killer.
2394 * init/job.c (job_config_new): Set to zero by default.
2395 * init/tests/test_job.c (test_config_new): And make sure it is zero.
2396 * init/parse_job.c (stanza_oom): And it helps to have a function
2397 to set that one.
2398 * init/tests/test_parse_job.c (test_stanza_oom): Test it.
2399 * init/errors.h: And we need an error if its out of bounds.
2400 * init/conf.c (conf_reload_path): Which also needs to be caught.
2401 * init/process.c (process_spawn): Of course, we have to do something
2402 with the oom adjustment.
2403 (process_error_read): message for failure error.
2404 * init/process.h (processErrorType): And need an error if it fails
2405
Scott James Remnant7c1accf2008-04-18 13:32:01 +01002406 * init/main.c: Drop the legacy configuration directory, the format
2407 of jobs has changed sufficiently to not support it.
2408 * init/Makefile.am (AM_CPPFLAGS): Remove LEGACY_CONFDIR definition.
2409 (install-data-local): Don't create it, either.
2410
Scott James Remnantaaa59582008-04-18 13:30:05 +01002411 * init/enum.c, init/enum.h, init/tests/test_enum.c: Remove these
2412 source files, a hold-over from when we had them in a separate
2413 library and passed around the integer values.
2414 * init/job.c, init/job.h, init/tests/test_job.c: Restore in their
2415 proper place.
2416 * init/Makefile.am: Remove enum.* from build instructions.
2417
Scott James Remnantf8491442008-04-18 13:19:24 +01002418 * init/main.c: Attempt to connect to the system bus on startup,
2419 but don't expect it to work.
2420
Scott James Remnant9fab4e92008-04-18 13:19:06 +01002421 * init/control.c (control_bus_open, control_bus_disconnected)
2422 (control_bus_close): Functions to open a connection to the D-Bus
2423 system bus, clean up if disconnected or disconnect ourselves
2424 explicitly.
2425 * init/control.h: Prototypes.
2426 * init/tests/test_control.c (test_bus_open)
2427 (test_bus_disconnected, test_bus_close): Test the functions using
2428 a fake D-Bus system bus daemon.
2429 * init/errors.h: Add error for "name taken".
2430 * init/Makefile.am (init_SOURCES): Build and link control.c and
2431 control.h
2432 (TESTS): Build and run control test suite.
2433 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
2434 Details for control test suite.
2435 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2436 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
2437 Link control.o
2438
Scott James Remnantf8db5892008-04-16 14:39:59 +010024392008-04-16 Scott James Remnant <scott@netsplit.com>
2440
2441 * init/job.h (JobConfig): Add leader member.
2442 * init/job.c (job_config_new): Initialise leader to FALSE.
2443 * init/tests/test_job.c (test_config_new): Make sure leader is FALSE.
2444 (test_change_goal, test_change_state, test_run_process)
2445 (test_kill_process, test_child_handler, test_handle_event)
2446 (test_handle_event_finished): Jobs have to be leaders now to allow
2447 waitpid() to work in test cases.
2448 * init/parse_job.c (stanza_session): Parse "session leader" stanza
2449 to set to TRUE.
2450 * init/tests/test_parse_job.c (test_stanza_session): Test new
2451 stanza parsing.
2452 (test_stanza_console): Add missing "missing argument" test.
2453 * init/process.c (process_error_read): Deal with new fork error.
2454 (process_spawn): If we're not to be a session leader, fork again and
2455 write the pid back on the open socket.
2456 * init/process.h (ProcessErrorType): Introduce new fork error.
2457 * init/tests/test_process.c (test_spawn): Test that we can't start
2458 a non-session-leader and still have process details.
2459 (test_spawn, test_kill): Other jobs have to be leaders now to
2460 allow waitpid() to work.
2461 * init/tests/test_event.c (test_poll): Jobs have to be leaders now
2462 to allow waitpid() to work.
2463
Scott James Remnant048c79a2008-04-12 11:11:22 +010024642008-04-12 Scott James Remnant <scott@netsplit.com>
2465
Scott James Remnant477d9d42008-04-12 14:07:48 +01002466 * configure.ac (NIH_INIT): Require that libnih build D-Bus support,
2467 failing configure if we can't get it.
2468 * init/Makefile.am (AM_CFLAGS): Build with D-Bus CFLAGS,
2469 (init_LDADD, test_process_LDADD, test_job_LDADD, test_event_LDADD)
2470 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): and
2471 link with libnih-dbus.la and D-Bus LIBS.
2472 (init_LDFLAGS): No need for -static now since libnih will only exist
2473 statically anyway.
2474
Scott James Remnant2c0bd592008-04-12 12:31:49 +01002475 * init/main.c: Use a better name for kbdrequest
2476 * init/event.h (KBDREQUEST_EVENT): Rename event to keyboard-request
2477
Scott James Remnant4b56d6f2008-04-12 12:23:15 +01002478 * init/main.c: Drop the attempt to rescue a crashed system by
2479 carrying on with no state
2480 (crash_handler): After the child has core dumped, the parent will
2481 die and the kernel will panic. That's the best we can do, I think.
2482
Scott James Remnant6fd5acc2008-04-12 12:10:27 +01002483 * init/job.c (job_change_state): Don't generate the stalled event;
2484 there's nothing useful you can do with it other than start a root
2485 shell and that's just a security hole waiting to happen.
2486 (job_new): Don't increment the instances counter.
2487 * init/job.h: Remove extern for instances counter.
2488 * init/tests/test_job.c (test_new): Remove the check that the
2489 instance counter is incremented.
2490 (test_change_state): Remove the test for the stalled event.
2491 * init/event.h (STALLED): Remove stalled event definition,
2492 * TODO: Update.
2493
Scott James Remnant830370a2008-04-12 11:51:45 +01002494 * init/job.h (Job): And while we're at it, the instance name is
2495 guaranteed unique for a given job name, which is also guaranteed
2496 to be unique - so don't bother with job ids either, since they
2497 also get reused in bad cases.
2498 * init/job.c (job_next_id): Drop this function.
2499 (job_new): Don't assign an id anymore.
2500 (job_find_by_id): Drop this function.
2501 (job_run_process): Set UPSTART_INSTANCE to the instance name if set.
2502 (job_name): Function to create the string used in messages.
2503 (job_change_goal, job_change_state, job_run_process)
2504 (job_kill_process, job_kill_timer, job_child_handler)
2505 (job_process_terminated, job_process_trace_new)
2506 (job_process_trace_new_child, job_process_trace_signal)
2507 (job_process_trace_fork, job_process_trace_exec): Use the instance
2508 name in messages (if set) in place of the job id.
2509 * init/tests/test_job.c (test_new): Drop checks on the id field.
2510 (test_find_by_id): Drop test.
2511 (test_run_process): Check that UPSTART_INSTANCE is set only for
2512 named job instances, and contains the instance name.
2513 (test_change_state, test_run_process, test_child_handler): Remove
2514 id setting and update error message checks.
2515 * TODO: Update.
2516
Scott James Remnant048c79a2008-04-12 11:11:22 +01002517 * init/event.h (Event): We don't use the id field for anything;
2518 and it can't be guaranteed to be unique since it can wrap over
2519 and get reused. Drop it.
2520 * init/event.c (event_next_id): Drop this function.
2521 (event_new): Don't assign an id anymore.
2522 (event_find_by_id): Drop this function.
2523 * init/tests/test_event.c (test_new): Drop checks on the id field
2524 (test_find_by_id): Drop test.
2525 (test_poll): Drop id setting which was needless anyway.
2526
Scott James Remnant4dce7b32008-04-11 10:47:08 +010025272008-04-11 Scott James Remnant <scott@netsplit.com>
2528
Scott James Remnantf2874b82008-04-11 14:55:27 +01002529 * init/tests/test_job.c (test_child_handler): Add tests to make
2530 sure that respawn works for both services and tasks; the only
2531 difference we want for tasks is that zero is a normal exit code.
2532 * init/job.c (job_process_terminated): Status need not be non-zero
2533 if the job is not a task.
2534
Scott James Remnant2c1c57f2008-04-11 14:41:55 +01002535 Change the default job type from task to service, which will
2536 finally match people's expectations.
2537
2538 * init/job.h (JobConfig): Replace service member with task
2539 * init/job.c (job_config_new): Initialise task to FALSE
2540 (job_change_state): Unblock if not a task instead of if a service
2541 * init/tests/test_job.c (test_config_new): Make sure task is FALSE
2542 (test_change_state): Check service by default, task with flag;
2543 this also means we expect blockers to be cleared if we end up in
2544 running for the other checks
2545 (test_child_handler): Expect blockers to be cleared if we end up
2546 in running now that service is the default.
2547 * init/tests/test_event.c (test_poll): Test with a task since
2548 we want to remain blocked for longer.
2549 * init/parse_job.c (stanza_respawn): Don't set service to TRUE
2550 (stanza_service): Rename to stanza_task and set task flag instead
2551 * init/tests/test_parse_job.c (test_stanza_respawn): Remove checks
2552 for setting of service flag
2553 (test_stanza_service): Rename to test_stanza_task and test task
2554
Scott James Remnant4dce7b32008-04-11 10:47:08 +01002555 * init/job.c (job_init): Create hash using nih_hash_string_new()
2556 * init/conf.c (conf_source_new): Likewise.
2557
Scott James Remnantf8f19e92008-03-08 01:41:51 +000025582008-03-08 Scott James Remnant <scott@netsplit.com>
2559
Scott James Remnantb598eba2008-03-08 18:17:38 +00002560 * HACKING: Terminology changes: Bazaar-NG is now just Bazaar;
Scott James Remnantf6466b42008-04-11 10:38:04 +01002561 Malone is now just Launchpad's bug tracking system. Update bugs
Scott James Remnantb598eba2008-03-08 18:17:38 +00002562 URL to match modern form.
2563
Scott James Remnant76e3bc92008-03-08 16:12:12 +00002564 * init/enum.h (JobWaitType): Rename to JobExpect
2565 * init/job.h (JobConfig): Rename wait_for to expect
2566 * init/job.c (job_config_new, job_change_state, job_run_process)
2567 (job_process_stopped, job_process_trace_new_child): Rename wait_for
2568 to expect in all occurances.
2569 * init/tests/test_job.c: Likewise rename all occurances.
2570 * init/parse_job.c (stanza_wait): Rename to stanza_expect and drop
2571 the intermediate argument.
2572 * init/tests/test_parse_job.c (test_stanza_wait): Rename to
2573 test_stanza_expect and adjust tests to match new syntax.
2574 * init/tests/test_process.c (test_spawn): Remove set of wait_for.
2575
Scott James Remnantda695302008-03-08 01:50:56 +00002576 * doc/states.dot: Remove the state transition from starting to
2577 waiting ("emit_stopped" in the graph); we don't have a "respawning
2578 too fast" exit here anymore, so always go to stopping.
2579 * doc/states.png: Regenerate.
2580
Scott James Remnantf8f19e92008-03-08 01:41:51 +00002581 * TODO: Document the problems with overflowing ids and instance
2582 counter before I forget about them.
2583
Scott James Remnant7b6c16c2008-03-07 15:16:29 +000025842008-03-07 Scott James Remnant <scott@netsplit.com>
2585
Scott James Remnantd62ef892008-03-07 23:20:50 +00002586 * TODO: Update.
2587
Scott James Remnantdebbdc92008-03-07 23:20:34 +00002588 * init/job.h (JobConfig): Add instance_name member.
2589 (Job): Add name member.
2590 * init/job.c (job_config_new): Initialise instance name to NULL.
2591 (job_new): Accept the name as an argument, reparenting and stealing
2592 (job_handle_event): Expand the instance name and pass to job_new
2593 (job_instance): Accept a name and look that up in the list of current
2594 instances returning the instance if found.
2595 * init/tests/test_job.c: Add extra argument to all job_new calls
2596 (test_config_new): Make sure instance name is initialised to NULL.
2597 (test_handle_event): Make sure the job name is set from the instance,
2598 and make sure an existing instance is reused if we can.
2599 (test_instance): Make sure that the existing instance is returned.
2600 * init/parse_job.c (stanza_instance): Check for an optional argument
2601 and store it in the instance_name member if it exists, otherwise
2602 free and reset the instance_name member.
2603 * init/tests/test_parse_job.c (test_stanza_instance): Check the new
2604 argument is handled properly and stored in the right place.
2605 * init/tests/test_conf.c (test_source_reload_job_dir)
2606 (test_file_destroy): Add extra NULL to job_new
2607 * init/tests/test_event.c (test_poll): Add extra NULL to job_new
2608
Scott James Remnant6f857582008-03-07 21:32:53 +00002609 * init/event.c (event_operator_match): Accept an environment array
2610 and expand the operator value against it before attempting to match.
2611 (event_operator_handle): Also accept the environment array and pass
2612 through to calls to event_operator_match().
2613 * init/event.h: Update prototypes.
2614 * init/tests/test_event.c (test_operator_match): Add extra NULL
2615 argument to most tests, and add tests for known and unknown variable
2616 references.
2617 (test_operator_handle): Add extra NULL arguments to most tests, and
2618 add test for passing of environment through.
2619 (test_operator_reset): Add extra NULL argument to call.
2620 * init/job.c (job_handle_event): Pass the job environment for the
2621 stop event handling, but NULL for the start event.
2622 * init/tests/test_job.c (test_handle_event): Make sure that a stop
2623 operator is expanded from the job environment before being matched
2624 against the stop event.
2625
Scott James Remnant7d4ffbb2008-03-07 20:56:15 +00002626 * init/event.c, init/event.h, init/environ.c: Documentation tweaks.
2627
Scott James Remnantb605dfc2008-03-07 19:24:52 +00002628 * init/job.c (job_change_state): Remove the code to check for runaway
2629 jobs from here, we'll always let people explicitly start an instance.
2630 (job_process_terminated): Call job_catch_runaway when actually doing
2631 the respawn instead.
2632 * init/tests/test_job.c (test_change_state): Remove "too fast" checks,
2633 we're going to allow start/stop requests to restart jobs as much as
2634 they like since this is an external request.
2635 (test_handle_event, test_handle_event_finished): No need to remove
2636 a respawn limit with this behaviour.
2637 (test_child_handler): Instead check that the respawn counter is
2638 dealt with by the child handler.
2639
Scott James Remnant67e86ff2008-03-07 18:38:12 +00002640 * TODO: Update, I found a bug with the current model.
2641
Scott James Remnant7b6c16c2008-03-07 15:16:29 +00002642 * init/tests/test_environ.c (test_expand): Check that a string
2643 without an expansion still works ok.
2644
Scott James Remnant46ba8e92008-03-06 20:24:08 +000026452008-03-06 Scott James Remnant <scott@netsplit.com>
2646
2647 * init/event.c (event_operator_collect): Just use strcat functions.
2648
Scott James Remnanta8430552008-03-03 00:28:51 +000026492008-03-03 Scott James Remnant <scott@netsplit.com>
2650
Scott James Remnant7d2c9fb2008-03-03 17:29:13 +00002651 * init/environ.c (environ_valid): New function to check the validity
2652 of an environment variable name, should call before accepting any.
2653 (environ_expand_until): New function to expand variable references
2654 in a string using an environment table; supports a few common
2655 shell-like expressions.
2656 (environ_getn): Change to return the value of the string, not the
2657 entire environment string.
2658 * init/environ.h: Add prototypes.
2659 * init/errors.h: Add errors raised by new functions.
2660 * init/tests/test_environ.c (test_valid, test_expand): Add test
2661 cases for the new functions.
2662 (test_get, test_getn): Change test case to check for the variable
2663 value instead of returning the whole string.
2664
Scott James Remnant2c342d92008-03-03 10:52:29 +00002665 * TODO: Add thoughts on blocking commands.
2666
Scott James Remnant62f2d862008-03-03 02:13:19 +00002667 * TODO: Update.
2668
Scott James Remnant089298d2008-03-03 01:48:34 +00002669 * init/event.h (Event): Remove the refs member; we now never hold
2670 a reference to an event we're blocking since we always copy the
2671 environment out if we want to keep it.
2672 (EventOperator): Events are always blocked while we hold them,
2673 so drop the blocked member.
2674 (EventProgress): The done state is no longer needed, we can free
2675 in finished now.
2676 * init/event.c (event_ref, event_unref): Drop these functions.
2677 (event_new): Don't ininitialise the refs member since it's gone.
2678 (event_poll): Remove the done state since it's directly freed
2679 in event_finished again
2680 (event_finished): No done state, event is freed before return.
2681 (event_operator_new): No blocked member.
2682 (event_operator_copy): Always block the event after copying.
2683 (event_operator_destroy): Simply unblock.
2684 (event_operator_handle): Simply block the event on match.
2685 (event_operator_collect): Always block the copied event
2686 (event_operator_unblock): This function is no longer required, since
2687 it has an identical effect to reset.
2688 (event_operator_reset): Simply unblock the event.
2689 * init/tests/test_event.c (test_new): Drop the check for refs
2690 being initialised to zero.
2691 (test_ref, test_unref, test_operator_collect): Drop test for
2692 functions that have been dropped in the code.
2693 (test_operator_new): Drop the check for blocked being initialised
2694 to FALSE.
2695 (test_block, test_unblock, test_operator_destroy): Drop any references
2696 to the refs member.
2697 (test_operator_destroy): Actually fix the function to test things.
2698 (test_poll): Drop the check for remaining in the done state.
2699 (test_operator_new, test_operator_copy): Drop the checks for blocked.
2700 (test_operator_handle, test_operator_collect, test_opreator_reset):
2701 Drop references to refs and blocked.
2702 * init/job.c (job_unblock, job_handle_event): Drop the call to
2703 event_unref() since the next call was always event_unblock() and
2704 that's the one that we didn't delete.
2705 * init/tests/test_job.c (test_change_state, test_child_handler)
2706 (test_handle_event, test_handle_event_finished): Events don't
2707 have references anymore, so remove calls to reference, unreference
2708 and checks for the reference count - it's all done with blocks now.
2709 (test_new): Remove check that the operator is not blocked for a
2710 new job since there's no such thing now.
2711 (test_handle_event): Operators don't have a blocked member anymore,
2712 if there's an event, it's blocked.
2713
Scott James Remnant00ad0002008-03-03 01:15:39 +00002714 * init/job.c (job_change_state): Don't reference the event we're
2715 blocked on, we'll always know when it's finished.
2716 (job_handle_event_finished): Likewise no reason to unreference it.
2717 * init/tests/test_job.c (test_change_goal, test_child_handler)
2718 (test_handle_event, test_change_state)
2719 (test_handle_event_finished): Remove the expectation that the blocked
2720 event is referenced by the job.
2721 * init/tests/test_event.c (test_poll): Don't reference the event,
2722 since the job would not have.
2723
Scott James Remnant66fe4e22008-03-03 01:07:16 +00002724 * init/job.c (job_emit_event): Use environ_add/set for style
2725 reasons.
2726
Scott James Remnantd719fdc2008-03-03 00:52:52 +00002727 * init/job.c (job_handle_event): Reset the stop_on operator after
2728 processing the event, thus the expression needs to be completely
2729 reevaluated before the job can be stopped again by it. At last,
2730 correct behaviour!
2731 (job_change_state): No reason to reset the stop_on operator when
2732 starting since it's always reset after evaluating to TRUE now;
2733 likewise no reason to reset on re-entering running or waiting,
2734 job_unblock() is sufficient.
2735 (job_failed): No reason to iterate stop_on to set failed, it's
2736 empty - job_unblock() does what we want.
2737 * init/tests/test_job.c (test_handle_event): Check that the operator
2738 is actually reset and the event not referenced when handling from
2739 the event.
2740 (test_change_state, test_child_handler): Don't put anything in stop_on
2741 and thus don't expect anything to come out of it -- event environment
2742 is all done in stop_env and blocking done in blocking.
2743
Scott James Remnanta8430552008-03-03 00:28:51 +00002744 * init/job.c (job_handle_event): Collect the stop events and store
2745 them in the blocking list, unblocking any that were there before
2746 such as the start events.
2747 (job_change_state): Unblock blocking events when returning to running
2748 from pre-stop.
2749 * init/tests/test_job.c (test_handle_event): Make sure the stop
2750 events are collected and replace any previously blocking events.
2751 (test_change_state, test_child_handler): Test that stop events in
2752 the blocking list are kept and unblocked when necessary.
2753
Scott James Remnante4be2c52008-03-02 00:05:47 +000027542008-03-02 Scott James Remnant <scott@netsplit.com>
2755
Scott James Remnant8e402682008-03-02 23:45:31 +00002756 * init/job.c (job_change_state): Shouldn't emit the started event
2757 on pre-stop cancellation, and shouldn't unblock the job because
2758 it's a service.
Scott James Remnanta8430552008-03-03 00:28:51 +00002759
Scott James Remnant56ec5602008-03-02 22:42:21 +00002760 * init/job.c (job_change_state): Throw away the stop environment
2761 when starting and returning to running.
2762 * init/tests/test_job.c (test_change_state): Make sure the stop
2763 environment is actually thrown away.
2764
Scott James Remnant3a06f5c2008-03-02 22:30:17 +00002765 * init/job.c (job_run_process): Append the environment from the
2766 stop events if given the pre-stop process to run; do this before
2767 the special events so they can never be overriden.
2768 * init/tests/test_job.c (test_run_process): Check that the stop event
2769 environment is included for pre-stop and not for other jobs.
2770
Scott James Remnant562a4f12008-03-02 22:20:27 +00002771 * init/job.c (job_handle_event): Remove setting of UPSTART_JOB
2772 and UPSTART_JOB_ID, we set that when we run the process.
2773 * init/tests/test_job.c (test_handle_event): Don't check for
2774 UPSTART_JOB and UPSTART_JOB_ID since we no longer copy it in here.
2775
Scott James Remnant99c6e4a2008-03-02 22:18:14 +00002776 * init/job.c (job_run_process): Copy the environment to pass it to
2777 the job, appending the UPSTART_JOB and UPSTART_JOB_ID variables here;
2778 we never want to be able to match these, etc.
2779 * init/tests/test_job.c (test_run_process): Add tests to make sure
2780 that the environment is actually set in the processes we run.
2781
Scott James Remnant96986832008-03-02 21:52:50 +00002782 * init/job.h (Job): Add stop_env member to store environment from
2783 stop events for the stop script.
2784 * init/job.c (job_new): Initialise stop_env to NULL.
2785 (job_handle_event): Copy environment from the stop_on operator into
2786 the stop_env member.
2787 * init/tests/test_job.c (test_new): Check that stop_env is NULL.
2788 (test_handle_event): Add lots of tests to make sure that the
2789 environment is collected from the events and stored in stop_env
2790 properly, overwriting what was there already if necessary.
2791
Scott James Remnantf1755ad2008-03-02 20:42:00 +00002792 * init/init.supp (job-run-process-args): Add a suppression for the
2793 fact that job_run_process will leak its arguments to a new process
2794 assuming that it will call exec() or exit()
2795
Scott James Remnant5f68a522008-03-02 20:41:19 +00002796 * init/tests/test_job.c (test_child_handler): Remove bogus free tag
2797 of the list, which we don't use in this test (valgrind failure)
2798
Scott James Remnantdd6e9422008-03-02 20:40:45 +00002799 * init/job.h (Job): Remove the start_on member.
2800 * init/job.c (job_new): Don't initialise start_on since it's gone.
2801 (job_change_state): Drop call to unblock the start_on operator since
2802 the events are already unblocked by job_unblock.
2803 (job_failed): Drop setting of start_on events to failed since this
2804 is already done by job_unblock. This results in a slight change in
2805 behaviour, now when a job fails to start - the event or command will
2806 be immediately unblocked since there's no point waiting until it
2807 stops again - it was waiting for it to start.
2808 * init/tests/test_job.c (test_new): Remove start_on checks
2809 (test_change_state, test_child_handler, test_handle_event): Remove
2810 all references to start_on, instead relying on the blocking checks
2811 instead.
2812 * init/tests/test_event.c (test_poll): Remove solitary reference
2813 to job's start_on, this wasn't necessary anyway - we proved that it
2814 was the right event by affecting the job. Revert previous commit
2815 that temporarily increased the number of references, they should be
2816 one again now only the blocking list holds them.
2817
Scott James Remnant37305082008-03-02 20:08:07 +00002818 * init/job.h (job): Add blocking member, a list of events that we're
2819 blocking from finishing.
2820 * init/job.c (job_new): Initialise blocking member to NULL.
2821 (job_handle_event): Collect the list of events from the operator
2822 and store them in the job's blocking list (unblocking any existing
2823 first); if the job is already running, unblock unref and discard.
2824 (job_unblock): New function to deal with unblocking the events we're
2825 holding onto and resetting the blocking list; this will be extended
2826 later to also unblock any command.
2827 (job_change_state): Unblock events in running for services and in
2828 waiting for everything.
2829 (job_failed): Unblock events and mark them as failed.
2830 * init/tests/test_job.c (test_new): Check that it's initialised to NULL
2831 (test_handle_event): Extend the test cases to check the value of the
2832 blocking list, and to make sure that the previous blocking list is
2833 overwritten when necessary.
2834 (test_change_state, test_child_handler): Extend test cases so that
2835 wherever we're had a blocked event in start_on, we also have that in
2836 the blocking list.
2837 * init/tests/test_event.c (test_poll): Temporarily increase the
2838 expected number of references/blockers to the event in the poll
2839 test.
2840
Scott James Remnanteec6b102008-03-02 12:24:22 +00002841 * init/job.h (Job): Add start_env member, this stores the environment
2842 to use when starting the event so it doesn't overwrite the current
2843 environment of a restarting job.
2844 * init/job.c (job_handle_event): Do the heavy lifting of starting a
2845 new job instance here; construct the environment from the built-ins
2846 and configured, append that collected from the start events, locate
2847 or create a new instance, add the job name and id then copy into
2848 the new start_env member before starting the job. At some point
2849 this will probably all become a function since it'll be similar for
2850 the control functions.
2851 (job_change_state): Copy the start_env member into the env member
2852 when in the starting state; thus the job environment remains the same
2853 until restarted.
2854 (job_new): Remove code to initialise the environment, we now do that
2855 when actually starting the instance.
2856 * init/tests/test_job.c (test_handle_event): Add test cases for
2857 starting the job, making sure that the environment is correctly
2858 copied into the right field and also checking what happens if it's
2859 already stopping or running.
2860 (test_change_state): Make sure that start_env is correctly copied
2861 over into env, overwriting what is there if non-NULL or keeping it
2862 if NULL.
2863 (test_new): Remove checks for environment setup, since we don't do
2864 that anymore here; replace with checking for NULL and restore the
2865 alloc fail tests.
2866 * TODO: Update.
2867
Scott James Remnant377f6162008-03-02 02:23:52 +00002868 * init/environ.c (environ_add): Allow it to accept NULL length, since
2869 we can't always keep that around.
2870
Scott James Remnantf83e4cf2008-03-02 01:33:06 +00002871 * init/process.c (process_spawn): Accept the environment list as
2872 a parameter, then finally we can change this function to take a
2873 JobConfig as the first argument.
2874 (process_error_read): Remove the associated error handler.
2875 * init/process.h: Change prototype.
2876 (ProcessErrorType): Remove error enum for environment.
2877 * init/tests/test_process.c (test_spawn): Update calls in test to
2878 just pass in an environment array (direct testing).
2879 * init/job.c (job_run_process): Pass configuration and environment
2880 to process_spawn.
2881
Scott James Remnantaf44bfe2008-03-02 01:22:29 +00002882 * init/process.c (process_spawn): Take the environment directly out
2883 the job structure, rather than recreating it.
2884 (process_environment): Drop function, absorbed elsewhere.
2885 * init/process.h: Remove prototype.
2886 * init/tests/test_process.c (test_spawn): Set the job_id variable
2887 before calling job_new and set config->start_on instead of
2888 job->start_on so that job_new can pick up both.
2889 (test_environment): Remove test cases.
2890
Scott James Remnant01c0ba72008-03-02 01:16:10 +00002891 * init/job.h (Job): finally gains env pointer of its own.
2892 * init/job.c (job_new): Initialise the environment, moving the last
2893 of the code from process_environment -- this is only temporary
2894 though in the interests of refactoring, it'll move out of here again
2895 soon enough.
2896 * init/tests/test_job.c (test_new): Make sure that the environment is
2897 set in a manner which tests the overriding of things by other things;
2898 we have to temporarily comment out the alloc fail stuff though :-(
2899
Scott James Remnant61b11fc2008-03-02 01:16:03 +00002900 * init/event.c (event_operator_collect): Make list the last argument
2901 for consistency with future functions.
2902 * init/event.h: Update prototype.
2903 * init/tests/test_event.c (test_operator_collect): Swap arguments.
2904 * init/process.c (process_environment): Update.
2905
Scott James Remnanta6ce1292008-03-02 00:24:08 +00002906 * init/job.c (job_config_environment): Function to generate an
2907 environment table from a JobConfig, code largely moved from process.c
2908 * init/job.h: Add protoyype.
2909 (JOB_DEFAULT_ENVIRONMENT): List of environment variables to always
2910 copy from the environment (moved from process.h)
2911 * init/tests/test_job.c (test_config_environment): Add test case,
2912 again largely copied from test_process.c
2913 * init/process.c (process_environment): Call job_config_environment
2914 instead of the code moved out.
2915 * init/process.h (PROCESS_ENVIRONMENT): Move to job.h
2916 * TODO: Update.
2917
Scott James Remnante4be2c52008-03-02 00:05:47 +00002918 * TODO: Update.
2919
Scott James Remnantec8ea0e2008-03-01 17:58:15 +000029202008-03-01 Scott James Remnant <scott@netsplit.com>
2921
Scott James Remnant9fd25422008-03-01 23:56:31 +00002922 * init/event.c (event_operator_collect): Create a mega-function to
2923 iterate an EventOperator tree (filtering out those bits that aren't
2924 TRUE) and collect the events, adding them to a linked list, adding
2925 their environment to a table and making a string list for another
2926 environment variable. Fundamentally this function marshals data
2927 out of the Event subsystem into the right format for the Job subsystem.
2928 * init/event.h: Add prototype.
2929 * init/tests/test_event.c (test_operator_collect): Tests for the
2930 collector function; some bits may seem similar to test_process.c
2931 * init/process.c (process_environment): Use event_operator_collect
2932 to gather the environment, instead of its own code (which pretty
2933 much got pasted into event_operator_collect anyway). Force everything
2934 else to allocate matching the caller.
2935 * init/tests/test_process.c (test_spawn, test_environment): Had
2936 forgotten to set the value of the intermediate AND operator to TRUE,
2937 necessary now.
2938
Scott James Remnant8e695502008-03-01 21:34:12 +00002939 * init/process.c (process_environment_add): Move and rename this
2940 function, since it's not really process associated
2941 (process_environment): Change to use environ_add or environ_setf
2942 instead.
2943 * init/process.h: Remove prototype.
2944 * init/environ.c (environ_add): New name/location of
2945 process_environment_add, modified to not take a copy of the string
2946 (environ_set): Wrapper for the above for common dealing with
2947 environment we want to set from a format string.
2948 (environ_get, environ_getn, environ_lookup): Functions to get an
2949 environment variable entry; largely cripped from event.c but
2950 bug-fixed at the same time.
2951 * init/environ.h: Function prototypes.
2952 * init/event.c (event_operator_match): Change to use environ_lookup
2953 * init/tests/test_process.c (test_environment_add): Move the tests.
2954 * init/tests/test_environ.c: Test suite for environment handling
2955 * init/Makefile.am (init_SOURCES): Build environ.c and environ.h
2956 (TESTS): Build environment test suite
2957 (test_environ_SOURCES, test_environ_LDFLAGS, test_environ_LDADD):
2958 Details for environment test suite
2959 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2960 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
2961 Link environ.o to other test suites
2962
Scott James Remnantec8ea0e2008-03-01 17:58:15 +00002963 * init/job.c (job_new): Increment the number of instances.
2964 (job_instance): Simplify the function, it now only returns the
2965 existing instance or NULL. This makes it easier to extend when
2966 we have env-limited instances later on.
2967 (job_handle_event): If job_instance returns NULL, create
2968 a new instance with job_new() and always reset the operator afterwards.
2969 * init/tests/test_job.c (test_new): Check that the instances variable
2970 is incremented when a new job is created.
2971 (test_instance): Change to check that it returns NULL when there is
2972 no active instance, or for multi-instance jobs, instead of creating
2973 a new one itself.
2974 (test_config_replace, test_find_by_pid)
2975 (test_find_by_id, test_change_goal, test_change_state)
2976 (test_next_state, test_run_process, test_kill_process)
2977 (test_child_handler, test_handle_event)
2978 (test_handle_event_finished): Call job_new to create a new instance
2979 from a config, instead of job_instance.
2980
2981 * init/tests/test_conf.c (test_source_reload_job_dir)
2982 (test_file_destroy): Call job_new to create a new instance from a
2983 config, instead of job_instance.
2984 * init/tests/test_event.c (test_poll): Call job_new to create a new
2985 instance from a config, instead of job_instance.
2986 * init/tests/test_process.c (test_spawn, test_environment): Call
2987 job_new to create a new instance from a config, instead of job_instance
2988
Scott James Remnant9f468de2008-02-29 16:17:17 +000029892008-02-29 Scott James Remnant <scott@netsplit.com>
2990
Scott James Remnant680d2fd2008-02-29 17:41:38 +00002991 * configure.ac: Compare the evaluated $sbindir against the common
2992 things we put in PATH, if it doesn't match, define EXTRA_PATH to
2993 contain it.
2994 * init/paths.h: Append EXTRA_PATH to PATH if defined.
2995
Scott James Remnant9f468de2008-02-29 16:17:17 +00002996 * init/Makefile.am (AM_CPPFLAGS): Replace TELINIT definition with
2997 SBINDIR, pointing at the common directory.
2998 * compat/sysv/Makefile.am (AM_CPPFLAGS): Replace SHUTDOWN definition
2999 with SBINDIR, pointing at the common directory.
3000 * init/paths.h (TELINIT): Redefine to be SBINDIR with "/telinit"
3001 on the end; define SBINDIR if necessary.
3002 * compat/sysv/reboot.c (SHUTDOWN): Redefine to be SBINDIR with
3003 "/shutdown" on the end; define SBINDIR if necessary.
3004
Scott James Remnantc3c78b02008-02-22 14:55:12 +000030052008-02-22 Scott James Remnant <scott@netsplit.com>
3006
Scott James Remnant72da2fe2008-02-22 20:10:53 +00003007 * init/event.c (event_operator_match): Rewrite to match both
3008 positionally and by name.
3009 * init/tests/test_event.c (test_operator_match): Update tests to
3010 check the new behaviour works.
3011
Scott James Remnantff48a242008-02-22 15:46:30 +00003012 * init/parse_job.c (parse_on_operand): Add arguments to env list
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00003013 rather than args; sanity check afterwards to ensure that positional
3014 doesn't follow name-based -- when parsing the job is the right place
3015 to catch this.
Scott James Remnantff48a242008-02-22 15:46:30 +00003016 * init/tests/test_parse_job.c (test_stanza_start)
3017 (test_stanza_stop): Change args to env when checking operators.
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00003018 Check that arguments may be quoted in manners that we expect to be
3019 sane. Check that positional arguments cannot follow name-based ones.
3020 * init/errors.h: Add new error.
3021 * init/conf.c (conf_reload_path): Treat expected variable as a
3022 permanent error.
Scott James Remnantff48a242008-02-22 15:46:30 +00003023
Scott James Remnantd816fbd2008-02-22 15:13:07 +00003024 * init/tests/test_process.c (test_spawn, test_environment):
3025 Update event_new() calls to remove extra argument.
3026
Scott James Remnant36eea462008-02-22 15:11:05 +00003027 * init/main.c (main, cad_handler, kbd_handler, pwr_handler):
3028 Update event_new() calls to remove extra argument.
3029
Scott James Remnantc398d782008-02-22 15:07:54 +00003030 * init/job.c (job_change_state): Update event_new () call.
3031 (job_emit_event): Update to put failure information in environment.
3032 * init/tests/test_job.c (test_new, test_instance)
3033 (test_child_handler, test_handle_event)
3034 (test_handle_event_finished): Remove extra argument to event_new,
3035 rename args to env in operator where necessary.
3036 (test_change_state): Update to check emitted event by full environment.
3037
Scott James Remnant53cb0012008-02-22 14:55:53 +00003038 * init/event.h (Event): Remove args member.
3039 (EventOperator): Rename args member to env.
3040 Update prototypes to match.
3041 * init/event.c (event_new): Remove args member.
3042 (event_finished): Remove copying of args member to failed event.
3043 (event_operator_new): Rename args member to env.
3044 (event_operator_copy): Rename args copying to env.
3045 (event_operator_match): ??
3046 * init/tests/test_event.c (test_new): Update test to remove args.
3047 (test_operator_new): Update test to rename args to env.
3048 (test_operator_copy): Update test to rename args to env.
3049 (test_operator_match): ???
3050
Scott James Remnantc3c78b02008-02-22 14:55:12 +00003051 * TODO: Update with job atomicity notes.
3052
Scott James Remnantc488ddb2008-02-20 16:35:24 +000030532008-02-20 Scott James Remnant <scott@netsplit.com>
3054
Scott James Remnant37fb28a2008-02-20 16:38:01 +00003055 * init/job.c: Switch around job_find_by_pid and job_find_by_id
3056 * init/job.h: Likewise.
3057
Scott James Remnantc488ddb2008-02-20 16:35:24 +00003058 * init/job.h: Update prototypes to match variable names in the
3059 code.
3060
Scott James Remnant676c9052008-02-17 16:08:40 +000030612008-02-17 Scott James Remnant <scott@netsplit.com>
3062
Scott James Remnant742d4662008-02-17 18:29:26 +00003063 * init/process.c (process_kill): Change to accept a JobConfig rather
3064 than a Job, since in theory this should only ever need that in a
3065 future where we can specify a kill signal (right now it's not used
3066 for anything!)
3067 * init/process.h: Update prototype.
3068 * init/tests/test_process.c (test_kill): Update test cases.
3069 * init/job.c (job_kill_process, job_kill_timer): Pass in JobConfig
3070 instead of Job.
3071
Scott James Remnantd37dd062008-02-17 18:25:51 +00003072 * init/process.c (process_spawn): Accept trace as an argument instead
3073 of using a random piece of job state to determine whether to trace
3074 or not.
3075 * init/process.h: Update prototype.
3076 * init/tests/test_process.c (test_spawn): Update tests to pass in
3077 via argument whether to trace the job or not.
3078 * init/job.c (job_run_process): Pass in the trace variable rather
3079 than relying on it working it out for itself; this means we don't
3080 need to set the state until after, therefore don't need to reset it.
3081
Scott James Remnant6b1c7ee2008-02-17 18:00:33 +00003082 * AUTHORS, logd/jobs.d/logd.in: Update e-mail addresses.
3083
Scott James Remnant676c9052008-02-17 16:08:40 +00003084 * README: Update kernel recommendation to 2.6.24, since that's
3085 the oldest version that the test suite will complete under.
3086
Scott James Remnanta3239f62008-01-17 03:34:27 +000030872008-01-17 Scott James Remnant <scott@netsplit.com>
3088
Scott James Remnant85a96502008-01-17 03:38:44 +00003089 * TODO: Update.
3090
Scott James Remnantdc4162b2008-01-17 03:37:02 +00003091 * init/job.c (job_run_process): Don't append the list of event
3092 names, they can be found in $UPSTART_EVENTS now. This is better
3093 since it's consistent for exec and script.
3094 * init/tests/test_job.c (test_run_process): Drop test case.
3095
Scott James Remnanta3239f62008-01-17 03:34:27 +00003096 * init/process.c (process_environment): Function to build an
3097 environment table for a job containing built-in variables, those
3098 from the configuration, events and finally the upstart job ones.
3099 (process_environment_add): Helper function for the above that
3100 handles adding a variable to the array; dealing with fetching the
3101 value from init's environment if necessary.
3102 (process_setup_environment): This function now gets dropped in
3103 favour of the new ones.
3104 (process_spawn): Call the new process_environment() function and set
3105 the environ variable directly.
3106 * init/process.h (PROCESS_ENVIRONMENT): Define built-in environment
3107 variables that are always copied from our own environment.
3108 Add prototypes.
3109 * init/tests/test_process.c (test_environment): Check that the
3110 environment is built correctly and that each bit overrides the
3111 right other bit.
3112 (test_environment_add): Check that the array is built correctly.
3113 (test_spawn): Adjust order and values of expected environment
3114 to match what's now set.
3115
Scott James Remnant5c87e6e2008-01-16 00:27:22 +000031162008-01-16 Scott James Remnant <scott@netsplit.com>
3117
Scott James Remnantb150df62008-01-16 03:14:16 +00003118 * init/job.c (job_failed): Separate the logic that marks the job
3119 and its associated events as failed into its own function, since
3120 it's a large enough amount of code that we were otherwise duplicating
3121 everywhere else (and in a few places, failing to mark the events as
3122 failed as well).
3123 (job_change_state, job_process_terminated): Call job_failed instead
3124 of doing it ourselves.
3125 (job_emit_event): De-nest the logic and fix so that we don't add
3126 environment to the failed respawn event.
3127 * init/tests/test_job.c (test_change_state): Add checks on whether
3128 the event was marked as failed or not.
3129
Scott James Remnant340083b2008-01-16 02:06:51 +00003130 * TODO: Update.
3131
Scott James Remnant30bc02b2008-01-16 01:49:20 +00003132 * configure.ac (AC_COPYRIGHT): Update copyright to 2008.
3133
Scott James Remnant4ff4a7d2008-01-16 01:47:20 +00003134 * TODO: Update.
3135
Scott James Remnant75e801a2008-01-16 00:44:17 +00003136 * init/tests/test_job.c (test_child_handler): Don't run the signal
3137 and ptrace tests while in valgrind, sometimes signals (specifically
3138 SIGCONT after SIGSTOP) don't behave right and we kinda need that
3139 reliability.
3140
Scott James Remnant798284f2008-01-16 00:31:23 +00003141 * init/tests/test_job.c (test_child_handler): After adding extra
3142 processes, make sure we clean up again so each test is roughly
3143 independant. Fix the final test case to not rely on previous
3144 setup and work on its own.
3145
Scott James Remnant0cfd4e72008-01-16 00:30:26 +00003146 * init/tests/test_job.c (test_change_state): Remove useless check
3147 of job->start_on from a killed/post-stop check (noticed while
3148 writing the other).
3149
Scott James Remnant5c87e6e2008-01-16 00:27:22 +00003150 * init/job.c (job_change_state): Check the return value of
3151 job_run_process() and if particular processes fail, change the
3152 goal to stop and push the job into the next state; setting the job
3153 as failed along the way.
3154 (job_emit_event): If the exit_status is -1 then it means the job
3155 failed to spawn, so don't place EXIT_SIGNAL or EXIT_STATUS in the
3156 event environment.
3157 * init/tests/test_job.c (test_change_state): Check what happens when
3158 each process type fails, make sure that the job is stopped for
3159 pre-start, spawned and post-stop and the failure is ignored for
3160 post-start and pre-stop.
3161
Scott James Remnantfa733382008-01-15 15:33:27 +000031622008-01-15 Scott James Remnant <scott@netsplit.com>
3163
Scott James Remnant9f62a8e2008-01-15 19:22:36 +00003164 * init/main.c: Selectively compile out certain pieces when make is
3165 run with CPPFLAGS=-DDEBUG, giving us a build that'll happily run from
3166 a user terminal.
3167 * init/event.h: Change the startup event to "debug" when built like
3168 that, so we don't accidentally do bad things.
3169
Scott James Remnantb53527f2008-01-15 19:15:29 +00003170 * init/job.c (job_run_process): Catch PROCESS_ERROR and abort the
3171 attempt to run the process, returning a non-temporary error condition.
3172 * init/tests/test_job.c (test_run_process): Add test case for
3173 attempting to spawn a file that doesn't exist.
3174
Scott James Remnant85a2a0e2008-01-15 19:09:23 +00003175 * init/process.c (process_error_read): Avoid the word process, since
3176 it's likely included in the higher error message.
3177
Scott James Remnantfaa898c2008-01-15 19:05:04 +00003178 * init/process.c (process_spawn): Call process_error_abort() on any
3179 error condition.
3180 * init/tests/test_process.c (test_spawn): Add a test case for failing
3181 to spawn a process and receiving ProcessError correctly; fix other
3182 cases to ensure they return a pid.
3183
Scott James Remnantc7211972008-01-15 18:55:59 +00003184 * init/errors.h: Add PROCESS_ERROR to the enum, but not to the string
3185 list since there's no specific defined string for this one.
3186 * init/process.h (ProcessError): Structure that builds on NihError
3187 to add additional information for a process error.
3188 (ProcessErrorType): enum of different process error types.
3189 * init/process.c (process_spawn): After forking read the error in
3190 the parent, returning if we raise one.
3191 Ensure we close the pipe if the fork fails.
3192 Re-order so that we set the environment, umask and priority after the
3193 resource limits (which should apply to them).
3194 (process_error_abort): New function to immediately abort with an
3195 error, writing it on the pipe first.
3196 (process_error_read): Counterpart function to read the error from
3197 the pipe and raise it, with appropriate error messages.
3198
Scott James Remnant66738782008-01-15 17:01:19 +00003199 * init/process.c (process_spawn): Create a pipe to use for
3200 communication with the child, ensuring its closed before the parent
3201 returns and ensuring that the writing end is close-on-exec in the
3202 child.
3203
Scott James Remnant2e23f6b2008-01-15 16:38:28 +00003204 * init/job.c (job_run_process): Change to return a value indicating
3205 whether there's been a non-temporary error (always returns zero so
3206 far).
3207 * init/job.h: Update prototype.
3208 * init/tests/test_job.c (test_run_process): Check that job_run_process
3209 always returns zero.
3210
Scott James Remnant5dee92e2008-01-15 16:30:23 +00003211 * init/job.c (job_change_goal): Document in which states this function
3212 has unexpected side-effects such as freeing the job, since we do
3213 attempt to call it from within job_change_state().
3214
Scott James Remnantfa733382008-01-15 15:33:27 +00003215 * init/process.c (process_setup_limits): Integrate this function back
3216 into process_spawn() since there's no reason for it to be separate.
3217 (process_setup_console): Alter this function so it closes the original
3218 console descriptors, opens the new ones and can reset them to if
3219 required -- in particular, this no longer takes a Job parameter.
3220 (process_spawn): Use the new process_setup_console function and
3221 integrate code from process_setup_limits().
3222 * init/process.h: Update function prototype.
3223 * init/main.c (main): Use the new process_setup_console() argument
3224 form. Move syslog opening to the end of the function, rather than
3225 where it is now where it could be at risk of being closed again
3226 immediately. Change the root directory in case we're run in some
3227 weird way.
3228 (reset_console): Remove function since the code is now in
3229 process_setup_console()
3230 * init/enum.h (console_type): Remove CONSOLE_LOGGED and make the
3231 CONSOLE_NONE constant be zero.
3232 * init/parse_job.c (stanza_console): Drop parsing of "logged"
3233 * init/tests/test_parse_job.c (test_stanza_console): Drop testing
3234 of "logged" parsing.
3235
Scott James Remnantde581cc2008-01-14 21:35:53 +000032362008-01-14 Scott James Remnant <scott@netsplit.com>
3237
3238 * HACKING: Correct bzr URLs to trunk.
3239
Scott James Remnant20d3a1c2007-12-15 14:52:33 +000032402007-12-15 Scott James Remnant <scott@netsplit.com>
3241
Scott James Remnantcc6810d2007-12-15 15:39:02 +00003242 * init/process.c (process_spawn): Fix some documentation strings.
3243
Scott James Remnant206c97a2007-12-15 14:55:51 +00003244 * init/process.c (process_kill): Move to beneath the process setup
3245 functions.
3246 * init/process.h: Adjust ordering here too.
3247
Scott James Remnant20d3a1c2007-12-15 14:52:33 +00003248 * init/process.c (process_spawn): Group console closing and setup
3249 together, becoming the session and process group leader first.
3250
Scott James Remnant6f1e41f2007-12-07 00:32:21 +000032512007-12-07 Scott James Remnant <scott@netsplit.com>
3252
Scott James Remnante4178252007-12-07 13:35:45 +00003253 * init/process.c (process_spawn): Drop the debug message since
3254 it's always repeated by the caller.
3255 * init/job.c (job_run_process): Drop the word Active which is a
3256 hold-over from when we had different process states.
3257
Scott James Remnant64c8c772007-12-07 10:20:13 +00003258 * TODO: Update.
3259
Scott James Remnant0f688672007-12-07 10:17:25 +00003260 * init/job.c (job_child_handler): Add code to handle the trapped
3261 signal and ptrace event cases, distinguishing between a trapped
3262 signal and process stopped after exec or fork using our trace
3263 state member. Call out to other functions to do the work.
3264 (job_process_trace_new): Called after the first exec to set the
3265 ptrace options, update the trace state and allow the process to
3266 continue without delivering the signal. Also called after the
3267 fork to do the same.
3268 (job_process_trace_new_child): Called after a fork for the new child;
3269 increments the fork counter and if it goes over the number we want,
3270 detaches from the process and allows it to move to running. Otherwise
3271 calls job_process_trace_new() instead.
3272 (job_process_trace_signal): Called when a signal is trapped, simply
3273 delivers it to the process unchanged.
3274 (job_process_trace_fork): Called before a fork for the parent, obtains
3275 the new child process id from the event, updating the job structure,
3276 and detaches from the parent which we're no longer interested in.
3277 (job_process_trace_exec): Called after an exec other than the first,
3278 assumed to be the end of forking so detaches from the process and
3279 allows it to move to running.
3280 * init/tests/test_job.c (test_child_handler): Add test cases for
3281 the various ptrace states.
3282
Scott James Remnante3c10ae2007-12-07 09:18:38 +00003283 * init/job.c (job_run_process): Set process trace state to new for
3284 the main job if we need to wait for the daemon or fork; otherwise
3285 reset the state.
3286 * init/tests/test_job.c (test_run_process): Add test cases to make
3287 sure the trace state is set right and picked up by process_spawn.
3288
Scott James Remnant3525ffd2007-12-07 09:04:10 +00003289 * init/process.c (process_spawn): Set a ptrace before execing the
3290 binary if the trace state is TRACE_NEW, set by the caller.
3291 * init/tests/test_process.c (test_spawn): Make sure that a job is
3292 ptraced if set up properly.
3293 (child): Add a simple case that just exits immediately for testing
3294 the above.
3295
Scott James Remnantd431eea2007-12-07 09:01:58 +00003296 * init/job.h (Job): Add new trace_forks member to keep count of how
3297 many forks we've seen and trace_state member to track whether we've
3298 just started the trace or just forked.
3299 * init/enum.h (TraceState): Add enumeration to keep track of ptrace
3300 state to differentiate between a signal and an event.
3301 * init/job.c (job_new): Initialise new members.
3302 * init/tests/test_job.c (test_new): Check new members are initialised
3303
Scott James Remnant319c7f92007-12-07 08:57:48 +00003304 * init/enum.h (JobWaitType): Add new daemon and fork wait types.
3305 * init/parse_job.c (stanza_wait): Add parsing for daemon and fork.
3306 * init/tests/test_parse_job.c (test_stanza_wait): Add tests too.
3307
Scott James Remnant58d23f52007-12-07 00:42:50 +00003308 * init/job.h (JobConfig): Remove daemon and pid members.
3309 (Job): Remove pid_timer member.
3310 (JOB_DEFAULT_PID_TIMEOUT): Remove this constant.
3311 * init/job.c (job_config_new, job_new): Remove initialisation of
3312 removed members.
3313 (job_change_state): Stay in spawned unless we're not waiting for
3314 anything -- remove the daemon flag.
3315 * init/tests/test_job.c (test_config_new, test_new): Remove checks
3316 for initialisation of removed members.
3317 (test_change_state): Remove daemon flag stays in spawned check since
3318 the daemon flag has gone.
3319 * init/parse_job.c (stanza_daemon, stanza_pid): Remove these
3320 functions since they have no members to set.
3321 * init/tests/test_parse_job.c (test_stanza_daemon, test_stanza_pid):
3322 Remove the tests for the now non-existant functions.
3323
Scott James Remnant6f1e41f2007-12-07 00:32:21 +00003324 * init/process.c (process_spawn): raise the system error before
3325 calling another syscall, in case we overwrite errno.
3326
Scott James Remnant5fdadda2007-12-06 11:09:00 +000033272007-12-06 Scott James Remnant <scott@netsplit.com>
3328
Scott James Remnant5ebc6c62007-12-06 16:01:13 +00003329 * init/job.c (job_child_handler): Implement a combined child event
3330 handler to replace the multiple separate ones. This handler deals
3331 with adding appropriate messages to the log and decoding any state
3332 information before calling specific action functions.
3333 (job_child_reaper): Remove, moving the bulk of the code into new
3334 (job_process_terminated): function that handles it cleanly.
3335 (job_child_minder): Remove, moving the bulk of the code into new
3336 (job_process_stopped): function that's a lot cleaner.
3337 * init/job.h: Update prototypes.
3338 * init/tests/test_job.c (test_child_reaper, test_child_minder):
3339 Combine unit tests from both functions into single new
3340 (test_child_handler): function.
3341 * init/main.c (main): Call the combined function on child events
3342 instead of separate ones.
3343
Scott James Remnant5fdadda2007-12-06 11:09:00 +00003344 * init/job.c (job_child_minder): Add informational message and
3345 improve style and documentation.
3346
Scott James Remnantab882c22007-12-02 18:17:09 +000033472007-12-02 Scott James Remnant <scott@netsplit.com>
3348
3349 * init/enum.h (JobWaitType): Introduce a new enum that specifies
3350 how to transition the job from spawned to running; either we don't
3351 wait, or we wait for it to emit the stopped signal.
3352 * init/job.h (JobConfig): Add the wait_for member.
3353 Add protoype for job_child_minder.
3354 * init/job.c (job_config_new): Initialise to JOB_WAIT_NONE.
3355 (job_child_minder): New function to catch when a process is stopped
3356 by a signal, and move it to the next state when it does so.
3357 * init/tests/test_job.c (test_config_new): Check the initialisation
3358 of wait_for to JOB_WAIT_NONE.
3359 (test_child_minder): Tests for the new function.
3360 (test_change_state): Copy the daemon test case to refer to waiter.
3361 * init/main.c (main): Call job_child_minder whenever the job is
3362 stopped by a signal
3363 * init/parse_job.c (stanza_wait): Parse a new "wait" stanza that
3364 specifies what to wait for before leaving the spawned state.
3365 * init/tests/test_parse_job.c (test_stanza_wait): Check the new
3366 stanza.
3367
Scott James Remnant4bef98a2007-11-30 01:28:28 +000033682007-11-29 Scott James Remnant <scott@netsplit.com>
3369
3370 * init/tests/test_job.c (test_change_state): Add a few sets to NULL
3371 so gcc is happy.
3372
Scott James Remnant0eade492007-11-15 05:48:07 +000033732007-11-15 Scott James Remnant <scott@netsplit.com>
3374
3375 * init/job.c (job_child_reaper): Update argument names and types
3376 to match new NihChildHandler pattern; switch on event instead,
3377 which can now have three values not two (it always could, this was
3378 a bug) to output warning and assume that status is always non-zero
3379 if killed so no need to check that separately.
3380 * init/job.h: Update prototype.
3381 * init/tests/test_job.c (test_child_reaper): Update calls to
3382 job_child_reaper to pass an NihChildEvents member instead of FALSE
3383 or TRUE for killed.
3384 * init/main.c: Adjust call to nih_child_add_watch to indicate which
3385 events we want to pass to the reaper; we don't use NIH_CHILD_ALL
3386 since we're going to add ptrace stuff to a different function.
3387
Scott James Remnant5c408432007-11-07 21:42:25 -050033882007-11-07 Scott James Remnant <scott@netsplit.com>
3389
3390 * init/main.c (main): Tidy up.
3391
Scott James Remnantbc9b6712007-11-04 01:49:04 -040033922007-11-04 Scott James Remnant <scott@netsplit.com>
3393
3394 Complete the simplification of job config; rather than try and
3395 precompute job replacements, keeping them all in the same hash table
3396 and chaining them together, we just work it out when it's actually
3397 necessary based on what's in the conf_sources list.
3398
3399 * init/job.h (JobConfig): Remove the replacement and replacement_for
3400 members and put a deleted member in instead.
3401 * init/job.c (job_config_new): Initialise deleted to FALSE; don't
3402 replace the job into the hash table, since we only want the current
3403 one in there now.
3404 (job_config_find_by_name): Now that there is only ever one job
3405 config in the hash table, we don't need any special function and
3406 can just use nih_hash_lookup directly, so drop this function.
3407 (job_config_should_replace): Rename to job_config_replace
3408 (job_config_replace): Rework, it now checks to see whether there
3409 are instances, and if not removes the job from the hash table
3410 before selecting a new one (which might be the same job).
3411 * init/tests/test_job.c (test_config_new): Update test to check
3412 deleted starts off as FALSE and that the job isn't in the hash.
3413 (test_config_find_by_name): Drop.
3414 (test_config_should_replace): Rename and rewrite to test replacement
3415 actually works as we expect.
3416 (test_change_state): Update tests for entering the waiting mode and
3417 replacing jobs.
3418 (test_find_by_pid, test_find_by_id, test_handle_event)
3419 (test_handle_event_finished): Add jobs to the hash table, otherwise
3420 we can't find them
3421 (test_child_reaper): Add job to the hash table, and also create a
3422 source for it since we end up with it in the waiting state so need
3423 to be able to keep it.
3424 * init/Makefile.am (test_process_LDADD, test_job_LDADD)
3425 (test_event_LDADD): Need the full .o file list now.
3426 * init/conf.c (conf_file_destroy): Rewrite to mark the job deleted,
3427 call job_config_replace if it's the current job and free it if
3428 it isn't the current job either before or after that call.
3429 (conf_reload_path): Handle job replacement here; look up the
3430 old job in the hash table, if it exists attempt a replacement
3431 otherwise add the new job to the hash table.
3432 * init/tests/test_conf.c (test_source_reload_job_dir)
3433 (test_source_reload_conf_dir, test_source_reload_file): Update
3434 tests to check job->deleted and use nih_hash_lookup to see whether
3435 it's the current job.
3436 (test_file_destroy): Write tests to check the common cases, we don't
3437 need to worry about the intermediate now since they can't happen.
3438 * init/parse_job.c (parse_job): Massively simplify, this only creates
3439 the config and parses it now.
3440 * init/tests/test_parse_job.c (test_parse_job): Remove the replacement
3441 checks.
3442 * init/tests/test_event.c (test_poll): Add configs to the hash
3443 table so they can be found.
3444 * TODO: Update.
3445
Scott James Remnant9fa1ce82007-11-03 02:06:54 -040034462007-11-03 Scott James Remnant <scott@netsplit.com>
3447
3448 * init/conf.h (ConfSource): Remove priority, we'll place these
3449 in a linked list and use that order instead.
3450 (ConfSourcePriority): Drop accordingly.
3451 (ConfItem): Drop this structure; permitting jobs and states to be
3452 defined inside larger conf files made things complicated for no
3453 benefit; move the item union into
3454 (ConfFile): here, instead of the items list.
3455 (ConfItemType): Drop accordingly.
3456 * init/conf.c (conf_init): Store sources in a linked list, instead
3457 of a hash table; no idea why it ever was.
3458 (conf_source_new): Drop priority argument and add to list not hash.
3459 (conf_file_new): Set data to NULL instead of initialising items,
3460 set destructor to conf_file_destroy.
3461 (conf_item_destroy): Rename to conf_file_destroy
3462 (conf_file_destroy): and adjust to refer to ConfItem instead,
3463 getting the item type through the source.
3464 (conf_item_new): Drop.
3465 (conf_reload): Iterate as linked list not hash table.
3466 (conf_reload_path): Simplify handling of old files and items a
3467 little, just look it up and always free if it exists before parsing
3468 the new file.
3469 (conf_file_get): No longer any need for this function.
3470 * init/tests/test_conf.c (test_file_get, test_item_new): Drop
3471 test functions for those that have been removed.
3472 (test_item_destroy): Rename to test_file_destroy.
3473 (test_source_new): Don't pass or check priority, or hash lookup.
3474 (test_file_new): Check data is set correctly.
3475 (test_source_reload_job_dir, test_source_reload_conf_dir)
3476 (test_source_reload_file): Update tests accordingly.
3477 * init/parse_conf.c (stanza_job): Drop the job stanza, jobs
3478 may only be defined in dedicated directories.
3479 * init/tests/test_parse_conf.c (test_parse_conf): Simply check to only
3480 make sure the file is parsed.
3481 (test_stanza_job): Drop function.
3482 * init/main.c: Update calls to conf_source_new.
3483 * init/init.supp: Update intermediate function in suppression.
3484
Scott James Remnantb4169fa2007-10-26 13:54:41 -040034852007-10-26 Scott James Remnant <scott@netsplit.com>
3486
3487 * init/process.c (process_spawn): Mask out all signals across the
3488 fork() rather than just SIGCHLD; reset the signal handlers to default
3489 before unmasking again. The original rationale was we needed to
3490 avoid SIGCHLD occurring before we'd stashed the pid, but that's no
3491 longer a problem; the new rationale is that we want to avoid the
3492 signal handlers running in the newly forked child.
3493
Scott James Remnantd29da6f2007-10-20 00:08:52 +010034942007-10-20 Scott James Remnant <scott@netsplit.com>
3495
Scott James Remnant333ad2d2007-10-20 15:30:29 +01003496 * init/job.c (job_init): The job's name is the first item in the
3497 structure again, so we can use nih_hash_string_key.
3498 (job_config_name): Drop this function, then.
3499
Scott James Remnanteda29582007-10-20 14:44:24 +01003500 * init/conf.h (ConfSourcePriority): Add a priority enum
3501 (ConfSource): Add priority member.
3502 * init/conf.c (conf_source_new): Take priority as an argument and
3503 set it in the structure.
3504 * init/tests/test_conf.c (test_source_new): Make sure priority
3505 is set from the argument.
3506 (test_file_new, test_file_get, test_item_new)
3507 (test_source_reload_job_dir, test_source_reload_conf_dir)
3508 (test_source_reload_file, test_source_reload, test_item_destroy):
3509 Pass in a priority when creating a ConfSource.
3510 * init/tests/test_parse_conf.c (test_parse_conf): Likewise.
3511 * init/main.c (main): Set relative priorities for the configuration
3512 directories.
3513
Scott James Remnant388621b2007-10-20 14:29:40 +01003514 * init/conf.h (conf_file, conf_item): Add source and file members
3515 respectively that point to the parent structure.
3516 * init/conf.c (conf_file_new, conf_item_new): Set the members.
3517 * init/tests/test_conf.c (test_file_new, test_file_get)
3518 (test_item_new): Make sure the new members are set properly.
3519
Scott James Remnant87145d62007-10-20 14:02:59 +01003520 * util/Makefile.am (install-data-hook, install-exec-hook): Apply
3521 transform to source and destination of both manpage and program
3522 symlinks.
3523 * compat/sysv/Makefile.am (install-data-hook, install-exec-hook):
3524 Likewise for the compatibility symlinks.
3525
Scott James Remnant9f093752007-10-20 02:16:39 +01003526 * TODO: Update.
3527
Scott James Remnant1518f6c2007-10-20 02:14:29 +01003528 * init/tests/test_process.c (test_spawn): Make the event a child
3529 of the operator so it doesn't get freed first.
3530
Scott James Remnant509f7912007-10-20 02:06:23 +01003531 * init/job.c (job_instance): Increment an instances counter each
3532 time we spawn an instance.
3533 (job_change_state): Decrement the instances counter again.
3534 (job_detect_stalled): Drop the main loop function, since we perform
3535 active detection of stall now.
3536 * init/job.h: Update header.
3537 * init/tests/test_job.c (test_change_state): Check that we get the
3538 stalled event for the last instance.
3539 (test_detect_stalled): Drop the test.
3540 * init/main.c: Remove job_detect_stalled from the main loop.
3541
Scott James Remnant0af43242007-10-20 01:16:04 +01003542 * init/event.c (event_operator_destroy): Destructor for an
3543 EventOperator that unblocks and unreferences the event first.
3544 (event_operator_new): Set the operator.
3545 (event_operator_copy): Remove error handling since it's unnecessary
3546 with the destructor in place.
3547 * init/event.h: Add prototype.
3548 * init/tests/test_event.c (test_operator_destroy): Make sure it
3549 works properly.
3550 (test_operator_copy): Don't unblock or unref events before freeing
3551 them, since that's now taken care of when it's referenced.
3552 * init/job.c (job_new): Remove unnecessary error handling.
3553 * init/tests/test_job.c (test_run_process): Reference the event
3554 when setting it, otherwise we'll assert when we try to free it.
3555 * TODO: Update.
3556
Scott James Remnant2be7d582007-10-20 00:43:19 +01003557 * init/job.c (job_new): Drop the parent argument for consistency.
3558 (job_instance): Update call to job_new.
3559 * init/job.h: Update prototype.
3560 * init/tests/test_job.c (test_new): Adjust call, check the parent
3561 and make sure that start_on and stop_on are copied over properly.
3562 * TODO: Update.
3563
Scott James Remnante548bc72007-10-20 00:29:39 +01003564 * init/conf.c (conf_file_get): Split out the allocation code from here
3565 (conf_file_new): into this new function.
3566 * init/conf.h: Add prototype.
3567 * init/tests/test_conf.c (test_file_new): New tests.
3568 * TODO: Update.
3569
Scott James Remnantd29da6f2007-10-20 00:08:52 +01003570 * init/job.c (job_change_state): Hardcode the next state when we
3571 catch a runaway job to be JOB_WAITING.
3572 (job_next_state): Change next state for JOB_STARTING when goal is
3573 JOB_STOP to be JOB_STOPPING for consistency with the others; otherwise
3574 if our goal is stopped during our starting event, we'll never emit
3575 a stopping event to match it.
3576 * init/tests/test_job.c (test_next_state): Update test case.
3577 * doc/states.dot: Adjust the state transitions.
3578 * doc/states.png: Regenerate.
3579 * TODO: Update.
3580
Scott James Remnant493f5cd2007-10-19 22:49:09 +010035812007-10-19 Scott James Remnant <scott@netsplit.com>
3582
3583 Dealing with instances has always been tricky since they're copies
3584 that exist in the hash table; this patch changes that so the job's
3585 configuration is separated from its state. The only difference
3586 between instance and non-instance jobs now is that non-instance
3587 jobs only ever have one entry in their instances list.
3588
3589 * init/job.h (Job): Separate out the members that come from the
3590 configuration into a new JobConfig structure which can be shared
3591 amongst all of the instances; this means we can drop instance_of.
3592 (JobConfig): Add instances list.
3593 (JobProcess): Remove pid member, replaced by pid list in Job.
3594 Update prototypes of functions to match.
3595 * init/job.c (job_new): Split off initialisation of configuration
3596 pieces into new job_config_new function leaving the state here;
3597 copy the start_on and stop_on members from JobConfig
3598 (job_copy): Drop this function, we don't need to copy jobs now.
3599 (job_name): Rename to job_config_name.
3600 (job_init): Set key function to job_config_name.
3601 (job_process_new): Drop initialisation of pid.
3602 (job_process_copy): Drop this function entirely, we don't need it.
3603 (job_find_by_name): Rename to job_config_find_by_name; massively
3604 simplify now we won't find instances or deleted jobs in the list.
3605 (job_should_replace): Rename to job_config_should_replace; simplify
3606 now that we can do a simple check to see whether a job exists or not
3607 (job_find_by_pid, job_find_by_id): Loop through the instances after
3608 looping through the hash table.
3609 (job_instance): Simplify, now all it needs to do is call job_new()
3610 if there isn't anything in the instances list, or it's multi-instance.
3611 (job_change_goal): Document that job should not be used on return.
3612 No need to check for instance jobs anymore. Place the job id in
3613 the output.
3614 (job_change_state): Document that job should not be used on return.
3615 Place the job id in the output. Check for information in the job's
3616 config. Merge the waiting and deleted states, so that a job instance
3617 is automatically deleted when it finishes.
3618 (job_next_state): Assert that we never call job_next_state when
3619 in JOB_WAITING since there's no possible next state. Check config
3620 for whether a main process exists.
3621 (job_emit_event): Obtain config-replaced pieces from the job's config
3622 (job_run_process): Obtain process information from the job's config
3623 but store the pid in the Job. Put job id in the output.
3624 (job_kill_process, job_kill_timer): We don't need to obtain the
3625 JobProcess just the pid from the job. Put job id in the output.
3626 (job_child_reaper): Put job id in the output. Check job config.
3627 (job_handle_event): Iterate job instances and process their stop_on
3628 operators, but process the start_on from the job configs.
3629 (job_handle_event_finished): Loop through the instances too.
3630 (job_detect_stalled): Check start_on from the config and just
3631 check whether there are any instances in the list.
3632 (job_free_deleted): No deleted state, so drop this function.
3633 * init/tests/test_job.c (test_new): Split into test_new and
3634 new test_config_new function. Create JobConfig object and spawn
3635 Job instances from that.
3636 (test_copy): Drop the tests.
3637 (test_process_new): Drop check of pid.
3638 (test_process_copy): Drop test.
3639 (test_find_by_name): Rename to test_config_find_by_name.
3640 (test_should_replace): Rename to test_config_should_replace.
3641 (test_instance): Create JobConfig object, and adjust tests to ensure
3642 that we always get a Job object.
3643 (test_find_by_pid, test_find_by_id, test_change_goal): Create
3644 JobConfig object and spawn Job instances from that.
3645 (test_change_state): Create JobConfig object and spawn Job
3646 instances from that. Adjust tests that previously checked for
3647 JOB_WAITING to check for job being freed. Drop checks for JOB_DELETED.
3648 (test_next_state): Create JobConfig object and spawn Job instances
3649 from that. Drop JOB_DELETED and JOB_WAITING checks.
3650 (test_run_process, test_kill_process, test_child_reaper)
3651 (test_handle_event, test_detect_stalled): Create JobConfig object
3652 and spawn Job instances from that.
3653 (test_free_deleted): Drop.
3654 * init/main.c: Don't add job_free_deleted to the main loop.
3655 * init/enum.h (JobState): Drop JOB_DELETED.
3656 * init/enum.c (job_state_name, job_state_from_name): Drop JOB_DELETED.
3657 * init/tests/test_enum.c (test_state_name, test_state_from_name):
3658 Drop tests that use the JOB_DELETED value.
3659 * init/process.c (process_spawn, process_setup_limits)
3660 (process_setup_environment, process_setup_console): Get details
3661 from the job config. Put job id in the output.
3662 * init/tests/test_process.c (test_spawn, test_kill): Create
3663 a JobConfig object and make Job instances from that.
3664 * init/tests/test_event.c (test_poll): Create a JobConfig object
3665 and make Job instances from that.
3666 (test_operator_copy): Set pointers to NULL to avoid gcc complaining.
3667 * init/conf.h (ConfItem): Make the type for a job be JobConfig.
3668 * init/conf.c (conf_item_destroy): Don't attempt to replace the
3669 new middle-man target, if it was due to be replaced it would have
3670 already been. If we can replace the config, ensure nothing points
3671 at it and then free it, rather than kicking state.
3672 * init/tests/test_conf.c (test_source_reload_job_dir)
3673 (test_source_reload_conf_dir, test_source_reload_file)
3674 (test_source_reload, test_item_destroy): Call job_config_new to
3675 create JobConfig objects, track when they are freed rather than
3676 marked in the deleted state. Create instances with job_instance,
3677 and fetch from the instances list. Expect the job to be freed
3678 with the item.
3679 * init/tests/test_parse_conf.c (test_parse_conf)
3680 (test_stanza_job): Change expected type from Job to JobConfig.
3681 * init/parse_job.c: Update prototypes of all functions to refer to
3682 JobConfig instead of Job.
3683 (parse_job): If the old job already has a replacement, remove the
3684 replacement from the hash table -- but don't free it because it's
3685 linked by a ConfItem -- this is temporary. Likewise for when we
3686 replace the old job.
3687 * init/parse_job.h: Update prototype.
3688 * init/tests/test_parse_job.c: Update all functions to use JobConfig
3689 instead of Job.
3690 (test_parse_job): Create an instance.
3691 * doc/states.dot: Remove the deleted state.
3692 * doc/states.png: Regenerate.
3693 * TODO: Update with notes from the conversion.
3694
Scott James Remnantf9ec8292007-10-16 00:08:33 +010036952007-10-16 Scott James Remnant <scott@netsplit.com>
3696
3697 Update to catch up with changes in libnih that make code a little
3698 bit easier to follow (we hope).
3699
3700 * init/tests/test_process.c (test_spawn, test_kill): Replace calls
3701 to nih_list_free() with nih_free()
3702 * init/event.c (event_poll): Replace nih_list_free with nih_free
3703 since the former function has gone from libnih.
3704 (event_new): Adjust setting of the destructor.
3705 (event_operator_new): Set destructor for the tree node.
3706 * init/tests/test_event.c (test_new, test_find_by_id, test_ref)
3707 (test_unref, test_block, test_unblock, test_poll)
3708 (test_operator_match): Replace nih_list_free with nih_free.
3709 (test_poll): Use TEST_FREE_TAG and TEST_FREE rather than abusing
3710 destructors.
3711 * init/job.c (job_new): Set destructor to nih_list_destroy.
3712 (job_copy, job_free_deleted): Use nih_free instead of nih_list_free
3713 * init/tests/test_job.c (test_new, test_copy, test_find_by_name)
3714 (test_find_by_pid, test_find_by_id, test_instance)
3715 (test_change_goal, test_change_state, test_next_state)
3716 (test_should_replace, test_run_process, test_kill_process)
3717 (test_child_reaper, test_handle_event)
3718 (test_handle_event_finished, test_detect_stalled)
3719 (test_free_deleted): Replace all uses of nih_list_free with nih_free
3720 (test_child_reaper, test_free_deleted): Replace destructor abuse
3721 with TEST_FREE, etc.
3722 * init/conf.c (conf_reload_path): Use nih_free instead of nih_list_free
3723 (conf_source_new, conf_file_get, conf_item_new): Set destructor
3724 (conf_source_reload, conf_delete_handler): Use nih_free not the
3725 custom conf_file_free() function.
3726 (conf_reload_path): Use nih_free not the custom conf_item_free()
3727 function.
3728 (conf_delete_handler): Use nih_free not nih_watch_free()
3729 (conf_source_free, conf_file_free): Drop these functions, since
3730 all the free chaining happens properly with destructors.
3731 (conf_item_free): Rename to conf_item_destroy and turn into destructor
3732 * init/conf.h: Update prototypes.
3733 * init/tests/test_conf.c (test_source_new, test_file_get)
3734 (test_item_new, test_source_reload_job_dir)
3735 (test_source_reload_conf_dir, test_source_reload_file)
3736 (test_item_free): Replace nih_list_free calls with nih_free
3737 (test_source_reload_job_dir, test_source_reload_conf_dir)
3738 (test_source_reload_file, test_source_reload, test_item_free): Replace
3739 calls to conf_source_free with nih_free
3740 (test_source_free, test_file_free): Drop functions.
3741 (test_item_free): Rename to test_item_destroy
3742 (test_item_new): Assign a job before freeing, otherwise the destroy
3743 function will foul up as it expects one.
3744 * init/parse_conf.c (stanza_job): Replace nih_list_free with nih_free
3745 * init/tests/test_parse_conf.c (test_parse_conf)
3746 (test_stanza_job): Replace conf_source_free() with nih_free()
3747 (test_parse_conf, test_stanza_job): Replace conf_item_free()
3748 with nih_free()
3749 * init/parse_job.c (parse_job, parse_on_paren, parse_on_collect):
3750 Replace nih_list_free with nih_free
3751 (parse_on): always cut out the stack head before returning (it won't
3752 be empty on error) otherwise we end up with a bunch of list entries
3753 pointing to it -- and it's way out of scope when we try and free them
3754 (parse_on_operator, parse_on_operand): Use the job as the context
3755 not the operator for consistency of freeing.
3756 * init/tests/test_parse_job.c: Replace all instances of nih_list_free
3757 with nih_free (too many functions to list).
3758
Scott James Remnant5d6466d2007-10-15 01:40:52 +010037592007-10-15 Scott James Remnant <scott@netsplit.com>
3760
Scott James Remnant3e32e082007-10-16 00:08:24 +01003761 Strip out all of the IPC code, removing it and consigning it to the
3762 great revision control history in the sky. We're going to switch
3763 from home-brew to D-BUS. so all this is somewhat obsolete. Rather
3764 than maintain this while we carry on developing, we'll strip it out
3765 now and put the D-BUS code in ater once the rest of the core changes
3766 are done (otherwise we'd just be dragging those through maintenance
3767 too).
3768
3769 * Makefile.am (SUBDIRS): Remove the upstart sub-directory entirely;
3770 comment out util, compat/sysv & logd since we'll fix them up later
3771 * configure.ac (AC_CONFIG_FILES): Remove from here too.
3772 * upstart/enum.c, upstart/enum.h, upstart/tests/test_enum.c: Move
3773 these files into the init/ sub-directory; strictly speaking we'll
3774 probably need to share them again later in some way, but for now
3775 they can live with the rest of the daemon code.
3776 * upstart/: Delete.
3777 * init/Makefile.am (init_SOURCES): Remove control.c, control.h,
3778 notify.c and notify.h; add enum.c and enum.h
3779 (TESTS): Remove test_control and test_notify; add test_enum
3780 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD)
3781 (test_notify_SOURCES, test_notify_LDADD): Remove.
3782 (test_enum_SOURCES, test_enum_LDFLAGS, test_enum_LDADD): Add details
3783 (init_LDADD): Remove libupstart
3784 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
3785 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): Remove
3786 libupstart, control.o and notify.o; add enum.o
3787 * init/control.c, init/control.h, init/tests/test_control.c: Delete
3788 * init/notify.c, init/notify.h, init/tests/test_notify.c: Delete
3789 * init/enum.c, init/job.c, init/job.h: Update include path for enum.h
3790 * init/parse_job.c: Remove unnecessary enum.h include
3791 * init/tests/test_enum.c: Update to reflect where it is.
3792 * init/main.c (main): Drop control socket opening.
3793 * init/tests/test_job.c: Remove unnecessary control.h include
3794 * init/event.c (event_pending, event_finished): Remove calls to
3795 notify_event and notify_event_finished
3796 * init/job.c (job_change_goal, job_change_state): Remove calls
3797 to notify_job.
3798 * init/tests/test_parse_conf.c: Remove calls to notify_init
3799 * init/tests/test_parse_job.c: Remove calls to notify_init
3800 * init/tests/test_event.c (test_poll): Strip out the part of the
3801 test that checks processes are notified.
3802 (check_event, check_event_finished): Remove.
3803
Scott James Remnanta86d3982007-10-15 17:55:09 +01003804 * configure.ac: Bump Autoconf dependency to 2.61 to match libnih
3805 * HACKING: Bump dependency in docs too.
3806
Scott James Remnant5d6466d2007-10-15 01:40:52 +01003807 * NEWS: Copy in news from 0.3.9; that release doesn't appear in
3808 this ChangeLog since it was made on a separate branch by backporting
3809 bug fixes made here.
3810 * configure.ac: Bump version to 0.5.0, which is where development
3811 is heading for.
3812
Scott James Remnant56d2d822007-10-12 18:06:21 +010038132007-10-12 Scott James Remnant <scott@netsplit.com>
3814
3815 * HACKING: Change URL for libnih.
3816
Scott James Remnant0c3bef32007-10-08 13:20:56 +010038172007-10-08 Scott James Remnant <scott@netsplit.com>
3818
Scott James Remnante16d32c2007-10-08 13:37:44 +01003819 * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.16.1 since this
3820 version of gettext is needed for compatibility with Automake 1.10
3821 * HACKING: Bump version in the docs too.
3822
Scott James Remnante6478362007-10-08 13:21:51 +01003823 * compat/sysv/Makefile.am: Only create symlinks if COMPAT_SYSV is
3824 enabled, otherwise we leave dangling ones.
3825
Scott James Remnant0c3bef32007-10-08 13:20:56 +01003826 * Makefile.am (ACLOCAL_AMFLAGS): Specify that aclocal install
3827 ordinarily system-wide macros into m4 (libtool.m4, specifically).
3828 This makes it easier for packagers to modify autoconfery since
3829 aclocal is no longer a destructive event.
3830 * configure.ac (AM_INIT_AUTOMAKE): Increase Automake requirement to
3831 1.10 to ensure we have aclocal --instal
3832 * HACKING: Increase Automake version in the docs.
3833
Scott James Remnant52ada042007-09-21 15:59:12 +010038342007-09-21 Scott James Remnant <scott@netsplit.com>
3835
3836 * init/job.c (job_detect_stalled, job_free_deleted): Call job_init()
3837 on entry, since we don't have a Job pointer passed to us, we need
3838 to make sure we don't dereference a potentially NULL list.
3839
Scott James Remnant65e21ac2007-06-22 12:48:14 +010038402007-06-22 Scott James Remnant <scott@netsplit.com>
3841
Scott James Remnant1e2e0b32007-06-22 16:59:29 +01003842 * TODO: Update.
3843
Scott James Remnant3a807ca2007-06-22 16:53:35 +01003844 * init/job.h: Update prototype of job_change_goal.
3845 (Job): Remove cause member.
3846 * init/job.c (job_change_goal): Drop additional argument since cause
3847 is no longer used.
3848 (job_change_state, job_child_reaper, job_handle_event): Only pass
3849 two arguments to job_change_goal.
3850 * init/control.c (control_job_start, control_job_stop): Only pass
3851 two argumenst to job_change_goal.
3852 * init/tests/test_job.c (test_change_goal, test_change_state): Only
3853 pass two arguments to job_change_goal.
3854
Scott James Remnant134e0592007-06-22 16:51:02 +01003855 * init/job.c (job_new): Drop setting of cause.
3856 (job_change_cause): Drop this function entirely.
3857 (job_change_goal, job_change_state): Drop calls to job_change_cause
3858 (job_change_state, job_child_reaper): Don't pass job->cause to
3859 job_change_goal calls.
3860
3861 * init/tests/test_job.c: Remove all tests that checked the value of
3862 job->cause, since that variable is going away.
3863 (test_change_goal): Remove the specific tests that checked whether
3864 cause was updated or not.
3865
Scott James Remnant108152d2007-06-22 16:43:07 +01003866 * init/job.c (job_run_process): Replace the arguments from the event
3867 with a list of event names.
3868 * init/tests/test_job.c (test_run_process): Update test case to
3869 supply arguments from the list of events.
3870
Scott James Remnantbc683992007-06-22 16:37:10 +01003871 * init/process.c (process_setup_environment): Drop the UPSTART_EVENT
3872 environment variable; it doesn't make sense when you can have multiple
3873 events.
3874 (process_setup_environment): Put all variables from the job's start
3875 events into the job's environment; replacing the UPSTART_EVENT variable
3876
Scott James Remnant47f5a762007-06-22 15:57:26 +01003877 * init/job.c (job_change_cause): Don't notify the job event
3878 subscribers when changing the cause.
3879 * init/notify.c (notify_job_finished): Instead notify them when
3880 the job reaches a rest state.
3881
Scott James Remnantfed4f262007-06-22 15:50:51 +01003882 * init/notify.c (notify_job): Call notify_job_event regardless,
3883 since this now looks over the start_on and stop_on fields.
3884 (notify_job_event): Rewrite to iterate over start_on and stop_on,
3885 and notifying for each cause event found.
3886 (notify_job_event_caused): Static function that is the guts of the
3887 above function.
3888 * init/tests/test_notify.c (test_job, test_job_event): Modify tests
3889 to refer exclusively to the start_on/stop_on expressions rather than
3890 the cause.
3891
Scott James Remnante379ab92007-06-22 15:35:42 +01003892 * init/job.c (job_change_cause): Only notify the job event and
3893 update the cause member, we don't need to ref or block it anymore
3894 since that's handled by start_on and stop_on.
3895 * init/tests/test_job.c (test_change_goal): Drop checks on cause
3896 being referenced and blocked.
3897 (test_change_state, test_child_reaper, test_handle_event): Update
3898 test cases to not reference ->cause, and not count any references
3899 or blockers towards it.
3900 * init/tests/test_event.c (test_poll): Update expected reference
3901 and block counts for events handled by jobs.
3902
Scott James Remnant06218642007-06-22 15:15:56 +01003903 * init/tests/test_process.c (test_kill): Make sure that all processes
3904 in the process group are killed, rather than just the lone one.
3905 * init/process.c (process_kill): Send the signal to all processes
3906 in the same process group as the pid.
3907 * init/tests/test_job.c (test_change_state, test_kill_process):
3908 After spawning a child, call setpgid() to put it in its own process
3909 group otherwise we could end up TERMing ourselves.
3910
Scott James Remnante84eb012007-06-22 13:42:14 +01003911 * init/tests/test_job.c (test_child_reaper): Update test cases to
3912 include checking of the start_on and stop_on expression trees.
3913 * init/job.c (job_child_reaper): Mark all blocked events in the
3914 start_on and stop_on trees as failed; since these are copies of
3915 the cause event, we can drop that setting already.
3916
Scott James Remnant65e21ac2007-06-22 12:48:14 +01003917 * TODO: Update again, still thinking about the atomicity of event
3918 expressions.
3919
Scott James Remnante332fa92007-06-21 15:35:53 +010039202007-06-21 Scott James Remnant <scott@netsplit.com>
3921
Scott James Remnantb4556392007-06-21 18:38:20 +01003922 * init/tests/test_job.c (test_change_state): Include tests on a job's
3923 start_on and stop_on event expression trees, and make sure that events
3924 are unblocked and unreferenced at the appropriate moments.
3925 * init/job.c (job_change_state): Unblock the events that started the
3926 job in running (if a service), and reset when we reach waiting (leave
3927 referenced otherwise so the environment is always present).
3928 Unblock and unreference the events that stopped the job in
3929 starting (for restarting), running (if coming from pre-stop) and
3930 waiting.
3931
Scott James Remnant7e198e42007-06-21 17:02:12 +01003932 * init/tests/test_job.c (test_handle_event): Rewrite tests using
3933 event expressions, and make sure events are referenced and blocked
3934 correctly matching how jobs are affected. Include tests for correct
3935 instance behaviour.
3936 (test_instance): Make sure that instances copy across the expression
3937 state, and reset the parent.
3938 * init/job.c (job_instance): After spawning a new instance, reset
3939 the start_on expression of the master job.
3940
Scott James Remnant625c8d02007-06-21 16:28:43 +01003941 * init/event.c (event_operator_copy): Change to making the parent
3942 of copies nodes be the actual tree parent, rather than the top
3943 parent; otherwise you can't free an entire tree in one go.
3944 * init/tests/test_event.c (test_operator_copy): Check parents of
3945 copied nodes.
3946 * init/tests/test_job.c (test_copy): Update parent checks here too.
3947
Scott James Remnante332fa92007-06-21 15:35:53 +01003948 * init/tests/test_job.c (test_copy): Make sure that the job copy
3949 references and blocks the event; and in the event of failure, doesn't
3950 * init/job.c (job_copy): Reset the start_on and stop_on expressions
3951 in the event of failure.
3952
Scott James Remnante7b6cd62007-06-20 22:17:09 +010039532007-06-20 Scott James Remnant <scott@netsplit.com>
3954
Scott James Remnant9b1d5202007-06-20 23:26:37 +01003955 * TODO: Update.
3956
Scott James Remnantce628ca2007-06-20 23:25:02 +01003957 * init/parse_job.c (parse_on): New generic parsing function to deal
3958 with event expressions, including operators, parentheses, etc.
3959 (parse_on_operator): Function called by parse_on() to deal with an
3960 operator or operand.
3961 (parse_on_paren): Function called by parse_on() to deal with a
3962 parenthesis.
3963 (parse_on_operand): Function called by parse_on_operator() to deal
3964 with a non-operator token.
3965 (parse_on_collect): Function called by all of the above to collect
3966 the operators on the stack and deposit them into the output box,
3967 either for collection by a later operator or for returning from
3968 parse_on().
3969 (stanza_start, stanza_stop): Call the new parse_on() function to
3970 deal with "start on" and "stop on", storing it in the appropriate
3971 part of the job.
3972 * init/tests/test_parse_job.c (test_parse_job): Replace list empty
3973 checks for start_events/stop_events with NULL checks on the new
3974 start_on/stop_on members.
3975 (test_stanza_start, test_stanza_stop): Test new stanza code.
3976
3977 * init/errors.h (PARSE_EXPECTED_EVENT, PARSE_EXPECTED_OPERATOR)
3978 (PARSE_MISMATCHED_PARENS): Add numerics and strings for the errors
3979 that can be generated by parsing an event expression.
3980 * init/conf.c (conf_reload_path): Handle the new errors properly,
3981 including the line number where they occurred.
3982 * logd/jobs.d/logd.in: Update "stop on" to work with the new parser.
3983
Scott James Remnant404f99c2007-06-20 22:18:39 +01003984 * init/parse_job.c (stanza_emits): Each entry in the emits list
3985 is now an NihListEntry with the event name as the string data
3986 pointer, rather than an EventInfo structure (since that structure
3987 is gone).
3988 * init/tests/test_parse_job.c (test_stanza_emits): Update test
3989 case to check for NihListEntry structures.
3990
Scott James Remnante7b6cd62007-06-20 22:17:09 +01003991 * init/parse_job.c: Where the stanza function parses an argument and
3992 can possibly reject it, save the position and line number and do not
3993 return that unless we're happy with the argument. This ensures errors
3994 are raised pointing *at* the argument, rather than past it.
3995 * init/tests/test_parse_job.c: Fix several test case errors where
3996 the buffer was built incorrectly. Pedantically check pos and lineno
3997 after successful parsing, and after errors, to make sure they are
3998 where they should be.
3999
Scott James Remnant77e9d342007-06-18 12:59:22 +010040002007-06-18 Scott James Remnant <scott@netsplit.com>
4001
Scott James Remnantc8ca88e2007-06-18 15:18:02 +01004002 * init/job.h (Job): Replace the start_events and stop_events NihLists
4003 with start_on and stop_on EventOperators.
4004 * init/job.c (job_new): Drop list initialising, and instead just set
4005 the new start_on/stop_on members to NULL.
4006 (job_copy): Copy the entire event operator tree to the new job,
4007 including references and blockers. emits has changed to a list of
4008 NihListEntry with embedded strings, so copy them that way.
4009 (job_run_process): Drop "->info."
4010 (job_handle_event): Instead of iterating the events lists, call
4011 event_operator_handle and check the return value and top node value.
4012 (job_detect_stalled): Modify to iterate the start_on tree.
4013 * init/tests/test_job.c (test_change_state, test_detect_stalled):
4014 Drop references to "->info." since we can get the variables directly.
4015 (test_new): Check that start_on and stop_on are NULL.
4016 (test_copy): Adjust tests of copying start_on and stop_on trees as
4017 well as the emits list.
4018 (test_handle_event, test_handle_event_finished)
4019 (test_detect_stalled): Change references from start_events to start_on,
4020 stop_events to stop_on and construct using EventOperators instead.
4021 (test_handle_event): Update number of blockers now that the event
4022 expressions themselves will block the event.
4023 * init/tests/test_event.c (test_poll): Update number of blockers since
4024 both the events and cause will block it for now; also change
4025 start_events and stop_events to start_on and stop_on respectively.
4026
Scott James Remnant210d6fa2007-06-18 15:12:29 +01004027 * init/event.c (event_operator_copy): Copy the children nodes as well.
4028 * init/tests/test_event.c (test_operator_copy): Test copying
4029 with children nodes.
4030
Scott James Remnant77e7a382007-06-18 14:10:39 +01004031 * init/tests/test_control.c (test_event_emit): Drop "->info."
4032
Scott James Remnant5b27f0b2007-06-18 14:09:49 +01004033 * init/notify.c (notify_event, notify_event_finished): Drop
4034 "->info." from event references.
4035
Scott James Remnant61b7ae82007-06-18 14:05:00 +01004036 * init/process.c (process_setup_environment): Drop "->info." from
4037 cause references
4038 * init/tests/test_process.c (test_spawn): Likewise.
4039
Scott James Remnant77e9d342007-06-18 12:59:22 +01004040 * init/event.h (Event): Directly include the name, args and env
4041 fields rather than using an interim structure; this makes more sense
4042 since we use them differently than a match does.
4043 (EventOperatorType, EventOperator): New structure to build event
4044 expression trees that combine a match with "or" and "and" boolean
4045 operators; solve some problems by holding the reference and blocker
4046 on the matched event inside this structure directly and provide
4047 methods to unblock and reset them.
4048 (EventInfo): Drop this structure completely now that it is unused.
4049 * init/event.c (event_info_new): Rename this structure to
4050 event_operator_new() and initialise the new fields properly.
4051 (event_info_copy): Likewise rename to event_operator_copy and deal
4052 with copying event references and blockers over to the new structure,
4053 since the state is useful to copy.
4054 (event_match): Rename to event_operator_match and switch the arguments
4055 around since it makes slightly more sense that way.
4056 (event_operator_update): Function to update the value of an EVENT_OR
4057 or EVENT_AND operator based on the value of the two children.
4058 (event_operator_handle): Function to iterate an entire expression
4059 tree looking for a given event, and update the values of other
4060 operators if matched.
4061 (event_operator_unblock): Function to iterate an expression tree
4062 and release any events we're blocking.
4063 (event_operator_reset): Function to iterate an expression tree,
4064 unreferencing any events and resetting all values back to FALSE.
4065 (event_new, event_pending, event_finished): Update references to
4066 the Event structure to discard the intermediate "->info."
4067 * init/tests/test_event.c (test_info_new): Rename to
4068 test_operator_new() and test various features of the function added
4069 in the converstion.
4070 (test_info_copy): Likewise rename to test_operator_copy() and add a
4071 few more tests, especially that blockers and references are copied.
4072 (test_match): Rename to test_operator_match() and adjust argument
4073 order to match the change.
4074 (test_new) Call event_init() to avoid a valgrind error and update
4075 references to drop "->info."
4076 (test_poll): Use EventOperators in the job to test event polling,
4077 rather than the old structures.
4078 (test_operator_update, test_operator_handle, test_operator_unblock)
4079 (test_operator_reset): Test behaviour of the new functions.
4080
Scott James Remnantf050aa62007-06-13 12:37:16 +010040812007-06-13 Scott James Remnant <scott@netsplit.com>
4082
4083 * TODO: Update utmp/wtmp thoughts.
4084
Scott James Remnantf9aec8c2007-06-12 12:18:15 +010040852007-06-12 Scott James Remnant <scott@netsplit.com>
4086
Scott James Remnantdd9249d2007-06-12 15:30:19 +01004087 * init/paths.h: Remove extra /, oops.
4088 * init/Makefile.am (install-data-local): Make destination
4089 configuration directories as part of "make install".
4090 (AM_CPPFLAGS): Define LEGACY_CONFDIR to be $(sysconfdir)/event.d
4091 * logd/Makefile.am (jobs.d/logd): Replace mkdir_p with MKDIR_P
4092 * init/main.c: Use macro to pick up /etc/event.d so it can be moved
4093 by configure
4094
Scott James Remnantdc6b5e42007-06-12 14:57:14 +01004095 * TODO: Update.
4096
Scott James Remnant0b3171a2007-06-12 14:55:58 +01004097 * init/Makefile.am (AM_CPPFLAGS): Define CONFDIR to be
4098 $(sysconfdir)/init, replacing the old CFG_DIR definition.
4099 * init/paths.h (CFG_DIR): Replace with CONFDIR definition,
4100 and set the default to /etc/init
4101 * init/main.c: Load configuration from /etc/init/init.conf,
4102 /etc/init/conf.d and /etc/init/jobs.d; retain loading from /etc/event.d
4103 for the time being.
4104 * init/man/init.8: Change reference to directory.
4105 * logd/Makefile.am: Replace references of eventdir with jobsdir,
4106 and event.d with jobs.d
4107 * logd/event.d: Rename to logd/jobs.d
4108
Scott James Remnant2b8a5052007-06-12 14:49:16 +01004109 * init/conf.c (conf_reload): Ignore ENOENT, it's not interesting
4110 in the general case.
4111
Scott James Remnant018e3562007-06-12 14:47:42 +01004112 * init/tests/test_conf.c (test_source_reload): Test the general
4113 reload function.
4114
Scott James Remnant0ca92cb2007-06-12 14:37:09 +01004115 * init/tests/test_conf.c (test_source_free): s/unlink/rmdir/
4116 (test_source_reload_file): Test that configuration files work, and
4117 are parsed with anything alongside ignored automatically.
4118 * init/conf.c (conf_file_filter): As well as not filtering out the
4119 source path itself, we also need to not filter out the path we're
4120 watching which is different in the case of files; we need to know
4121 about it because we handle its removal.
4122 (conf_delete_handler): Compare the path deleted against the path
4123 we're watching, rather than the source path, since this means the
4124 watch needs to be freed.
4125
Scott James Remnantf9aec8c2007-06-12 12:18:15 +01004126 * compat/sysv/shutdown.c: Use nih pidfile functions since they're
4127 more reliable than doing it ourselves.
4128
Scott James Remnant11b08b52007-06-11 12:00:40 +010041292007-06-11 Scott James Remnant <scott@netsplit.com>
4130
Scott James Remnant7e6d3a92007-06-11 18:37:44 +01004131 * init/conf.c (conf_reload_path): Call parse_conf for mixed files
4132 and directories. Make a correction to the old_items code, was
4133 passing the wrong arguments to nih_list_add; the effect we wanted
4134 was that we add the old items head into the list, and remove the
4135 existing head (what we did was add the first item to the old_items
4136 list and then cut the rest out).
4137 * init/tests/test_conf.c (test_source_reload_dir): Rename to
4138 test_source_reload_job_dir, since that's what this does.
4139 (test_source_reload_conf_dir): Add another function that tests
4140 directories of mixed configuration.
4141
Scott James Remnantc12704a2007-06-11 17:17:22 +01004142 * init/parse_conf.c (parse_conf): Parse a configuration file that
4143 defines jobs by name.
4144 (stanza_job): Job stanza, slightly trickier than it would appear to
4145 need to be, to parse the block in-place and keep pos/lineno
4146 consistent.
4147 * init/parse_conf.h: Prototype for external function.
4148 * init/tests/test_parse_conf.c: Test suite for mixed configuration
4149 parsing.
4150 * init/Makefile.am (init_SOURCES): Build and link parse_conf.c and
4151 parse_conf.h
4152 (TESTS): Build and run parse_conf tests
4153 (test_parse_conf_SOURCES, test_parse_conf_LDFLAGS)
4154 (test_parse_conf_LDADD): Details for parse_conf test suite.
4155 (test_conf_LDADD): Add parse_conf.o and conf.o since this calls
4156 them now.
4157
Scott James Remnantc14ec862007-06-11 16:47:34 +01004158 * init/conf.c (conf_source_reload, conf_source_reload)
4159 (conf_reload_path): Add some debugging messages.
4160
Scott James Remnant142a3222007-06-11 16:22:33 +01004161 * init/conf.c (conf_source_new): Add missing call to conf_init()
4162
Scott James Remnant11b08b52007-06-11 12:00:40 +01004163 * init/conf.c (conf_item_new): Drop source parameter, since it's
4164 unused in the function and makes it harder to call this when we
4165 only have one data pointer.
4166 (conf_reload_path): Drop source from conf_item_new() call.
4167 * init/conf.h: Update prototype.
4168 * init/tests/test_conf.c (test_item_new, test_item_free)
4169 (test_file_free): Drop source parameter from calls.
4170
Scott James Remnant56760be2007-06-10 14:23:53 +010041712007-06-10 Scott James Remnant <scott@netsplit.com>
4172
Scott James Remnant7ba2cf62007-06-10 22:20:38 +01004173 * init/main.c (main): Add a handler for the SIGHUP signal
4174 (hup_handler): Handler for SIGHUP, just calls conf_reload().
4175
Scott James Remnant54b2a952007-06-10 22:15:24 +01004176 * init/main.c (main): Read the configuration again.
4177
Scott James Remnantd9619482007-06-10 22:11:42 +01004178 * TODO: Update.
4179
Scott James Remnant4b324142007-06-10 22:08:40 +01004180 * init/tests/test_conf.c (test_source_reload_dir): Reset the priority
4181 and clean up consumed inotify instances.
4182 (test_source_free, test_file_free, test_item_free): Test the free
4183 functions on their own, paying special attention to conf_item_free()
4184 even though this really duplicates other tests.
4185
Scott James Remnant4561b262007-06-10 21:43:52 +01004186 * init/conf.c (conf_reload_path): In the case where we fail to map
4187 the file into memory, we still need to purge all the items that
4188 previously existed.
4189 * init/tests/test_conf.c (test_source_reload): Rename to
4190 test_source_reload_dir, so that we can keep this and the file
4191 tests separate to make it easier to deal with.
4192 (test_source_reload_dir): Add tests for physical and parse errors
4193 when re-loading jobs with and without inotify, and for inotify-based
4194 modification handling of jobs.
4195
Scott James Remnantde27a552007-06-10 21:17:55 +01004196 * init/tests/test_conf.c (test_source_reload): Add test for walk
4197 of non-existant directory with and without inotify; also test for
4198 what happens when the top-level directory is deleted, again with
4199 and without inotify.
4200 * init/conf.c (conf_delete_handler): Handle the case of the top-level
4201 directory being deleted by freeing the watch (so next time we asked
4202 to reload, we can restore it).
4203
Scott James Remnant4ee170f2007-06-10 20:58:09 +01004204 * init/tests/test_conf.c (test_source_reload): Add a test for
4205 deletion of a running job.
4206
Scott James Remnantcf52ef72007-06-10 20:55:41 +01004207 * init/conf.c (conf_item_free): Fix this up; when deleting an item
4208 from a source, we first mark it for deletion unless it's already
4209 marked for replacement. Then if it's the replacement for something
4210 else, we mark that to be replaced by whatever we're being replaced
4211 by (so there are no references to us) and change that state if
4212 necessary. Finally we replace our own item and free the record
4213 before returning.
4214 * init/tests/test_conf.c (test_source_reload): Check that we handle
4215 the cases of modiciation of a running job, modification of a
4216 replacement of a running job and deletion of a replacement for a
4217 running job.
4218
Scott James Remnanta77229e2007-06-10 20:52:55 +01004219 * init/parse_job.c (parse_job): Instead of freeing the previous
4220 replacement, which could leave invalid references to it, mark it
4221 for deletion and change the state.
4222 * init/tests/test_parse_job.c (test_parse_job): Adjust the test so
4223 that we hold a reference to the replacement job and make sure that
4224 the state is changed to deleted, rather than checking for a destructor
4225 being called on it.
4226
Scott James Remnantf1de26c2007-06-10 20:43:16 +01004227 * init/init.supp (conf-init): Add valgrind suppression for the
4228 configuration sources hash table.
4229
Scott James Remnant11a1cf22007-06-10 17:38:06 +01004230 * init/conf.c (conf_item_free): Don't overwrite any previous
4231 replacement, only mark us for deletion if we wouldn't otherwise
4232 be replaced. Add some commented possible code for testing.
4233 * init/tests/test_conf.c (test_source_reload): Test replacement of
4234 jobs works properly; test modification with direct write and with
4235 atomic rename replace; test deletion.
4236
Scott James Remnantfa38c532007-06-10 16:49:13 +01004237 * init/conf.c (conf_reload_path): It turns out that the flag trick
4238 doesn't work for items since we often reparse them within the same
4239 file tag (it works with files because they're atomic and reparsed).
4240 Store the old items in a different list instead.
4241 (conf_source_free): We need to be careful about freeing sources,
4242 so have a function to do it properly.
4243 (conf_item_new): Since the flag member isn't useful, don't bother
4244 setting it.
4245 * init/conf.h: Add conf_source_free prototype.
4246 (ConfFile): Remove flag member.
4247 * init/tests/test_conf.c (test_source_reload): Add test for inotify
4248 create detection.
4249
Scott James Remnant79b9bde2007-06-10 15:43:18 +01004250 * init/conf.c (conf_file_delete): Rename to conf_file_free and match
4251 the pattern of those kinds of functions.
4252 (conf_item_delete): Likewise rename to conf_item_free and match the
4253 pattern of these kinds of functions.
4254 * init/conf.h: Add prototypes.
4255
Scott James Remnantdb56d502007-06-10 15:37:28 +01004256 * init/conf.c (conf_reload_path): Fix bug with job name generation.
4257 Allow non-parsing errors to be returned from the function.
4258 (conf_item_delete): Drop all replacement management code, we'll put
4259 this back through testing.
4260 * init/tests/test_conf.c (test_source_reload): Test reloading adds
4261 the right inotify watch and parses the files, also check that loading
4262 without inotify and mandatory reloading work.
4263
Scott James Remnant56760be2007-06-10 14:23:53 +01004264 * init/conf.c (conf_source_reload): Move the item deletion detection
4265 code from this function, where it would only happen on a mandatory
4266 reload
4267 (conf_reload_path): to this function, where it will happen every time
4268 the file is parsed; which is actually what we want.
4269
Scott James Remnantac1f0682007-06-08 16:04:50 +010042702007-06-08 Scott James Remnant <scott@netsplit.com>
4271
4272 * init/conf.h (ConfItem): Drop the name and replace it with a type.
4273 (ConfItemType): Enum for different types of configuration items
4274 (ConfFile): Change items from a hash table to a list.
4275 * init/conf.c (conf_file_get): Initialise the items member as a list.
4276 (conf_item_set): Rename to conf_item_new again.
4277 (conf_item_new): Allocates a new ConfItem and adds it to the file's
4278 list, we won't reuse items anymore since it doesn't really make sense.
4279 (conf_source_reload): Adjust clean-up code now that items is a list.
4280 (conf_reload_path): Work out the name of jobs found by filename,
4281 allocate a new item for them and parse the job into it. Perform
4282 handling of errors by outputting a warning.
4283 (conf_item_delete): Takes both source and file so we can make
4284 intelligent decisions.
4285 (conf_file_delete): Takes a source and passes it to conf_item_delete
4286 (conf_delete_handler): Pass both source and file to conf_file_delet
Scott James Remnantac1f0682007-06-08 16:04:50 +01004287 * init/tests/test_conf.c (test_file_get): Check that the items
4288 list is empty; rather than the hash being unallocated.
4289 (test_item_set): Rename back to test_item_new and only allocate a
4290 single item which should get added to the list.
4291
Scott James Remnant3c063422007-06-06 13:25:15 +010042922007-06-06 Scott James Remnant <scott@netsplit.com>
4293
Scott James Remnanta940d5c2007-06-06 15:45:26 +01004294 * init/parse_job.c (stanza_respawn): Permit the word "unlimited",
4295 raise a specific error for illegal limit and illegal interval.
4296 (stanza_pid, stanza_kill, stanza_normal, stanza_umask)
4297 (stanza_nice, stanza_limit): Raise specific errors rather than
4298 a generic "illegal value" error.
4299 * init/tests/test_parse_job.c (test_stanza_respawn): Check that
4300 we can use "unlimited", also check for new error return.
4301 (test_stanza_pid, test_stanza_kill, test_stanza_normal)
4302 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Check
4303 for new specific errors.
4304 * init/errors.h: Replace CFG_ILLEGAL_VALUE with a series of parse
4305 errors.
4306
Scott James Remnantd516e3a2007-06-06 13:37:45 +01004307 * init/conf.c: Comments.
4308
Scott James Remnantf5ade4a2007-06-06 13:36:24 +01004309 * init/conf.c (conf_item_set): Call out to conf_item_delete() to
4310 handle unsetting of an item's data.
4311 (conf_source_reload): Add code to deal with mandatory reloading,
4312 calls conf_file_delete() and/or conf_item_delete() as appropriate.
4313 (conf_delete_handler): Call conf_file_delete() on the ConfFile that
4314 we find.
4315 (conf_file_delete): Function to delete all items in a file.
4316 (conf_item_delete): Placeholder function to delete an item.
4317
Scott James Remnant3c063422007-06-06 13:25:15 +01004318 * init/conf.c (conf_file_new): Rename to conf_file_get; in practice
4319 we never just want to allocate one of these, we always want to
4320 return the existing entry if it exists.
4321 (conf_item_new): Rename to conf_item_set; again in practice we always
4322 want to update an existing item. This function will grow the "deal
4323 with replacement" stuff.
4324 (conf_reload): Start putting in place the code that will allow
4325 mandatory reloads, as well as initial setup. This function iterates
4326 over the sources and deals with errors.
4327 (conf_source_reload): Function to reload an individual source, calls
4328 out to one of the following two functions and will eventually perform
4329 the deleted items scan.
4330 (conf_source_reload_file): Set up a watch on a file, and reload it.
4331 (conf_source_reload_dir): Set up a watch on a directory and reload it.
4332 (conf_file_filter): Filter for watching parent directory of files.
4333 (conf_create_modify_handler): File creation and modification handler.
4334 (conf_delete_handler): File deletion handler.
4335 (conf_file_visitor): Tree walk handler.
4336 (conf_reload_path): Function that deals with files themselves,
4337 currently just sorts out the ConfFile structure and maps the file
4338 into memory.
4339 * init/conf.h: Add new prototypes, update existing ones.
4340 * init/tests/test_conf.c (test_file_new): Rename to test_file_get,
4341 also test repeated calls when already in the table.
4342 (test_item_new): Rename to test_item_set, also test repeated calls
4343 when already in the table.
4344 (test_source_reload): Start of test for reloading sources.
4345
Scott James Remnant83826412007-06-05 16:52:12 +010043462007-06-05 Scott James Remnant <scott@netsplit.com>
4347
4348 * init/conf.c: Make a start on the new configuration management
4349 routines, which will allow finer-grained tracking of configuration
4350 and support mandatory reloading.
4351 (conf_source_new, conf_file_new, conf_item_new): Start off with the
4352 functions to allocate the tracking structures we need to use.
4353 * init/conf.h: Structures and prototypes
4354 * init/tests/test_conf.c: Test suite for allocation functions.
4355 * init/Makefile.am (init_SOURCES): Build and link conf.c and conf.h
4356 (TESTS): Run the conf test suite.
4357 (test_conf_SOURCES, test_conf_LDFLAGS, test_conf_LDADD): Details for
4358 the conf test suite.
4359
Scott James Remnant1f719242007-06-04 10:14:38 +010043602007-06-04 Scott James Remnant <scott@netsplit.com>
4361
Scott James Remnant758cd3a2007-06-04 11:49:02 +01004362 * init/parse_job.c (stanza_description, stanza_author, stanza_version)
4363 (stanza_chroot, stanza_chdir, stanza_pid): Instead of erroring when
4364 the string has already been allocated, free it and replace it with the
4365 new one. Attempting to forbid duplicates is just too inconsistent,
4366 especially for the integer ones which we compare against the default;
4367 using the last one allows us to be entirely consistent.
4368 (stanza_daemon, stanza_respawn, stanza_service, stanza_instance):
4369 Don't error if the flag is already set, just ignore it.
4370 (stanza_respawn, stanza_pid, stanza_kill, stanza_console)
4371 (stanza_umask, stanza_nice): Don't compare the current value against
4372 the default, just overwrite it!
4373 (parse_exec, parse_script): Free existing process command string
4374 before setting a new one over the top.
4375 (parse_process, stanza_exec, stanza_script, stanza_limit): Instead of
4376 erroring if the structure is already set and allocated, just don't
4377 allocate a new one and allow its members to be overwritten.
4378 * init/tests/test_parse_job.c (test_stanza_exec)
4379 (test_stanza_script, test_stanza_pre_start)
4380 (test_stanza_post_start, test_stanza_pre_stop)
4381 (test_stanza_post_stop, test_stanza_description)
4382 (test_stanza_author, test_stanza_version, test_stanza_daemon)
4383 (test_stanza_respawn, test_stanza_service, test_stanza_instance)
4384 (test_stanza_pid, test_stanza_kill, test_stanza_console)
4385 (test_stanza_umask, test_stanza_nice, test_stanza_limit)
4386 (test_stanza_chroot, test_stanza_chdir): Replace tests that check
4387 for an error in the case of duplicate stanzas with tests that make
4388 sure the last of the duplicates is used.
4389 * init/errors.h (CFG_DUPLICATE_VALUE, CFG_DUPLICATE_VALUE_STR): Drop
4390 this error, since we don't consider this a problem anymore.
4391
Scott James Remnant1f719242007-06-04 10:14:38 +01004392 * upstart/Makefile.am (libupstart_la_LIBADD): Add $(LTLIBINTL)
4393 * init/Makefile.am (init_LDADD): Reorder and add $(LTLIBINTL)
4394 * util/Makefile.am (initctl_LDADD): Reorder and add $(LTLIBINTL)
4395 * compat/sysv/Makefile.am (reboot_LDADD): Reorder and add $(LTLIBINTL)
4396 (runlevel_LDADD): add $(LTLIBINTL)
4397 (shutdown_LDADD): Reorder and add $(LTLIBINTL)
4398 (telinit_LDADD): Reorder and add $(LTLIBINTL)
4399 * logd/Makefile.am (logd_LDADD): Add $(LTLIBINTL)
4400
Scott James Remnante8b584e2007-06-03 19:08:38 +010044012007-06-03 Scott James Remnant <scott@netsplit.com>
4402
Scott James Remnant48a3a942007-06-03 19:21:34 +01004403 * init/tests/test_job.c (test_run_process): Add a test case for a
4404 crasher when the event has no arguments.
4405 * init/job.c (job_run_process): Fix the bug, we need to check the
4406 arguments before trying to append them.
4407
Scott James Remnante8b584e2007-06-03 19:08:38 +01004408 * init/cfgfile.c, init/cfgfile.h, init/tests/test_cfgfile.c: Rename
4409 to parse_job and strip out all functions except the parsing and stanza
4410 ones.
4411 * init/Makefile.am (init_SOURCES): Build and link parse_job.c and h
4412 (TESTS): Run the parse job test suite
4413 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
4414 Rename and update.
4415 * init/parse_job.c: Rename all cfg_stanza_*() functions to just
4416 stanza_*(), rename all cfg_parse_*() functions to just parse_*().
4417 (parse_job, parse_process, stanza_exec, stanza_script, stanza_start)
4418 (stanza_stop, stanza_emits, stanza_normal, stanza_env, stanza_limit):
4419 Don't use NIH_MUST, it's fine to be out of memory and we should fail
4420 in that case with a useful error. The user can always reload the
4421 config file.
4422 (cfg_read_job, cfg_watch_dir, cfg_job_name, cfg_create_modify_handler)
4423 (cfg_delete_handler, cfg_visitor): Drop these functions for now.
4424 * init/parse_job.h: Update so it just contains the one prototype.
4425 * init/tests/test_parse_job.c: Update all tests to pass a string
4426 to parse_job(), and check errors raised; rather than mucking around
4427 with file descriptors all of the time. Spend the effort while we're
4428 in here to run TEST_ALLOC_FAIL where we can.
4429 * init/main.c: Drop config file loading for now since it's missing.
4430
Scott James Remnanta482d9a2007-05-27 16:57:35 +010044312007-05-27 Scott James Remnant <scott@netsplit.com>
4432
Scott James Remnante7464fd2007-06-02 11:43:11 +01004433 * init/cfgfile.h (CFG_DIR): Drop this define, since it's in paths.h
4434 (CfgDirectory):
4435
Scott James Remnanta482d9a2007-05-27 16:57:35 +01004436 * init/cfgfile.c (cfg_read_job): Separate out the job-handling code
4437 into a new function that we could call from a stanza if we want
4438 later; this one now just maps the file into memory and deals with
4439 exceptions from the parsing.
4440 (cfg_parse_job): Function containing the seperated out code; parses
4441 a new job, marking it as a replacement for any existing job with the
4442 same name. Drop the warnings for using pid options without a daemon,
4443 since these are actually useful for other things later.
4444 * init/tests/test_cfgfile.c (test_read_job): Drop the check on
4445 unexpected daemon options, since we don't issue these warnings
4446 anymore.
4447
Scott James Remnant4fa7b872007-05-20 13:09:17 +010044482007-05-20 Scott James Remnant <scott@netsplit.com>
4449
Scott James Remnant2b4e0ed2007-05-20 14:00:06 +01004450 * init/event.c (event_match): Change to accept Event as the first
4451 argument and EventInfo as the second, making it obvious that this
4452 matches a received Event against known EventInfo rather than just
4453 comparing two info structs (since the order matters).
4454 * init/event.h: Update prototype.
4455 * init/tests/test_event.c (test_match): Update test accordingly.
4456 (test_poll): Fix typo.
4457 * init/job.c (job_handle_event): Pass in the event as the first
4458 argument to event_match, rather than its info.
4459 * TODO: Update.
4460
Scott James Remnant64b5f682007-05-20 13:14:51 +01004461 * init/job.c (job_emit_event): Return the event that we emit; don't
4462 bother tracking block status or setting blocked, leave that to the
4463 state loop so things are more obvious.
4464 (job_change_state): Set the blocked flag here for starting and stopping
4465 to the return value of job_emit_event().
4466
Scott James Remnant4fa7b872007-05-20 13:09:17 +01004467 * init/event.c (event_ref, event_unref): Reference counting of events
4468 so we don't free those we still need.
4469 (event_block, event_unblock): Blocker counting that replaces the
4470 previous jobs member.
4471 (event_new): Initialise refs and blockers fields.
4472 (event_emit_finished): Remove this function.
4473 (event_poll): Handle the new done state, and deal with the blockers
4474 and references counts; turns out that we can fall all the way through
4475 this switch if these are zero without needing to check again.
4476 (event_pending): Remove call to event_emit_finished, the event_poll()
4477 loop handles this case now.
4478 (event_finished): Set progress to done on the way out.
4479 * init/event.h (EventProgress): Add new done state
4480 (Event): Add refs and blockers members, replacing jobs
4481 * init/tests/test_event.c (test_new): Check refs and blockers are
4482 initialised to zero.
4483 (test_ref, test_unref, test_block, test_unblock): Check the ref
4484 counting function behaviours.
4485 (test_emit_finished): Drop this function since it's not used
4486 * init/job.c (job_change_cause): Reference and block the event,
4487 and unblock and unreference before changing.
4488 (job_emit_event): Reference the event that blocks the job from
4489 continuing.
4490 (job_handle_event_finished): Unreference the blocking event again.
4491 (job_change_state): Make sure that blocked has been cleared before
4492 allowing a state change.
4493 * init/tests/test_job.c: Change tests to use refs/blockers on the
4494 cause event when counting, and also to follow the status of blocked
4495 since that is now ref-counted as well.
4496
Scott James Remnantfea1e9c2007-05-18 15:42:25 +010044972007-05-18 Scott James Remnant <scott@netsplit.com>
4498
Scott James Remnant186ecdc2007-05-18 20:18:17 +01004499 * init/main.c (main, cad_handler, kbd_handler, pwr_handler): Use
4500 event_new rather than event_emit.
4501 * init/job.h (Job): Change type of cause and blocked to Event
4502 * init/job.c (job_change_goal, job_change_cause, job_emit_event)
4503 (job_handle_event, job_handle_event_finished): Update all references
4504 to EventEmission to use Event instead.
4505 (job_detect_stalled): Call event_new instead of event_emit
4506 (job_run_process): Use the info member of cause, not event member
4507 * init/tests/test_job.c (test_change_goal, test_change_state)
4508 (test_run_process, test_child_reaper, test_handle_event)
4509 (test_handle_event_finished): Update all references to EventEmission
4510 to use Event instead.
4511 (test_detect_stalled): Correct to use right structure types.
4512 * init/process.c (process_setup_environment): Use cause's info member,
4513 rather than event member.
4514 * init/tests/test_process.c (test_spawn): Update to use Event.
4515 * init/notify.h (NotifySubscription): Change member to event
4516 * init/notify.c (notify_subscribe_event)
4517 (notify_subscription_find, notify_job_event, notify_event)
4518 (notify_event_finished): Update functions to use event member and
4519 Event structures.
4520 * init/tests/test_notify.c (test_subscribe_event)
4521 (test_subscription_find, test_job, test_job_event, test_event)
4522 (test_event_finished): Update to use Event instead of EventEmission
4523 * init/control.c (control_event_emit): Update to use event_new.
4524 * init/tests/test_control.c (test_event_emit)
4525 (test_subscribe_events, test_unsubscribe_events): Update to use
4526 Event rather than EventEmission.
4527
4528 * init/event.h: Fix up a few references.
4529 * init/tests/test_event.c (test_new): Remove reference to emission.
4530
Scott James Remnant3a6b7f62007-05-18 19:54:45 +01004531 * init/event.h (EventEmission): Rename to Event, and rename event
4532 member to info.
4533 * init/event.c (event_emit_next_id): Rename to event_next_id
4534 (event_emit): Rename to event_new, and add standard parent argument.
4535 (event_emit_find_by_id): Rename to event_find_by_id
4536 (event_poll): Iterate over Events in the list
4537 (event_pending, event_finished): Operate on Event
4538 * init/tests/test_event.c (test_emit): Rename to test_new and
4539 adjust for names and arguments.
4540 (test_emit_find_by_id): Rename to test_find_by_id and adjust for
4541 names.
4542 (test_emit_finished, test_poll): Adjust names.
4543
Scott James Remnant23adaa42007-05-18 19:17:42 +01004544 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
4545 (cfg_stanza_emits): Convert to use EventInfo and event_info_*.
4546 * init/job.c (job_copy): Use EventInfo and event_info_copy.
4547 (job_handle_event, job_detect_stalled): Iterate EventInfo structures
4548 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop)
4549 (test_stanza_emits): Update to use EventInfo
4550 * init/tests/test_job.c (test_copy, test_handle_event)
4551 (test_handle_event_finished, test_detect_stalled): Update to use
4552 EventInfo and event_info_new
4553 * init/event.c (event_copy): Use nih_str_array_copy here, to make the
4554 code somewhat simpler.
4555 (event_finished): Copy the arguments and environment from the old
4556 event, rather than stealing and reparenting.
4557 * init/job.c (job_copy): Use nih_str_array_copy here too.
4558 (job_run_process): Use nih_str_array_append to add the arguments from
4559 the emission onto the command run.
4560
Scott James Remnantccf3ac22007-05-18 19:17:36 +01004561 * init/event.h (Event): Rename to EventInfo, since this structure
4562 representations information about an event, rather than an actual
4563 event in progress.
4564 * init/event.c (event_new): Rename to event_info_new, also now can
4565 take arguments and environment like event_emit() can.
4566 (event_copy): Rename to event_info_copy.
4567 * init/tests/test_event.c (test_new): Rename to test_info_new,
4568 update names in test and test being given args or env.
4569 (test_copy): Rename to test_info_copy and update names in test.
4570 (test_match, test_poll): Use EventInfo.
Scott James Remnant4a558b62007-05-18 18:41:12 +01004571
Scott James Remnantfea1e9c2007-05-18 15:42:25 +01004572 * TODO: Update.
4573
Scott James Remnantc043a8a2007-04-24 12:59:54 +010045742007-04-24 Scott James Remnant <scott@netsplit.com>
4575
4576 * configure.ac: Add AM_PROG_CC_C_O since we use per-target flags
4577 for one of the test cases.
4578
Scott James Remnant0495ff82007-03-16 17:18:00 +000045792007-03-16 Scott James Remnant <scott@netsplit.com>
4580
4581 * upstart/message.c (upstart_message_newv): Add va_end to match
4582 va_copy because the standard says so.
4583 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add
4584 va_end here as well.
4585
Scott James Remnant5b78ebf2007-03-13 17:04:16 +000045862007-03-13 Scott James Remnant <scott@netsplit.com>
4587
Scott James Remnantd03c53c2007-03-13 19:13:19 +00004588 * init/main.c: Wait until we've closed inherited standard file
4589 descriptors and opened the console instead before trying to open the
4590 control socket; otherwise we end up closing it by accident if we
4591 weren't opened with sufficient descriptors in the first place.
4592 Also wait until we've set up the logger before trying to parse the
4593 configuration. In fact both of these things need to be pretty low
4594 down the main() function.
4595
Scott James Remnantdde290e2007-03-13 18:52:30 +00004596 * init/tests/test_job.c (test_run_process): Skip /dev/fd test cases
4597 if that's not available.
4598
Scott James Remnant32844192007-03-13 18:47:54 +00004599 * init/tests/test_control.c (test_log_priority): Make sure we know
4600 that the message has been sent before calling the watcher.
4601
Scott James Remnanta951cec2007-03-13 18:39:13 +00004602 * init/cfgfile.c (cfg_watch_dir): We get ENOSYS for missing inotify
4603 support, not EOPNOTSUPP.
4604 * init/tests/test_cfgfile.c (test_watch_dir): Actually make the
4605 directory tree before testing for inotify, since we use the same
4606 tree there too.
4607
Scott James Remnant7f6ac152007-03-13 18:08:31 +00004608 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
4609 name can be used uninitialised.
4610 * init/tests/test_cfgfile.c (test_watch_dir): Correct an error where
4611 i wouldn't be initialised if we skipped the inotify tests.
4612
4613 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
Scott James Remnant7e5d0062007-03-13 17:27:38 +00004614 * init/process.c (process_setup_environment): job id fits inside
4615 a %u now
4616
Scott James Remnant72301022007-03-13 17:27:09 +00004617 * upstart/message.h: Style; always refer to "unsigned int" as
4618 "unsigned int", and never "unsigned.
4619 * upstart/tests/test_message.c (my_handler): Catch a stray couple
4620 of "unsigned"s
4621
Scott James Remnant25a71542007-03-13 17:25:34 +00004622 * init/control.c (control_job_query, control_job_start)
4623 (control_job_stop): Change type of id argument to unsigned int,
4624 and call printf with %u to output it.
4625 * init/tests/test_control.c (check_job, check_job_instance)
4626 (check_job_instance_end, check_job_status__waiting)
4627 (check_job_status_end__waiting, check_job_status__starting)
4628 (check_job_status_end__starting, check_job_status__running)
4629 (check_job_status_end__running, check_job_status__pre_stop)
4630 (check_job_status_end__pre_stop, check_job_status__stopping)
4631 (check_job_status_end__stopping, check_job_status__deleted)
4632 (check_job_status_end__deleted, check_job_unknown)
4633 (check_job_invalid, check_job_unchanged, check_event): Change
4634 type of id arguments to unsigned int.
4635 (check_list): Change type of id to unsigned int.
4636 * init/tests/test_notify.c (check_job_status)
4637 (check_job_status_end, check_job_finished, check_event)
4638 (check_event_caused, check_event_finished): Change type of id
4639 arguments to unsigned int.
4640
Scott James Remnant4e7af0c2007-03-13 17:20:20 +00004641 * init/job.h (Job): Change the type of the id to unsigned int.
4642 * init/job.c (job_next_id): Change ids to be unsigned ints, and now
4643 we can just use %u in the nih_error call.
4644 (job_find_by_id): Change argument to be unsigned int
4645 * init/tests/test_job.c (test_find_by_id): Change id type to unsigned
4646 int.
4647 * init/event.h (Event): Change the type of the id to unsigned int.
4648 * init/event.c (event_emit_next_id): Change ids to be unsigned ints,
4649 and now we can just use %u in the nih_error call.
4650 (event_emit_find_by_id): Change argument to be unsigned int
4651 * init/tests/test_event.c (test_emit, test_emit_find_by_id)
4652 (check_event, check_event_finished): Change id type to unsigned int.
4653
Scott James Remnant8de2c532007-03-13 17:14:27 +00004654 * util/initctl.c (output_name): Use an unsigned int for the job id,
4655 which means we can use ordinary %u for the printf argument.
4656 (handle_job, handle_job_finished, handle_job_instance)
4657 (handle_job_instance_end, handle_job_status)
4658 (handle_job_status_end, handle_job_unknown, handle_job_invalid)
4659 (handle_job_unchanged, handle_event, handle_event_caused)
4660 (handle_event_finished): Change argument type of id from uint32_t
4661 to unsigned int.
4662 (job_info_output): Change output type of id from %zu to %u
4663
Scott James Remnant92406412007-03-13 17:10:40 +00004664 * upstart/message.c (upstart_message_handle): Use unsigned int for
4665 ids, rather than a fixed-width type.
4666 * upstart/tests/test_message.c (my_handler): Use unsigned int for
4667 the ids, and give "unsigned int" instead of "unsigned" to va_arg as
4668 a matter of style.
4669
Scott James Remnant5b78ebf2007-03-13 17:04:16 +00004670 * upstart/wire.c (upstart_push_int, upstart_pop_int): Send over the
4671 wire using a plain old integer type, instead of a fixed width type;
4672 there's no advantage to using the fixed-width type and we could hurt
4673 ourselves if we tried running on ILP64.
4674 (upstart_push_unsigned, upstart_pop_unsigned): Likewise use a plain
4675 unsigned int over the wire.
4676 (upstart_push_string, upstart_pop_string): Use an unsigned int for
4677 the length of the string, technically this means that we silently
4678 truncate any string that's greater than 4GB on 64-bit platforms;
4679 it's either that or make the test cases harder (we did this before
4680 anyway).
4681 (upstart_push_header, upstart_pop_header): Type is always an unsigned
4682 int (best conversion from an enum)
4683
Scott James Remnant57f02a72007-03-11 12:53:49 +000046842007-03-11 Scott James Remnant <scott@netsplit.com>
4685
Scott James Remnantfc7e60d2007-03-11 19:13:41 +00004686 * configure.ac: Bump version to 0.3.9
4687
Scott James Remnant7c862ed2007-03-11 19:13:24 +00004688 * NEWS: Update.
4689
Scott James Remnant2bc5c5e2007-03-11 19:01:57 +00004690 * util/man/initctl.8: Document the new commands.
4691
Scott James Remnantd055a9d2007-03-11 17:58:15 +00004692 * TODO: Update.
4693
Scott James Remnant19198252007-03-11 17:57:34 +00004694 * init/job.c (job_handle_event): Correct the function so we don't
4695 try and stop the master of an instance, and cause an assertion error.
4696
Scott James Remnantbea9e8d2007-03-11 17:41:58 +00004697 * util/initctl.c: Oops, correct function pointers in command table
4698
4699 * util/tests/test_initctl.c (test_version_action):
4700
Scott James Remnant509f8a62007-03-11 17:39:27 +00004701 * util/initctl.c (handle_version): Handle receipt of the version
4702 reply.
4703 (version_action): Send the version-query message to the server and
4704 expect one response.
4705 (log_priority_action): Parse the single argument into an NihLogLevel
4706 and send it to the server.
4707
Scott James Remnantae1927e2007-03-11 13:45:13 +00004708 * init/control.c (control_version_query, control_log_priority):
4709 Functions to handle the new messages from the server pov
4710 * init/tests/test_control.c (test_version_query)
4711 (test_log_priority): Test the new messages are handled properly.
4712 (check_version): Check the version string matches.
Scott James Remnantebeb2b62007-03-11 13:33:36 +00004713 * upstart/message.h: Add messages for querying the version of the
4714 init daemon and changing the log priority.
4715 * upstart/message.c (upstart_message_newv)
4716 (upstart_message_handle): Marshal the new messages.
4717 * upstart/tests/test_message.c (test_new, my_handler)
4718 (test_handle): Test the marshalling of the new messages,
4719
Scott James Remnant57312ad2007-03-11 12:55:32 +00004720 * upstart/libupstart.ver: Add enum functions to the global list.
4721
Scott James Remnant57f02a72007-03-11 12:53:49 +00004722 * util/initctl.c (start_action, stop_action): Imply --no-wait if
4723 we take the job id or name from an environment variable, since we'd
4724 end up waiting for ourselves otherwise
4725 * util/tests/test_initctl.c (test_start_action, test_stop_action):
4726 Update test cases to make sure no-wait is implied.
4727
Scott James Remnantcd84c312007-03-09 12:51:31 +000047282007-03-09 Scott James Remnant <scott@netsplit.com>
4729
Scott James Remnantb1c7eb22007-03-09 21:35:52 +00004730 * configure.ac: Bump version to 0.3.8
4731
Scott James Remnant79a3c9a2007-03-09 21:35:31 +00004732 * NEWS: Updated.
4733 * configure.ac: Increase version to 0.3.7
4734
Scott James Remnantcf8ede02007-03-09 19:56:07 +00004735 * init/tests/test_job.c (test_change_state): Add a test case for
4736 deleting the last instance of a replaced job.
4737 * init/job.c (job_change_state): When moving a instance of a job into
4738 the deleted state, check whether we should replace the job it's an
4739 instance of, and if so, change that job's state too.
4740 * TODO: Update.
4741
Scott James Remnant51881912007-03-09 18:15:58 +00004742 * util/initctl.c (handle_job_list): Always allocate current_list,
4743 since we need it to be the parent of pointers we attach to it.
4744 (handle_job_list_end): Always free the current list, only suppress
4745 output if there aren't any entries in it.
4746 (initctl_recv): Check the current_list pointer, no need for in_list
4747 (handle_job_instance, handle_job_instance_end, handle_job_status):
4748 Check current_list not in_list.
4749 * util/tests/test_initctl.c: Correct some memory leaks.
4750
Scott James Remnant46390a72007-03-09 17:38:35 +00004751 * init/process.c (process_setup_environment): Set the UPSTART_JOB_ID
4752 environment variable to the job's unique id.
4753 * init/tests/test_process.c (test_spawn): Make sure it's set.
4754
Scott James Remnant671c31c2007-03-09 17:34:34 +00004755 * util/man/initctl.8: Update the initctl manpage.
4756 * compat/sysv/man/reboot.8: Correct a minor grammar error.
4757 * compat/sysv/man/shutdown.8: Fix reference from runlevel to telinit.
4758
Scott James Remnantecf322c2007-03-09 16:58:48 +00004759 * README: Add a README that copies the text from the web page and
4760 adds some notes about recommended operating system versions.
4761
Scott James Remnant4f19cb92007-03-09 16:48:41 +00004762 * util/initctl.c: Completely rewrite initctl, top to bottom; handling
4763 of the new messages is done natively, meaning that the commands just
4764 vary the requests send and number of responses expected.
4765 * util/tests/test_initctl.c: Test all of the new code.
4766
Scott James Remnant06abbec2007-03-09 13:02:38 +00004767 * init/main.c: Improve restarting and rescuing a little; store the
4768 program path in a static variable so we can always access it, and
4769 use the exported loglevel to pass the same to the new process.
4770 * TODO: Update.
4771
Scott James Remnantcd84c312007-03-09 12:51:31 +00004772 * compat/sysv/shutdown.c: More error/fatal adjustments.
4773 * compat/sysv/telinit.c: More error/fatal adjustments.
4774
Scott James Remnantab1dd0d2007-03-08 12:29:02 +000047752007-03-08 Scott James Remnant <scott@netsplit.com>
4776
Scott James Remnant31421b72007-03-08 23:53:05 +00004777 * init/main.c (main, crash_handler): Promote deadly errors to nih_fatal
4778 * logd/main.c (main): Promote deadly errors to nih_fatal
4779 * compat/sysv/reboot.c (main): Promote deadly errors to nih_fatal
4780 * compat/sysv/shutdown.c (main, shutdown_now): Promote deadly errors
4781 to nih_fatal
4782 * compat/sysv/telinit.c (main): Promote deadly errors to nih_fatal
4783
Scott James Remnant12d741e2007-03-08 23:39:59 +00004784 * init/event.c (event_pending): The message that we're handling an
4785 event should be logged with --verbose.
4786
Scott James Remnant5cf17ea2007-03-08 15:42:32 +00004787 * init/cfgfile.c (cfg_parse_script): Remove the unnecessary check for
4788 a token inside a script block.
4789
Scott James Remnant3ee512d2007-03-08 14:30:21 +00004790 * TODO: Update.
4791
Scott James Remnant9435b8b2007-03-08 14:22:45 +00004792 * init/control.c (control_watch_jobs): Rename to control_subscribe_jobs
4793 and update to handle new event name.
4794 (control_unwatch_jobs): Rename to control_unsubscribe_jobs and update
4795 to handle the new event name.
4796 (control_watch_events): Rename to control_subscribe_events and update
4797 to handle the new event name.
4798 (control_unwatch_events): Rename to control_unsubscribe_events and
4799 update to handle the new event name.
4800 * init/tests/test_control.c (test_watch_jobs): Rename to
4801 test_subscribe_jobs and update to new event name.
4802 (test_unwatch_jobs): Rename to test_unsubscribe_jobs and update to
4803 new event name.
4804 (test_watch_events): Rename to test_subscribe_events and update to
4805 new event name.
4806 (test_unwatch_events): Rename to test_unsubscribe events and update
4807 to new event name.
4808
4809 * upstart/message.h: Rename the watch commands to subscribe/unsubscribe
4810 and regroup with new message numbers.
4811 * upstart/message.c (upstart_message_newv)
4812 (upstart_message_handle): Marshal the updated subscription messages.
4813 * upstart/tests/test_message.c (test_new, my_handler)
4814 (test_handle): Update tests to new names and numbers.
4815 * TODO: Update.
4816
Scott James Remnant47d4b8b2007-03-08 13:24:59 +00004817 * upstart/message.c (upstart_message_handle): Raise a the unknown
4818 message error if the type is unknown, rather than the invalid message
4819 error.
4820 * upstart/tests/test_message.c (test_handle): Correct test case.
4821
Scott James Remnant05345162007-03-08 12:37:09 +00004822 * init/job.c (job_change_state): Correct a problem here too, when
4823 moving from pre-stop to running, we don't want to emit a started event
4824 since we never emitted a stopping event and never killed the process
4825 anyway. We do need to notify the job as finished, since the process
4826 that tried to stop it will need to be told not to wait any longer.
4827 * init/tests/test_job.c (test_change_state): Add a test for pre-stop
4828 back to running.
4829
Scott James Remnantab1dd0d2007-03-08 12:29:02 +00004830 * doc/states.dot: Fix an error in the state diagram; when moving from
4831 starting back to waiting, due to a failed respawn, we need to emit
4832 the stopped event otherwise it will never happen.
4833 * doc/states.png: Update.
4834
Scott James Remnant609b24e2007-03-05 12:05:20 +000048352007-03-05 Scott James Remnant <scott@netsplit.com>
4836
Scott James Remnantfd5609b2007-03-05 20:48:06 +00004837 * upstart/message.c (upstart_message_new): Make this a wrapper around
4838 (upstart_message_newv): which has all the old code, but accepts a
4839 va_list instead of making its own.
4840 * upstart/message.h: Add prototype.
4841
Scott James Remnant502ea702007-03-05 20:47:18 +00004842 * init/main.c (crash_handler): Simply trying to leave a SEGV handler
4843 doesn't work so well, we end up repeating the problem instruction.
4844 We really can't resume from this point, and can't even jump elsewhere
4845 since our state is probably buggered up. Only thing for it is to
4846 re-exec ourselves with a clean state.
4847
Scott James Remnantb27ad2e2007-03-05 20:45:04 +00004848 * init/cfgfile.c (cfg_read_job, cfg_delete_handler): Don't try and
4849 free the magic (void *)-1 replacement (delete).
4850
Scott James Remnant4cd63672007-03-05 16:15:39 +00004851 * util/events.c, util/events.c, util/jobs.c, util/jobs.h: With the
4852 new message responses, that intermix event and job information freely,
4853 it no longer makes sense to distinguish between them. So fold these
4854 files back into the main initctl.c
4855 * util/initctl.h: Drop unused header.
4856 * util/Makefile.am (initctl_SOURCES): Update sources list.
4857 (TESTS): Change which tests we build
4858 (test_initctl_SOURCES, test_initctl_CFLAGS, test_initctl_LDFLAGS)
4859 (test_initctl_LDADD): Build the new combined test case binary, use
4860 an automake feature to rebuild initctl.c with -DTEST and a different
4861 .o file, and thus be able to define out main()
4862
4863 * util/tests/test_events.c, util/tests/test_jobs.c: Collapse the two
4864 test case files into one single
4865 * util/tests/test_initctl.c
4866
Scott James Remnant751245c2007-03-05 14:35:09 +00004867 * init/control.c (control_job_find): And implement the find function
4868 that returns a list of jobs matching an optional pattern.
4869 * init/tests/test_control.c: Make sure we do send all messages.
4870 (check_list): Complex function to check the responses to a job list
4871 (test_job_find): Test a couple of job lists.
4872 * init/tests/test_notify.c: Make sure we do send all messages.
4873
Scott James Remnant4ea9ddd2007-03-05 13:33:55 +00004874 * init/control.c (control_job_query): Implement the query message,
4875 this just needs to return the status or instance set.
4876 * init/tests/test_control.c (test_job_query): Test the query command.
4877 (check_job_status__deleted, check_job_status_end__deleted): Pair of
4878 functions to check we can query deleted jobs directly.
4879
Scott James Remnanteca04df2007-03-05 13:18:00 +00004880 * init/control.c (control_send_instance): Function to send an instance
4881 job, collating all of its instances together.
4882 * init/control.h: Update.
4883 * init/tests/test_control.c (test_send_instance): Check we receive
4884 the right messages.
4885 (check_job_instance, check_job_instance_end): Pair of functions to
4886 check the instance messages.
4887
Scott James Remnantd62b9042007-03-05 13:04:02 +00004888 * upstart/message.h: Add new UPSTART_JOB_INSTANCE and
4889 UPSTART_JOB_INSTANCE_END messages which we'll use to communicate that
4890 a job is an instance, and group the instances of it together.
4891 * upstart/message.c (upstart_message_new, upstart_message_handle):
4892 Marshal the new instance messages.
4893 * upstart/tests/test_message.c (test_new, my_handler)
4894 (test_handle): Test the new message types.
4895
Scott James Remnant609b24e2007-03-05 12:05:20 +00004896 * upstart/message.h: Restore arguments to JOB_LIST, but rename to
4897 pattern since that's what it is.
4898 * upstart/message.c (upstart_message_handle): Restore arguments
4899 with updated name.
4900 * upstart/tests/test_message.c (test_new, my_handler)
4901 (test_handle): Restore tests for arguments, rename and make sure we
4902 include a wildcard.
4903
Scott James Remnantf1091d12007-03-04 01:09:16 +000049042007-03-04 Scott James Remnant <scott@netsplit.com>
4905
Scott James Remnantbfb31a12007-03-04 20:52:43 +00004906 * upstart/message.h: Drop arguments to JOB_LIST.
4907 * upstart/message.c (upstart_message_new, upstart_message_handle):
4908 Drop arguments to JOB_LIST.
4909 * upstart/tests/test_message.c (test_new, my_handler)
4910 (test_handle): Drop the arguments from the test.
4911
Scott James Remnant117e16c2007-03-04 20:17:25 +00004912 * init/control.c (control_job_start): Update to return INVALID for
4913 instances and replacements; add the forgotten UPSTART_JOB message.
4914 (control_job_stop): Update to return INVALID for replacements; add
4915 the forgotten UPSTART_JOB message. Deal with instance masters
4916 magically by iterating all instances and stopping those instead.
4917 * init/tests/test_control.c (check_job_deleted): Rename to
4918 check_job_invalid and check that message.
4919 (check_job): Function to check the job we've acted upon.
4920 (test_job_start): Check that we get the UPSTART_JOB message first,
4921 restore the check on deleted jobs causing an error and add checks
4922 that instance and replacement jobs also cause an error.
4923 (test_job_stop): Check that we get the UPSTART_JOB message first,
4924 restore the check on deleted jobs causing an error. Make sure
4925 instances are handled.
4926
Scott James Remnant510b8082007-03-04 19:54:56 +00004927 * upstart/message.h: More message changes; add a JOB_FIND message
4928 and replace UPSTART_JOB_DELETED with UPSTART_JOB_INVALID since there's
4929 a few more problem conditions.
4930 * upstart/message.c (upstart_message_new, upstart_message_handle):
4931 Marshal the new message and update names.
4932 * upstart/tests/test_message.c (test_new, my_handler)
4933 (test_handle): Update tests to check the new message and update the
4934 values and names of the existing ones.
4935
Scott James Remnanta7e3bf12007-03-04 19:39:32 +00004936 * init/job.h (Job): Remove the delete flag, add replacement and
4937 replacement_for pointers instead.
4938 * init/job.c (job_new): Initialise replacement and replacement_for
4939 pointers to NULL.
4940 (job_find_by_name): Update to return what job the one we found is
4941 a replacement for, and to skip DELETED jobs.
4942 (job_instance): Make it simply illegal to call this for deleted jobs,
4943 instances or replacements.
4944 (job_change_goal): Make it illegal to change the goal of a replacement
4945 job.
4946 (job_free_deleted): Remove the previous code to handle deleted instance
4947 masters, because it's now bogus.
4948 (job_should_replace): New function to determine whether a job is
4949 replaceable.
4950 * init/tests/test_job.c (test_new): Check pointers are set.
4951 (test_copy): Check that replacement and replacement_for are not
4952 copied, since their state of an individual job.
4953 (test_find_by_name): Update tests to make sure we ignore deleted jobs,
4954 instances and replacements.
4955 (test_instance): Remove test that will now cause an assertion,
4956 and no longer check delete is set.
4957 (test_change_goal): Remove test that will now cause an assertion.
4958 (test_free_deleted): Remove test cases for deleted masters.
4959 (test_should_replace): Test the new check function.
4960 (test_change_state): Make sure that we end up in deleted for instances
4961 and replaced jobs, and that replacements become the real job.
4962 * init/cfgfile.c (cfg_read_job): Update to handle replacement jobs;
4963 the old job's previous replacement is discarded, and set to the
4964 current job; and then if the job should be replaced, it's moved
4965 to deleted (which should promote the new job).
4966 (cfg_delete_handler): Handle deletion of a job in a similar manner,
4967 except we sent the replacement pointer to the special -1 value since
4968 we have no actual replacement.
4969 * init/tests/test_cfgfile.c (test_watch_dir): Update tests to make
4970 sure that deletion and modification are handled wrt replacement.
4971 (test_read_job): Make sure that reparsing an existing file is handled.
4972 * init/tests/test_control.c (test_job_start): Remove checks that
4973 delete gets set to true for instances.
4974 (test_job_stop, test_job_start): Temporarily comment out deleted
4975 job behaviour, since that's been somewhat changed.
4976
Scott James Remnantffcbc5f2007-03-04 17:34:38 +00004977 * upstart/message.h: We're not going to return JOB_LIST for JOB_STOP
4978 since that's just awkward for the client; just act on the master,
4979 and return JOB_UNCHANGED.
4980
Scott James Remnant78dce1d2007-03-04 17:04:28 +00004981 * init/notify.c (notify_job_status): Move this function to
4982 * init/control.c (control_send_job_status): here, since we need it for
4983 the new control responses.
4984 (control_job_query): New single function to list all jobs or a
4985 particular job.
4986 * init/control.h: Add prototype.
4987 * init/tests/test_control.c (test_error_handler): Simplify this a
4988 little to just sending a NO_OP message, since we can send an entire
4989 stream of messages and leave them in the queue.
4990 (check_job_status__stopping, check_job_process)
4991 (check_job_status_end__stopping): Trio of check functions for a job
4992 status that's stopping, with an active main process.
4993 (test_send_job_status): Test the now global status function.
4994 (check_job_status__starting, check_job_status_end__starting): Pair
4995 of check functions for a starting job with no process yet.
4996 (test_watch_jobs, test_unwatch_jobs): Update to expect the full new
4997 job status messages, with an optional process part as well.
4998 (check_event): Function to check an event.
4999 (test_watch_events): Minor update to use above function.
5000 (check_job_status__waiting, check_job_status_end__waiting): Pair of
5001 check functions for the first step in starting a job (goal change only)
5002 (check_job_unknown, check_job_deleted, check_job_unchanged): Trio
5003 of functions to check common error responses.
5004 (test_job_start): Update tests to newer behaviour.
5005 (check_job_status__running, check_job_status_end__running)
5006 (check_job_status__pre_stop, check_job_status_end__pre_stop): Checks
5007 for the states we go through when stopping a job.
5008 (test_job_stop): Update tests to newer behaviour.
5009 * init/notify.c (notify_job, notify_job_event, notify_job_finished):
5010 Update to call the newly exported function.
5011 * init/job.c: Make job_id and job_id_wrapped externally available.
5012 * init/job.h: Update.
5013 * init/event.c: Make emission_id and emission_id_wrapped externally
5014 available.
5015 * init/event.h: Update.
5016
Scott James Remnanta90e6422007-03-04 14:41:05 +00005017 * upstart/message.h: Rename UPSTART_JOB_INVALID to
5018 UPSTART_JOB_UNCHANGED, as it's not really invalid just a no-op
5019 * upstart/message.c (upstart_message_new, upstart_message_handle):
5020 Update the constant, fields are unchanged,
5021 * upstart/tests/test_message.c (test_new, my_handler)
5022 (test_handle): Rename constants/messages.
5023
Scott James Remnant82626a92007-03-04 14:37:12 +00005024 * upstart/message.h: Turns out we need extra errors to indicate that
5025 the job was deleted or already at that goal, otherwise the client
5026 would sit there waiting for the finished event.
5027 * upstart/message.c (upstart_message_new, upstart_message_handle):
5028 Marshal the new error messages.
5029 * upstart/tests/test_message.c (test_new, my_handler)
5030 (test_handle): Test the handling of the new messages.
5031
Scott James Remnantd39165c2007-03-04 14:27:41 +00005032 * init/tests/test_job.c (test_free_deleted): Found a bug; because
5033 master instances never change state, they never end up in the deleted
5034 state so are never reaped. Add some test cases for cleaning them up,
5035 but not while they have remaining instances.
5036 * init/job.c (job_free_deleted): Implement the bug fix.
5037
Scott James Remnantd3cbc562007-03-04 14:18:36 +00005038 * init/job.c (job_instance): Split out the instance spawning code
5039 into its own function, as we'll frequently need a pointer to the
5040 instance before we try and change the goal.
5041 (job_change_goal): Clean this function back up again, it no longer
5042 needs to return values and can assert that it's never called for
5043 deleted jobs or instance mastersr.
5044 (job_handle_event): Spawn an instance when we get a start event.
5045 * init/job.h: Update.
5046 * init/tests/test_job.c (test_instance): Check instance creation.
5047 (test_change_goal): Update tests now that it doesn't return a value
5048 again, and doesn't spawn instances itself.
5049 (test_handle_event): Make sure instances are spawned.
5050
Scott James Remnant5bcc62b2007-03-04 13:27:15 +00005051 * init/tests/test_event.c (test_poll): Needs a slight fix now that
5052 we generate more events than we check, and that subscriptions go
5053 away automatically.
5054
Scott James Remnantb844efb2007-03-04 13:00:06 +00005055 * init/notify.c (notify_job_status): Static function to handle
5056 sending the more complicated job status message series
5057 (notify_job): Call notify_job_status() to send the new-style message
5058 (notify_job_event): Send the new UPSTART_EVENT_CAUSED message with
5059 the emission id, then call notify_job_status() to send the new-style
5060 common status message.
5061 (notify_job_finished): New function to be called when we reach the
5062 job rest state, notifies and unsubscribes directly subscribed
5063 processes, and includes failed information.
5064 (notify_event_finished): Unsubscribe processes after sending the
5065 finished event, since the event has gone away. Also don't send
5066 this to processes subscribed to all events, since it's not useful
5067 for them.
5068 * init/notify.h: Add prototype.
5069 * init/tests/test_notify.c: Update all test cases and helper
5070 functions to the new message types.
5071 (test_job_finished): Check the new finished message is sent with
5072 a status message preceeding it.
5073 * init/job.c (job_change_state, job_change_state): Notify subscribed
5074 processes with notify_job_finished() when in the running (for service)
5075 or waiting states, just before we drop the cause.
5076
Scott James Remnant79c95ff2007-03-04 12:30:37 +00005077 * upstart/message.h: Add failed, failed_process and exit_status
5078 arguments to UPSTART_JOB_FINISHED.
5079 * upstart/message.c (upstart_message_new, upstart_message_handle):
5080 Marshal the new arguments.
5081 * upstart/tests/test_message.c (test_new, my_handler)
5082 (test_handle): Test the new arguments.
5083
Scott James Remnantf1091d12007-03-04 01:09:16 +00005084 * upstart/message.h: Update the message types, introducing a more
5085 structured job message set and replacing the UPSTART_EVENT_JOB_STATUS
5086 message with UPSTART_EVENT_CAUSED which will be immediately followed
5087 by an ordinary UPSTART_JOB_STATUS message.
5088 * upstart/message.c (upstart_message_new, upstart_message_handle):
5089 Marshal the new messages.
5090 * upstart/tests/test_message.c (test_new, my_handler)
5091 (test_handle): Test the new message types.
5092 * TODO: Update.
5093
Scott James Remnant15538792007-03-03 15:30:23 +000050942007-03-03 Scott James Remnant <scott@netsplit.com>
5095
Scott James Remnantcd157612007-03-03 17:09:09 +00005096 * TODO: Update.
5097
Scott James Remnant8568a062007-03-03 17:06:43 +00005098 * init/cfgfile.c (cfg_parse_exec, cfg_parse_script): Separate out
5099 the parsing of an exec or script stanza into separate functions,
5100 seeing as this is quite a common operation. This also means we
5101 just need to change them in one place now.
5102 (cfg_parse_process): Function to call either of the above depending
5103 on the next argument.
5104 (cfg_stanza_exec): Call cfg_parse_exec instead.
5105 (cfg_stanza_script): Call cfg_parse_script instead.
5106 (cfg_stanza_pre_start, cfg_stanza_post_start)
5107 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Call cfg_parse_process
5108 with the right arguments instead of doing by hand in each function.
5109
Scott James Remnant15538792007-03-03 15:30:23 +00005110 * init/event.c (event_emit_next_id): Split the id assigning code into
5111 a static inline function for easier modification.
5112 * init/job.c (job_next_id): Use the same style function here too.
5113
Scott James Remnant3d39c7d2007-03-02 10:50:14 +000051142007-03-02 Scott James Remnant <scott@netsplit.com>
5115
Scott James Remnant9c7a9112007-03-02 17:08:46 +00005116 * init/event.c (event_emit): Port the slightly more efficient in the
5117 early case code from job_new.
5118
Scott James Remnantb61f5932007-03-02 17:06:44 +00005119 * init/job.h (Job): Add a unique id to the job structure.
5120 * init/job.c (job_new): Assign an incrementing id to each new job
5121 allocated.
5122 (job_find_by_id): Locate a job by its unique id, sadly not very
5123 efficient in a hash table ;-)
5124 (job_name): New hash key function since name isn't the first entry
5125 anymore.
5126 (job_init): Change hash key function.
5127 * init/tests/test_job.c (test_find_by_id): Make sure we can find a
5128 job by its id.
5129
Scott James Remnant5e453162007-03-02 16:27:57 +00005130 * init/job.c (job_change_goal): Return the new instance in that
5131 circumstance, and clean up a little bit.
5132 * init/job.h: Update prototype.
5133 * init/tests/test_job.c (test_change_goal): Update tests.
5134
Scott James Remnant3caa9f42007-03-02 15:09:34 +00005135 * init/job.c (job_find_by_name): Skip jobs marked for deletion too.
5136 * init/tests/test_job.c (test_find_by_name): Update test case.
5137
Scott James Remnant0720acf2007-03-02 14:58:27 +00005138 * init/event.h, init/notify.h, upstart/message.h: Provide C-level names
5139 for enums, this makes the compiler generate things that gdb can get.
5140
Scott James Remnantf60ee622007-03-02 13:13:11 +00005141 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
5142 Change process argument to be a plain ProcessType, this means we
5143 know exactly which process we're trying to run or kill.
5144 (job_change_state): Update calls to job_run_process
5145 and job_kill_process
5146 * init/tests/test_job.c (test_run_process, test_kill_process): Update
5147 function calls to just pass a ProcessType in.
5148
Scott James Remnantdb61ca82007-03-02 13:02:42 +00005149 * upstart/enum.h: Rename JobAction to ProcessType.
5150 * upstart/enum.c (job_action_name): Rename to process_name.
5151 (job_action_from_name): Rename to process_from_name.
5152 * upstart/tests/test_enum.c (test_action_name, test_action_from_name):
5153 Rename and update to match.
5154 * init/job.c (job_new, job_copy, job_change_state)
5155 (job_next_state): Change JOB_*_ACTION constants to PROCESS_*.
5156 (job_find_by_pid): Change JobAction argument to ProcessType.
5157 (job_emit_event): Call process_name on the failed process.
5158 (job_child_reaper): Update to use ProcessType instead of JobAction.
5159 * init/job.h (Job): Change type of failed_process to ProcessType.
5160 * init/tests/test_job.c (test_find_by_pid): Update to use ProcessType
5161 instead of JobAction in tests.
5162 (test_new, test_copy, test_change_goal, test_change_state)
5163 (test_next_state, test_run_process, test_kill_process)
5164 (test_child_reaper, test_handle_event_finished): Change JOB_*_ACTION
5165 constants to PROCESS_*
5166 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
5167 (cfg_stanza_pre_start, cfg_stanza_post_start)
5168 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Change JOB_*_ACTION
5169 constants to PROCESS_*
5170 * init/tests/test_cfgfile.c (test_stanza_exec)
5171 (test_stanza_script, test_stanza_pre_start)
5172 (test_stanza_post_start, test_stanza_pre_stop)
5173 (test_stanza_post_stop, test_read_job, test_watch_dir): Change
5174 JOB_*_ACTION constants to PROCESS_*
5175 * init/tests/test_event.c (test_poll): Change JOB_*_ACTION constants
5176 to PROCESS_*
5177 * init/tests/test_control.c (test_job_start, test_job_stop): Change
5178 JOB_*_ACTION constants to PROCESS_*
5179
Scott James Remnant4a104b52007-03-02 12:21:45 +00005180 * init/cfgfile.c (cfg_watch_dir): Restore the prefix argument; pass
5181 as the data pointer to the inotify callbacks and visitor function.
5182 Change the return value to be the watch structure.
5183 (cfg_job_name): Add prefix argument and prepend to relative path.
5184 (cfg_create_modify_handler, cfg_delete_handler, cfg_visitor): Get
5185 the prefix for the job names from the data pointer and pass to
5186 cfg_job_name().
5187 * init/cfgfile.h: Update prototypes.
5188 * init/tests/test_cfgfile.c (test_watch_dir): Actually test the
5189 watch functions.
5190 * init/main.c (main): Pass NULL for the prefix for the global job
5191 directory, compare the return value against (void *)-1.
5192 * TODO: Update.
5193
Scott James Remnant002dcda2007-03-02 11:05:56 +00005194 * init/cfgfile.c (cfg_stanza_on): Drop the simple on stanza.
5195 * init/tests/test_cfgfile.c (test_stanza_on): Remove test case.
5196
Scott James Remnant3d39c7d2007-03-02 10:50:14 +00005197 * TODO: Update.
5198
Scott James Remnantbc1ebc02007-03-01 12:27:09 +000051992007-03-01 Scott James Remnant <scott@netsplit.com>
5200
Scott James Remnant75914fd2007-03-01 19:05:45 +00005201 * util/jobs.c (handle_job_status): Drop the process field from the
5202 output for now.
5203 * util/events.c (handle_event_job_status): Likewise
5204 * util/tests/test_jobs.c (test_start_action, test_list_action)
5205 (test_jobs_action): Drop pid from messages we simulate.
5206 * util/tests/test_events.c (test_emit_action): Likewise.
5207
Scott James Remnant0c68cc12007-03-01 18:53:23 +00005208 * upstart/message.c (upstart_message_new, upstart_message_handle):
5209 Remove the pid field from the job status and event job status
5210 messages.
5211 * upstart/message.h: Update description of job status and event
5212 job status message to remove the pid field.
5213 * upstart/tests/test_message.c (test_new, my_handler)
5214 (test_handle): Remove checks using the pid field.
5215
Scott James Remnantd134fe82007-03-01 18:46:53 +00005216 * init/control.c (control_job_start, control_job_stop)
5217 (control_job_query, control_job_list): Remove the pid field from
5218 the messages, it'll come back later when we get better message
5219 formats.
5220 * init/tests/test_control.c (check_job_status, check_job_waiting)
5221 (check_job_started, check_job_stopped): Remove checks on the process
5222 id, since that field is gone from the message.
5223 (test_job_stop): Use the pid field of the main process.
5224 (test_job_start): Initialise the main action process.
5225
Scott James Remnantdd1a6742007-03-01 18:42:42 +00005226 * init/notify.c (notify_job, notify_job_event): Remove the pid field
5227 from the message, it'll come back later when we get better message
5228 formats.
5229 * init/tests/test_notify.c (check_job_status)
5230 (check_event_job_status): Remove checks on the pid, since that field
5231 is no longer present.
5232
Scott James Remnante2ce6372007-03-01 18:37:53 +00005233 * init/job.c (job_process_copy): Use job_process_new here, oops.
5234
Scott James Remnant8ed70e42007-03-01 18:34:37 +00005235 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
5236 (cfg_stanza_pre_start, cfg_stanza_post_start)
5237 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Use job_process_new
5238 to allocate process structures and store in the process array.
5239 * init/tests/test_cfgfile.c (test_read_job, test_stanza_exec)
5240 (test_stanza_script, test_stanza_pre_start)
5241 (test_stanza_post_start, test_stanza_pre_stop)
5242 (test_stanza_post_stop): Update test cases to use process array
5243 member information.
5244
Scott James Remnant42479f92007-03-01 18:12:34 +00005245 * init/tests/test_event.c (test_poll): Update to use newer job process
5246 array and find the pid under there.
5247
Scott James Remnantc8f15ac2007-03-01 18:03:22 +00005248 * init/job.h (Job): Remove the pid and aux_pid fields; replace the
5249 individual JobProcess pointers with an array of them of a fixed
5250 minimum size; replace failed_state with failed_process.
5251 (JobProcess): add a pid field here, so now we can obtain the pid on
5252 an individual process/action basis rather than global.
5253 * init/job.c (job_process_new): Function to create a JobProcess
5254 structure, setting the initial values to FALSE/NULL/0.
5255 (job_process_copy): Function to copy a JobProcess.
5256 (job_new): Don't initialise the pid or aux_pid members, initialise
5257 the process array to a fixed initial size and set the members to NULL,
5258 initialise the failed_process member to -1.
5259 (job_copy): Update to use job_process_copy and copy the process array.
5260 (job_find_by_pid): Look through the process structures in the job's
5261 process array to find the pid, and optionally return which action it
5262 was.
5263 (job_change_state): Call job_kill_process in the JOB_KILLED state if
5264 we have a main process and that has a pid, pass in the main process.
5265 (job_next_state): Check the process id of the main process when
5266 deciding what the next state is for running.
5267 (job_run_process): Store the process id in the process structure
5268 (job_kill_process): Accept a process structure and use that to obtain
5269 the process id we need to send TERM too. Remove the code that forced
5270 a state change if kill() failed, since we will get a child signal
5271 anyway and should do it there.
5272 (job_kill_timer): Likewise, accept a process structure and don't
5273 forcibly change the state anymore.
5274 (job_child_reaper): Rewrite to switch based on the action that died,
5275 rather than the state we were in; assert that the state is what we
5276 expected.
5277 (job_emit_event): The argument to the failed event is now the action
5278 name, rather than the state name; an action of -1 indicates that
5279 respawn failed.
5280 * init/tests/test_job.c (test_process_new, test_process_copy): Make
5281 sure the structure is created and copied properly.
5282 (test_new, test_copy): Drop checks on the pid and aux_pid members,
5283 add checks for the process array and pid members of processes.
5284 (test_find_by_pid): Update test case to make sure we can find the pid
5285 of any process, returning the action index rather than the process
5286 pointer.
5287 (test_run_process, test_kill_process, test_change_goal)
5288 (test_change_state, test_next_state, test_child_reaper): Update test
5289 cases to use pid fields inside process structures rather than the
5290 pid or aux_pid members.
5291 (test_handle_event, test_handle_event_finished)
5292 (test_free_deleted): Update to avoid pid field checks.
5293
Scott James Remnant4652e3b2007-03-01 16:25:56 +00005294 * upstart/enum.h (JobAction): Enumeration of different actions.
5295 * upstart/enum.c (job_action_name, job_action_from_name): Enumeration
5296 to string conversion functions.
5297 * upstart/tests/test_enum.c (test_action_name)
5298 (test_action_from_name): Tests for the new functions.
5299
Scott James Remnantdc9d7902007-03-01 12:57:37 +00005300 * init/cfgfile.c (cfg_read_job): Instead of trying to copy over an
5301 old job's state and instances into the new one, mark the old job
5302 as deleted. This ensures we never end up applying a new post-stop
5303 script to a job started with an old pre-start script, etc. It also
5304 makes life so much simpler.
5305 * init/tests/test_cfgfile.c (test_read_job): Update tests to make
5306 sure the old job is marked for deletion, instead of freed.
5307 * TODO: Update.
5308
Scott James Remnant26a41cf2007-03-01 12:50:10 +00005309 * init/notify.c (notify_job): Split out notification to processes
5310 subscribed to the cause event into a new function
5311 (notify_job_event): We can call this when we change cause.
5312 * init/job.c (job_change_state): Notify anyone subscribed to the
5313 job after we've changed the state, rather than before, otherwise
5314 we won't know the new pids or anything.
5315 (job_change_cause): Call notify_job_event before changing the cause
5316 so that subscribers get a final status update.
5317 * init/tests/test_notify.c (test_job_event): Check the new function.
5318 * TODO: Update.
5319
Scott James Remnantbc1ebc02007-03-01 12:27:09 +00005320 * init/cfgfile.c (cfg_stanza_respawn): Remove the shortcut that
5321 lets you specify "respawn COMMAND". It was confusing as it hid
5322 the common "[when] exec"/"[when] script" syntax, made it non-obvious
5323 that "exec" and "respawn" were the same flag, etc.
5324 * init/tests/test_cfgfile.c (test_stanza_respawn): Update tests.
5325 (test_stanza_service): Fix test case to not use shortcut.
5326 * logd/event.d/logd.in: Update to not use respawn shortcut.
5327
Scott James Remnantb1f34052007-02-25 09:12:53 +000053282007-02-25 Scott James Remnant <scott@netsplit.com>
5329
Scott James Remnant43d8f092007-02-25 12:56:37 +00005330 * init/job.c (job_child_reaper): Shift the signal value into the
5331 higher byte to make it easier to detect, and not stamp over exit
5332 statuses between 128 and 255.
5333 (job_emit_event): Detect the signal stored in the new way.
5334 * init/cfgfile.c (cfg_stanza_normal): Store signal in the higher bytes.
5335 * init/tests/test_job.c (test_copy, test_change_state)
5336 (test_child_reaper): Update test cases.
5337 * init/tests/test_cfgfile.c (test_stanza_normal): Update test.
5338
Scott James Remnant8a77b5d2007-02-25 11:45:47 +00005339 * TODO: Update.
5340
Scott James Remnant2c950692007-02-25 09:13:38 +00005341 * init/event.h (PWRSTATUS_EVENT): Add new power-status-changed event.
5342 * init/main.c (pwd_handler): Handle the SIGPWR signal by generating
5343 the new event, leave it up to a job to parse the file and do
5344 whatever it likes.
5345
Scott James Remnantb1f34052007-02-25 09:12:53 +00005346 * TODO: Update.
5347
Scott James Remnant7e3ad172007-02-13 15:53:39 +000053482007-02-13 Scott James Remnant <scott@netsplit.com>
5349
5350 * upstart/tests/test_message.c (test_reader, test_handle_using)
5351 (test_handle); Usual fix for gcc optimiser thinking that fixed
5352 for loops might not be.
5353 * init/tests/test_job.c (test_run_process, test_kill_process):
5354 Likewise.
5355 * init/tests/test_notify.c (test_subscription_find): I still don't
5356 know what a type-punned pointer is, nor why dereferencing such a
5357 thing would break strict-aliasing rules.
5358 * init/tests/test_cfgfile.c (test_read_job): More type-punning.
5359 * util/tests/test_jobs.c (test_start_action): More for-loop action.
5360 * util/tests/test_events.c (test_emit_action): And again.
5361
Scott James Remnant5c89c502007-02-11 14:08:19 +000053622007-02-11 Scott James Remnant <scott@netsplit.com>
5363
Scott James Remnant17305e12007-02-11 18:20:19 +00005364 * init/job.c (job_change_goal): We need to be able to stop a running
5365 job without a process, because that's what a job-as-state is! The
5366 check was added because job_child_reaper calls job_change_goal and
5367 then job_change_state immediately after, we should fix that instead.
5368 (job_child_reaper): If we call job_change_goal while in the running
5369 state, it will call job_change_state for us; so check for that first
5370 and don't change the state!
5371 * init/tests/test_job.c (test_change_goal): Update the test to ensure
5372 that we can stop a job with no running process.
5373
Scott James Remnantddda5f92007-02-11 14:18:00 +00005374 * init/cfgfile.c (cfg_stanza_normalexit): normalexit is inconsistent,
5375 change to "normal exit"
5376 * init/tests/test_cfgfile.c (test_stanza_normalexit): Update.
5377
Scott James Remnant5c89c502007-02-11 14:08:19 +00005378 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
5379 (cfg_stanza_pre_start, cfg_stanza_post_start)
5380 (cfg_stanza_pre_stop, cfg_stanza_post_stop, cfg_stanza_respawn):
5381 We're not going to allow stanza keywords to be quoted, since this
5382 gives us an easy way to allow users to make something explicitly
5383 not a keyword.
5384
Scott James Remnant5dd50e32007-02-10 00:44:44 +000053852007-02-10 Scott James Remnant <scott@netsplit.com>
5386
Scott James Remnant9675c072007-02-10 21:36:48 +00005387 * configure.ac: Bump version to 0.3.6
5388
Scott James Remnant4e977172007-02-10 21:24:29 +00005389 * configure.ac: Increase version to 0.3.5
5390 * NEWS: Update.
5391 * TODO: Update.
5392
Scott James Remnanta2f0a542007-02-10 18:07:26 +00005393 * TODO: More notes.
5394
Scott James Remnant78456a52007-02-10 17:46:21 +00005395 * TODO: Note an issue with using JobProcess->pid
5396
Scott James Remnantd11d0fd2007-02-10 17:45:17 +00005397 * init/cfgfile.c (cfg_stanza_pre_start, cfg_stanza_post_start)
5398 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Add a needed check
5399 for a token when parsing "exec". Correct line number we expect
5400 to see the duplicated value on. Correct expected error for missing
5401 argument from "Unexpected token" to "Expected token".
5402
5403 * init/tests/test_cfgfile.c (main): Actually invoke the tests for
5404 the scripts.
5405
Scott James Remnant2ebe37b2007-02-10 17:35:33 +00005406 * init/cfgfile.c (cfg_read_job): Correct type of lineno in error.
5407
Scott James Remnant178f3a62007-02-10 17:34:02 +00005408 * TOOD: Minor notify bug
5409
Scott James Remnante72695c2007-02-10 17:11:26 +00005410 * TODO: Big update.
5411
Scott James Remnant743c1c12007-02-10 16:49:17 +00005412 * init/tests/test_job.c (test_child_reaper): Make sure that we can
5413 reap post-start and pre-stop processes, and have only the aux_pid
5414 changed. Also make sure that if the running process dies while
5415 in these states, with or without an aux process, that we don't
5416 transition badly.
5417
Scott James Remnanta54bfd02007-02-10 14:33:32 +00005418 * init/job.c (job_find_by_pid): Check aux_pid as well.
5419 * init/tests/test_job.c (test_find_by_pid): Make sure we can find it.
5420
Scott James Remnant153e3b52007-02-10 14:15:47 +00005421 * init/job.h (Job): Add an auxiliary pid member.
5422 * init/job.c (job_new): Initialise the aux_pid member.
5423 (job_change_state): Run the post-start and pre-stop scripts when we
5424 enter the state with the same name (assuming they exist).
5425 (job_run_process): Store the pid in aux_pid when starting the
5426 post-start or pre-stop processes.
5427 * init/tests/test_job.c (test_change_state): Add tests for running
5428 the new post-start and pre-stop scripts; which get their process ids
5429 stored in aux_pid instead of pid.
5430 (test_new): Make sure the aux_pid member is initialised properly.
5431 (test_copy): Make sure the aux_pid member is not copied.
5432
5433 * TODO: Update.
5434
Scott James Remnantf415d8d2007-02-10 13:55:04 +00005435 * init/tests/test_job.c (test_change_state): Add a check for the
5436 daemon stanza holding the job in spawned; we snuck this in a while
5437 back and never tested it (there's no support to get it out of
5438 spawned yet).
5439
Scott James Remnante9332be2007-02-10 13:46:50 +00005440 * init/job.h (Job): Add new post_start and pre_stop scripts.
5441 * init/job.c (job_new): Initialise new scripts to NULL.
5442 (job_copy): Copy the information from the new scripts over as well.
5443 * init/tests/test_job.c (test_new): Check they're initialised.
5444 (test_copy): Check that the information is copied properly.
5445 * init/cfgfile.c (cfg_stanza_post_start, cfg_stanza_pre_stop): Add
5446 new script stanza functions for the additional two scripts that
5447 we want.
5448 * init/tests/test_cfgfile.c (test_stanza_post_start)
5449 (test_stanza_pre_stop): Add tests for the new stanzas.
5450
Scott James Remnant5dd50e32007-02-10 00:44:44 +00005451 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script): Rewrite to
5452 allocate a JobProcess and parse the command or script into it.
5453 (cfg_read_job): Fix the long broken assumption that pid_file and
5454 pid_binary are required for respawn, when they're actually required
5455 for daemon.
5456 (cfg_stanza_start, cfg_stanza_stop): Remove script second-level.
5457 (cfg_stanza_respawn): Parse into the job's process.
5458 (cfg_stanza_pre_start, cfg_stanza_post_stop): New stanzas for the
5459 processes alone.
5460 * init/tests/test_cfgfile.c (test_read_job): Update a few test
5461 cases to match reality.
5462 (test_stanza_start, test_stanza_stop): Remove script-related checks.
5463
Scott James Remnante885d552007-02-09 00:01:46 +000054642007-02-09 Scott James Remnant <scott@netsplit.com>
5465
Scott James Remnant315a80a2007-02-09 22:50:00 +00005466 * init/tests/test_job.c (test_kill_process): Poll the event queue
5467 after each test to get rid of the allocated events and make valgrind
5468 happy.
5469 * init/tests/test_control.c (test_job_start, test_job_stop)
5470 (test_event_emit): Poll the event queue after each test to get rid
5471 of the allocated events, as they make valgrind complain.
5472 (test_event_emit): Free args and env when done.
5473
Scott James Remnant1ada0e22007-02-09 22:40:51 +00005474 * init/job.h (JobName): Drop obsolete structure
5475 (JobProcess): Add a new structure to represent a single process
5476 within the job, instead of using two variables to pick either the
5477 script or command.
5478 (Job): Change command and script to a single JobProcess called process;
5479 change start_script and stop_script to a JobProcess called pre_start
5480 and post_stop respectively.
5481 * init/job.c (job_new): Initialise new members to NULL.
5482 (job_copy): Copy the process structures across, including contents.
5483 (job_change_state): Call job_run_process passing in the structure;
5484 rather than fiddling with if statements.
5485 (job_run_script, job_run_command, job_run_process): Combine all of
5486 these three functions into a single new job_run_process function.
5487 * init/tests/test_job.c (test_new, test_copy, test_change_goal)
5488 (test_change_state, test_child_reaper)
5489 (test_handle_event_finished): Change to using JobProcess for when
5490 we need to construct a command.
5491 (test_run_script, test_run_command): Merge into single new
5492 (test_run_process) function.
5493 * init/tests/test_event.c (test_poll): Replace command with process.
5494 * init/tests/test_control.c (test_job_start): Change to using
5495 JobProcess to specify the command.
5496
Scott James Remnantc6740472007-02-09 21:16:28 +00005497 * init/main.c (main): Run job_free_deleted each time through the
5498 main loop.
5499
Scott James Remnantcb468602007-02-09 21:13:16 +00005500 * init/job.c (job_change_goal): Minor tweak to the logic; we may
5501 have just made the job an instance, that should still let us stop
5502 the one underneath.
5503
Scott James Remnant3fbdda72007-02-09 21:12:10 +00005504 * TODO: Update.
5505
Scott James Remnantdde96ff2007-02-09 21:10:45 +00005506 * util/jobs.c (do_job): Always expect a list of replies.
5507
Scott James Remnantf9409952007-02-09 21:02:18 +00005508 * init/control.c (control_job_status, control_job_stop)
5509 (control_job_query): Reply with information about all instances of
5510 the job.
5511 * init/tests/test_control.c (test_job_status, test_job_stop)
5512 (test_job_query): Make sure we get the list end even for a single job;
5513 and make sure we get details of all instances attached to the job.
5514
Scott James Remnant6cfc8ab2007-02-09 20:34:37 +00005515 * init/tests/test_job.c (test_change_goal): Check that starting
5516 an instance job actually starts a new instance of it.
5517
Scott James Remnant87c46472007-02-09 20:05:32 +00005518 * init/cfgfile.c (cfg_stanza_limit): Support the word "unlimited" in
5519 limit arguments for both the soft and hard values.
5520 * init/tests/test_cfgfile.c (test_stanza_limit): Make sure that we
5521 can make limits be unlimited.
5522
Scott James Remnant22ac92f2007-02-09 19:39:42 +00005523 * init/event.c (event_copy): Function to copy an event structure.
5524 * init/event.h: Add prototype.
5525 * init/tests/test_event.c (test_copy): Make sure we copy the event
5526 correctly, with or without arguments and/or environment.
5527 * init/job.c (job_copy): Function to copy a job structure, leaving
5528 the state as it is.
5529 * init/job.h: Add prototype.
5530 * init/tests/test_job.c (test_copy): Make sure that we copy the
5531 job details whether they are NULL or non-NULL, but don't copy the
5532 state.
5533 * init/init.supp: Update supression.
Scott James Remnant099ece22007-02-09 18:13:51 +00005534 * init/job.c (job_find_by_name): If we get a job that's an instance,
5535 return what it's an instance of.
5536 * init/tests/test_job.c (test_find_by_name): Restore accidentally
5537 deleted test function; test that we get the real job, not an instance.
5538
Scott James Remnant99e3ecc2007-02-09 18:08:45 +00005539 * init/job.c (job_new): instance_of is initialised to NULL.
5540 * init/job.h: Add a new instance_of pointer, pointing to the parent
5541 that we're an instance of.
5542 * init/tests/test_job.c (test_new): Check that.
5543 * init/tests/test_cfgfile.c (test_read_job): Make sure instance_of
5544 pointers are updated.
5545
Scott James Remnant4513fae2007-02-09 17:52:32 +00005546 * init/job.c (jobs): Store jobs in a hash table.
5547 (job_new): Add to hash table, not to a list.
5548 (job_handle_event, job_handle_event_finished, job_detect_stalled)
5549 (job_free_deleted): Iterate across the hash table, rather than list.
5550 (job_find_by_name): Use nih_hash_lookup, we keep this function because
5551 we'll add "is instance or not" smarts soon!
5552 (job_find_by_pid): Iterate across the entire hash table.
5553 * init/tests/test_job.c (test_find_by_name): Drop test since this
5554 function is now gone.
5555 (test_free_deleted): Can't assume things are in a line now.
5556 * init/control.c (control_job_list): Iterate the hash table.
5557
Scott James Remnant3f9624c2007-02-09 17:16:07 +00005558 * init/event.c: Don't hide the events list anymore
5559 * init/event.h: Publish it and the init function.
5560 * init/job.c: Don't hide the jobs list anymore.
5561 (job_list): Since we don't hide it, we can drop this.
5562 * init/job.h: Publish it and the init function.
5563 * init/notify.c: Don't hide the subscriptions list anymore.
5564 * init/notify.h: Publish it and the init function.
5565 * init/control.c (control_job_list): Iterate the job list directly
5566 * init/tests/test_control.c (test_event_emit): Use the events list
5567 available to us.
5568 * init/tests/test_event.c (test_poll): Call job_init directly and
5569 just use the events list available to us.
5570 * init/tests/test_job.c (test_new): Call job_init directly.
5571 (test_change_state): Use the events list available to us.
5572 * init/tests/test_notify.c (test_unsubscribe): Use the subscriptions
5573 list available to us.
5574
Scott James Remnant9709a8d2007-02-09 16:08:21 +00005575 * doc/states.dot: Add updated state graph.
5576 * doc/Makefile.am (EXTRA_DIST): Ship the states diagram.
5577 (states.png): Include rules to build the png, we'll put it in bzr
5578 anyway, but this is useful.
5579
Scott James Remnant92b01602007-02-09 15:46:55 +00005580 * init/cfgfile.c (cfg_delete_handler): Handle deleted jobs; mark
5581 the job as deleted, and if it's dormant, invoke a state change.
5582
Scott James Remnant9c0215a2007-02-09 15:42:20 +00005583 * upstart/enum.h: Add a new JOB_DELETED state.
5584 * upstart/enum.c (job_state_name, job_state_from_name): Add the new
5585 state to the string functions.
5586 * upstart/tests/test_enum.c (test_state_name)
5587 (test_state_from_name): Check the enum works.
5588 * init/job.c (job_change_goal): New decision; we can start a waiting
5589 job if it's marked delete (it might be a new instance) -- we'll use
5590 the new deleted state to decide that we shouldn't.
5591 (job_change_state): Once we reach waiting, if the job is to be deleted,
5592 move to the next state.
5593 (job_next_state): The next state for a waiting job if the goal is stop
5594 is deleted. We should never call job_next_state () for a deleted job.
5595 (job_free_deleted): Very simple function, just detects
5596 deleted jobs and frees them.
5597 * init/job.h: Add prototype for new function.
5598 * init/tests/test_job.c (test_change_goal): Update test to use new
5599 deleted state; and don't even change the goal.
5600 (test_change_state): Add a check to make sure we end up in deleted.
5601 (test_next_state): Make sure waiting goes to deleted.
5602 (test_free_deleted): Check the function.
5603
Scott James Remnant07dd5db2007-02-09 15:20:25 +00005604 * init/job.c (job_change_goal): Don't try and start a job if it's
5605 marked to be deleted and is just waiting for cleanup.
5606 * init/tests/test_job.c (test_change_state): Make sure that the cause
5607 is released when we reach waiting.
5608
Scott James Remnanta1ade132007-02-09 15:07:30 +00005609 * init/tests/test_cfgfile.c (test_read_job): Make sure that a deleted
5610 job gets resurrected.
5611
Scott James Remnant25873b52007-02-09 13:35:43 +00005612 * init/cfgfile.c (cfg_visitor): Correct number of arguments and call
5613 to cfg_job_name.
5614
Scott James Remnant3b5daf62007-02-09 13:31:01 +00005615 * TODO: Update.
5616
Scott James Remnant845c6cb2007-02-09 13:29:27 +00005617 * init/cfgfile.c (cfg_stanza_daemon): Don't allow arguments anymore.
5618 * init/tests/test_cfgfile.c (test_stanza_daemon): Update tests.
5619
Scott James Remnant1cdc1632007-02-09 13:26:09 +00005620 * init/job.c (job_handle_event_finished): Function to unblock all
5621 jobs blocked on a given event emission.
5622 (job_new, job_emit_event): Rename blocker to blocked; it's useful for
5623 testing for truth.
5624 * init/job.h: Add prototype, rename member.
5625 * init/tests/test_job.c (test_handle_event_finished): Test it.
5626 (test_new, test_change_state): Update name here too.
5627 * init/event.c (event_finished): Call job_handle_event_finished
5628 function to unblock jobs.
5629 * init/tests/test_event.c (test_poll): Make sure the job gets
5630 unblocked; a few other tests have to change since running event_poll
5631 always unblocks the job if nothing listens to it.
5632
Scott James Remnantba5ebb02007-02-09 04:46:39 +00005633 * init/job.c (job_child_reaper): Set failed back to FALSE if
5634 we're respawning, since we don't want to be failing.
5635 * init/tests/test_job.c (test_child_reaper): cause will be NULL.
5636 also free and poll events when done.
5637 (test_handle_event): pid can never be -1
5638 (test_change_state): poll events when done
5639
Scott James Remnantfd0cc552007-02-09 04:39:36 +00005640 * init/tests/test_job.c (test_child_reaper): Process will always
5641 be zero on return from reaper.
5642
Scott James Remnantef11ca42007-02-09 04:37:24 +00005643 * init/tests/test_job.c (test_child_reaper): Killed doesn't go past
5644 stopping; it goes to waiting, which will clear the cause.
5645
Scott James Remnanta5034982007-02-09 04:36:12 +00005646 * init/tests/test_job.c (test_child_reaper): Fill in values before
5647 we test against them.
5648
Scott James Remnantda1ae312007-02-09 04:35:33 +00005649 * init/tests/test_job.c (test_kill_process): Fix violated assertion
5650
Scott James Remnant011e4ae2007-02-09 04:35:00 +00005651 * init/tests/test_job.c (test_change_state): This should be failed
5652 because nothing cleared it.
5653
Scott James Remnant4f4ea832007-02-09 04:33:50 +00005654 * init/tests/test_job.c (test_change_state): Fix a couple of array
5655 index problems.
5656
Scott James Remnantaf9b63f2007-02-09 04:32:50 +00005657 * init/tests/test_job.c (test_change_state): Why set that which
5658 does not change?
5659
Scott James Remnantfcc51902007-02-09 04:30:43 +00005660 * init/tests/test_job.c (test_change_state): Add newline to test.
5661
Scott James Remnant5f936192007-02-09 04:29:54 +00005662 * init/job.c (job_emit_event): Add the job name as an argument;
5663 oops.
5664
Scott James Remnantf89b1612007-02-09 04:28:09 +00005665 * init/tests/test_control.c (test_job_stop): Need to kill the process
5666 ourselves, as we're blocked on an event.
5667 (test_job_query): Fix wrong value in test.
5668 (check_job_stopped, test_job_stop, test_unwatch_jobs): Change job
5669 name to match the test.
5670
Scott James Remnant7178e722007-02-09 04:22:04 +00005671 * init/job.c (job_change_state): Must only not enter some states
5672 with no process now; others like killed actually usually want one!
5673
Scott James Remnant851a05c2007-02-09 04:18:20 +00005674 * init/tests/test_cfgfile.c (test_read_job): Fix test case.
5675
Scott James Remnant6c088782007-02-09 04:13:43 +00005676 * init/tests/test_job.c (test_handle_event): Clean up tests.
5677 (test_detect_stalled): Clean up.
5678
Scott James Remnantbfcb6162007-02-09 04:08:53 +00005679 * init/job.c (job_child_reaper): Update the reaping of the child
5680 processes; there's a much larger state range for the main process
5681 now, so that needs to be taken into account.
5682 * init/tests/test_job.c (test_child_reaper): New test cases.
5683
Scott James Remnantd7ac93f2007-02-09 03:39:00 +00005684 * init/job.c (job_next_state): Encapsulate the slightly odd three
5685 exit states of running in this function, otherwise we'll end up
5686 special-casing it in places I'd rather not think about.
5687 (job_change_goal): Only change the state of a running job if it
5688 has a process.
5689 * init/tests/test_job.c (test_next_state): Add a test case for the
5690 dead running job
5691 (test_change_goal): Add test case for the dead running job
5692
Scott James Remnantd285b832007-02-09 02:49:06 +00005693 * init/tests/test_job.c (test_change_state): Add test cases for
5694 the forgotten stopping to killed transition.
5695
Scott James Remnant999fc9a2007-02-09 02:44:25 +00005696 * init/job.c (job_kill_process, job_kill_timer): Just check the pid
5697 and state, and no longer any need to notify jobs since we're just
5698 called from one state amongst many.
5699 (job_change_state): Skip over the killed state if there's no process.
5700 * init/tests/test_job.c (test_kill_process): Update test cases.
5701
Scott James Remnantad011612007-02-09 02:34:03 +00005702 * init/job.c (job_run_process): Simplify a little bit, no need to
5703 do the state assertions here, just make sure there's no already
5704 a process running.
5705 * init/tests/test_job.c (test_run_command, test_run_script): Run
5706 tests in the spawned state, since that's where we run the primary
5707 command or script. Drop check for process state since that's no
5708 longer set.
5709
Scott James Remnant8bd1b042007-02-09 02:27:40 +00005710 * init/job.c (job_change_state, job_next_state): Ok, here's the big
5711 one ... rewrite this to use the new state transitions. This has
5712 suddenly got a lot simpler and easier to read, this was definitely a
5713 good idea.
5714 (job_emit_event): Function to make emission of events easier.
5715 (job_failed_event): replaces this one which wasn't so easy.
5716 * init/tests/test_job.c (test_change_state): I can't say how much I
5717 wasn't looking forwards to rewriting these test cases; anyway, it's
5718 done now and I hope they're all right;
5719 (test_next_state): Make sure the state transitions are correct too.
5720
Scott James Remnant6aee3782007-02-09 00:45:29 +00005721 * init/job.h: Rename is_instance to delete and spawns_instance to
5722 just instance.
5723 * init/job.c (job_new): Update.
5724 * init/tests/test_job.c (test_new): Update.
5725 * init/cfgfile.c (cfg_stanza_instance): Update.
5726 * init/tests/test_cfgfile.c (test_stanza_instance): Update.
5727
Scott James Remnant535c6902007-02-09 00:43:03 +00005728 * init/event.h: Correct the event names.
5729
Scott James Remnante2edac92007-02-09 00:39:24 +00005730 * init/job.h: Add blocker event member.
5731 * init/job.c (job_new): Initialise it to NULL.
5732 * init/tests/test_job.c (test_new): Check it.
5733
Scott James Remnante885d552007-02-09 00:01:46 +00005734 * init/job.c (job_change_goal): Have a stab at this function with the
5735 new state machine; it gets somewhat simpler (until we introduce the
5736 second scripts), now we just induce things by a state change.
5737 * init/tests/test_job.c (test_change_goal): Made easier (for now)
5738 because we don't need to deal with processes and can just wait to
5739 be blocked on an event.
5740
Scott James Remnant9e13a242007-02-08 00:24:21 +000057412007-02-08 Scott James Remnant <scott@netsplit.com>
5742
Scott James Remnant5e469e42007-02-08 23:49:01 +00005743 * init/cfgfile.c (cfg_read_job): Drop check for useless respawn script
5744 (cfg_stanza_respawn): Drop handling of "respawn script"
5745 * init/tests/test_cfgfile.c (test_stanza_respawn): Drop the checks
5746 for "respawn script"
5747
Scott James Remnant4fdf7552007-02-08 23:45:34 +00005748 * init/job.h: Move things about a bit more; remove respawn_script
5749 since that state is going away.
5750 * init/job.c (job_new): Drop initialisation of process_state.
5751 * init/tests/test_job.c (test_new): Improve the tests.
5752
Scott James Remnant3856c632007-02-08 23:29:17 +00005753 * init/main.c (STATE_FD): Remove this define, not used anymore.
5754
Scott James Remnantbc281c32007-02-08 23:25:33 +00005755 * init/tests/test_event.c (test_poll): Update the event checking
5756 to match what's likely to happen.
5757
Scott James Remnant049b50f2007-02-08 23:23:29 +00005758 * init/event.h: Remove commented out bit.
5759
Scott James Remnant1abebfd2007-02-08 23:20:02 +00005760 * init/tests/test_notify.c (check_job_status, test_job): Correct
5761 state usage to match a possible state.
5762
Scott James Remnant64bc2a82007-02-08 22:59:46 +00005763 * init/control.c (control_job_start, control_job_stop)
5764 (control_job_query, control_job_list): Drop process state and
5765 description from the job status messages we send back.
5766 * init/tests/test_control.c (test_error_handler)
5767 (check_job_started, test_job_start, check_job_stopped)
5768 (check_job_stopping, test_job_query, check_job_starting)
5769 (test_job_list, test_watch_jobs, test_unwatch_jobs): Remove
5770 process_state and description, and update usage of job states.
5771
Scott James Remnantcb178f82007-02-08 22:47:42 +00005772 * init/notify.c (notify_job): Don't include process state or
5773 description in the job status message anymore.
5774 * init/tests/test_notify.c (check_job_status, test_job): Update tests
5775
Scott James Remnant79cd4bf2007-02-08 22:44:46 +00005776 * init/cfgfile.c (cfg_read_job): Drop the copying of the process_state
5777 member, since it doesn't exist anymore.
5778 * init/tests/test_cfgfile.c (test_read_job): Drop the check too.
5779
Scott James Remnant6f0ff592007-02-08 22:43:04 +00005780 * init/job.h (Job): Drop the process_state member.
5781
Scott James Remnant56a1fa82007-02-08 22:40:01 +00005782 * util/jobs.c (handle_job_status): Drop the process_state and
5783 description arguments; output a process id only if it's greater
5784 than zero.
5785 * util/tests/test_jobs.c (test_start_action, test_list_action)
5786 (test_jobs_action): Update tests to use newer states and arguments.
5787 * util/events.c (handle_event_job_status): Simplify in the same way
5788
Scott James Remnantac0c88b2007-02-08 22:31:00 +00005789 * upstart/message.h: Remove process_state and description from the
5790 job status event (we already had the foresight to not put them in
5791 the event job status event).
5792 * upstart/message.c (upstart_message_new, upstart_message_handle):
5793 Update handling of the messages to reduce the arguments.
5794 * upstart/tests/test_message.c (test_new, my_handler)
5795 (test_handle): Update the tests for the new job status message.
5796
Scott James Remnante76986a2007-02-08 22:21:22 +00005797 * upstart/enum.h (JobState): Change the job states to the new set
5798 of states that we've planned.
5799 (ProcessState): Drop process state entirely; this information is now
5800 contained in the single JobState field.
5801 * upstart/enum.c (job_state_name, job_state_from_name): Update
5802 strings to match the new state names.
5803 (process_state_name, process_state_from_name): Drop these functions.
5804 * upstart/tests/test_enum.c (test_state_name)
5805 (test_state_from_name): Update test cases to match new names.
5806 (test_process_state_name, test_process_state_from_name): Drop.
5807
Scott James Remnant08100e02007-02-08 17:57:21 +00005808 * init/main.c (main): Remove the logd hack for now.
5809 * init/job.c (job_new): Change the default console to none for now.
5810 * init/tests/test_job.c (test_new): Update test.
5811 * init/cfgfile.c (cfg_stanza_console): Can't guard against duplicates
5812 for a while.
5813 * init/tests/test_cfgfile.c (test_stanza_console): Comment out dup test
5814
Scott James Remnantf247adf2007-02-08 15:23:43 +00005815 * init/cfgfile.c (cfg_read_job): Remove the restriction that there
5816 must be either an 'exec' or 'script' for a job; jobs without either
5817 define states others can use.
5818 * init/tests/test_cfgfile.c (test_read_job): Convert the test to
5819 a "must work".
5820 * init/job.c (job_change_state): Remove restriction that we must
5821 have either a script or a command; having neither should just wedge
5822 the job at the running rest state. Note that there's no way to get
5823 it out yet, because we don't force that particular state change.
5824 * init/tests/test_job.c (test_change_state): Make sure that works.
5825
Scott James Remnant920d65b2007-02-08 13:49:53 +00005826 * init/job.c (job_change_cause): Put the knowledge about how to
5827 change the cause into a separate function, since it's slightly
5828 tricky.
5829 (job_change_goal, job_change_state): Set the cause using the above
5830 function.
5831
Scott James Remnanta3bcac12007-02-08 13:40:53 +00005832 * init/job.h (Job): Rename goal_event to cause, also shuffle things
5833 around so that the state is mostly together.
5834 * init/job.c, init/process.c, init/notify.c, init/cfgfile.c: Update
5835 references (and comments) to match the new name.
5836 * init/tests/test_job.c, init/tests/test_event.c,
5837 init/tests/test_process.c, init/tests/test_cfgfile.c,
5838 init/tests/test_notify.c: Likewise.
5839
Scott James Remnantef119832007-02-08 13:24:16 +00005840 * init/job.c (job_child_reaper): Don't change the goal event; the
5841 state changes will handle this.
5842 (job_change_goal): Only dereference/reference the goal event if we're
5843 actually changing it.
5844 * init/tests/test_job.c (test_change_state, test_child_reaper):
5845 Update tests to not assume that the goal event gets changed.
5846 (test_kill_process): Eliminate race condition.
5847
Scott James Remnant93376ef2007-02-08 12:53:53 +00005848 * init/job.c (job_child_reaper): Correct some problems with job and
5849 event failure; we now don't overwrite an existing failure record,
5850 and don't record failure if the main process failed and the goal was
5851 stop; since we likely caused it.
5852 * init/tests/test_job.c (test_child_reaper): More test cases.
5853
Scott James Remnantc3db81c2007-02-08 12:38:19 +00005854 * logd/event.d/logd.in: Stop on the new runlevel events, not the
5855 shutdown event.
5856
Scott James Remnante8d263c2007-02-08 03:20:30 +00005857 * compat/sysv/shutdown.c (shutdown_now): Emit an ordinary runlevel
5858 change event now; including the INIT_HALT environment variable
5859 * compat/sysv/man/shutdown.8: Update the manual
5860
Scott James Remnant52360ea2007-02-08 03:06:40 +00005861 * compat/sysv/telinit.c: Now just sends out a runlevel event with
5862 an argument giving the new runlevel.
5863 * compat/sysv/man/telinit.8: Update description of the command.
5864
Scott James Remnant8662bd02007-02-08 02:57:56 +00005865 * upstart/message.h: Remove the UPSTART_SHUTDOWN message.
5866 * upstart/message.c (upstart_message_new, upstart_message_handle):
5867 Remove handling for the shutdown message.
5868 * upstart/tests/test_message.c (test_new, test_handle): Remove
5869 tests against the shutdown message.
5870 * init/control.c (control_shutdown): Remove the shutdown command
5871 from the server.
5872 * init/tests/test_control.c (test_shutdown): Remove tests for it.
5873 * init/event.h: Remove the shutdown event.
5874 * util/initctl.c: Remove the shutdown command reference.
5875 * util/events.c (shutdown_action): Remove the command.
5876 * util/events.h: Update.
5877 * util/tests/test_events.c (test_shutdown_action): Remove tests.
5878
Scott James Remnant65906602007-02-08 02:51:39 +00005879 * init/job.c (job_detect_idle): Rename to job_detect_stalled
5880 (job_detect_stalled): Remove the idle state detection
5881 (job_set_idle_event): Idle event has been removed.
5882 * init/job.h: Update.
5883 * init/tests/test_job.c (test_detect_idle): Rename to
5884 (test_detect_stalled): and remove idle detection tests.
5885 * init/main.c (main): Replace job_detect_idle with job_detect_stalled
5886 * init/control.c (control_shutdown): Don't set the idle event.
5887 * init/tests/test_control.c (test_shutdown): Don't detect the idle
5888 event (and thus the second event)
5889
Scott James Remnantb0d99d52007-02-08 02:40:43 +00005890 * init/cfgfile.c (cfg_stanza_service): Parser for service stanza.
5891 * init/tests/test_cfgfile.c (test_stanza_service): Test the service
5892 stanza.
5893 (test_stanza_respawn): Check that respawn implies service.
5894 * TODO: Update.
5895
5896 * init/job.h (Job): Add a new service member.
5897 * init/job.c (job_new): Service starts off as false.
5898 (job_change_state): Check service instead of respawn.
5899 * init/tests/test_job.c (test_change_state): Check with service
5900 instead of respawn, since that's what we really mean.
5901
Scott James Remnante4ab75c2007-02-08 02:28:19 +00005902 * init/cfgfile.c (cfg_read_job): Copy a whole bunch more state
5903 into the newly parsed job.
5904 * init/job.c (job_run_process): Only output the first error.
5905 * init/tests/test_cfgfile.c (test_read_job): Make sure important
5906 things are copied.
5907 * TODO: Update.
5908
Scott James Remnantdb31c152007-02-08 02:05:38 +00005909 * init/main.c: Restore a much simplified version of the term
5910 handler that doesn't try and copy across any state.
5911
Scott James Remnant517f5552007-02-08 02:02:52 +00005912 * compat/sysv/telinit.c: Update call to event_emit; we'll revisit
5913 this shortly when we get rid of the shutdown event.
5914
Scott James Remnant1dc0de52007-02-08 01:57:34 +00005915 * util/events.c (handle_event): Add new id field (but ignore it)
5916 Functio
5917 (handle_event_job_status): New function to handle the new event.
5918 (handle_event_finished): Function to handle the end of the event.
5919 (emit_action): Send the newer event, and loop over replies until
5920 we get a finished one.
5921 * util/tests/test_events.c (test_emit_action): Update tests cases.
5922
Scott James Remnantd9520172007-02-08 01:18:24 +00005923 * init/control.c (control_event_emit): New function to handle the
5924 new-style emit message.
5925 * init/tests/test_control.c (test_event_emit): Make sure the new
5926 message function behaves.
5927
Scott James Remnantb3e539e2007-02-08 01:10:12 +00005928 * init/event.c, init/job.c, init/main.c, init/tests/test_event.c,
5929 init/tests/test_job.c: Completely drop the serialisation code, it's
5930 getting out of date and in the way.
5931
Scott James Remnant71b91fc2007-02-08 01:07:56 +00005932 * init/event.h: Remove compatibility macros.
5933 (EventEmission): Drop the callback function; it was too error prone
5934 to try and do it this way, and we only ever wanted to release a job
5935 anyway as control requests are better handled through the notify
5936 interface.
5937 (EventEmissionCb): Drop unused typedef.
5938 * init/event.c (event_emit): Drop callback argument.
5939 (event_finished): Don't call the callback
5940 * init/tests/test_event.c: Update to avoid callbacks.
5941 * init/job.c (job_change_state): Convert to using event_emit and
5942 EventEmission.
5943 (job_detect_idle): Drop extra arguments to event_emit.
5944 * init/main.c (main, cad_handler, kbd_handler): Drop extra arguments
5945 to event_emit.
5946 * init/control.c (control_shutdown): Use event_emit instead of
5947 event_queue.
5948 * init/tests/test_control.c (test_shutdown): Convert to using
5949 EventEmission.
5950 (test_watch_events, test_unwatch_events): Drop extra arguments to
5951 event_emit.
5952 * init/tests/test_notify.c (test_subscribe_event, test_job)
5953 (test_event, test_event_finished): Drop extra arguments to event_emit
5954 * init/tests/test_job.c (test_change_goal, test_change_state)
5955 (test_run_script, test_child_reaper, test_detect_idle): Drop
5956 extra arguments to event_emit.
5957 * init/tests/test_process.c (test_spawn): Drop extra arguments to
5958 event_emit.
5959
Scott James Remnantf082fc42007-02-08 00:50:11 +00005960 * TODO: Update.
5961
Scott James Remnant716f75c2007-02-08 00:49:40 +00005962 Rewrite the notification subsystem quite significantly; now we
5963 have individual functions to subscribe to different types of
5964 notification, and can even subscribe to individual jobs or events.
5965
5966 * init/notify.c (notify_subscribe_job, notify_subscribe_event)
5967 (notify_unsubscribe): New subscription and unsubscription functions
5968 that assume one record per subscription, not process.
5969 (notify_subscription_find): Function to find a subscription.
5970 (notify_job): Send a message to anything subscribed to the goal event
5971 as well.
5972 (notify_event): Use EventEmission and include the id in the event.
5973 (notify_event_finished): New function, sends a finished message and
5974 includes both the id and whether the event failed.
5975 * init/notify.h (NotifySubscribe): New notify structure that is
5976 once per subscription, rather than per-process; and allows
5977 subscription to individual jobs or events.
5978 * init/tests/test_notify.c (test_subscribe_job)
5979 (test_subscribe_event, test_unsubscribe): Test the new subscription
5980 functions, replacing the old
5981 (test_subscribe): tests.
5982 (test_subscription_find): Check finding works
5983 (check_event, test_event): Update to use emissions, and check that the
5984 id is correct.
5985 (test_event_finished): Check this one works too
5986 (check_event_job_status, test_job): Make sure processes subscribed
5987 via the goal event are notified too.
5988 * init/event.c (event_pending): Pass the emission directly.
5989 (event_finished): Notify subscribers that the event has finished.
5990 * init/control.c (control_error_handler): Call notify_unsubscribe
5991 (control_watch_jobs, control_unwatch_jobs, control_watch_events)
5992 (control_unwatch_events): Update to the new subscription API.
5993 * init/tests/test_control.c (test_error_handler): Use new API
5994 (test_watch_jobs, test_unwatch_jobs, test_watch_events)
5995 (test_unwatch_events): Also update these to the new API; use a
5996 destructor to make sure the subscription is freed.
5997
Scott James Remnant9e13a242007-02-08 00:24:21 +00005998 * init/tests/test_process.c: Don't use printf, use TEST_FUNCTION
5999
Scott James Remnante627ad42007-02-07 00:23:57 +000060002007-02-07 Scott James Remnant <scott@netsplit.com>
6001
Scott James Remnant459aee32007-02-07 22:44:08 +00006002 * upstart/message.h: Allocate new grouped event messages.
6003 * upstart/message.c (upstart_message_new, upstart_message_handle):
6004 Add support for the new grouped event messages.
6005 * upstart/tests/test_message.c (test_new, test_handle)
6006 (my_handler): Make sure the new messages are passed correctly.
6007
Scott James Remnant1d792152007-02-07 20:56:01 +00006008 * init/job.c (job_change_state): Clear the goal event whenever we
6009 reach the final rest state of a job (waiting for all jobs, running
6010 for services).
6011 * init/tests/test_job.c (test_change_state): Check that the goal
6012 event goes away at the right times.
6013 * TODO: Update.
6014
Scott James Remnantab17ab92007-02-07 20:38:01 +00006015 * init/tests/test_job.c (test_child_reaper): Make sure that the
6016 event is marked failed properly
6017
Scott James Remnant6d007b82007-02-07 20:21:54 +00006018 * init/job.c (job_start_event, job_stop_event): There's no reason
6019 for these to exist as seperate functions anymore, especially since
6020 we want to eventually have some kind of match table.
6021 (job_handle_event): Perform the iterations and match calls here
6022 instead, since we just call job_change_goal now.
6023 * init/job.h: Remove prototypes.
6024 * init/tests/test_job.c (test_start_event, test_stop_event): Fold into
6025 (test_handle_event): which now handles all the cases.
6026
Scott James Remnant269b7b92007-02-07 20:04:42 +00006027 * init/job.c (job_detect_idle): Call event_emit
6028 * init/main.c (main, cad_handler, kbd_handler): Call event_emit
6029 instead of event_queue.
6030 * init/tests/test_event.c (test_new): Call event_poll
6031 * init/tests/test_job.c (test_change_state, test_child_reaper)
6032 (test_detect_idle, test_change_state): Update to use newer event API.
6033 * TODO: Update.
6034
Scott James Remnant80eabbc2007-02-07 19:54:27 +00006035 * init/job.c (job_start, job_stop): Drop these functions; call
6036 job_change_goal instead (which is now public).
6037 (job_change_state, job_child_reaper): Call job_change_goal instead.
6038 * init/job.h: Update.
6039 * init/tests/test_job.c (test_start, test_stop): Merge into new
6040 (test_change_goal): function.
6041 * init/main.c (main): Call job_change_goal instead of job_start.
6042 * init/control.c (control_job_start, control_job_stop): Call
6043 job_change_goal instead.
6044
Scott James Remnant4522f4d2007-02-07 19:38:19 +00006045 * init/tests/test_job.c (test_new, test_change_state)
Scott James Remnant80eabbc2007-02-07 19:54:27 +00006046 (test_run_script, test_start, test_stop, test_start_event):
Scott James Remnant4522f4d2007-02-07 19:38:19 +00006047
6048 * init/job.h (Job): goal_event is now an EventEmission, and is
6049 a direct pointer to the one in the events queue, rather than a copy.
6050 * init/process.c (process_setup_environment): Reference the event
6051 name and environment through the goal event, not directly.
6052 * init/job.c (job_run_script): Reference the event name and
6053 environment through the goal event, not directly.
6054 (job_change_state, job_child_reaper): Replace direct setting of the
6055 job goal with a call to job_stop; the process state is always
6056 PROCESS_NONE in all three cases, so this is completely safe.
6057 (_job_start, _job_stop): Merge these two functions together into
6058 (job_change_goal): which behaves a lot more like job_change_state,
6059 except that it doesn't loop. This handles the changing of the
6060 emission.
6061 (job_start, job_start_event, job_stop, job_stop_event): Simplify
6062 these functions, now they just call job_change_goal passing in
6063 the emission pointer (or NULL).
6064
Scott James Remnantb1db7a32007-02-07 16:33:27 +00006065 * init/main.c, init/job.c, init/job.h, init/event.c, init/event.h,
6066 init/tests/test_job.c, init/tests/test_event.c: Remove state
6067 serialisation code for the time being; maintaining it is getting
6068 increasingly harder, and it introduces some major bugs. It will
6069 get rewritten shortly.
6070
Scott James Remnant4216cc82007-02-07 16:22:47 +00006071 * init/event.c (event_pending): Pass the emission directly to
6072 job_handle_event now.
6073 * init/job.c (job_handle_event, job_start_event, job_stop_event):
6074 Deal with event emissions rather than just plain events, the change
6075 so far doesn't do anything else other than take the structure change.
6076 * init/job.h: Change prototypes.
6077 * init/tests/test_job.c (test_start_event, test_stop_event)
6078 (test_handle_event): Update tests to use emissions.
6079
Scott James Remnantb2d06d42007-02-07 15:55:33 +00006080 * init/tests/test_event.c (test_read_state, test_write_state): Check
6081 the passing of the progress information.
6082 * init/event.c (event_read_state, event_write_state): Add progress
6083 field to the serialisation (oops).
6084
Scott James Remnantab132da2007-02-07 15:48:02 +00006085 * init/event.h: Add missing attribute for event_read_state.
6086 * init/cfgfile.h: Add missing attributes.
6087 * init/main.c (read_state): Don't discard return value.
6088 * TODO: Update.
6089
Scott James Remnantfcc9a0d2007-02-07 15:41:57 +00006090 * init/main.c (read_state): Handle the Emission keyword; also handle
6091 Event really being an EventEmission.
6092 * init/event.c (event_emit): Make the next emission id a static global
6093 (event_read_state, event_write_state): Serialise event emission
6094 structures, not plain events; also send over the last id we used so
6095 it appears seamless. This doesn't yet handle the callback/data bit
6096 of the serialisation, which turns out to be a little tricky ... oops
6097 * init/event.h: Update.
6098 * init/tests/test_event.c (test_read_state, test_write_state): Check
6099 that serialisation is done with EventEmissions instead, and all the
6100 fields are passed (except callback and data which are ... tricky).
6101
Scott James Remnanta39da0f2007-02-07 13:52:42 +00006102 * init/main.c (main): Call event_poll instead of event_queue_run.
6103
Scott James Remnante47588c2007-02-07 13:50:01 +00006104 * init/event.c (event_poll): Add the new function that replaces
6105 event_queue_run(); handles the new-style event emission structures
6106 in the list and only returns when there are no non-handling events.
6107 (event_pending, event_finished): Handling of particular event states
6108 during poll; split out for readability.
6109 (event_queue, event_queue_run): Drop these obsolete functions.
6110 (event_read_state): Force type from event_queue.
6111 * init/event.h: Add event_poll prototype; remove prototypes of old
6112 functions, replacing with #defines for now so things still compile.
6113 * init/tests/test_event.c (test_queue): Drop tests.
6114 (test_read_state, test_write_state): Force type from event_queue
6115 Change type we check size of.
6116 (test_poll): Pretty thoroughly test the new poll function.
6117 * init/job.c (job_change_state): Force type from event_queue
6118 * init/control.c (control_event_queue): Force type from event queue
6119 * init/tests/test_job.c (test_detect_idle): Force type from event_queue
6120 * init/tests/test_control.c (test_event_queue, test_shutdown):
6121 Force type from event_queue
6122
Scott James Remnant162c2b22007-02-07 11:32:04 +00006123 * init/event.c: Revert to a single list of events with an enum
6124 (event_emit): Set the progress to pending initially.
6125 (event_emit_find_by_id): Simplify now it just checks one list
6126 (event_emit_finished): Function for jobs to call once they've done
6127 with an event; just sets the progress to finished for the event
6128 queue to pick up.
6129 * init/tests/test_event.c (test_emit_finished): Check it.
6130
6131 * init/event.h: Add prototype.
6132 (EventProgress): Add new enum
6133 (EventEmission): And add progress member to this structure
6134 * init/tests/test_event.c (test_emit): Make sure the event is pending
6135
Scott James Remnantd379a602007-02-07 10:58:06 +00006136 * init/event.c (event_emit_find_by_id): Locate an event emission
6137 by its id in either the pending or handling queue.
6138 * init/event.h: Add prototype
6139 * init/tests/test_event.c (test_emit): Make sure that the emission
6140 id is unique each time.
6141 (test_emit_find_by_id): Test the function.
6142
Scott James Remnant7282c9a2007-02-07 03:14:08 +00006143 * init/event.c (event_emit): New function to replace event_queue();
6144 returns an EventEmission structure with the details filled in as
6145 given.
6146 * init/event.h: Add prototype.
6147
Scott James Remnant81cc7942007-02-07 02:54:25 +00006148 * init/event.c (event_init): Rename the single events queue to
6149 pending and add a new handling list.
6150
6151 * init/event.h (EventEmission, EventEmissionCb): Add a new emission
6152 structure that wraps an event, for use in the queue.
6153
Scott James Remnantd82109e2007-02-07 02:15:39 +00006154 * util/tests/test_events.c (test_events_action): Update test now
6155 that nih_message is more sensible.
6156 * util/tests/test_jobs.c (test_start_action, test_list_action)
6157 (test_jobs_action): Update test
6158
Scott James Remnante5d3f012007-02-07 01:59:57 +00006159 * util/events.c (emit_action): Actually pass the emit_env array
6160 * util/tests/test_events.c (test_emit_action): Make sure it does.
6161
6162 * util/initctl.c (main): Catch nih_command_parser() returning a
6163 negative value to indicate an internal error, and always exit 1.
6164
Scott James Remnant2cb93052007-02-07 01:49:43 +00006165 * util/events.c (handle_event): Build up multiple lines to describe
6166 the event, including its arguments and environment.
6167 * util/tests/test_events.c (test_events_action): Check the new output
6168 format is right.
6169
Scott James Remnant685644e2007-02-07 01:29:28 +00006170 * init/main.c (main): Take out inadvertantly leaked debugging code;
6171 sorry about that.
6172
Scott James Remnant5130e6d2007-02-07 01:18:38 +00006173 * init/job.c (job_child_reaper): Rewrite this to make the logic a
6174 little easier to follow, and support signals in normalexit. This
6175 also now applies to deciding whether the job failed, if it did, we
6176 store that information in the job so the stop and stopped events
6177 can get it.
6178 * init/tests/test_job.c (test_child_reaper): Add new test cases for
6179 the setting of the failed flags.
6180
Scott James Remnant18935fe2007-02-07 00:38:13 +00006181 * init/cfgfile.c (cfg_stanza_normalexit): Allow signal names in the
6182 arguments, which are added to the normalexit array or'd with 0x80
6183 * init/tests/test_cfgfile.c (test_stanza_normalexit): Check that we
6184 can now parse signal names correctly.
6185
Scott James Remnant326c2312007-02-07 00:31:18 +00006186 * init/job.c (job_failed_event): Change add to addp to fix leak.
6187
Scott James Remnante627ad42007-02-07 00:23:57 +00006188 * init/job.c (job_failed_event): Function to turn an event into one
6189 that includes all the necessary arguments and environment.
6190 (job_change_state): Call job_failed_event for the stop and stopped
6191 events (bit hacky at the moment, will improve later).
6192 * init/tests/test_job.c (test_change_state): Check that the failed
6193 events are generated properly.
6194
Scott James Remnant2b2b7d12007-02-06 00:07:28 +000061952007-02-06 Scott James Remnant <scott@netsplit.com>
6196
Scott James Remnant038ef4d2007-02-06 23:46:53 +00006197 * init/job.c (job_change_state): Reset the failed member when
6198 we enter the starting state.
6199 * init/tests/test_job.c (test_change_state): Make sure that the
6200 failed member is reset when we enter the starting state.
6201
Scott James Remnantbd7ad1a2007-02-06 23:43:59 +00006202 * init/job.h (Job): Add failed, failed_state and exit_status members.
6203 * init/job.c (job_new): Initialise new members.
6204
Scott James Remnantddbf1162007-02-06 23:40:30 +00006205 * init/job.c (job_child_reaper): Convert signals to names when
6206 outputting status messages.
6207 * init/tests/test_job.c (test_child_reaper): Check that the signal
6208 name gets converted over.
6209
Scott James Remnantf11b7dc2007-02-06 23:03:48 +00006210 * init/event.h (CTRLALTDEL_EVENT): Now we've broken the shared
6211 namespace of events and jobs, rename the control-alt-delete event
6212 back to control-alt-delete.
6213
Scott James Remnant0ef0d392007-02-06 23:00:28 +00006214 * init/job.c (job_change_state): Replace the events generated as
6215 part of the job state, named for the job and state, with new state
6216 events that have the job name as an argument.
6217 * init/event.h: Define new job event names.
6218 * init/tests/test_job.c (test_change_state): Make sure the new
6219 events are correct, with the job name as an argument.
6220
Scott James Remnant1416d052007-02-06 22:42:55 +00006221 * init/job.c (job_change_state): Remove the job event; this has
6222 been repeatedly proved to be confusing.
6223 * init/tests/test_job.c (test_change_state): Remove checks for the
6224 job event.
6225
Scott James Remnant08146b92007-02-06 20:45:38 +00006226 * util/events.c (emit_action): Pass in extra arguments.
6227 (env_option): Function to parse an option given an environment
6228 variable.
6229 * util/events.h: Add prototype.
6230 * util/tests/test_events.c (test_emit_action): Make sure that the
6231 emit action works with no arguments and with arguments.
6232 (test_events_action): Send back events with the right number of args.
6233 (test_env_option): Check the env option parser works.
6234 * util/initctl.c: Give shutdown its own command and options, give
6235 emit a new -e option.
Scott James Remnante8f3ef92007-02-06 20:20:33 +00006236
Scott James Remnant7f69c622007-02-06 20:16:50 +00006237 * util/events.c (shutdown_action): Split out from emit, seeing as
6238 these are going to be different from now on.
6239 * util/events.h: Add prototype.
6240 * util/tests/test_events.c (test_shutdown_action): Copy test cases.
6241
Scott James Remnantca2df742007-02-06 20:13:32 +00006242 * init/control.c (control_event_queue): Take the arguments and
6243 environment from the event queue request; and reparent into the
6244 event.
6245 * init/tests/test_control.c (test_event_queue): Check that arguments
6246 and environment are copied across properly.
6247
Scott James Remnanta30a25f2007-02-06 20:08:22 +00006248 * init/notify.c (notify_event): Pass in the arguments and environment
6249 for the event.
6250 * init/tests/test_notify.c (check_event): Check for event arguments
6251 and environment from the notify process.
6252 (test_event): Add arguments and environment to the event we test with
6253
Scott James Remnantce51bfb2007-02-06 20:04:05 +00006254 * upstart/tests/test_message.c (test_new, test_handle): Send
6255 arguments and environment with the UPSTART_EVENT_QUEUE and
6256 UPSTART_EVENT messages.
6257 * upstart/wire.c (upstart_pop_int, upstart_pop_unsigned): Shrink
6258 only once.
6259 (upstart_pop_string): Check the length is at least one first, as
6260 we may just have an 'S'.
6261
6262 * upstart/message.c (upstart_message_new, upstart_message_handle):
6263 The UPSTART_EVENT and UPSTART_EVENT_QUEUE messages gain new array
6264 arguments containing the arguments and environment for the event.
6265 * upstart/message.h: Document the new arguments.
6266
Scott James Remnantd1a65342007-02-06 19:25:38 +00006267 * util/tests/test_events.c, util/tests/test_jobs.c: Update the
6268 message format checks here too.
6269
Scott James Remnantfb45e432007-02-06 19:07:24 +00006270 * upstart/tests/test_wire.c (test_pop_pack): Free the array.
6271
Scott James Remnanta8882032007-02-06 19:06:44 +00006272 * upstart/tests/test_message.c (test_new, test_handle)
6273 (test_handle_using, test_reader): Update tests to include and
6274 expect new type markers between each field.
6275
Scott James Remnantf9663f02007-02-06 18:58:37 +00006276 * upstart/wire.c (upstart_push_int, upstart_push_unsigned):
6277 Take out silly asserts; it must have room!
6278
Scott James Remnantc874a942007-02-06 18:57:34 +00006279 * upstart/wire.c (upstart_push_string, upstart_pop_string): Rewrite
6280 to use a type like the rest of the functions; this removes the strange
6281 length restriction and allows us to make the pop function
6282 non-destructive.
6283 * upstart/tests/test_wire.c (test_push_string): Update.
6284 (test_pop_string): Update, adding in non-destructive, wrong type
6285 and insufficient space for type test cases.
6286 (test_push_array, test_pop_array): These needed updated too,
6287 changing the string format changed the array format.
6288 (test_push_pack, test_pop_pack): And obviously the pack format changed.
6289
Scott James Remnant9ed52092007-02-06 18:36:51 +00006290 * upstart/wire.c (upstart_pop_header): Make the function
6291 non-destructive in the face of errors.
6292 * upstart/tests/test_wire.c (test_pop_header): Make sure that
6293 invalid headers are non-destructive on error.
6294
Scott James Remnantdc4436f2007-02-06 18:33:27 +00006295 * upstart/tests/test_wire.c (test_pop_int, test_pop_unsigned):
6296 Make sure that insufficient space is non-destructive.
6297
Scott James Remnantafc5b8c2007-02-06 18:32:08 +00006298 * upstart/wire.c (upstart_push_int, upstart_pop_int)
6299 (upstart_push_unsigned, upstart_pop_unsigned): Convert to array-style
6300 type first format.
6301 (upstart_push_string, upstart_push_header): Write the length and
6302 type fields out by hand so they don't get an 'i' prefix.
6303 (upstart_pop_string, upstart_pop_header): Read the length and type
6304 fields by hand so they don't get an 'i' prefix.
6305 * upstart/tests/test_wire.c (test_push_int, test_pop_int)
6306 (test_push_unsigned, test_pop_unsigned): Update test cases to match.
6307 (test_push_pack, test_pop_pack): Pack format was changed too.
6308
Scott James Remnanta63d4862007-02-06 18:10:58 +00006309 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add calls
6310 to push and pop array.
6311 * upstart/tests/test_wire.c (test_push_pack, test_pop_pack): Test
6312 support for arrays.
6313
Scott James Remnant5b6a2022007-02-06 18:00:49 +00006314 * upstart/wire.c (upstart_push_array, upstart_pop_array): Implement
6315 new array functions; note that these use a newer format that allows
6316 us to transmit NULL without needing to limit the size of the array.
6317 * upstart/wire.h: Add prototypes.
6318 * upstart/tests/test_wire.c (test_push_array, test_pop_array):
6319 Test the new array functions.
6320
Scott James Remnantf1d51112007-02-06 16:22:48 +00006321 * init/job.c (job_run_script): Build up the argument list, appending
6322 those from the goal event if one is set.
6323 (job_run_command): Use nih_str_array_add to build up the arguments,
6324 but don't append those from the goal event (use script).
6325 * init/tests/test_job.c (test_run_script): Make sure the arguments get
6326 passed to the running shell scripts.
6327
Scott James Remnant2efe5562007-02-06 15:51:19 +00006328 * init/job.c (job_run_script): Only use the /dev/fd trick if we can
6329 actually stat /dev/fd; also don't hardcode that path ...
6330 * init/paths.h (DEV_FD): Add here.
6331
Scott James Remnantefa8c7e2007-02-06 15:02:23 +00006332 * init/process.c (process_setup_environment): Copy environment
6333 variables from the goal event into the job's process.
6334 * init/tests/test_process.c (test_spawn): Make sure the environment
6335 reaches the job, but doesn't override that in the job already.
6336
6337 * init/tests/test_job.c (test_start_event):
6338
Scott James Remnant0071dd32007-02-06 14:57:37 +00006339 * init/job.c (job_start_event, job_stop_event): Copy the arguments
6340 and environment from the event into the goal event.
6341
Scott James Remnantb3d4dee2007-02-06 14:39:35 +00006342 * init/job.c (job_read_state, job_write_state): Read and write
6343 arguments and environment for goal event.
6344 * init/tests/test_job.c (test_read_state, test_write_state): Test
6345 with arguments and environment to the goal event.
6346
Scott James Remnant4bba9702007-02-06 14:28:10 +00006347 * init/event.c (event_read_state, event_write_state): Read and write
6348 the arguments and environment of the event.
6349 * init/tests/test_event.c (test_read_state, test_write_state): Make
6350 sure arguments and environment are correctly serialised.
6351
Scott James Remnant462e7172007-02-06 13:30:24 +00006352 * init/cfgfile.c (cfg_stanza_console): Fix a leak of the console
6353 argument in the case of duplicated options.
6354 (cfg_stanza_env): Drop the counting now nih_str_array_addp does it;
6355 and be sure to use that function.
6356 (cfg_stanza_umask): Fix leak of umask argument
6357 (cfg_stanza_nice): Fix leak of nice argument
6358 * init/tests/test_event.c (test_new): Call event_queue_run so init
6359 is called outside of a TEST_ALLOC_FAIL block.
6360
Scott James Remnantfd196342007-02-06 13:19:03 +00006361 * init/event.c (event_new): Start off with NULL args and env, to
6362 match job (saves a few bytes).
6363 (event_match): Watch for NULL arguments!
6364 * init/tests/test_event.c (test_new): Check for NULL not alloc'd
6365
Scott James Remnantfc9a76e2007-02-06 13:14:46 +00006366 * init/cfgfile.c (cfg_stanza_on, cfg_stanza_start)
6367 (cfg_stanza_stop): Parse arguments to the on stanza and store them
6368 directly in the event.
6369 * init/tests/test_cfgfile.c (test_stanza_on, test_stanza_start)
6370 (test_stanza_stop): Make sure arguments are parsed into the event.
6371
Scott James Remnant5dd1bc92007-02-06 12:57:50 +00006372 * init/event.c (event_new): Use nih_str_array_new.
6373 * init/cfgfile.c (cfg_stanza_env): Rewrite to use nih_str_array.
6374
Scott James Remnant4d0fc0f2007-02-06 11:34:41 +00006375 * init/job.c (job_run_script): Check the error returned from
6376 nih_io_reopen; don't just loop. We only ever expect ENOMEM (the
6377 other error, EBADF, is impossible).
6378
Scott James Remnanteb8cb142007-02-06 11:31:27 +00006379 * init/job.c (job_change_state): Reset the goal_event to NULL when
6380 we catch a run-away job (as it's not stopping for the same event
6381 it started with).
6382 (job_child_reaper): Reset the goal_event to NULL after setting the
6383 goal to STOP.
6384 * init/tests/test_job.c (test_change_state, test_child_reaper):
6385 Check that the goal event gets reset whenever the goal gets changed.
6386
Scott James Remnant62e22f42007-02-06 02:08:19 +00006387 * init/tests/test_event.c: Use TEST_ALLOC_FAIL
6388
Scott James Remnant93cd4d22007-02-06 02:07:45 +00006389 * init/event.c (event_match): Match arguments using fnmatch() and
6390 allow more arguments in event1 than event2 (but not the other way
6391 around).
6392 * init/tests/test_event.c (test_match): Check the new permitted
6393 combinations.
6394
Scott James Remnant34b7c712007-02-06 01:57:45 +00006395 * init/event.h (Event): Add args and env members to Event.
6396 * init/event.c (event_new): Initialise args and env members to
6397 zero-length arrays.
6398 * init/tests/test_event.c (test_new): Use TEST_ALLOC_FAIL and
6399 make sure args and env are both initialised to a list containing
6400 just NULL.
6401
Scott James Remnantb36c1962007-02-06 01:48:09 +00006402 * util/jobs.c (start_action): Get the UPSTART_JOB environment variable
6403 and use that if we don't have any arguments passed to us.
6404 (do_job): Code split from the above function that handles a named job
6405 * util/tests/test_jobs.c (test_start_action): Make sure UPSTART_JOB
6406 is picked up.
6407
Scott James Remnant2a0b0852007-02-06 01:35:56 +00006408 * init/process.h: Add necessary attributes.
6409
Scott James Remnant0b10d502007-02-06 01:28:01 +00006410 * init/process.c (process_setup_environment): Set the UPSTART_JOB
6411 environment variable from the job, and the UPSTART_EVENT environment
6412 variable from the job's goal_event member (if set).
6413 * init/tests/test_process.c (test_spawn): Make sure we get the
6414 environment in the job.
6415
Scott James Remnantafce5282007-02-06 01:22:54 +00006416 * init/job.h: Add attributes to job_new and job_read_state.
6417 * init/tests/test_job.c: Use CHECK_ALLOC_FAIL on the functions we
6418 didn't get around to touching while we were in here.
6419
Scott James Remnant1b9914d2007-02-06 01:01:11 +00006420 * init/job.c (job_start_event, job_stop_event): Set the goal_event
6421 member to a copy of the event we found.
6422 (job_read_state): Use event_new instead of trying to do it by hand.
6423 * init/tests/test_job.c (test_start_event, test_stop_event): Use
6424 CHECK_ALLOC_FAIL; and make sure the goal_event is set properly.
6425 (test_start, test_stop, test_write_new): Use event_new here too
6426
Scott James Remnant9e7d25c2007-02-06 00:42:41 +00006427 * init/job.c (job_write_state): Output a goal_event field containing
6428 the event name or nothing for NULL.
6429 (job_read_state): Parse the goal_event field
6430 * init/tests/test_job.c (test_write_state): Make sure the state is
6431 written out properly.
6432 (test_read_state): Make sure that the state is parsed correctly too.
6433
Scott James Remnant7aa22b62007-02-06 00:32:30 +00006434 * init/job.c (job_start, job_stop): Split all of the code except
6435 the goal_event setting into two new static functions that this calls
6436 (_job_start, _job_stop): New static functions
6437 (job_start_event, job_stop_event): Call _job_start and _job_stop
6438 instead of job_start and job_stop
6439
Scott James Remnante4111be2007-02-06 00:17:27 +00006440 * init/job.c (job_catch_runaway): Move this function up a bit.
6441
Scott James Remnant5761ef02007-02-06 00:15:51 +00006442 * init/job.c (job_start, job_stop): Clear the goal_event member,
6443 these functions are called for a manual start.
6444 * init/tests/test_job.c (test_start, test_stop): Make sure the
6445 goal_event member is freed and set to NULL.
6446
Scott James Remnant2b2b7d12007-02-06 00:07:28 +00006447 * init/job.h (Job): Add a new goal_event member
6448 * init/job.c (job_new): Initialise the goal_event member to NULL.
6449 * init/tests/test_job.c (test_new): Check with TEST_ALLOC_FAIL;
6450 also make sure goal_event is initialised to NULL.
6451
Scott James Remnant506ad092007-02-05 21:09:30 +000064522007-02-05 Scott James Remnant <scott@netsplit.com>
6453
Scott James Remnantee7e5552007-02-05 23:14:10 +00006454 * configure.ac: Bump version to 0.3.3
6455
Scott James Remnantcf64c482007-02-05 23:14:00 +00006456 * NEWS: Update.
6457
Scott James Remnant506ad092007-02-05 21:09:30 +00006458 * init/process.c (process_spawn): Exit with 255 so we don't clash
6459 with anything that uses 1 as a normal exit code. Note why we only
6460 close 0..2 (everything else is FD_CLOEXEC).
6461 * init/cfgfile.c (cfg_watch_dir): Mark the inotify watch descriptor
6462 as FD_CLOEXEC.
6463 * init/control.c (control_open): nih_io_set_cloexec can only ever
6464 return EINVAL, so no point checking it.
6465
Scott James Remnant0b74ff62007-02-04 00:43:20 +000064662007-02-04 Scott James Remnant <scott@netsplit.com>
6467
6468 * init/tests/test_control.c: Remove strange old code.
6469
Scott James Remnant9c44a422007-02-03 12:17:14 +000064702007-02-03 Scott James Remnant <scott@netsplit.com>
6471
Scott James Remnant7b618862007-02-03 23:41:33 +00006472 * init/control.c (control_open_sock, control_reopen)
6473 (control_close_handler): Drop these functions; unconnected datagram
6474 sockets don't close -- so why try dealing with it?
6475 (control_error_handler): Don't reopen the socket on error, just log
6476 it -- the socket should be fine, there's no remote end to be lost,
6477 after all.
6478 * init/tests/test_control.c (test_close_handler): Drop.
6479 (test_error_handler): Drop the reopen tests.
6480
Scott James Remnant88c1aac2007-02-03 23:26:36 +00006481 * init/tests/test_job.c (test_run_script): Control socket doesn't
6482 get unexpectedly opened anymore; so no need to close it.
6483
6484 * init/control.c (control_open): Remove the strange behaviour that
6485 this can be called to get the socket. Instead make control_io
6486 global; we're all adults after all.
6487 * init/tests/test_control.c (test_open): Remove the test for the
6488 silly behaviour.
6489 * init/notify.c (notify_job, notify_event): Use the control_io
6490 pointer directly, and just do nothing if we lost it somehow.
6491
Scott James Remnant2e204b72007-02-03 23:15:28 +00006492 * init/main.c (main): Being unable tp open the control socket, or
6493 parse the configuration, should be a fatal error; stop being so
6494 damned liberal! <g> Don't reset the signal state if we're
6495 being restarted, as this loses any pending signals -- be happy
6496 that our parent left them in a good state. Set SIGCHLD to the
6497 standard handler, otherwise we might lose this before we start
6498 the main loop (which does the same anyway).
6499 (term_handler): Rework so we don't need to close and open the
6500 control socket; instead we just close it in the child that's
6501 going to send the state, and notify the parent that it's safe to
6502 exec (which will cause it to be closed so the new init can open it).
6503
Scott James Remnant3af85462007-02-03 18:31:54 +00006504 * init/tests/test_control.c (test_open): Fix valgrind error
6505 * init/tests/test_notify.c (test_subscribe): Fix valgrind error
6506
Scott James Remnante443b9c2007-02-03 18:24:18 +00006507 * init/notify.c (notify_subscribe): Make safe against ENOMEM.
6508 * init/tests/test_notify.c (test_subscribe): Use TEST_ALLOC_FAIL
6509
Scott James Remnant4b601d12007-02-03 18:20:00 +00006510 * init/control.c: Add needed attributes; tidy up formatting.
6511 (control_open): Don't let ENOMEM fail opening the control socket.
6512 * init/control.h: Add needed attributes.
6513 * init/tests/test_control.c (test_open): Test for failed allocation.
6514 * init/main.c (term_handler): Make sure we catch failure to open
6515 the control socket again.
6516
Scott James Remnantd308b432007-02-03 17:36:41 +00006517 * TODO: Update
6518
Scott James Remnant272938f2007-02-03 17:35:11 +00006519 * init/cfgfile.c (cfg_watch_dir): Clean this up a bit; now we only
6520 output a warning if inotify failed for any reason other than not
6521 being supported AND walking worked.
6522
Scott James Remnantd78d00e2007-02-03 17:27:32 +00006523 * init/cfgfile.c (cfg_watch_dir): Update to even newer watch API;
6524 our create_handler is now always called if inotify is successful,
6525 so we just need to fall back to walking the directory when it
6526 isn't -- if inotify isn't supported, don't even bother complaining.
6527 (cfg_create_modify_handler): Check the stat of the file visited to
6528 make sure it's a regular file.
6529 (cfg_visitor): Check the stat of the file visited to make sure it's
6530 a regular file.
6531
Scott James Remnantbcbb1122007-02-03 17:11:21 +00006532 * init/cfgfile.c: Update include to upstart/enum.h
6533 * init/job.c: Update include to upstart/enum.h
6534 * init/job.h: Update include to upstart/enum.h
6535
Scott James Remnant801f9e12007-02-03 17:10:06 +00006536 * logd/main.c: Add attribute to open_logging
6537
Scott James Remnantcbd0cf82007-02-03 17:05:39 +00006538 * util/initctl.c: Split out the command functions into new files;
6539 * util/jobs.c: This gets the job-related commands
6540 * util/events.h: This gets the event-related commands
6541 * util/initctl.h, util/jobs.h, util/events.h: Headers
6542 * util/tests/test_jobs.c: Test suite for job-related commands.
6543 * util/tests/test_events.c: Test suite for event-related commands.
6544 * util/Makefile.am (initctl_SOURCES): Add new files.
6545 (TESTS): Build new test suites.
6546 (test_jobs_SOURCES, test_jobs_LDFLAGS, test_jobs_LDADD):
6547 Details for job-related commands test suite binary.
6548 (test_events_SOURCES, test_events_LDFLAGS, test_events_LDADD):
6549 Details for event-related commands test suite binary.
6550 * TODO: Remove item about splitting initctl now we've done it.
6551
Scott James Remnantadfcc3f2007-02-03 12:24:07 +00006552 * TODO: Big update; strip anything we have a spec for.
6553
Scott James Remnant1157bbf2007-02-03 12:17:55 +00006554 * upstart/message.c (upstart_message_handle): Make sure that if we
6555 fail to parse a message, we don't leave strings around in memory.
6556 * upstart/tests/test_message.c (test_open): Check that we get a
6557 raised EADDRINUSE if we try an open a socket twice.
6558 (test_handle): Add lots of checks for things like NULL names and
6559 incomplete messages; as well as the obvious unknown message.
6560 (test_reader): Make sure that errors while handling messages are
6561 dealt with by logging it.
6562
Scott James Remnant9c44a422007-02-03 12:17:14 +00006563 * upstart/job.c, upstart/job.h, upstart/tests/test_job.c: Rename to
6564 enum.c, enum.h and tests/test_enum.c; since this just includes enums
6565 and convert functions really.
6566 * upstart/Makefile.am: Update.
6567 * upstart/libupstart.h: Update include.
6568 * upstart/tests/test_message.c: Update include.
6569
Scott James Remnant1e57ab22007-02-01 16:51:28 +000065702007-02-01 Scott James Remnant <scott@netsplit.com>
6571
Scott James Remnant0f1d9b62007-02-01 18:20:00 +00006572 * logd/main.c (main): Ensure we error if daemonise fails.
6573
Scott James Remnant36911572007-02-01 18:18:27 +00006574 * compat/sysv/shutdown.c (main): Ensure that signals and timers
6575 are added, even if we run out of memory.
6576
Scott James Remnant9b705ee2007-02-01 17:34:39 +00006577 * upstart/tests/test_message.c: Change from assert to assert0
6578 * upstart/tests/test_wire.c: Change from assert to assert0
6579 * init/tests/test_notify.c: Change from assert to assert0
6580 * init/tests/test_control.c: nih_io_message_send should always return
6581 a value greater than zero.
6582
Scott James Remnant91c6eb72007-02-01 17:19:32 +00006583 * upstart/tests/test_wire.c: Change to use assert instead of NIH_ZERO;
6584 the rationale here is that in test cases we just want to fail, not
6585 try again repeatedly.
6586 * upstart/tests/test_message.c: Likewise.
6587
Scott James Remnant9caf2822007-02-01 17:04:34 +00006588 * init/tests/test_control.c: Use assert to ensure we get the expected
6589 return values of functions that raise errors.
6590 * init/tests/test_notify.c: Use assert to ensure we get the expected
6591 return values of functions that raise errors.
6592
Scott James Remnant1e57ab22007-02-01 16:51:28 +00006593 * init/cfgfile.c (cfg_watch_dir): Port to the new NihWatch API and
6594 use nih_dir_walk(). This also fixes the long-standing bug where we
6595 wouldn't watch the configuration directory if inotify was disabled.
6596 Drop both the parent and prefix members for now, until we clean this
6597 up later.
6598 (cfg_create_modify_handler): Wrap cfg_read_job after figuring out
6599 the job name.
6600 (cfg_job_name): Function to figure out the job name from a path.
6601 (cfg_visitor): Visitor function to handle initial parsing, figuring
6602 out the job name; otherwise identical to the standard handler.
6603 * init/cfgfile.h: Update prototype for cfg_watch_dir.
6604 * init/main.c (main): Update call to cfg_watch_dir.
6605
Scott James Remnantbfd712d2007-01-31 12:13:25 +000066062007-01-31 Scott James Remnant <scott@netsplit.com>
6607
6608 * upstart/tests/test_message.c: Use TEST_ALLOC_FAIL to make sure
6609 allocations are handled properly.
6610
Scott James Remnant44828472007-01-30 11:53:33 +000066112007-01-30 Scott James Remnant <scott@netsplit.com>
6612
Scott James Remnant2cc36542007-01-30 17:12:34 +00006613 * upstart/wire.c: Note that if any of the push functions fail, the
6614 entire buffer should be discarded.
6615 * upstart/tests/test_wire.c (test_push_int, test_push_unsigned)
6616 (test_push_string, test_push_header, test_push_pack): Us
6617 TEST_ALLOC_FAIL to ensure that failing to allocate memory is caught.
6618
Scott James Remnant1084c682007-01-30 15:17:41 +00006619 * upstart/tests/test_message.c (my_handler): Free the name and
6620 description after checking; they aren't otherwise.
6621
Scott James Remnantdc8b3292007-01-30 15:01:30 +00006622 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Consume
6623 a copy of the va_list, so these can be called multiple times on the
6624 same list without ill effect.
6625
Scott James Remnant92d87442007-01-30 15:01:21 +00006626 * upstart/message.h: Add warn_unused_result attributes to
6627 upstart_message_handle and upstart_message_handle_using as they raise
6628 errors.
6629
Scott James Remnant2de25012007-01-30 14:57:27 +00006630 * upstart/wire.c: push functions return negative values to indicate
6631 insufficient memory.
6632 * upstart/wire.h: Add warn_unused_result attributes to push functions
6633
Scott James Remnant4ccebcf2007-01-30 14:51:17 +00006634 * upstart/tests/test_message.c: Guard calls to nih_io_buffer_push and
6635 nih_io_message_add_control with NIH_ZERO to ensure they succeed.
6636 * upstart/tests/test_wire.c: Guard calls to nih_io_buffer_push
6637
Scott James Remnant44828472007-01-30 11:53:33 +00006638 * HACKING: Update from libnih with new Documentation,
6639 Function Attributes and Test Cases sections.
6640
Scott James Remnant16a286f2007-01-10 15:38:33 +000066412007-01-10 Scott James Remnant <scott@netsplit.com>
6642
Scott James Remnantde443012007-01-10 18:45:40 +00006643 * init/main.c (crash_handler): s/SEGV/SIGSEGV/
6644
Scott James Remnant505f9282007-01-10 18:44:38 +00006645 * init/main.c (main): Rename variable
6646
Scott James Remnant56a4d062007-01-10 17:33:39 +00006647 * TODO: Update.
6648
Scott James Remnant78626fb2007-01-10 16:48:10 +00006649 * init/main.c (main): Change the way we clear the arguments; by
6650 deleting just the final NULL terminator, we fool the kernel into
6651 only returning one argument in cmdline.
6652
Scott James Remnant16a286f2007-01-10 15:38:33 +00006653 * init/main.c (segv_handler): Rename to crash_handler and handle
6654 SIGABRT as well, so we can catch assertion errors. Of course, in
6655 theory, with our high test converage this should never happen in
6656 practice <chortle>
6657
Scott James Remnant39ec35b2007-01-09 08:16:01 +000066582007-01-09 Scott James Remnant <scott@netsplit.com>
6659
Scott James Remnant7f4db422007-01-09 20:51:08 +00006660 * init/main.c (main): Clear arguments so that upstart only ever
6661 appears as /sbin/init in ps, top, etc.
6662
Scott James Remnant8fd06de2007-01-09 20:38:27 +00006663 * TODO: Update.
6664
Scott James Remnant4d0481d2007-01-09 20:38:07 +00006665 * util/initctl.c: Add data pointer to functions and handle calls.
6666
Scott James Remnantbcf9e972007-01-09 20:34:47 +00006667 * init/control.c: Add data pointer to all functions.
6668 * init/tests/test_control.c: Pass data pointer to
6669 upstart_message_handle_using()
6670 * init/tests/test_notify.c: Pass data pointer to
6671 upstart_message_handle_using()
6672
Scott James Remnant6aa008c2007-01-09 20:26:44 +00006673 * upstart/message.c (upstart_message_handle)
6674 (upstart_message_handle_using): Add a data pointer argument to these
6675 functions and pass it to the handler.
6676 (upstart_message_reader): Pass the io structure's data pointer.
6677 * upstart/message.h (UpstartMessageHandler): Add a data pointer to
6678 the message handler.
6679 * upstart/tests/test_message.c (test_handle, test_handle_using):
6680 Pass a data pointer to the function call and check it's passed
6681 to the handler correctly.
6682 (test_reader): Check that the io data pointer gets passed.
6683
Scott James Remnantc7017d32007-01-09 18:44:58 +00006684 * init/tests/test_cfgfile.c (test_stanza_console, test_stanza_env)
6685 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Finish off
6686 the newer style test cases.
6687
Scott James Remnante63ef802007-01-09 17:54:56 +00006688 * init/cfgfile.c (cfg_stanza_console, cfg_stanza_umask)
6689 (cfg_stanza_nice, cfg_stanza_limit, cfg_stanza_chroot)
6690 (cfg_stanza_chdir): Guard against duplicate uses of the stanzas.
6691 * init/tests/test_cfgfile.c (test_stanza_daemon)
6692 (test_stanza_respawn): Check that neither daemon or respawn override
6693 exec if they have no arguments.
6694 (test_stanza_script): Add missing function
6695 (test_stanza_chroot, test_stanza_chdir): Add tests for these simple
6696 stanzas.
6697
Scott James Remnant0cd393d2007-01-09 17:36:34 +00006698 * init/cfgfile.c: Change remaining uses of nih_error_raise and
6699 return to just nih_return_error.
6700
Scott James Remnantc352b632007-01-09 17:31:41 +00006701 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_daemon)
6702 (cfg_stanza_respawn, cfg_stanza_script): Disallow duplicates,
6703 both of command strings, scripts, limits and of just the flags.
6704 * init/tests/test_cfgfile.c (test_stanza_exec)
6705 (test_stanza_daemon, test_stanza_respawn, test_stanza_instance):
6706 Check the behaviour of these stanzas.
6707
Scott James Remnant94188d42007-01-09 16:43:58 +00006708 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop): Disallow
6709 duplicate values for the script.
6710 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop):
6711 Test cases for those two functions.
6712
Scott James Remnant474a6ff2007-01-09 16:17:49 +00006713 * init/cfgfile.c (cfg_stanza_description, cfg_stanza_author)
6714 (cfg_stanza_version): Don't allow stanza to be duplicated anymore.
6715 * init/tests/test_cfgfile.c (test_stanza_description)
6716 (test_stanza_author, test_stanza_version): Test cases for these
6717 simple stanza; making sure duplication is not permitted.
6718 (test_stanza_on): Add a test case for this stanza too.
6719
Scott James Remnant49e8bb82007-01-09 15:57:59 +00006720 * init/cfgfile.c (cfg_stanza_kill): Guard against duplicate uses
6721 of the kill timeout stanza.
6722 * init/tests/test_cfgfile.c (test_stanza_kill): Test the complex
6723 kill stanza.
6724 (test_stanza_pid): Check duplicate usage results in an error.
6725
Scott James Remnant443ef2e2007-01-09 15:47:24 +00006726 * init/job.h (Job): Rename pidfile to pid_file and binary to pid_binary
6727 * init/job.c (job_new): Update names here too.
6728 * init/errors.h: Add a new "duplicate value" error.
6729 * init/cfgfile.c (cfg_read_job): Change name of variables, and catch
6730 the duplicate value error to add the line number.
6731 (cfg_stanza_pid): Change variable names, and clean this function up
6732 a little. Make it an error to use a stanza more than once.
6733 * init/tests/test_cfgfile.c (test_stanza_pid): Write a newer test
6734 case function for the pid stanza.
6735
Scott James Remnant34ff87d2007-01-09 09:00:30 +00006736 * init/cfgfile.c (cfg_stanza_normalexit): Use do/while instead of
6737 while, that we don't have to test has_token first as next_arg does
6738 that for us.
6739
Scott James Remnanta7354692007-01-09 08:56:02 +00006740 * init/cfgfile.c (cfg_stanza_normalexit): Change to peek at the next
6741 token to see whether it's missing or not, and then just fetch each
6742 next argument at a time. This is more efficient than parsing them
6743 all in one go, and also means we can report the error in the right
6744 place!
6745 * init/tests/test_cfgfile.c (test_stanza_normalexit): Since we've
6746 changed the function that parses the stanza, add a proper test case
6747 function for it, covering all the behaviours.
6748
Scott James Remnant92e7fda2007-01-09 08:40:13 +00006749 * init/job.c (job_new): Initialise the emits member to an empty list.
6750 * init/job.h (Job): Add the emits member as a list.
6751 * init/tests/test_job.c (test_new): Check the emits list starts off
6752 empty.
6753 * init/tests/test_cfgfile.c (test_stanza_emits): Test the new emits
6754 stanza; this function will also serve as a prototype for cleaning up
6755 the config tests.
6756
6757 * init/cfgfile.c (cfg_stanza_emits): Add function to parse the new
6758 emits stanza.
6759
Scott James Remnant39ec35b2007-01-09 08:16:01 +00006760 * init/cfgfile.c (cfg_stanza_depends): Remove the depends stanza
6761 from the configuration file. Dependency support has never been used,
6762 and is to be replaced by a more flexible event/state configuration
6763 and blocking on the starting/stopping events.
6764 * init/tests/test_cfgfile.c: Remove references and tests for the
6765 depends stanza.
6766 * init/job.h: Remove the depends list from the job structure.
6767 * init/job.c (job_new): No depends list to initialise.
6768 (job_change_state): No dependencies to release
6769 (job_start): No dependencies to iterate; this removes a particularly
6770 hairy and complex interaction between state changes. Remove the
6771 dependency event.
6772 (job_release_depends): Drop this function.
6773 * init/tests/test_job.c (test_start, test_stop): Massively simplify
6774 these tests cases now we don't have dependencies to worry about.
6775 (test_release_depends): Drop tests
6776
Scott James Remnantd4f5fb82007-01-08 23:25:23 +000067772007-01-08 Scott James Remnant <scott@netsplit.com>
6778
6779 * init/cfgfile.c: Rewrite using the nih_config API, rather than one
6780 huge function we now just have seperate handler functions for each
6781 stanza. We can also use more fine-grained parsing than slurping
6782 all args in and counting them.
6783 (cfg_read_job): Catch exceptions from the configuration parser and
6784 add the line number where the problem occurred to an output message.
6785 Parser errors are now fatal, and not ignored.
6786 * init/errors.h: Add a file containing errors raised within the init
6787 daemon codebase.
6788 * init/Makefile.am (init_SOURCES): Build with errors.h
6789 * init/tests/test_cfgfile.c: Update test cases now we don't expect
6790 a job to be returned if there's a parser error.
6791
6792 * TODO: Update
6793
Scott James Remnant66384202007-01-06 14:23:18 +000067942007-01-06 Scott James Remnant <scott@netsplit.com>
6795
Scott James Remnant4f968192007-01-06 20:31:13 +00006796 * logd/main.c (logging_reader): Fix inadvertent shadowing of the
6797 len parameter.
6798
Scott James Remnantda100272007-01-06 20:24:18 +00006799 * compat/sysv/telinit.c: Oops, nearly forgot to port this to send
6800 the messages in the new way.
6801 * compat/sysv/shutdown.c (shutdown_now): Likewise, port this too.
6802
Scott James Remnant83a86522007-01-06 19:55:38 +00006803 * TODO: Update.
6804
Scott James Remnant6e941882007-01-06 14:38:57 +00006805 * util/initctl.c (handle_job_status): Output the process argument,
6806 not the pid argument which contains the origin of the message.
6807
Scott James Remnant17d6dca2007-01-06 14:33:30 +00006808 * upstart/message.c (upstart_message_handle): Raise a new unknown
6809 message error if we don't have a handler and a new illegal message
6810 error if the source is illegal.
6811 * upstart/tests/test_message.c (test_handle): Adjust tests to check
6812 for the new errors that we raise.
6813 * upstart/errors.h: Define strings for new errors.
6814
Scott James Remnant66384202007-01-06 14:23:18 +00006815 * util/initctl.c: Yet another makeover for this little program,
6816 port it to the new message/control framework using handler functions
6817 and NihIoMessage. This starts to make each action function look
6818 very similar, so there's method to this madness.
6819
Scott James Remnantb4725d92007-01-05 13:10:21 +000068202007-01-05 Scott James Remnant <scott@netsplit.com>
6821
Scott James Remnant3d6bb792007-01-05 22:33:43 +00006822 * logd/main.c (main): Make sure that we add the SIGTERM handler.
6823
Scott James Remnantefbaafb2007-01-05 18:12:15 +00006824 * init/tests/test_job.c (test_run_script): This test case relies
6825 on there only being one file descriptor watch, which won't be true
6826 if the control socket has been opened because there's a message to
6827 go out. Make sure it's closed first.
6828
Scott James Remnantbe1941f2007-01-05 17:57:59 +00006829 * init/init.supp: Update supressions file now that control_init
6830 has been renamed to notify_init
6831
Scott James Remnant71cc4d82007-01-05 17:53:32 +00006832 * init/Makefile.am: Include notify.o from all tests.
6833 * init/job.c (job_change_state, job_kill_process, job_start)
6834 (job_stop): Use the new notify_job function name.
6835 * init/event.c (event_queue_run): Use the new notify_event function
6836 name.
6837
Scott James Remnantfea6cb62007-01-05 17:49:13 +00006838 * init/control.c (control_error_handler): Handle ECONNREFUSED now
6839 that the process id is available to us.
6840 * init/tests/test_control.c (test_error_handler): Make sure children
6841 going away is handled properly.
6842
Scott James Remnant3dfb2132007-01-05 17:44:48 +00006843 * upstart/message.c (upstart_message_new): Store the process id in
6844 the int_data message field.
6845 * upstart/tests/test_message.c (test_new): Check the int_data field
6846 is filled in.
6847
Scott James Remnant5d702952007-01-05 17:21:34 +00006848 * init/main.c (main): Guard against various things returning an error
6849 that we weren't catching.
6850
Scott James Remnant601a0e32007-01-05 17:06:31 +00006851 * init/tests/test_notify.c: Whitespace fix.
6852
Scott James Remnant15cd0862007-01-05 17:06:20 +00006853 * init/control.c (control_watch_jobs, control_unwatch_jobs)
6854 (control_watch_events, control_unwatch_events): Restore functionality
6855 to subscribe and unsubscribe from job and event notifications.
6856 * init/tests/test_control.c (test_watch_jobs, test_unwatch_jobs)
6857 (test_watch_events, test_unwatch_events): Check that the subscription
6858 and unsubscription messages work.
6859 * init/Makefile.am (test_control_LDADD): Link to notify.o
6860
6861 * init/control.c: Drop unused include of upstart/errors.h
6862
Scott James Remnant58cef572007-01-05 16:18:42 +00006863 * init/notify.c: Move functions that handle subscription and
6864 notification from control.c. Other than changing the names, we're
6865 keeping the API the same for now; expect it to change later when we
6866 add the ability to subscribe to individual jobs or events.
6867 (notify_init): initialise the subscriptions list; we don't have a
6868 separate send queue now that the control I/O is always asynchronous.
6869 * init/notify.h: Moved notification enum, structure and prototypes
6870 from control.h, changing the names so they match notify_* in the
6871 process.
6872 * init/Makefile.am (init_SOURCES): Build and link notify.c using
6873 notify.h
6874 (TESTS): Build the notify test suite binary.
6875 (test_notify_SOURCES, test_notify_LDFLAGS, test_notify_LDADD): Details
6876 for notify test suite binary.
6877 * init/tests/test_notify.c: Rewrite test cases in the manner of
6878 test_control.c so that we have one function for notify_job and
6879 one for notify_event, each of which contains the child process that
6880 receives the notification,
6881
Scott James Remnantb1679c62007-01-05 15:49:54 +00006882 * init/control.c (control_open): Allow this to be called to obtain
6883 the control socket, which means we can make it static.
6884 * init/tests/test_control.c (test_open): Check that it works.
6885
Scott James Remnantf7c6b062007-01-05 15:33:33 +00006886 * init/control.c, init/control.h, init/tests/test_control.c: Move
6887 functions that handle subscription and notification to new notify.c
6888 (control_init): Drop completely, no need to maintain a send queue now
6889 (control_open): Change to return an NihIo that uses the default
6890 control watcher, and our error handler. Split socket opening into
6891 (control_open_sock): which can be called from other functions.
6892 (control_close): Use nih_io_close() to close the socket and free the
6893 structure in one go.
6894 (control_reopen): Close the open control socket and open it again
6895 without destroying the NihIo structure, its queues or state.
6896 (control_close_handler): Handle the control socket going away
6897 (control_error_handler): Handle errors on the control socket,
6898 including the connection refused error that indicates a client went
6899 away.
6900 (control_handle): Split this into a miriad of small functions with
6901 a table to link them to the message type; this will make expanding
6902 each message handler much easier in future.
6903 * init/control.h: Update.
6904 * init/tests/test_control.c: Rewrite test cases to check the new
6905 handler functions; as a side-effect, this gets rid of the evil giant
6906 child/parent functions in favour of one test function per handler
6907 function.
6908
Scott James Remnantb4725d92007-01-05 13:10:21 +00006909 * upstart/message.c (upstart_message_handle_using): Wrapper function
6910 around upstart_message_handle that ensures all messages as passed to
6911 a single function.
6912 * upstart/message.h: Update.
6913 * upstart/tests/test_message.c (test_handle_using): Make sure it
6914 calls the single function.
6915
Scott James Remnantde3666f2007-01-04 23:00:07 +000069162007-01-04 Scott James Remnant <scott@netsplit.com>
6917
6918 * upstart/message.c (upstart_message_reader): Handle any errors
6919 that occurred while handling the message.
6920
Scott James Remnant92feed92007-01-02 15:27:47 +000069212007-01-02 Scott James Remnant <scott@netsplit.com>
6922
Scott James Remnant7833bbf2007-01-02 20:57:23 +00006923 * upstart/message.c (upstart_message_handle): Check that the name
6924 argument is never NULL.
6925 (upstart_message_reader): Simple message reader function that can
6926 be associated with an I/O watch and handles each message received.
6927 * upstart/message.h: Add prototype.
6928 * upstart/tests/test_message.c (test_reader): Test the reader function.
6929
Scott James Remnant0e3b5fe2007-01-02 18:39:03 +00006930 * upstart/control.c: Rename to upstart/message.c
6931 * upstart/control.h: Rename to upstart/message.h
6932 * upstart/tests/test_control.c: Rename to upstart/tests/test_message.c
6933 * upstart/libupstart.h: Update includes.
6934 * upstart/wire.c: Include message.h
6935 * upstart/wire.h: Update includes.
6936 * upstart/tests/test_wire.c: Update includes.
6937 * upstart/errors.h: Rename UPSTART_INVALID_MESSAGE to
6938 UPSTART_MESSAGE_INVALID so that it's prefixed.
6939 * upstart/Makefile.am (libupstart_la_SOURCES)
6940 (upstartinclude_HEADERS, TESTS): Update filenames.
6941
Scott James Remnant2ad9a042007-01-02 18:29:49 +00006942 * upstart/control.c (upstart_message_new): New function that
6943 creates an NihIoMessage directly from its arguments, which are a type
6944 followed by a variable number of args depending on that type.
6945 (upstart_message_handler): Function to find a handler function for
6946 a particular message type and origin process.
6947 (upstart_message_handle): New function that takes an NihIoMessage
6948 and invokes a handler function with a variable number of args
6949 depending on the message type.
6950 (upstart_send_msg, upstart_send_msg_to, upstart_recv_msg): Drop these
6951 functions, leave it up to the caller to decide whether to send and
6952 receive the messages synchronously or asynchronously; now that the
6953 capability is in nih_io_*.
6954 * upstart/control.h (UpstartMsgType): Rename to UpstartMessageType.
6955 (UpstartMessageHandler): Function with variable number of arguments
6956 that handles a message received.
6957 (UpstartMsg): Drop this structure entirely, we'll encode or decode
6958 the wire format directly from or into a function call, rather than
6959 use an intermediate structure to marshal it.
6960 (UpstartMessage): New structure to make a table that can be passed
6961 to upstart_message_handle to determine which handler should be called.
6962 * upstart/tests/test_control.c: Test new behaviour.
6963 * upstart/wire.c (upstart_push_header, upstart_pop_header): Change
6964 structure name for type parameter.
6965 * upstart/wire.h: Update.
6966 * upstart/tests/test_wire.c: Update.
6967
Scott James Remnant92feed92007-01-02 15:27:47 +00006968 * configure.ac (AC_COPYRIGHT): Update copyright to 2007.
6969
Scott James Remnant67546d12006-12-29 13:08:32 +000069702006-12-29 Scott James Remnant <scott@netsplit.com>
6971
6972 * upstart/wire.c (upstart_write_int, upstart_write_unsigned)
6973 (upstart_write_string, upstart_write_header, upstart_write_packv)
6974 (upstart_write_pack): Rename to *_push_*
6975 (upstart_read_int, upstart_read_unsigned, upstart_read_string)
6976 (upstart_read_header, upstart_read_packv, upstart_read_pack): Rename
6977 to *_pop_*.
6978 All of the above modified to modify an NihIoMessage structure,
6979 instead of trying to carry around buffers ourself.
6980 * upstart/wire.h: Update to match above.
6981 * upstart/tests/test_wire.c: Update all tests to match the above
6982 changes.
6983
Scott James Remnantd76e8e32006-12-21 18:34:31 +000069842006-12-21 Scott James Remnant <scott@netsplit.com>
6985
Scott James Remnantf922a982006-12-21 18:45:30 +00006986 * upstart/wire.c (upstart_read_packv, upstart_write_packv): Change
6987 nih_assert_notreached to nih_assert_not_reached.
6988
Scott James Remnantd76e8e32006-12-21 18:34:31 +00006989 * init/job.c (job_run_script): Open the NihIo structure in stream mode.
6990 * logd/main.c (logging_watcher): Open the NihIo structure in
6991 stream mode.
6992 (logging_reader): Need to pass the length of the size_t as a pointer
6993 so that it can be modified if less is read.
6994
Scott James Remnanta0385232006-12-17 15:21:39 +000069952006-12-17 Scott James Remnant <scott@netsplit.com>
6996
Scott James Remnant00cc6882006-12-17 19:54:36 +00006997 * upstart/wire.c (upstart_write_packv, upstart_write_pack)
6998 (upstart_read_packv, upstart_read_pack): Functions to write a pack
6999 of different variables to the stream, or read them from it
7000 * upstart/wire.h: Add prototypes.
7001 * upstart/tests/test_wire.c (test_write_pack, test_read_pack):
7002 Check we can read and write a pack of variables at once.
7003
Scott James Remnant518e1c12006-12-17 18:12:14 +00007004 * upstart/wire.c (upstart_write_header, upstart_read_header): Drop
7005 the version from the header, we'll just keep the protocol always
7006 backwards compatible.
7007 * upstart/wire.h: Update.
7008 * upstart/tests/test_wire.c (test_write_header, test_read_header):
7009 Check that everything works.
7010
Scott James Remnant64e378f2006-12-17 17:24:44 +00007011 * upstart/wire.c (upstart_write_string, upstart_read_string):
7012 Transmit the length as an unsigned, and use 0xffffffff to mean NULL
7013 instead of zero so we can still transmit the empty string.
7014 * upstart/wire.h: Update.
7015 * upstart/tests/test_wire.c (test_write_string, test_read_string):
7016 Tests for the functions to make sure the wire is at it should be.
7017
Scott James Remnantd6dde952006-12-17 17:00:56 +00007018 * upstart/wire.c (upstart_read_str, upstart_write_str): Rename to
7019 upstart_read_string and upstart_write_string.
7020 * upstart/wire.h: Update.
7021
Scott James Remnantc71ab3b2006-12-17 16:58:28 +00007022 * upstart/wire.c (upstart_write_unsigned, upstart_read_unsigned):
7023 Functions to send unsigned values over the wire, which we'll use
7024 to get a bit extra for the string lengths.
7025 * upstart/wire.h: Update.
7026 * upstart/tests/test_wire.c (test_write_unsigned)
7027 (test_read_unsigned): Test the new functions.
7028
Scott James Remnant0218e3a2006-12-17 16:39:33 +00007029 * upstart/wire.c (upstart_write_ints, upstart_read_ints): Drop
7030 these functions, we'll go with something far more generic and
7031 useful.
7032 * upstart/wire.h: Remove prototypes.
7033
Scott James Remnant9ee44302006-12-17 16:37:59 +00007034 * upstart/wire.c (upstart_write_int, upstart_read_int): Transmit
7035 integers as signed 32-bit values in network byte order.
7036 * upstart/tests/test_wire.c (test_write_int, test_read_int): Test
7037 the functions to make sure the wire is at it should be,
7038
Scott James Remnant5cef53e2006-12-17 15:41:13 +00007039 * upstart/control.c (upstart_read_int, upstart_write_int)
7040 (upstart_read_ints, upstart_write_ints, upstart_read_str)
7041 (upstart_write_str, upstart_read_header, upstart_write_header): Move
7042 functions to new wire.c file.
7043 * upstart/wire.c: Source file to hold wire protocol functions.
7044 * upstart/wire.h: Prototypes.
7045 * upstart/tests/test_wire.c: (empty) test suite.
7046 * upstart/libupstart.h: Include wire.h
7047 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link wire.c
7048 (upstartinclude_HEADERS): Install wire.h
7049 (TESTS): Build and run wire test suite.
7050 (test_wire_SOURCES, test_wire_LDFLAGS, test_wire_LDADD): Details for
7051 wire test suite binary.
7052
Scott James Remnanta0385232006-12-17 15:21:39 +00007053 * upstart/control.c (MAGIC): Change to "upstart\n", the final
7054 character was originally \0 and then was a " " for the 0.2 series.
7055 * upstart/tests/test_control.c (test_recv_msg): Change to match.
7056
Scott James Remnantfb9412a2006-12-15 18:03:22 +000070572006-12-15 Scott James Remnant <scott@netsplit.com>
7058
Scott James Remnant2e5fe2b2006-12-15 18:27:58 +00007059 * util/initctl.c, compat/sysv/telinit.c, compat/sysv/shutdown.c:
7060 Update all uses of the UpstartMsg structure to avoid the
7061 intermediate union that no longer exists.
7062
Scott James Remnantfb521462006-12-15 18:24:57 +00007063 * init/control.c, init/tests/test_control.c: Update all uses of
7064 the UpstartMsg structure to avoid the intermediate union that no
7065 longer exists.
7066
Scott James Remnant99b97662006-12-15 18:15:22 +00007067 * upstart/control.h: Combine all the previous message structures
7068 into just one that has all of the fields anyway.
7069 * upstart/control.c, upstart/tests/test_control.c: Update all uses of
7070 the UpstartMsg structure to avoid the intermediate union that no
7071 longer exists.
7072
Scott James Remnantd452ab12006-12-15 18:05:23 +00007073 * upstart/control.h (UPSTART_API_VERSION): Define API version macro
7074 to be public.
7075 * upstart/control.c (MSG_VERSION, upstart_send_msg_to): Replacing the
7076 previous MSG_VERSION macro here.
7077
Scott James Remnantfb9412a2006-12-15 18:03:22 +00007078 * upstart/control.c (upstart_read_int, upstart_write_int)
7079 (upstart_read_ints, upstart_write_ints, upstart_read_str)
7080 (upstart_write_str, upstart_read_header, upstart_write_header):
7081 New functions to replace the old "write a struct" protocol with
7082 something a little more regimented and supportable.
7083 (IOVEC_ADD, IOVEC_READ, WireHdr, WireJobPayload, WireJobStatusPayload)
7084 (WireEventPayload): Remove these structures, use the functions
7085 instead.
7086 (upstart_send_msg_to): Call write functions intead of using macros,
7087 this makes the code somewhat neater.
7088 (upstart_recv_msg): Call read functions instead of using macros,
7089 again making the code somewhat neater.
7090 * upstart/tests/test_control.c (test_recv_msg): Change wire
7091 tests to match new protocol, and thus actually work properly,
7092 previously these were endian sensitive.
7093
Scott James Remnant27ebd792006-12-14 11:37:14 +000070942006-12-14 Scott James Remnant <scott@netsplit.com>
7095
Scott James Remnant136dc6f2006-12-14 12:36:43 +00007096 * compat/sysv/shutdown.c (wall): Construct the wall message so that
7097 we don't put \r into a po file; for some reason, gettext hates that
7098 and bitches about it. Someone's confusing internationalisation with
7099 operating system portability, I expect.
7100
Scott James Remnantf334f842006-12-14 11:46:14 +00007101 * util/man/initctl.8: Drop reference to start(8), as that's just
7102 a symlink to initctl now.
7103
Scott James Remnant88847432006-12-14 11:44:36 +00007104 * init/man/init.8: Link to initctl.
7105
Scott James Remnantf6b237a2006-12-14 11:40:49 +00007106 * compat/sysv/reboot.c (main): Clear up help text a little.
7107
Scott James Remnant3b4b2272006-12-14 11:39:05 +00007108 * HACKING: Correct some typos.
7109
Scott James Remnant27ebd792006-12-14 11:37:14 +00007110 * configure.ac (AC_INIT): Correct bug reporting address.
7111
Scott James Remnant1d8763a2006-12-13 17:49:38 +000071122006-12-13 Scott James Remnant <scott@netsplit.com>
7113
Scott James Remnantecec0fe2006-12-13 21:55:28 +00007114 * configure.ac: Bump version to 0.3.2
7115
Scott James Remnantf642ffa2006-12-13 18:24:22 +00007116 * NEWS: Update.
7117
Scott James Remnant1d8763a2006-12-13 17:49:38 +00007118 * util/initctl.c (print_job_status): Drop the newline from the
7119 output.
7120
Scott James Remnant567cbdc2006-12-13 17:07:58 +000071212006-12-13 Alex Smith <alex@alex-smith.me.uk>
7122
7123 * util/initctl.c (print_job_status): Clean up initctl job status
7124 output, which was badly converted from printf to nih_message.
7125
Scott James Remnante2cf6392006-12-13 17:02:20 +000071262006-12-13 Scott James Remnant <scott@netsplit.com>
7127
7128 * compat/sysv/man/shutdown.8: Add missing documentation on the
7129 format of TIME by copying it from --help output.
7130
Scott James Remnantfec90562006-12-13 17:00:40 +000071312006-12-13 Alex Smith <alex@alex-smith.me.uk>
7132
7133 * init/process.c (process_setup_console): Actually send output to
7134 /dev/null instead of /dev/console, when CONSOLE_NONE.
7135
Scott James Remnantf233c9d2006-12-13 16:45:35 +000071362006-12-13 Scott James Remnant <scott@netsplit.com>
7137
Scott James Remnantfbf7a5c2006-12-13 16:54:42 +00007138 * Makefile.am (EXTRA_DIST): Distribute the nih ChangeLog as well.
7139
Scott James Remnantf233c9d2006-12-13 16:45:35 +00007140 * init/tests/test_job.c: Port to the new test framework.
7141 * init/job.c (job_set_idle_event): Fix a slight memory leak,
7142 repeated setting of the idle event never freed the previous one set.
7143
Scott James Remnant1abced42006-12-12 11:28:49 +000071442006-12-12 Scott James Remnant <scott@netsplit.com>
7145
Scott James Remnantfbad50c2006-12-12 18:47:43 +00007146 * init/tests/test_cfgfile.c: Port to the new test framework.
7147
Scott James Remnantef372232006-12-12 17:23:05 +00007148 * init/tests/test_control.c: Port to the new test framework.
7149 * init/init.supp: Suppress the list head allocated within control_init.
7150
Scott James Remnant2c2e01a2006-12-12 17:22:40 +00007151 * init/control.c (control_watcher): Need to save the pid when we
7152 get ECONNREFUSED, otherwise we lose it when we free the message.
7153
Scott James Remnant40f7d912006-12-12 15:31:35 +00007154 * init/tests/test_process.c: Port to the new test framework.
7155 * init/init.supp: Suppress the list head allocated within job_init.
7156
Scott James Remnantfc456592006-12-12 14:09:45 +00007157 * init/init.supp: Include a valgrind suppressions file.
7158 * init/Makefile.am (EXTRA_DIST): Distribute the suppressions file.
7159
Scott James Remnant96c9b072006-12-12 14:07:30 +00007160 * init/tests/test_event.c: Port to the new test framework.
7161
Scott James Remnant237c7f62006-12-12 13:49:19 +00007162 * logd/Makefile.am, util/Makefile.am, compat/sys/Makefile.am
7163 (AM_CPPFLAGS): Add -I$(srcdir), necessary for testing "programs"
7164 that don't have usual library path semantics.
7165
Scott James Remnant2a35ab92006-12-12 13:23:10 +00007166 * upstart/tests/test_control.c: Port to the new test framework.
7167 * upstart/control.c (upstart_free): Drop this function, while not
7168 exposing libnih is a valiant effort, it already slips out because
7169 of the error handling.
7170
Scott James Remnant905dd272006-12-12 12:38:34 +00007171 * upstart/tests/test_job.c: Add missing include.
7172
Scott James Remnante77567f2006-12-12 12:25:46 +00007173 * upstart/tests/test_job.c: Port to the new test framework.
7174 (test_process_state_name): Check that this returns NULL.
7175
Scott James Remnantb7983062006-12-12 11:34:49 +00007176 * HACKING: Update location of download directory. Document
7177 requirement that all code have test cases.
7178
Scott James Remnant0c577ce2006-12-12 11:31:13 +00007179 * logd/main.c (open_logging): Likewise.
7180
Scott James Remnantc654baf2006-12-12 11:30:44 +00007181 * init/control.c (control_open): No need to set ENOMEM, errno is
7182 always set anyway.
7183
Scott James Remnant1abced42006-12-12 11:28:49 +00007184 * configure.ac (AM_INIT_AUTOMAKE): Include nostdinc so we don't get
7185 Automake's broken default includes.
7186 * upstart/Makefile.am (DEFAULT_INCLUDES): Drop override now that
7187 we don't need it.
7188 (DEFS, INCLUDES): Replace these variables with the combined
7189 (AM_CPPFLAGS): variable that declares everything.
7190 * init/Makefile.am (DEFAULT_INCLUDES): Drop override now that
7191 we don't need it.
7192 (DEFS, INCLUDES): Replace these variables with the combined
7193 (AM_CPPFLAGS): variable that declares everything.
7194 * util/Makefile.am (DEFAULT_INCLUDES): Drop override now that
7195 we don't need it.
7196 (DEFS, INCLUDES): Replace these variables with the combined
7197 (AM_CPPFLAGS): variable that declares everything.
7198 * compat/sysv/Makefile.am (DEFAULT_INCLUDES): Drop override now that
7199 we don't need it.
7200 (DEFS, INCLUDES): Replace these variables with the combined
7201 (AM_CPPFLAGS): variable that declares everything.
7202 * logd/Makefile.am (DEFAULT_INCLUDES): Drop override now that
7203 we don't need it.
7204 (DEFS, INCLUDES): Replace these variables with the combined
7205 (AM_CPPFLAGS): variable that declares everything.
7206
Scott James Remnantacec3b22006-11-02 16:36:53 +000072072006-11-02 Scott James Remnant <scott@netsplit.com>
7208
7209 * util/initctl.c (start_action): Remove break calls which shouldn't
7210 be there.
7211
Scott James Remnantea806b72006-10-18 15:01:00 +010072122006-10-18 Sean E. Russell <ser@ser1.net>
7213
7214 * init/main.c: Include sys/time.h
7215 * init/cfgfile.c: Include sys/time.h and sys/resource.h
7216 * init/job.c: Include sys/time.h and sys/resource.h
7217
Scott James Remnant6702ac12006-10-17 18:55:24 +010072182006-10-17 Scott James Remnant <scott@netsplit.com>
7219
Scott James Remnantd5758f42006-10-17 19:21:25 +01007220 * configure.ac: Bump version to 0.3.1
7221
Scott James Remnantfd029da2006-10-17 19:21:07 +01007222 * NEWS: Update.
7223 * TODO: Update.
7224
Scott James Remnant9f67cb82006-10-17 19:12:28 +01007225 * configure.ac (AM_GNU_GETTEXT_VERSION): Quote version number.
7226
Scott James Remnant4ebe87f2006-10-17 19:04:40 +01007227 * logd/Makefile.am (event.d/logd): Make the event.d sub-directory
7228 in case we're building outside of the source tree.
7229
Scott James Remnant6702ac12006-10-17 18:55:24 +01007230 * compat/sysv/runlevel.c (store): Don't break strict-aliasing rules
7231 by avoiding dereferencing type-punned pointer. Answers on a
7232 postcard, please.
7233
Scott James Remnant7f133012006-10-13 12:00:34 +010072342006-10-13 Scott James Remnant <scott@netsplit.com>
7235
Scott James Remnantecbb2b52006-10-13 15:18:24 +01007236 * util/initctl.c (start_action, emit_action): Add missing \n
7237
Scott James Remnant48622982006-10-13 15:15:50 +01007238 * util/initctl.c: Rewrite using nih_command_parser.
7239 * util/man/initctl.8: Improve.
7240
7241 * util/start.c: Remove, replaced by initctl.
7242 * util/man/start.8: Remove, replaced by initctl.
7243 * util/Makefile.am (sbin_PROGRAMS): Drop start, now just a symlink
7244 to initctl.
7245 (dist_man_MANS): Drop start.8, now a symlink to initctl.8
7246 (install-exec-hook): Make symlinks to initctl, add start
7247 (install-data-hook): Make symlinks to initctl.8, add start.8
7248
Scott James Remnantb1d8a7d2006-10-13 13:57:31 +01007249 * initctl: Rename to util again, I don't want a separate directory
7250 for every single little tool; and we'll be shipping more than just
7251 initctl (e.g. a non-compat reboot).
7252 * configure.ac (AC_CONFIG_FILES): Make util/Makefile instead of
7253 initctl/Makefile.
7254 * Makefile.am (SUBDIRS): Descend into util, not initctl.
7255
Scott James Remnanta48b4fe2006-10-13 13:49:46 +01007256 * compat/sysv/reboot.c: Remove long options where they didn't exist
7257 before. Write help text.
7258 * compat/sysv/man/reboot.8: Update.
7259
Scott James Remnant462734c2006-10-13 13:36:00 +01007260 * init/main.c (main): Formatting.
7261 * logd/main.c (main): Formatting.
7262 * logd/man/logd.8: Formatting.
7263 * compat/sysv/runlevel.c (main): Formatting.
7264 * compat/sysv/telinit.c (main): Formatting.
7265 * compat/sysv/man/shutdown.8: Remove long options.
7266
Scott James Remnanteff01f12006-10-13 13:32:12 +01007267 * compat/sysv/shutdown.c: Remove -e/--event, it has no place in a
7268 compatibility tool. Get rid of long options that never existed
7269 before. Specify help text to describe the options.
7270 * compat/sysv/man/shutdown.8: Spruce up a bit.
7271
Scott James Remnant4a5cd212006-10-13 12:59:15 +01007272 * compat/sysv/telinit.c (main): Set help text to list the valid
7273 runlevels.
7274 * compat/sysv/man/telinit.8: Refine the notes to mention runlevel(8).
7275
Scott James Remnantf7819622006-10-13 12:54:43 +01007276 * compat/sysv/runlevel.c (main): Make the help text describe the
7277 options, rather than the behaviour.
Scott James Remnant4a5cd212006-10-13 12:59:15 +01007278 * compat/sysv/man/runlevel.8: Flesh out a little more.
Scott James Remnantf7819622006-10-13 12:54:43 +01007279
Scott James Remnant930e25a2006-10-13 12:28:05 +01007280 * configure.ac (AC_INIT): Change bug reporting address to the
7281 mailing list, since Launchpad doesn't accept random bugs without
7282 accounts and complicated control messages.
7283 * init/main.c, logd/main.c: Add a period to the synopsis.
7284
Scott James Remnanta6ed7eb2006-10-13 12:14:45 +01007285 * init/main.c (main): Set the synopsis, and direct people to look
7286 at telinit in the --help output.
7287 * init/man/init.8: Flesh this out a little more, still a lot of
7288 explaining to do about jobs and events, but we'll wait until we've
7289 changed that code before documentating the behaviour.
7290
Scott James Remnant7f133012006-10-13 12:00:34 +01007291 * logd/main.c (main): Correct help text to describe the options,
7292 rather than what the program does. As per standard style.
7293 Don't become a daemon until the logging socket is open, and make
7294 that exclusive with waiting for SIGCONT.
7295 * logd/man/logd.8: Write some more extensive documentation,
7296 including describing the startup interlock and the socket protocol.
7297 * TODO: Plan to get rid of the signal interlock from logd.
7298
Scott James Remnant8985dd32006-10-12 15:26:29 +010072992006-10-12 Scott James Remnant <scott@netsplit.com>
7300
7301 * configure.ac: Expand AC_GNU_SOURCE so we get _GNU_SOURCE and so
7302 that gettext doesn't complain.
7303 (AM_GNU_GETTEXT_VERSION): Increase to 0.15
7304 (AC_PREREQ): Increase to 2.60
7305 * HACKING: Update autoconf and gettext requirements.
7306
Scott James Remnantc16a9b42006-10-11 17:08:58 +010073072006-10-11 Scott James Remnant <scott@netsplit.com>
7308
Scott James Remnant74a11442006-10-11 17:58:56 +01007309 * init/control.c (control_init): Pass NULL to nih_list_new.
7310 Clarify list item types.
7311 * init/event.c (event_init): Pass NULL to nih_list_new.
7312 * init/job.c (job_init): Pass NULL to nih_list_new.
7313
Scott James Remnantc34c4be2006-10-11 17:56:34 +01007314 * init/main.c: Change nih_signal_add_callback to nih_signal_add_handler
7315 and NihSignalCb to NihSignalHandler.
7316
Scott James Remnant8b227402006-10-11 17:55:27 +01007317 * init/cfgfile.c, init/cfgfile.h, init/control.c, init/control.h,
7318 init/event.c, init/event.h, init/job.c, init/job.h, init/main.c,
7319 init/process.c: Clean up documentation strings and parent pointer
7320 types.
7321
Scott James Remnantd033c862006-10-11 17:41:22 +01007322 * compat/sysv/shutdown.c: Change nih_signal_add_callback to
7323 nih_signal_add_handler.
7324
Scott James Remnant1ee0f482006-10-11 17:40:41 +01007325 * compat/sysv/reboot.c: Set synopsis text depending on command
7326 used (probably should use nih_command_parser?)
7327 * compat/sysv/runlevel.c: Set synopsis and help text, and correct
7328 usage.
7329 * compat/sysv/shutdown.c: Set synopsis text.
7330 * compat/sysv/telinit.c: Set synopsis text.
7331
Scott James Remnant3b734642006-10-11 17:22:33 +01007332 * compat/sysv/runlevel.c, compat/sysv/shutdown.c: Clean up
7333 documentation strings.
7334
Scott James Remnantc6e4f002006-10-11 17:22:03 +01007335 * logd/main.c: Set synopsis and help text.
7336
Scott James Remnant5e31d742006-10-11 17:16:55 +01007337 * logd/main.c: Clean up documentation strings.
7338 Change nih_signal_add_callback to nih_signal_add_handler.
7339
Scott James Remnant48359382006-10-11 17:13:48 +01007340 * upstart/control.c, upstart/control.h, upstart/job.c: Clean up
7341 documentation strings and correct parent pointer type.
7342
Scott James Remnantc16a9b42006-10-11 17:08:58 +01007343 * HACKING: Detail function documentation requirement and format.
7344
Scott James Remnant59093a82006-10-10 13:09:58 +010073452006-10-10 Scott James Remnant <scott@netsplit.com>
7346
Scott James Remnant335947d2006-10-11 17:08:34 +01007347 * event.d/logd.in: Move to logd/event.d
7348 * event.d/Makefile.am: Remove
7349 * logd/Makefile.am: Create the logd job definition and install
7350 * Makefile.am (SUBDIRS): event.d directory has been removed.
7351 * configure.ac (AC_CONFIG_FILES): No longer make event.d/Makefile
7352
Scott James Remnant59093a82006-10-10 13:09:58 +01007353 * configure.ac: Check for --enable-compat, default to sysv if given
7354 or no compat if not given.
7355 * compat/sysv/Makefile.am: Don't build binaries or install manpages
7356 unless COMPAT_SYSV is defined.
7357
Scott James Remnant45150942006-10-06 16:36:27 +010073582006-10-06 Scott James Remnant <scott@netsplit.com>
7359
7360 * doc/upstart-logo.svg: Include the logo Alexandre designed.
7361 * doc/Makefile.am (EXTRA_DIST): Ship the logo in the tarball.
7362 * Makefile.am (SUBDIRS): Install under doc
7363 * configure.ac: Generate doc/Makefile
7364 * AUTHORS: Ensure he's credited fully.
7365
Scott James Remnant10b8c0e2006-09-27 21:27:38 +010073662006-09-27 Scott James Remnant <scott@netsplit.com>
7367
Scott James Remnant44052a32006-09-28 00:04:32 +01007368 * event.d/Makefile.am (do_subst): Eliminate duplicate /s
7369
Scott James Remnant5222c402006-09-27 22:48:48 +01007370 * man/init.8: Move to init/man
7371 * init/Makefile.am: Update to install man page.
7372 * man/logd.8: Move to logd/man
7373 * logd/Makefile.am: Update to install man page.
7374 * man/initctl.8, man/start.8: Move to initctl/man
7375 * initctl/Makefile.am: Update to install man pages.
7376 * man/reboot.8, man/runlevel.8, man/shutdown.8, man/telinit.8:
7377 Move to compat/sysv/man
7378 * compat/sysv/Makefile.am: Update to install man pages.
7379 * man/Makefile.am: Remove
7380 * configure.ac (AC_CONFIG_FILES): Remove man/Makefile
7381 * Makefile.am (SUBDIRS): Don't build in man
7382
Scott James Remnant545cb8c2006-09-27 21:32:49 +01007383 * util: Rename to initctl
7384 * configure.ac (AC_CONFIG_FILES): Update.
7385 * Makefile.am (SUBDIRS): Update.
7386
Scott James Remnant960c82d2006-09-27 21:30:42 +01007387 * util/reboot.c: Move to compat/sysv
7388 * util/shutdown.c: Move to compat/sysv
7389 * util/Makefile.am: Update.
7390 * compat/sysv/Makefile.am: Update.
7391
Scott James Remnant10b8c0e2006-09-27 21:27:38 +01007392 * configure.ac: Replace macros with single call to NIH_INIT.
7393 Bump version to 0.3.0 to begin new development cycle.
7394
Scott James Remnante5591992006-09-21 05:49:34 +010073952006-09-21 Scott James Remnant <scott@netsplit.com>
7396
7397 * logd/main.c: Revert the change that logged to the console, in
7398 practice this doesn't work so well. I want to get rid of logd
7399 in the long term, or at least just have it as a simple logging
7400 proxy, so giving it features seems wrong.
7401
Scott James Remnant9b58b842006-09-20 05:37:47 +010074022006-09-20 Scott James Remnant <scott@netsplit.com>
7403
Scott James Remnant97f08fa2006-09-20 06:34:12 +01007404 * configure.ac: Bump version to 0.2.8
7405 * NEWS: Updated.
7406
Scott James Remnante59c71e2006-09-20 06:14:32 +01007407 * logd/main.c (main): Check the kernel command-line for "quiet"
7408 (line_reader): Write to console unless silent or a daemon
7409
Scott James Remnant9b58b842006-09-20 05:37:47 +01007410 * man/Makefile.am (dist_man_MANS): Drop sulogin.8
7411 * man/sulogin.8: Drop, we don't include an sulogin
7412
Scott James Remnant0fafba42006-09-20 01:36:29 +010074132006-09-19 Michael Biebl <mbiebl@gmail.com>
7414
7415 * event.d/Makefile.am (logd): Drop $(srcdir)
7416 * init/Makefile.am (init_SOURCES): Distribute paths.h
7417
Scott James Remnant58f165f2006-09-18 19:43:07 +010074182006-09-18 Michael Biebl <mbiebl@gmail.com>
7419
7420 * configure.ac: Check for sys/inotify.h
7421
Scott James Remnante371cab2006-09-18 16:16:00 +010074222006-09-18 Scott James Remnant <scott@netsplit.com>
7423
7424 * util/shutdown.c (warning_message): Adjust method of constructing
7425 the message to not confuse poor translators who think \r and \n are
7426 the same thing!
7427
Scott James Remnantf2b1c052006-09-14 10:34:45 +010074282006-09-14 Scott James Remnant <scott@netsplit.com>
7429
Scott James Remnantb2e03d02006-09-14 11:20:13 +01007430 * init/job.c (job_change_state): Catch runaway respawns when we
7431 enter the running state, so we catch stop/start loops too.
7432 * init/tests/test_job.c (test_change_state): Update test.
7433
Scott James Remnantb7714f72006-09-14 11:07:38 +01007434 * event.d/logd: Rename to logd.in
7435 * event.d/logd.in: Replace /sbin with @sbindir@ so we can transform
7436 * event.d/Makefile.am: Generate logd from logd.in
7437
Scott James Remnant7e6bdb32006-09-14 10:57:03 +01007438 * util/reboot.c: Don't hardcode the location of /sbin/shutdown
7439 * util/Makefile.am (DEFS): Use autoconf to seed it
7440 * util/shutdown.c (sysvinit_shutdown): Don't hardcode the location
7441 of /dev/initctl
7442
Scott James Remnante0d0dd12006-09-14 10:51:05 +01007443 * init/paths.h: Create a new configuration file that can contain
7444 all of the path definitions, and in particular, allow them to be
7445 overidden elsewhere.
7446 * init/Makefile.am (DEFS): Override definitions of CFG_DIR and
7447 TELINIT using autoconf
7448 * init/main.c: Include paths.h. Don't hardcode location of telinit
7449 * init/job.c: Include paths.h
7450 * init/process.c: Include paths.h
7451 * init/process.h: Remove definitions from here.
7452
Scott James Remnantf2b1c052006-09-14 10:34:45 +01007453 * configure.ac: Bump version to 0.2.7
7454
Scott James Remnant0b8f23f2006-09-13 16:51:38 +010074552006-09-13 Scott James Remnant <scott@netsplit.com>
7456
Scott James Remnant948ab872006-09-14 10:34:34 +01007457 * NEWS: Updated.
7458
Scott James Remnant0b8f23f2006-09-13 16:51:38 +01007459 * TODO: More TODO.
7460
Scott James Remnant080dd8d2006-09-10 12:42:03 +010074612006-09-10 Scott James Remnant <scott@netsplit.com>
7462
7463 * util/reboot.c (main): Don't give -H with "halt".
7464
Scott James Remnantd7042862006-09-09 00:50:10 +010074652006-09-09 Scott James Remnant <scott@netsplit.com>
7466
Scott James Remnantedb97902006-09-09 05:48:42 +01007467 * configure.ac: Bump version to 0.2.6
7468
Scott James Remnant760237e2006-09-09 05:38:32 +01007469 * NEWS: Update.
7470 * TODO: Update.
7471
Scott James Remnant5e267a42006-09-09 05:21:28 +01007472 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
7473 the magic to be the package string.
7474 * upstart/tests/test_control.c (test_recv_msg): Update tests.
7475
Scott James Remnant17fec6e2006-09-09 05:05:42 +01007476 * util/initctl.c (main): Set the usage string.
7477 * util/shutdown.c (main): Set the usage string.
7478 * util/start.c (main): Set the usage string.
7479 * compat/sysv/runlevel.c (main): Set the usage string.
7480 * compat/sysv/telinit.c (main): Set the usage string.
7481
Scott James Remnantabede802006-09-09 05:01:45 +01007482 * man/Makefile.am: Use install-data-hook and $(man8dir)
7483 * util/Makefile.am: Also use install-exec-hook
7484
Scott James Remnantc6c20052006-09-09 04:58:11 +01007485 * Makefile.am (SUBDIRS): Install contents of the man directory
7486 * configure.ac (AC_CONFIG_FILES): Generate man/Makefile
7487 * man/Makefile.am: Install manpages in the appropriate places.
7488 * man/init.8, man/logd.8, man/initctl.8, man/reboot.8,
7489 * man/shutdown.8, man/start.8, man/sulogin.8, man/runlevel.8,
7490 * man/telinit.8: Include some basic manpages so we at least have
7491 some level of documentation.
7492
Scott James Remnant33e47112006-09-09 03:45:00 +01007493 * init/job.c (job_child_reaper): Don't check the exit status of
7494 a respawning job if the goal is to stop it.
7495
Scott James Remnant1889aa62006-09-09 03:41:53 +01007496 * compat/sysv/telinit.c (main): Generate events rather than
7497 starting and stopping jobs directly, the events are named
7498 "runlevel-X". 0, 1, 6 and s/S are shutdown events.
7499
Scott James Remnant515b2b92006-09-09 03:41:27 +01007500 * logd/main.c (main): Raise SIGSTOP before entering the main loop.
7501 * init/main.c (main): Interlock with logd.
7502
Scott James Remnant17eb9052006-09-09 03:41:04 +01007503 * event.d/logd: Should not be a console owner, but should stop
7504 on shutdown.
7505
Scott James Remnant34752262006-09-09 01:38:02 +01007506 * init/process.c (process_setup_console): Revert part of the previous
7507 change, should just output to /dev/null if we don't have logd.
7508
Scott James Remnante5533332006-09-09 01:36:07 +01007509 * configure.ac: Bump version to 0.2.5
7510
Scott James Remnantb4a1c2b2006-09-09 01:28:26 +01007511 * init/main.c (main): Start the logd job if it exists.
7512
7513 * init/process.c (process_setup_console): Ignore ECONNREFUSED as
7514 that just means that logd isn't around, handle errors by falling
7515 back to opening the console.
7516
Scott James Remnant9fb20d42006-09-09 01:22:03 +01007517 * init/process.c (process_setup_console): Implement handling for
7518 CONSOLE_LOGGED and generally clean up the other handling.
7519 * init/process.h: Update.
7520 * init/main.c (main): Pass NULL for the job to setup console.
7521 * TODO: Update.
7522
Scott James Remnantd7042862006-09-09 00:50:10 +01007523 * logd/main.c: Implement the logging daemon, it accepts connections
7524 on a unix stream socket with the abstract name
7525 "/com/ubuntu/upstart/logd", expects the length of the name and the
7526 name to follow; then sequences of lines which are logged to
7527 /var/log/boot, or memory until that file can be opened.
7528
Scott James Remnant527b9452006-09-08 17:15:07 +010075292006-09-08 Scott James Remnant <scott@netsplit.com>
7530
Scott James Remnantcb655e72006-09-08 17:49:20 +01007531 * util/shutdown.c (event_setter): Change the event names to
7532 distinguish between "shutdown -h" and "shutdown -h -H".
7533
Scott James Remnant90732d32006-09-08 17:33:19 +01007534 * init/job.c (job_handle_event): Allow jobs to react to their own
7535 events, this is how we'll do respawn eventually.
7536 * init/tests/test_job.c (test_handle_event): Remove test.
7537
Scott James Remnantbb3cc3f2006-09-08 17:17:47 +01007538 * init/main.c (cad_handler, kbd_handler): Generate the new event
7539 names.
7540 * init/event.h (CTRLALTDEL_EVENT, KBDREQUEST_EVENT): Add definitions
7541 of these event names, change the ctrlaltdel event to just that.
7542
Scott James Remnant527b9452006-09-08 17:15:07 +01007543 * logd/main.c (main): Add the code to daemonise, etc.
7544
Scott James Remnanta17917d2006-09-07 00:18:28 +010075452006-09-07 Scott James Remnant <scott@netsplit.com>
7546
Scott James Remnant214ebe82006-09-07 21:48:55 +01007547 * TODO: Long discussion today on #upstart, many improvements to the
7548 job and event model that make it more elegant.
7549 * AUTHORS: Include a list of thanks.
7550
Scott James Remnantb8280072006-09-07 03:19:00 +01007551 * util/shutdown.c (shutdown_now): If we get ECONNREFUSED when we
7552 try and send the shutdown event to init, it probably means we're
7553 still in sysvinit. So try that instead.
7554 (sysvinit_shutdown): Function to send a hand-crafted runlevel
7555 change message across /dev/initctl.
7556
Scott James Remnantae969062006-09-07 00:43:57 +01007557 * util/initctl.c (main): Add a shutdown command that takes an
7558 arbitrary event name to be issued after "shutdown". You'll
7559 nearly always want the /sbin/shutdown tool instead.
7560
Scott James Remnant987bcc42006-09-07 00:38:24 +01007561 * init/job.c (job_detect_idle): Only generate the stalled event
7562 if at least one job handles it in its start_events list.
7563 * init/tests/test_job.c (test_detect_idle): Make sure that works.
7564
Scott James Remnantea204d42006-09-07 00:30:53 +01007565 * init/event.h (STARTUP_EVENT, SHUTDOWN_EVENT, STALLED_EVENT):
7566 Macros to define the standard event names.
7567 * init/main.c (main): Use STARTUP_EVENT macro instead of "startup"
7568 * init/control.c (control_handle): Use SHUTDOWN_EVENT macro
7569 instead of "shutdown".
7570 * init/job.c (job_detect_idle): Use STALLED_EVENT macro instead
7571 of "stalled".
7572
Scott James Remnant84607df2006-09-07 00:27:22 +01007573 * init/job.c (job_detect_idle): Add some log messages for when we
7574 detect the idle or stalled states.
7575 (job_kill_process, job_kill_timer): Increase log verbosity.
7576 * init/event.c (event_queue_run): Log which events we're handling
7577 if --debug is given.
7578
Scott James Remnanta17917d2006-09-07 00:18:28 +01007579 * compat/sysv/telinit.c (main): Send a shutdown command when
7580 requesting to enter runlevel 0 or runlevel 6, likewise for
7581 runlevel 1, s or S which all run "rc1" not "rcS".
7582 * init/main.c (main): When called directory (pid != 1) try and
7583 run telinit before complaining that we're not init. Make sure
7584 errors aren't lost.
7585
Scott James Remnantf5c376c2006-09-04 16:25:04 +010075862006-09-04 Johan Kiviniemi <johan@kiviniemi.name>
Scott James Remnantedcae302006-09-04 07:06:23 +01007587
Scott James Remnantf5c376c2006-09-04 16:25:04 +01007588 * upstart/control.c (upstart_addr): Replace use of __builtin_offsetof
7589 with offsetof.
7590 * upstart/tests/test_control.c (test_recv_msg): Likewise.
7591
75922006-09-04 Scott James Remnant <scott@netsplit.com>
7593
Scott James Remnantedcae302006-09-04 07:06:23 +01007594 * util/shutdown.c (main): Exit normally after sending the warning
7595 message if -k is given.
7596
Scott James Remnante94bd202006-09-01 00:48:36 +010075972006-09-01 Scott James Remnant <scott@netsplit.com>
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01007598
Scott James Remnant294cde72006-09-01 19:58:35 +01007599 * configure.ac: Bump version to 0.2.2
7600
Scott James Remnant7663bfb2006-09-01 19:58:19 +01007601 * NEWS: Update.
7602 * configure.ac: Bump version to 0.2.1
7603
Scott James Remnant67982142006-09-01 19:47:39 +01007604 * init/process.c (process_setup_console): Ensure that the console
7605 is always initialised to at least /dev/null
7606 * init/job.c (job_change_state): Initialise event to NULL.
7607 * init/event.c (event_read_state): Don't mask initialisation of
7608 other variable.
7609 * init/cfgfile.c (cfg_job_stanza, cfg_parse_script, cfg_next_token):
7610 Print lineno using %zi not %d
7611 * compat/sysv/runlevel.c (store): Cast pointer type of timeval.
7612
Scott James Remnant097b2a92006-09-01 19:30:37 +01007613 * init/main.c: Move the kernel headers include beneath the C
7614 library ones, so that compilation doesn't fail on !i386.
7615 * util/reboot.c: Likewise.
7616
Scott James Remnant28fcc922006-09-01 04:15:57 +01007617 * init/main.c (term_handler): Close the control connection if we
7618 re-exec init, otherwise it won't be able to bind. Drop debugging.
7619
Scott James Remnant6f464962006-09-01 04:10:20 +01007620 * init/main.c (term_handler): It always helps if we dup2 the
7621 right file descriptor.
7622
Scott James Remnant1db88042006-09-01 03:14:19 +01007623 * init/main.c: Use the TERM signal instead of USR1, as old init
7624 used that for something else. Also rather than passing across
7625 file descriptor numbers, use a fixed descriptor and just pass
7626 "--restart". When we get that option we need to unmask signals
7627 otherwise we sit there looking like a lemon.
7628
Scott James Remnante7a73262006-09-01 02:32:27 +01007629 * init/job.c (job_change_state): Don't free the event unless we
7630 generate one.
7631
Scott James Remnant12dd7252006-09-01 02:27:04 +01007632 * NEWS: Update.
7633
Scott James Remnant694172a2006-09-01 02:26:45 +01007634 * init/cfgfile.c (cfg_watcher): Ignore any file with '.' or '~'
7635
Scott James Remnantc6e63dd2006-09-01 02:16:43 +01007636 * TODO: Update.
7637
Scott James Remnant3401ab72006-09-01 02:14:47 +01007638 * init/main.c (main): Parse command-line arguments, specifically
7639 look for --state-fd which we'll use for reexec. Don't do a couple
7640 of things if we're passed this.
7641 (read_state): Parse the line-buffered state.
7642 * init/job.c (job_read_state, job_write_state): Job state
7643 serialisation so that we can re-exec ourselves.
7644 * init/job.h: Update.
7645 * init/tests/test_job.c: Test the serialisation.
7646 * init/event.c (event_read_state, event_write_state): And similar
7647 functions for serialising the event queue.
7648 * init/event.h: Update.
7649 * init/tests/test_event.c: Test the serialisation.
7650 * init/cfgfile.c (cfg_read_job): Fix a bug, need to subtract current
7651 time to get due time.
7652
Scott James Remnante94bd202006-09-01 00:48:36 +01007653 * upstart/job.c (job_goal_from_name, job_state_from_name)
7654 (process_state_from_name): Add opposite numbers that convert a
7655 string back into an enumeration.
7656 * upstart/job.h: Update.
7657 * upstart/tests/test_job.c: Test the new functions.
7658
76592006-08-31 Scott James Remnant <scott@netsplit.com>
Scott James Remnant694172a2006-09-01 02:26:45 +01007660
Scott James Remnantb7260a72006-08-31 22:08:56 +01007661 * init/job.h (Job): Add respawn_limit, respawn_interval,
7662 respawn_count and respawn_time members so that we can keep track of
7663 runaway processes.
7664 * init/job.c (job_catch_runaway): Increment the respawn_count
7665 within respawn_interval, or reset it if we go over.
7666 (job_new): Initialise respawn_limit and respawn_interval to sensible
7667 defaults.
7668 * init/tests/test_job.c (test_new): Check the defaults are set.
7669 (test_change_state): Check the respawning code works.
7670 * init/cfgfile.c (cfg_job_stanza): Parse the "respawn limit" stanza.
7671 * init/tests/test_cfgfile.c (test_read_job): Test the new stanza.
7672
Scott James Remnantff0d26a2006-08-31 20:49:43 +01007673 * init/process.c (process_setup_console): Remove the console reset
7674 code, it tends to just crash X and seems to do nothing interesting.
7675 * init/main.c (reset_console): Instead put it here and just do it
7676 on startup.
7677
Scott James Remnant25b263a2006-08-31 18:59:02 +01007678 * configure.ac: Bump version to 0.2.0
7679
Scott James Remnant4b61be92006-08-31 17:08:44 +01007680 * util/Makefile.am (install-exec-local): Create symbolic links,
7681 not hard links.
7682
Scott James Remnantaf1404f2006-08-31 16:04:16 +01007683 * init/main.c: Can't catch STOP.
7684
Scott James Remnant242b50b2006-08-31 15:40:42 +01007685 * util/reboot.c: Pause init while shutting down or rebooting.
7686
Scott James Remnanteabb7802006-08-31 15:39:04 +01007687 * init/main.c (stop_handler): Catch STOP/TSTP and CONT.
7688 * init/event.c (event_queue_run): Don't run the event queue while
7689 paused.
7690 * init/job.c (job_detect_idle): Don't detect idle jobs while paused.
7691
Scott James Remnant1cd8d862006-08-31 15:17:16 +01007692 * util/reboot.c: if we get the -w argument ("only write to wtmp")
7693 we need to exit, and not behave as halt normally would.
7694
Scott James Remnantff63cf72006-08-31 04:39:34 +01007695 * compat/sysv/runlevel.c (main): Add missing newline.
7696 * compat/sysv/telinit.c (main): And here too.
7697
Scott James Remnant32de9222006-08-31 04:34:27 +01007698 * init/main.c (main): Check for idle after the startup event queue
7699 has been run, otherwise we may just sit there.
7700
Scott James Remnant13ffffe2006-08-31 04:33:39 +01007701 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install telinit
7702 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Details for
7703 telinit binary.
7704 * compat/sysv/telinit.c: Trivial telinit program that just runs
7705 the appropriate rcX job.
7706 * compat/sysv/runlevel.c (main): Suggest help on illegal runlevel.
7707
Scott James Remnant40f09012006-08-31 04:21:49 +01007708 * util/Makefile.am: Tidy up.
7709
Scott James Remnant12473562006-08-31 04:21:05 +01007710 * configure.ac (AC_CONFIG_FILES): Create compat/sysv/Makefile
7711 * Makefile.am (SUBDIRS): Build things found in compat/sysv
7712 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install runlevel
7713 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD): Details for
7714 runlevel binary.
7715 * compat/sysv/runlevel.c: Helper to store and retrieve the current
7716 "runlevel" from utmp/wtmp; as well as the reboot time.
7717
Scott James Remnantd909cca2006-08-31 04:20:14 +01007718 * init/main.c (main): Drop debugging set.
7719
Scott James Remnantcedd11a2006-08-31 02:59:29 +01007720 * init/job.c (job_change_state): As well as the job/state events,
7721 send the job event when a service is running or a task is stopping.
7722 * init/tests/test_job.c (test_change_state): Check the events get
7723 sent properly.
7724
Scott James Remnant44b684a2006-08-31 02:58:45 +01007725 * util/start.c: Write a simple utility to start, stop, or query
7726 the status of the named jobs.
7727 * util/Makefile.am (sbin_PROGRAMS): Build and install start
7728 (start_SOURCES, start_LDFLAGS, start_LDADD): Details for start
7729 (install-exec-local): Also install as stop and status.
7730 * util/reboot.c (main): Drop the debugging set.
7731
Scott James Remnantb8ed2d12006-08-31 02:15:48 +01007732 * init/cfgfile.c (cfg_job_stanza): Correct nih_alloc error.
7733
Scott James Remnanta6125ae2006-08-31 02:14:25 +01007734 * init/process.c (process_setup_environment): Guard memory alloc.
7735 * init/job.c (job_set_idle_event): Likewise.
7736 (job_change_state): And here too.
7737 (job_run_command): Likewise.
7738 * init/control.c (control_send): Likewise.
7739 * init/cfgfile.c: And throughout this file.
7740 * upstart/control.c (upstart_recv_msg): And once here too.
7741
Scott James Remnant0b358ab2006-08-31 02:07:32 +01007742 * upstart/control.h: Abolish the separate halt, reboot and poweroff
7743 messages and replace with a single shutdown message that takes
7744 an event name (for the idle event issued afterwards).
7745 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
7746 the new shutdown event type by just treating it as an event.
7747 * upstart/tests/test_control.c (test_messages): Update tests.
7748 * init/job.c (job_set_idle_event): Store a copy of the idle event
7749 name.
7750 * init/control.c (control_send): Copy the shutdown event name.
7751 (control_handle): Replace individual handling with the new
7752 single event.
7753 * init/tests/test_control.c (test_watcher): Update.
7754 * util/initctl.c: Drop handling for things that shutdown does now.
7755 * util/shutdown.c: Send the UPSTART_SHUTDOWN event and let the user
7756 specify anything they want, just give defaults.
7757
Scott James Remnantff5efb92006-08-31 01:45:19 +01007758 This is quite a big change and abolishes level events entirely,
7759 along with the event history. We now just treat events as a
7760 transient queue of strings that go past, may cause things to change,
7761 but are otherwise forgotten. This turns out to be much easier to
7762 understand and has no real loss of power.
7763
7764 * init/event.c: Vastly simplify; gone are the separate notions of
7765 edge and level events, instead we just treat them as one-shot
7766 things that go past and are forgotten about.
7767 * init/event.h (Event): Remove value member.
7768 Update prototypes.
7769 * init/tests/test_event.c: Update.
7770 * init/job.c (job_change_state): Change the event pattern to be
7771 one that includes the job name and a description of the transition
7772 instead of the new state.
7773 (job_detect_idle): Call event_queue rather than event_queue_edge.
7774 * init/tests/test_job.c: Update.
7775 * init/cfgfile.c (cfg_job_stanza): Drop "when" and "while".
7776 * init/tests/test_cfgfile.c (test_read_job): Drop mentions of
7777 "when" and "while".
7778 * init/control.c (control_send, control_handle): Drop cases for
7779 level events.
7780 (control_handle_event): Don't include a level in the event.
7781 * init/tests/test_control.c: Update
7782 * init/main.c: Call event_queue rather than event_queue_edge.
7783 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
7784 event handling so that only a name is read.
7785 * upstart/control.h: Remove value/level event structures.
7786 * upstart/tests/test_control.c (test_messages): Update.
7787 * upstart/job.c (process_state_name): Not used for events, adjust
7788 documentation so it doesn't lie.
7789 * util/initctl.c (main): Drop the set function, simplify trigger.
7790 * util/shutdown.c (shutdown_now): Call UPSTART_EVENT_QUEUE for
7791 shutdown into maintenance mode.
7792
Scott James Remnantfcbee2d2006-08-31 00:49:36 +01007793 * init/control.c (control_handle): Place a message in the syslog
7794 before halting, powering off or rebooting.
7795
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01007796 * util/shutdown.c: Adjust so that the warning message is sent out
7797 if shutdown is immediate, and when it actually happens. Include
7798 the hostname as wall does.
7799
Scott James Remnant255c5f22006-08-30 16:05:01 +010078002006-08-30 Scott James Remnant <scott@netsplit.com>
7801
Scott James Remnant5be55662006-08-30 19:13:25 +01007802 * TODO: Update.
7803
Scott James Remnant4a9245f2006-08-30 19:13:00 +01007804 * util/shutdown.c: Implement shutdown utility along the same lines
7805 as the sysvinit one, but with rather different code.
7806
Scott James Remnant2a71aaa2006-08-30 16:34:06 +01007807 * util/initctl.c (main): Call setuid on the effective user id so
7808 that we can be made setuid root and executable by a special group.
7809 * util/reboot.c (main): Likewise.
7810
Scott James Remnant70cc2292006-08-30 16:06:03 +01007811 * util/initctl.c (main): Check the effective rather than the real
7812 user id, if we're effectively root, that's good enough.
7813
Scott James Remnant255c5f22006-08-30 16:05:01 +01007814 * util/reboot.c: Implement reboot/halt/poweroff utility.
7815 * util/Makefile.am (sbin_PROGRAMS): Build and install reboot
7816 (reboot_SOURCES, reboot_LDFLAGS, reboot_LDADD): Details for reboot
7817 (install-exec-local): Create hardlinks to reboot for halt and poweroff.
7818
Scott James Remnantdc8877d2006-08-29 16:56:48 +010078192006-08-29 Scott James Remnant <scott@netsplit.com>
7820
7821 * init/main.c (main): Actually run the idle-detect function.
7822 * init/job.c (job_detect_idle): Interrupt the main loop, otherwise
7823 we may end up waiting for a signal before we process the event
7824 we just issued.
7825
Scott James Remnantf43bdf32006-08-27 18:20:29 +010078262006-08-27 Scott James Remnant <scott@netsplit.com>
7827
Scott James Remnant47158482006-08-27 22:37:10 +01007828 * util/shutdown.c: Template main function.
7829 * util/Makefile.am (sbin_PROGRAMS): Build and install the
7830 shutdown binary.
7831 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD): Details for
7832 the shutdown binary
7833
Scott James Remnant70a6ec62006-08-27 22:23:50 +01007834 * util/initctl.c (main): Add commands for halt, poweroff and reboot.
7835
Scott James Remnant0c7e72a2006-08-27 22:22:53 +01007836 * init/event.c (event_queue_run): Remove the parameters.
7837 * init/event.h: Update.
7838 * init/main.c (main): Update.
7839 * init/tests/test_control.c (test_watcher): Update.
7840 * init/tests/test_job.c (test_detect_idle): Update.
7841
Scott James Remnant96ae9e42006-08-27 22:15:34 +01007842 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Deal
7843 with halting, rebooting and powering off; or at least the appropriate
7844 messages.
7845 * upstart/control.h: Add control message structures for halting,
7846 powering off and rebooting the machine.
7847 * upstart/tests/test_control.c (test_messages): Run the tests.
7848 * init/control.c (control_handle): Add handling for halt, power off
7849 and reboot that issue the shutdown event and arrange for the halt,
7850 poweroff or reboot to be issued the next time the system is idle.
7851 * init/tests/test_control.c (test_watcher): Test the events.
7852
Scott James Remnant01a37082006-08-27 21:51:00 +01007853 * TODO: Update.
7854
Scott James Remnante02892b2006-08-27 21:49:44 +01007855 * init/job.c (job_detect_idle): Function to detect when the system is
7856 stalled or idle.
7857 * init/job.h: Update
7858 * init/tests/test_job.c (test_detect_idle): Test the new function.
7859
Scott James Remnant6a8508c2006-08-27 19:10:44 +01007860 * util/initctl.c (main): Handle the list command.
7861
Scott James Remnanta9476ad2006-08-27 19:07:23 +01007862 * TODO: Update.
7863
Scott James Remnant4da474d2006-08-27 19:06:35 +01007864 * upstart/control.c (WireJobStatusPayload): add description to the
7865 job status payload.
7866 (upstart_send_msg_to, upstart_recv_msg): Send and receieve the
7867 description over the wire.
7868 * upstart/control.h (UpstartJobStatusMsg): add a description field
7869 * upstart/tests/test_control.c: Update test cases.
7870 * init/control.c (control_handle): Include the job description in
7871 the message.
7872 (control_send): Copy the description when we put the message on
7873 the queue.
7874 (control_handle_job): Copy the description here too
7875 * init/tests/test_control.c: Update test cases.
7876
Scott James Remnant84f5e932006-08-27 18:49:25 +01007877 * init/job.c (job_list): Add a function to return the job list.
7878 * init/job.h: Update.
7879 * init/control.c (control_handle): Handle the JOB_LIST message
7880 by sending back a list of job status messages followed by the
7881 JOB_LIST_END message.
7882 * init/tests/test_control.c (test_watcher_child): Check the
7883 JOB_LIST message works properly.
7884
Scott James Remnantf4ad6d12006-08-27 18:40:01 +01007885 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
7886 the JOB_LIST and JOB_LIST_END messages which have no payload.
7887 * upstart/control.h: Add enums and structures for job list messages.
7888 * upstart/tests/test_control.c (test_messages): Update tests.
7889
Scott James Remnantf4970812006-08-27 18:27:19 +01007890 * init/main.c (main): Check that we're both uid and process #1
7891
Scott James Remnantf43bdf32006-08-27 18:20:29 +01007892 * init/main.c (main): Stop handling SIGTERM, we never want people
7893 to kill init. Handle SIGINT and SIGWINCH through the ordinary
7894 handler and SIGSEGV through a direct handler.
7895 (segv_handler): Write a sensible core dump handler, we use a child
7896 to dump core while we carry on in the parent hopefully stepping over
7897 the bad instruction.
7898 (cad_handler): Generate the control-alt-delete event.
7899 (kbd_handler): Generate the kbdrequest event.
7900
Scott James Remnant33e64d02006-08-25 14:44:32 +020079012006-08-25 Scott James Remnant <scott@netsplit.com>
7902
Scott James Remnant21679252006-08-25 16:22:13 +02007903 * configure.ac: Bump version to 0.1.2
7904 * NEWS: Update.
7905
Scott James Remnantfef12b52006-08-25 16:16:45 +02007906 * TODO: Update.
7907
Scott James Remnant94d00982006-08-25 15:38:22 +02007908 * init/process.c (process_setup_environment): Inherit the PATH
7909 and TERM environment variables from the init process, so the
7910 console works properly.
7911 * init/process.h (PATH): Declare a default value for this variable
7912 * init/main.c (main): Set the value of PATH to the default.
7913 * init/tests/test_process.c (child): Update test case.
7914
Scott James Remnant33e64d02006-08-25 14:44:32 +02007915 * NEWS: Update.
7916 * configure.ac: Bump version to 0.1.1
7917
Scott James Remnant68ccc9e2006-08-24 00:10:41 +020079182006-08-24 Scott James Remnant <scott@netsplit.com>
7919
Scott James Remnant279d4352006-08-24 15:33:19 +02007920 * init/cfgfile.h (CFG_DIR): Change configuration directory to
7921 /etc/event.d -- it's not been used by anyone, but is similar to
7922 other directories that have which is a good precedent.
7923 * event.d/Makefile.am (eventdir, dist_event_DATA): Install files
7924 into the new directory name.
7925 * Makefile.am (SUBDIRS): Rename sub directory
7926 * configure.ac (AC_CONFIG_FILES): Rename generated Makefile
7927
Scott James Remnant937192c2006-08-24 02:57:50 +02007928 * init/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7929 directories so out of tree builds work.
7930 * logd/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7931 directories so out of tree builds work.
7932 * upstart/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7933 directories so out of tree builds work.
7934 (upstartinclude_HEADERS): Install errors.h
7935 * util/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7936 directories so out of tree builds work.
7937
7938 * Makefile.am (SUBDIRS): Add m4 to the list
7939 * configure.ac (AC_CONFIG_FILES): Generate m4/Makefile
7940 * upstart/Makefile.am (upstartinclude_HEADERS): Add errors.h
7941
7942 * upstart/control.c (upstart_open):
7943
Scott James Remnante4c3d552006-08-24 02:34:01 +02007944 * init/control.c (control_open): Raise the error before
7945 performing other actions so errno is not lost.
Scott James Remnant73550092006-08-24 02:27:03 +02007946
Scott James Remnante4c3d552006-08-24 02:34:01 +02007947 * TODO: Update.o
Scott James Remnantf8b776b2006-08-24 00:36:15 +02007948 * init/cfgfile.c (cfg_next_token): Don't count quote characters
7949 unless we're actually planning to dequote the file, otherwise we
7950 end up allocating short.
7951
Scott James Remnant9e17fc02006-08-24 00:28:10 +02007952 * init/control.c (control_close): Free the io_watch using list_free
7953 in case a destructor has been set.
7954 * init/tests/test_control.c: Initialise the type of the message, and
7955 free job correctly.
7956
Scott James Remnant68ccc9e2006-08-24 00:10:41 +02007957 * upstart/tests/test_control.c: Fix overwrite of buffer.
7958 * init/tests/test_job.c: Clean up not-freed job.
7959
Scott James Remnantc961ce32006-08-23 19:46:29 +020079602006-08-23 Scott James Remnant <scott@netsplit.com>
7961
Scott James Remnant013e9722006-08-23 23:00:14 +02007962 * init/tests/test_event.c: free the entry allocated and initialise
7963 the return values.
7964
Scott James Remnantc961ce32006-08-23 19:46:29 +02007965 * init/cfgfile.c (cfg_skip_token): Drop this function; we'll
7966 make sure *pos is pointing at the start of the thing we want
7967 to parse, not the first token. Update the other functions
7968 accordingly.
7969 (cfg_read_job): Implement function to look over a job file and
7970 parse all of the stanzas that are found. Also sanity checks the
7971 job afterwards and deals with reloading existing jobs.
7972 (cfg_job_stanza): Function that parses an individual stanza,
7973 calling out to the other parse functions; this is the main config
7974 file parser!
7975 (cfg_parse_args, cfg_parse_command): Drop requirement that filename
7976 and lineno be passed, so we can be called to reparse arguments after
7977 we've already done so.
7978 (cfg_parse_script): Remove requirement that it be called at the
7979 start of the entire stanza, and instead at the start of the script.
7980 When hitting EOF, return the script so far, not NULL.
7981 (cfg_parse_args): Correct bug where we didn't check sufficient
7982 characters while skipping whitespace.
7983 (cfg_next_token): Correct bug where we didn't copy the character
7984 after a slash into the text, instead of just not copying the slash.
7985 Adjust line numbers to match the fact that it's zero based now.
7986 * init/cfgfile.h: Define prototype.
7987 * init/tests/test_cfgfile.c (test_read_job): Pretty thoroughly
7988 test the config file parser code.
7989
Scott James Remnant0c58ed02006-08-22 11:42:19 +020079902006-08-22 Scott James Remnant <scott@netsplit.com>
7991
Scott James Remnant214168f2006-08-22 18:52:51 +02007992 * init/cfgfile.c (cfg_tokenise): Rename to cfg_next_token.
7993 (cfg_skip_token): Code to skip whitespace, token and whitespace.
7994 (cfg_parse_args): Function to parse an argument list.
7995 (cfg_next_token): Extend to support the removal of quotes and
7996 slashes from the token.
7997
Scott James Remnant21590a22006-08-22 17:40:48 +02007998 * init/cfgfile.c (cfg_parse_script): Pass filename and lineno and
7999 increment the latter as we go.
8000 (cfg_script_end): Pass and increment lineno.
8001
Scott James Remnanteed2e8d2006-08-22 17:31:07 +02008002 * init/cfgfile.c: Correct a missing semi-colon in prototypes.
8003 (cfg_parse_command): Function to parse any stanza that requires
8004 a command and arguments list, e.g. exec/respawn/daemon. We don't
8005 want to require that the list be quoted, etc. and do want to allow
8006 it to be folded over lines.
8007 (cfg_tokenise): Function used by the above to tokenise the file,
8008 handling things like \, quoted strings and newlines, etc. Can be
8009 used both to determine the length of the token and to copy it.
8010
Scott James Remnantfcc98ad2006-08-22 12:28:19 +02008011 * init/cfgfile.c (cfg_read_script): Rename to cfg_parse_script.
8012
Scott James Remnantfd32dd32006-08-22 11:46:01 +02008013 * init/cfgfile.c (cfg_read_script): Function to parse a script
8014 fragment ("foo script\n....end script\n") from the job file, which
8015 is the most complex form we can find. Write it assuming the file is
8016 in a character array which may not be NULL terminated (ie. a mmap'd
8017 file).
8018 (cfg_script_end): Used by the above to detect the end of the
8019 fragment.
8020 * init/cfgfile.h: Empty header file.
8021 * init/Makefile.am (init_SOURCES): Build and link cfgfile.c
8022 using the cfgfile.h header
8023 (TESTS): Build and run the config file test cases.
8024 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
8025 Details for config file test case binary.
8026
Scott James Remnant0c58ed02006-08-22 11:42:19 +02008027 * init/main.c (main): Remove the calls to the unfinished config
8028 file code.
8029
Scott James Remnant6ce44812006-08-21 08:46:32 +020080302006-08-21 Scott James Remnant <scott@netsplit.com>
8031
Scott James Remnant027dd7b2006-08-21 09:01:25 +02008032 * init/main.c: Add missing include for unistd.h
8033 * init/process.c (process_setup_console): Drop use of job.
8034 * util/initctl.c (main): Check that we're run as root.
8035
Scott James Remnant77e8db32006-08-21 08:47:50 +02008036 * init/main.c (main): Write the main function
8037
Scott James Remnant6ecceb82006-08-21 08:47:23 +02008038 * init/event.c (event_queue_cb): Rename to event_queue_run.
8039 * init/event.h: Update.
8040
Scott James Remnant6ce44812006-08-21 08:46:32 +02008041 * init/process.c (process_setup_console): Become an exported
8042 function that includes the code to reset a console.
8043
Scott James Remnant5befd932006-08-19 19:24:54 +010080442006-08-19 Scott James Remnant <scott@netsplit.com>
8045
Scott James Remnantcd39a7c2006-08-19 20:02:17 +01008046 * logd/main.c (main): Write the basic main function.
8047
Scott James Remnant3bcd15e2006-08-19 19:50:12 +01008048 * util/initctl.c (main): Fill in the details to give us a basic
8049 test client.
8050
Scott James Remnant3dc965c2006-08-19 19:25:23 +01008051 * TODO: Update.
8052
Scott James Remnant5befd932006-08-19 19:24:54 +01008053 * util/initctl.c (main): Provide the most basic main function.
8054 * util/Makefile.am (sbin_PROGRAMS): Build the initctl binary
8055 * Makefile.am (SUBDIRS): Build the utilities.
8056 * configure.ac (AC_CONFIG_FILES): Generate the util Makefile.
8057
Scott James Remnant1fe38a82006-08-18 17:06:25 +010080582006-08-18 Scott James Remnant <scott@netsplit.com>
8059
Scott James Remnantc2659612006-08-18 22:19:47 +01008060 * init/Makefile.am (test_job_LDADD): Remove the duplicate link.
8061
Scott James Remnantd5e07052006-08-18 20:39:30 +01008062 * TODO: Update.
8063
Scott James Remnanta060bb72006-08-18 20:16:55 +01008064 * init/job.c (job_handle_child): Rename to job_child_reaper.
8065 * init/job.h: Update.
8066 * init/tests/test_job.c: Update function names.
8067
Scott James Remnant829dc082006-08-18 20:10:02 +01008068 * init/control.c (control_cb): Rename to control_watcher
8069 * init/tests/test_control.c: Update function names.
8070
Scott James Remnantddc3e282006-08-18 18:49:50 +01008071 * TODO: Update.
8072
Scott James Remnantc2cac3f2006-08-18 17:17:57 +01008073 * Makefile.am (SUBDIRS): Install the rc.d files.
8074 * configure.ac (AC_CONFIG_FILES): Generate the rc.d Makefile.
8075 * rc.d/Makefile.am (rcdir): Define rcdir to be /etc/rc.d
8076 (dist_rc_DATA): Install the logd file into that directory.
8077 * rc.d/logd: Write a simple service definition for the log daemon,
8078 this saves us hardcoding any information about it into init; it'll
8079 just need to know the name.
8080
Scott James Remnant1fe38a82006-08-18 17:06:25 +01008081 * Makefile.am (SUBDIRS): Build the logd daemon
8082 * configure.ac (AC_CONFIG_FILES): Generate the logd Makefile.
8083 * logd/Makefile.am (sbin_PROGRAMS): Install the logd binary into
8084 the sbin directory by default.
8085 (logd_SOURCES): Build and link main.c
8086 * logd/main.c (main): Add basic main function for testing purposes.
8087
Scott James Remnantb9814432006-08-16 02:11:51 +010080882006-08-16 Scott James Remnant <scott@netsplit.com>
8089
Scott James Remnantc5da6fd2006-08-16 18:06:49 +01008090 * init/job.c (job_start): Ignore self-dependencies; over-document
8091 why the dependency event prodding has a surprise in its tail.
8092 (job_change_state): Move the job_release_depends call to here.
8093
Scott James Remnant133a7a32006-08-16 17:45:51 +01008094 * init/event.c (event_queue_cb): Add event consumer/dispatcher.
Scott James Remnant13e5dbf2006-08-16 17:48:01 +01008095 * init/event.h: Update.
Scott James Remnant133a7a32006-08-16 17:45:51 +01008096
Scott James Remnant3772bc62006-08-16 17:41:34 +01008097 * init/control.c (control_send): Make the event code clearer.
8098 (control_handle): Handle the changed event semantics.
8099 (control_handle_event): Issue the new event type.
8100 * init/tests/test_control.c: Update tests.
8101
Scott James Remnantcaee5b52006-08-16 17:32:12 +01008102 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Adjust
8103 marshal code to match.
8104 * upstart/control.h: Update all structures appropriately to the
8105 previous changes.
8106 * upstart/tests/test_control.c: Update.
8107
Scott James Remnant4d4389d2006-08-16 17:19:20 +01008108 * init/job.c (job_change_state): Change call to event_trigger_level
8109 to event_queue_level.
8110
Scott James Remnant51664d72006-08-16 17:17:58 +01008111 * init/event.c (event_trigger_edge, event_trigger_level): Place
8112 the event on the event_queue rather than directly triggering it.
8113 Rename to event_queue_edge and event_queue_level respectively.
8114 * init/event.h: Update.
8115 * init/tests/test_event.c: Update test cases.
8116
Scott James Remnant4ddc86e2006-08-16 16:17:48 +01008117 * init/job.c (job_handle_event): Add another sanity check, jobs
8118 should not be able to react to their own events; that's just silly.
8119 * init/tests/test_job.c (test_handle_event): Check that the new
8120 condition does the right thing.
8121
Scott James Remnant930f3e02006-08-16 16:13:03 +01008122 * init/job.c (job_change_state): Make it illegal for a job to exist
8123 without either a command or script or both. This is for sanity
8124 reasons, allowing no primary process makes no sense and can lead
8125 to event loops if someone is feeling nefarious.
8126 * init/tests/test_job.c (test_change_state): Drop test on behaviour
8127 we've just outlawed.
8128
Scott James Remnant7dd047e2006-08-16 13:43:50 +01008129 * init/job.c (job_start): Only announce the change if we're still
8130 in the waiting state, we could have moved on to running already.
8131
Scott James Remnantf9261ba2006-08-16 13:40:05 +01008132 * init/job.c (job_start): If holding the job, at least announce
8133 the goal change to subscribed clients.
8134
Scott James Remnant853cc772006-08-16 13:34:51 +01008135 * TODO: Update.
8136
Scott James Remnantfdb82592006-08-16 13:31:49 +01008137 * init/job.c (job_start): Check for dependencies before starting
8138 the process, if we have any that aren't running we stay in waiting
8139 until they are. Any that aren't even starting get poked with a
8140 dependency event to see whether that wakes them up.
8141 * init/tests/test_job.c (test_start): Test paths through new
8142 dependency code.
8143
Scott James Remnant278150a2006-08-16 12:56:34 +01008144 * init/job.c (job_run_process): Once we've got an active process
8145 in the running state, release our dependencies.
8146
Scott James Remnant6d4104d2006-08-16 12:50:39 +01008147 * init/job.c (job_release_depends): Function to release any waiting
8148 dependencies on the given job.
8149 * init/job.h: Update.
8150 * init/tests/test_job.c (test_release_depends): Test the behaviour
8151 of the function on its own.
8152
Scott James Remnant1da1dad2006-08-16 12:18:50 +01008153 * init/job.h (Job): Add depends list field
8154 (JobName): New structure to hold the name of a job.
8155 * init/job.c (job_new): Initialise the depends list.
8156 * init/tests/test_job.c (test_new): Make sure the depends list is
8157 initialised properly.
8158
Scott James Remnant37eee032006-08-16 12:10:49 +01008159 * init/job.c (job_next_state): Return JOB_STARTING if we're in
8160 JOB_WAITING and the goal is JOB_START. This is only called when
8161 there's some change, and I don't want to hard-code the goal there.
8162 (job_start): Don't hardcode JOB_STARTING, instead just use the next
8163 state.
8164 * init/tests/test_job.c (test_next_state): Adjust test case.
8165
Scott James Remnantc3d3ead2006-08-16 09:00:50 +01008166 * init/control.c (control_subscribe): Allow the current
8167 subscription to be found by passing NOTIFY_NONE.
8168 (control_handle): Don't remove an existing subscription to jobs,
8169 a GUI will probably want a permanent one to keep the status up to
8170 date.
8171
Scott James Remnantb9a568c2006-08-16 08:57:46 +01008172 * init/job.c (job_kill_process, job_kill_timer): Don't hardcode
8173 JOB_STOPPING here, instead move to the next logical state.
8174 (job_kill_process): Notify subscribed processes that we killed
8175 the job.
8176 (job_start, job_stop): Notify subscribed processes of a change of
8177 goal that doesn't result in an immediate state change.
8178
Scott James Remnant8dbc6012006-08-16 08:57:38 +01008179 * init/event.c (event_trigger_edge, event_trigger_level): Swap
8180 order so that events are announced before processed.
8181
Scott James Remnant28161252006-08-16 08:41:48 +01008182 * init/control.c (control_handle): Handle requests to watch and
8183 unwatch jobs and events.
8184 * init/tests/test_control.c (test_cb_child, test_cb): Check that
8185 subscriptions work.
8186
Scott James Remnantb6d55bf2006-08-16 08:24:16 +01008187 * init/tests/test_control.c (test_cb_child): Add a sleep to avoid
8188 a race that upsets gdb, have tried this with a STOP/CONT interlock
8189 but can't seem to find where the child should reach first.
8190
Scott James Remnant5612b232006-08-16 08:21:06 +01008191 * init/job.c (job_change_state): Notify the control handler.
8192 * init/event.c (event_trigger_edge, event_trigger_level): Pass
8193 event to the control handler.
8194 * init/tests/test_control.c (test_cb_child): Expect to receive
8195 job status events as well.
8196 * init/Makefile.am (test_event_LDADD, test_process_LDADD)
8197 (test_job_LDADD): Add control.o to the linkage.
8198
Scott James Remnant9e0626a2006-08-16 08:17:07 +01008199 * init/control.c (control_cb): Don't display an error for
8200 ECONNREFUSED, just remove any subscriptions.
8201 * init/tests/test_control.c (test_handle_job, test_handle_error):
8202 Clean up our subscriptions properly.
8203
Scott James Remnant3c465c82006-08-16 07:40:24 +01008204 * init/control.c (control_handle_job): Function to send out an
8205 UPSTART_JOB_STATUS message to subscribed processes whenever a
8206 job state changes.
8207 (control_handle_event): Function to send out an
8208 UPSTART_EVENT_TRIGGERED message to subscribed processes whenever
8209 an event is triggered.
8210 * init/control.h: Update.
8211 * init/tests/test_control.c (test_handle_job, test_handle_event):
8212 Check that the functions work properly.
8213
Scott James Remnant16dadc52006-08-16 07:27:40 +01008214 * init/control.c (control_handle): Handle messages that trigger
8215 edge and level events; subscribe the process to receive notification
8216 of job changes during the event.
8217 * init/tests/test_control.c (test_cb_child): Check that the messages
8218 are handled properly (without subscription check).
8219
Scott James Remnanta7ba72a2006-08-16 07:11:30 +01008220 * init/control.c (control_cb): Unsubscribe a process if it stops
8221 listening.
8222
Scott James Remnant2c9669c2006-08-16 07:10:05 +01008223 * init/control.c (control_send): Copy the pointers in the new
8224 event messages.
8225 * init/tests/test_control.c (test_send): Check the pointers are
8226 copied across correctly.
8227
Scott James Remnant15d61c62006-08-16 06:55:58 +01008228 * init/control.c (control_subscribe): Add function to handle
8229 processes that want to subscribe to changes.
8230 (control_init): Initialise the subscriptions list.
8231 * init/control.h: Add structures and prototypes.
8232 * init/tests/test_control.c (test_subscribe): Test the function.
8233
Scott James Remnant8692f762006-08-16 06:21:13 +01008234 * upstart/control.h (UpstartMsgType): add messages for triggering
8235 edge and level events, receiving the trigger for an event and for
8236 watching jobs and events.
8237 (UpstartEventTriggerEdgeMsg, UpstartEventTriggerLevelMsg)
8238 (UpstartEventTriggeredMsg, UpstartWatchJobsMsg)
8239 (UpstartUnwatchJobsMsg, UpstartWatchEventsMsg):
8240 (UpstartUnwatchEventsMsg): Add structures for the new messages.
8241 (UpstartMsg): And add them to the union.
8242 * upstart/control.c (WireEventPayload): The event messages can all
8243 share a wire payload type; the watch messages don't need any special
8244 payload.
8245 (upstart_send_msg_to): Add the payloads onto the wire.
8246 (upstart_recv_msg): And take the payloads back off the wire.
8247 * upstart/tests/test_control.c (test_messages): Test the new
8248 message types.
8249
Scott James Remnant8ed97eb2006-08-16 05:46:44 +01008250 * upstart/control.h (UpstartJobStatusMsg): add a process id.
8251 * upstart/control.c (WireJobStatusPayload): and here too.
8252 (upstart_send_msg_to): copy the process id onto the wire.
8253 (upstart_recv_msg): copy the process id from the wire.
8254 * init/control.c (control_handle): Fill in the pid from the job.
8255 * upstart/tests/test_control.c (test_messages): Check the pid gets
8256 passed across the wire properly.
8257
Scott James Remnant7d914312006-08-16 05:37:50 +01008258 * init/control.c (control_cb): Disable the poll for write once the
8259 send queue becomes empty.
8260
Scott James Remnant59707c22006-08-16 05:32:20 +01008261 * upstart/Makefile.am (libupstart_la_SOURCES): Correct ordering.
8262
Scott James Remnanta98c8b82006-08-16 05:32:02 +01008263 * init/control.c (control_handle): Add missing break.
8264
Scott James Remnantb5c7a302006-08-16 05:24:55 +01008265 * upstart/job.c (job_goal_name, process_state_name): For completeness
8266 add these two functions as well.
8267 * upstart/job.h: Update.
8268 * upstart/tests/test_job.c (test_goal_name)
8269 (test_process_state_name): Test the new functions.
8270
Scott James Remnant20b15ad2006-08-16 05:20:02 +01008271 * init/job.c (job_state_name): Move this utility function from here
8272 * upstart/job.c (job_state_name): to here so all clients can use
8273 it.
8274 * init/job.h: Update.
8275 * upstart/job.h: Update.
8276 * init/tests/test_job.c (test_state_name): Move the test case from here
8277 * upstart/tests/test_job.c: to here as well.
8278 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link job.c
8279 (TESTS): Run the job test cases
8280 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for
8281 job test case binary.
8282 * init/Makefile.am (test_job_LDADD, test_process_LDADD)
8283 (test_event_LDADD): Link to libupstart.la
8284
Scott James Remnant7a5c6672006-08-16 05:01:13 +01008285 * init/control.c: Code to handle the server end of the control
8286 socket, a bit more complex than a client as we want to avoid
8287 blocking on malcious clients.
8288 * init/control.h: Prototypes.
8289 * init/tests/test_control.c: Test the control code.
8290 * init/Makefile.am (init_SOURCES): Build and link control.c
8291 using the control.h header
8292 (init_LDADD): Link to libupstart as well
8293 (TESTS): Build and run the control test suite.
8294 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
8295 Details for control test suite binary.
8296
Scott James Remnantb7cbda52006-08-16 04:53:38 +01008297 * upstart/control.c: Add a way to disable the safety checks.
8298 * upstart/tests/test_control.c (test_free): Fix bad test case.
8299
Scott James Remnant71d4d842006-08-16 04:29:21 +01008300 * upstart/control.c (upstart_recv_msg): fixed bogus return type
8301 for recvmsg from size_t to ssize_t so we don't infiniloop on error.
8302
Scott James Remnant2bda3832006-08-16 03:41:10 +01008303 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Avoid
8304 job_start as the short-cut for assigning name, as that might become
8305 a more complex message eventually. Use job_query instead.
8306
Scott James Remnantd154b952006-08-16 03:39:35 +01008307 * upstart/control.c (upstart_free): Add wrapper function around
8308 nih_free so we're a proper library and don't expose libnih too much
8309 (upstart_recv_msg): Stash the sender pid in an argument.
8310 * upstart/control.h: Update.
8311 * upstart/tests/test_control.c (test_recv_msg): Test pid is
8312 returned properly.
8313 (test_free): Test the nih_free wrapper.
8314
Scott James Remnantdc0eb442006-08-16 02:40:29 +01008315 * init/job.c (job_run_script): Document future FIXME.
8316
Scott James Remnant2f558532006-08-16 02:24:55 +01008317 * init/exent.h, init/job.h, init/process.h: Fix up headers.
8318
Scott James Remnant45aab692006-08-16 02:23:27 +01008319 * upstart/control.c, upstart/control.h, upstart/errors.h,
8320 upstart/job.h, upstart/libupstart.h: Fix up headers.
8321
Scott James Remnant8c16cc82006-08-16 02:13:40 +01008322 * upstart/control.c: Write the code to handle the control socket
8323 and communication over it; turns out this was possible to write so
8324 that both ends are handled in the same code.
8325 * upstart/control.h: Structures and prototypes.
8326 * upstart/tests/test_control.c: Test the new code.
8327
Scott James Remnant729d9222006-08-16 02:12:23 +01008328 * upstart/Makefile.am (libupstart_la_LIBADD): Link to libnih
8329
Scott James Remnantb9814432006-08-16 02:11:51 +01008330 * upstart/errors.h: Header file containing errors raised by
8331 libupstart.
8332 * upstart/libupstart.h: Include errors.h
8333
Scott James Remnant342451a2006-08-15 00:08:20 +010083342006-08-15 Scott James Remnant <scott@netsplit.com>
8335
Scott James Remnant0a8e3472006-08-15 23:54:14 +01008336 * init/event.h: Add missing attribute for event_new()
8337
Scott James Remnant6f128872006-08-15 23:54:05 +01008338 * init/job.h (JobGoal, JobState, ProcessState, ConsoleType): Move
8339 the enums from here
8340 * upstart/job.h: into here so that we can use them across the
8341 control socket.
8342
Scott James Remnante5831792006-08-15 21:46:21 +01008343 * Makefile.am (SUBDIRS): Build the libupstart library
8344 * configure.ac (AC_CONFIG_FILES): Generate upstart/Makefile
8345 * upstart/Makefile.am: Makefile for sub-directory
8346 * upstart/libupstart.ver: Linker version script.
8347 * upstart/libupstart.h: "Include everything" header file.
8348
Scott James Remnant26a8eec2006-08-15 05:46:27 +01008349 * TODO: Update.
8350
Scott James Remnant1f8619c2006-08-15 05:45:38 +01008351 * init/job.c (job_handle_child): Warn when processes are killed
8352 or exit with an abnormal status. Warn when respawning.
8353
Scott James Remnanteb5ad272006-08-15 05:43:05 +01008354 * init/job.c (job_handle_child): Respawn processes that were not
8355 supposed to have died.
8356 * init/tests/test_job.c (test_handle_child): Test the respawn code.
8357
Scott James Remnant77c926d2006-08-15 05:22:08 +01008358 * TODO: Update.
8359
Scott James Remnant429cd672006-08-15 05:09:51 +01008360 * init/event.c (event_trigger_edge, event_trigger_level): Call
8361 job_handle_event so that we actually do something useful.
8362 * init/Makefile.am (test_event_LDADD): Link to process.o and job.o
8363 now that event.c calls code from job.
8364
Scott James Remnant355e1b62006-08-15 05:07:24 +01008365 * init/job.c (job_start_event): Function to start a job if an event
8366 matches.
8367 (job_stop_event): Function to stop a job if an event matches.
8368 (job_handle_event): Iterate the job list and dispatch the given event,
8369 causing jobs to be stopped or started using the above two functions.
8370 * init/job.h: Update.
8371 * init/tests/test_job.c: Test the new functions.
8372
Scott James Remnant923400d2006-08-15 04:27:44 +01008373 * init/job.c (job_new): Initialise start_events and stop_events to
8374 an empty list.
8375 * init/job.h (Job): Add start_events and stop_events list heads.
8376 * init/tests/test_job.c (test_new): Check the lists are initialised
8377 correctly to the empty list.
8378
Scott James Remnant865534f2006-08-15 04:22:06 +01008379 * init/event.c (event_match): Function to check events for equality.
8380 * init/event.h: Update.
8381 * init/tests/test_event.c (test_match): Test function.
8382
Scott James Remnant97137a72006-08-15 04:07:08 +01008383 * init/job.c (job_change_state): Trigger the level event with the
8384 same name as the job, with the value taken from the state.
8385 * init/tests/test_job.c (test_change_state): Check the event
8386 gets set to the right values as we go.
8387 * init/Makefile.am (test_job_LDADD, test_process_LDADD): Link to
8388 event.o now that job.c uses code from there.
8389
Scott James Remnant3b35a522006-08-15 04:01:32 +01008390 * init/event.c (event_change_value): Rename event_set_value to this
8391 as we intended in the first place; makes it more consistent with job.
8392 Always change the value.
8393 (event_trigger_edge): Add a high-level function to trigger an edge
8394 event.
8395 (event_trigger_level): And another to trigger a level event with
8396 a given value, this inherits the "don't change it" functionality
8397 that was in event_set_value.
8398 * init/event.h: Update.
8399 * init/tests/test_event.c: Test new behaviours and functions.
8400
Scott James Remnant4fef0732006-08-15 01:45:02 +01008401 * init/event.c: Add simple code to keep track of events, whether
8402 they have been recorded or not and their current value if any.
8403 * init/event.h: Structures and prototypes.
8404 * init/tests/test_event.c: Test cases for event code.
8405 * init/Makefile.am (init_SOURCES): Build and link event.c using event.h
8406 (TESTS): Run the event test suite.
8407 (test_event_SOURCES, test_event_LDFLAGS, test_event_LDADD): Details
8408 for event test suite binary.
8409
Scott James Remnant38fc8ff2006-08-15 00:43:26 +01008410 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
8411 Downgrade error messages to warning as they're not fatal.
8412 (job_change_state): Change info message to be more regular.
8413
Scott James Remnantf033fb02006-08-15 00:37:33 +01008414 * init/job.c (job_start): A very simple, but very necessary, function.
8415 Set the goal of the given job to JOB_START and kick it off.
8416 (job_stop): And its companion, cause a running job to be stopped.
8417 * init/job.h: Update.
8418 * init/tests/test_job.c: Test the functions.
8419
Scott James Remnant342451a2006-08-15 00:08:20 +01008420 * init/job.c (job_handle_child): Child handler to kick jobs into
8421 the next state when their process dies.
8422 * init/job.h: Update.
8423 * init/tests/test_job.c (test_handle_child): Test the handler
8424 directly by just invoking it with various job states.
8425
Scott James Remnant1c463b92006-08-14 14:46:17 +010084262006-08-14 Scott James Remnant <scott@netsplit.com>
8427
Scott James Remnant51c827d2006-08-14 23:06:00 +01008428 * init/tests/test_process.c (test_kill): Use select rather than
8429 poll for consistency with other test cases.
8430
Scott James Remnante6e4a732006-08-14 23:04:53 +01008431 * init/job.c (job_kill_process): Add function to send the active
8432 process of a job the TERM signal, and then set a timer to follow
8433 up with the KILL signal if the job doesn't get cleaned up in time.
8434 (job_kill_timer): Timer callback to send the KILL signal; this
8435 does the same job as the child handler and puts the job into the
8436 next state as there's no point waiting around now.
8437 * init/job.h: Update.
8438 * init/tests/test_job.c (test_kill_process): Test both functions
8439 in one test case (as one is just the bottom half of the other).
8440
Scott James Remnant6868f652006-08-14 21:42:45 +01008441 * init/tests/test_process.c (test_spawn): Use the right thing in
8442 the test case filename and unlink it to make sure.
8443
Scott James Remnant85df9422006-08-14 21:41:39 +01008444 * init/job.c (job_change_state): Write the principal state gate
8445 function, called once a state has been left to enter the given new
8446 state (which one should determine with job_next_state). Spawns
8447 the necessary processes or moves to the next appropriate state.
8448 * init/job.h: Update.
8449 * init/tests/test_job.c: Test the state changes.
8450
Scott James Remnantba44b8b2006-08-14 20:06:28 +01008451 * init/job.c (job_run_process): Internal function to call
8452 process_spawn and update the job structure.
8453 (job_run_command): Simple(ish) wrapper for the above to split
8454 a command by whitespace, or use a shell if it needs more complex
8455 argument processing.
8456 (job_run_script): More complex wrapper that uses a shell to execute
8457 verbatim script, either using -c or a /dev/fd/NN and feeding the
8458 shell down a pipe to it.
8459 * init/job.h: Update.
8460 * init/tests/test_job.c: Test the new functions.
8461
Scott James Remnant156f5482006-08-14 19:09:55 +01008462 * init/Makefile.am (init_SOURCES, TESTS): Reorder so that process.c,
8463 which is arguably lower level, comes first.
8464 (test_job_LDADD): Link the process code.
8465 (test_process_LDADD): Swap the order.
8466
Scott James Remnant00bcc932006-08-14 19:07:28 +01008467 * TODO: Update.
8468
Scott James Remnant1c463b92006-08-14 14:46:17 +01008469 * init/process.c (process_spawn): Correct typo (progress -> process),
8470 thanks Johan.
8471
Scott James Remnant43534ca2006-08-12 14:52:01 +010084722006-08-12 Scott James Remnant <scott@netsplit.com>
8473
Scott James Remnant3030cc22006-08-12 15:18:55 +01008474 * init/process.c (process_spawn): Correct formatting of function.
8475 * init/process.h (SHELL): Define the location of the shell, all in
8476 the spirit of not hard-coding stuff like this.
8477
Scott James Remnant43534ca2006-08-12 14:52:01 +01008478 * init/job.c (job_new): Initialise all structure members to zero
8479 as this doesn't happen automatically.
8480
Scott James Remnant60b03e32006-08-10 00:59:00 +010084812006-08-10 Scott James Remnant <scott@netsplit.com>
8482
8483 * init/job.h (job_state_name): Declare as a const function.
8484
Scott James Remnant143a8572006-08-09 17:37:00 +010084852006-08-09 Scott James Remnant <scott@netsplit.com>
8486
Scott James Remnantd945d2e2006-08-09 23:47:44 +01008487 * init/job.c (job_next_state): State transition logic; this uses
8488 our departure from the specification (the goal) so that the state
8489 can always be currently accurate rather than suggestive.
8490 (job_state_name): Cute function to convert enum into a name.
8491 * init/job.h: Update.
8492 * init/tests/test_job.c (test_next_state): Test the transitions.
8493 (test_state_name): And the return values.
8494
Scott James Remnant5fa15672006-08-09 23:23:17 +01008495 * TODO: Add file to keep track of things.
8496
Scott James Remnantdbc78612006-08-09 23:22:45 +01008497 * init/job.c: Include nih/macros.h and nih/list.h
8498 * init/process.c: Include order fixing, include nih/macros.h
8499 * init/tests/test_job.c: Include nih/macros.h and nih/list.h
8500 * init/tests/test_process.c: Include nih/list.h
8501
Scott James Remnant03853ed2006-08-09 23:11:59 +01008502 * init/job.c: Include order fixing.
8503 (job_find_by_name): Function to find a job by its (unique) name.
8504 (job_find_by_pid): Function to find a job by the pid of its process.
8505 * init/job.h: Update.
8506 * init/tests/test_job.c (test_find_by_name, test_find_by_pid): Test
8507 new functions.
8508
Scott James Remnant143a8572006-08-09 17:37:00 +01008509 * init/process.c (process_spawn): Spawn a process using the job
8510 details to set up the environment, etc.
8511 (process_setup_console): Set up the console according to the job.
8512 (process_setup_limits): Set up the limits according to the job.
8513 (process_setup_environment): Set up the environment according to
8514 the job.
8515 (process_kill): Simple function to send a kill signal or raise an
8516 error; mostly just a wrapper without any particular logic.
8517 * init/process.h: Prototypes and macros.
8518 * init/tests/test_process.c: Test cases.
8519 * init/Makefile.am (init_SOURCES): Build and link process.c and
8520 its header file.
8521 (TESTS): Run the process test suite.
8522 (test_process_SOURCES, test_process_LDFLAGS, test_process_LDADD):
8523 Details for process test sutie binary.
8524
Scott James Remnant29abda02006-08-08 15:01:24 +010085252006-08-08 Scott James Remnant <scott@netsplit.com>
8526
Scott James Remnant31ee2632006-08-08 15:06:02 +01008527 * init/job.c (job_new): nih_list_free is necessary.
8528 * init/tests/test_job.c (test_new): Free job when done.
8529
Scott James Remnant29abda02006-08-08 15:01:24 +01008530 * init/job.h: Header file to contain the definition of the Job
8531 structure and associated typedefs, etc.
8532 (JobGoal): In a divergence from the specification, we introduced a
8533 "goal" for a job which tells us which way round the state machine
8534 we're going (towards start, or towards stop).
8535 (JobState): Which means this always holds the current state, even
8536 if we're trying to get out of this state (ie. if we've sent the TERM
8537 signal to the running process, we're still in the running state until
8538 it's actually been reaped).
8539 (ProcessState): And in another divergence, we keep the state of the
8540 process so we know whether we need to force a state transition or
8541 can just expect one because something transient is happening.
8542 * init/job.c (job_new): Function to allocate a Job structure, set
8543 the pointers to NULL and other important members to sensible
8544 defaults.
8545 (job_init): Initialise the list of jobs.
8546 * init/tests/test_job.c: Test suite.
8547 * init/Makefile.am (init_SOURCES): Compile and link job.c using
8548 its header file.
8549 (TESTS): Run the job test suite.
8550 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for the
8551 job test suite binary.
8552
Scott James Remnantb933bc92006-08-02 02:29:25 +010085532006-08-02 Scott James Remnant <scott@netsplit.com>
8554
Scott James Remnant6c7667a2006-08-02 02:43:12 +01008555 * configure.ac: Check for C99
8556
Scott James Remnantb933bc92006-08-02 02:29:25 +01008557 * HACKING: Document dependency on libnih.
8558
Scott James Remnanta780d6c2006-07-27 18:40:51 +010085592006-07-27 Scott James Remnant <scott@netsplit.com>
8560
8561 * init/Makefile.am (DEFS): Append to the default DEFS list, rather
8562 than overriding, otherwise we lose HAVE_CONFIG_H
8563
Scott James Remnantb6270dd2006-07-13 02:16:38 +010085642006-07-13 Scott James Remnant <scott@netsplit.com>
8565
Scott James Remnant1bb35142006-07-13 02:30:58 +01008566 * HACKING: Correct incorrect Bazaar URL.
8567
Scott James Remnantb6270dd2006-07-13 02:16:38 +01008568 * AUTHORS: Change e-mail address to ubuntu.com.
8569 * HACKING: Update Bazaar and Release URLS.
8570 * configure.ac (AC_COPYRIGHT): Change copyright to Canonical Ltd.
8571 (AC_INIT): Change bug submission address to Launchpad.
8572 * init/main.c: Update header to use Canonical copyright and
8573 credit me as author.
8574
Scott James Remnant50748842006-05-16 21:02:31 +010085752006-05-16 Scott James Remnant <scott@netsplit.com>
8576
8577 * init/main.c: Add the simplest template main.c
8578 * init/Makefile.am: Add template Makefile.am that builds init from
8579 main.c and links to libnih statically
8580 * configure.ac (AC_CONFIG_FILES): Configure nih and init subdirs.
8581 * Makefile.am (SUBDIRS): Recurse into nih and init subdirs.
8582
Scott James Remnant8a0cd072006-05-14 18:28:58 +010085832006-05-14 Scott James Remnant <scott@netsplit.com>
8584
8585 * ChangeLog: Initial project infrastructure created.