blob: d5cf0bb11c663f15f07a9d483dfd4a2148ba0185 [file] [log] [blame]
Scott James Remnant3347da92009-10-14 05:25:48 +010012009-10-03 Scott James Remnant <scott@netsplit.com>
2
Scott James Remnant22d76e92009-10-14 05:29:56 +01003 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
4 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
5 ($(com_ubuntu_Upstart_Instance_OUTPUTS)):
6 * util/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
7 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
8 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Use pre-built nih-dbus-tool
9 when necessary (e.g. cross-compiling)
10
Scott James Remnant4f4f84b2009-10-14 05:27:25 +010011 * util/shutdown.c (shutdown_now): Free error before exiting.
12
Scott James Remnant3347da92009-10-14 05:25:48 +010013 * conf/rc-sysinit.conf: Improve regular expression so that it
14 doesn't match commented-out inittab lines.
15
Scott James Remnanta062abd2009-10-14 05:25:35 +0100162009-08-04 Johan Kiviniemi <johan@kiviniemi.name>
17
18 * conf/rc-sysinit.conf: Don't replace DEFAULT_RUNLEVEL with an
19 empty string when there is no "initdefault" line in /etc/inittab
20
Scott James Remnantfacdb672009-08-02 20:01:34 +0100212009-08-02 Scott James Remnant <scott@netsplit.com>
22
23 * NEWS: Release 0.6.3
24
Scott James Remnant826b8762009-08-01 19:08:50 +0100252009-08-01 Scott James Remnant <scott@netsplit.com>
26
27 * init/tests/test_job_process.c (test_handler): Add a missing test
28 case for the running process exiting while we're in the stopping
29 state.
30 * init/job_process.c (job_process_terminated): Don't change the
31 state or record failure information if we're in the stopping state
32 when the main process dies, otherwise we hit an assertion later;
33 just wait for the stopping event to finish and carry on as before.
34
Scott James Remnant1eb81432009-07-31 12:34:43 +0100352009-07-31 Scott James Remnant <scott@netsplit.com>
36
37 * dbus/upstart.h: Allow the service name and address to be overriden
38
Michael Biebl5e2f15b2009-07-29 11:18:47 +0100392009-07-29 Michael Biebl <mbiebl@gmail.com>
40
41 * init/tests/test_job_process.c: Add missing sys/ptrace.h include
42
Scott James Remnantbeae7f22009-07-21 12:27:55 +0100432009-07-21 Scott James Remnant <scott@netsplit.com>
44
Scott James Remnant726290a2009-07-21 18:31:35 +010045 * configure.ac: Bump version to 0.6.3
46 * NEWS: Begin new release
47
Scott James Remnant73e8fd32009-07-21 18:30:51 +010048 * NEWS: Release 0.6.2
49
Scott James Remnant9d736bb2009-07-21 18:15:20 +010050 * init/main.c (crash_handler): Restore missing chdir ("/") call.
51
Scott James Remnant0a0c47d2009-07-21 13:03:23 +010052 * init/tests/test_job_process.c (test_handler): We should allow
53 a job to exec() before it calls fork() to allow shell scripts to
54 exec daemons.
55 * init/job_process.c (job_process_trace_exec): Continue the traced
56 process instead of detaching if it has not yet forked.
57
Scott James Remnantbeae7f22009-07-21 12:27:55 +010058 * init/job.c (job_change_state): Obvious bug fix; the set of states
59 into which we can enter JOB_STOPPING includes JOB_STARTING because
60 we can get the "stop" event or command there.
61
Scott James Remnante6de0452009-07-16 17:26:00 +0100622009-07-16 Scott James Remnant <scott@netsplit.com>
63
Scott James Remnant9c372302009-07-16 18:08:52 +010064 * configure.ac: Bump version to 0.6.2
65 * NEWS: Begin new release
66
Scott James Remnantb52deb12009-07-16 18:05:31 +010067 * NEWS: Release 0.6.1
68
Scott James Remnant3ef8fac2009-07-16 17:39:04 +010069 * util/runlevel.c: Output the path before the error message,
70 to make it clear that it's the utmp file missing not runlevel.
71
Scott James Remnante6de0452009-07-16 17:26:00 +010072 * util/runlevel.c: If there is no current runlevel because the
73 environment variable is empty, output "unknown" instead of "N N".
74
Scott James Remnant0acfdc52009-07-15 11:13:46 +0100752009-07-15 Scott James Remnant <scott@netsplit.com>
76
77 * README: Now that D-Bus 1.2.16 proper has been released, update
78 our requirements.
79
Scott James Remnant6ca3c752009-07-14 11:40:08 +0100802009-07-14 Scott James Remnant <scott@netsplit.com>
81
Scott James Remnant9f175212009-07-14 18:45:47 +010082 * TODO: Update
83
Scott James Remnantcf9f3ce2009-07-14 14:55:47 +010084 * init/tests/test_job_process.c (test_handler): Rework the existing
85 ptrace fork handler test case to make sure we test the case where
86 we get the fork event before the stopped child. Add a second test
87 case for the opposite (stopped child before the fork event) which
88 we don't currently handle.
89 * init/job_process.c (job_process_trace_fork): Test for the missed
90 child event using ptrace(), if it succeeds the child is ready so
91 we can just assume we had the event.
92
Scott James Remnant5de1bfe2009-07-14 12:34:49 +010093 * util/Makefile.am (EXTRA_DIST): Distribute the valgrind suppressions
94 file
95
Scott James Remnant92ac1ce2009-07-14 12:04:34 +010096 * util/tests/test_utmp.c (test_write_shutdown): Additional instance
97 of the same test.
98
Scott James Remnant6ca3c752009-07-14 11:40:08 +010099 * util/tests/test_utmp.c (test_write_runlevel): Looks like glibc
100 is fixed to return the right error code.
101
Scott James Remnantce95ce22009-07-11 12:46:57 +01001022009-07-11 Scott James Remnant <scott@netsplit.com>
103
Scott James Remnantde9cacb2009-07-11 12:47:12 +0100104 * init/control.c (control_server_open): Don't hardcode the server
105 address, otherwise the test suite can't test this function.
106 * init/tests/test_control.c (test_server_open)
107 (test_server_connect, test_server_close): Change the server
108 address in the tests.
109
Scott James Remnantce95ce22009-07-11 12:46:57 +0100110 * configure.ac: Bump version to 0.6.1
111 * NEWS: Begin new release
112
Scott James Remnant6e177852009-07-09 00:09:09 +01001132009-07-09 Scott James Remnant <scott@netsplit.com>
114
Scott James Remnant11caefc2009-07-09 17:18:26 +0100115 * NEWS: Release 0.6.0
116
Scott James Remnant057a8692009-07-09 16:40:34 +0100117 * README: Note that we need D-Bus GIT HEAD.
118 * NEWS: Update.
119
Scott James Remnant6e568432009-07-09 16:01:07 +0100120 * init/man/inittab.5: People keep trying "man inittab", so explain
121 that it's gone.
122 * init/Makefile.am (dist_man_MANS): Install it
123
Scott James Remnant7c23b1f2009-07-09 15:56:49 +0100124 * NEWS: Declare the "lacks documentation" bug fixed
125
Scott James Remnant8bdf0712009-07-09 15:54:28 +0100126 * init/man/init.8: Refresh and turn it into more of an overview
127 of Upstart now that we have lots of other pages to refer to.
128 * init/man/upstart.7: Since it's an overview, people might go
129 "man upstart" so redirect to it.
130 * init/man/init.5: Actually document the configuration format.
131 * init/Makefile.am (dist_man_MANS): Install the configuration
132 documentation, and the redirect.
133
Scott James Remnanta5b683a2009-07-09 14:21:16 +0100134 * util/man/runlevel.8, util/man/telinit.8, util/man/shutdown.8,
135 * util/man/reboot.8: Add environment and files sections.
136
Scott James Remnant8a50b2c2009-07-09 13:26:11 +0100137 * init/man/startup.7, init/man/starting.7, init/man/started.7,
138 * init/man/stopping.7, init/man/stopped.7
139 * init/man/control-alt-delete.7, init/man/keyboard-request.7,
140 * init/man/power-status-changed.7: Write manual pages for each
141 of the events generated by the init daemon by default.
142 * init/Makefile.am (dist_man_MANS): Distribute and install the
143 new manpages.
144 * util/man/runlevel.7: Indent the example, don't boldface
145
Scott James Remnantb175de82009-07-09 12:50:19 +0100146 * init/job.c (job_start, job_stop, job_restart): Restructure
147 slightly to avoid gcc warning
148 * init/job_class.c (job_class_start, job_class_restart): Make the
149 same change to these too
150 * util/shutdown.c: Warn if we can't change directory
151 * util/telinit.c: Assert that we don't fall out of the switch
152 * init/tests/test_job_class.c (test_get_version)
153 (test_get_author, test_get_description, test_get_name): Initialise
154 alloc-safe variables to NULL to avoid gcc warning
155 * util/tests/test_initctl.c (test_job_status, test_start_action)
156 (test_stop_action, test_restart_action, test_status_action)
157 (test_list_action, test_emit_action)
158 (test_reload_configuration_action, test_version_action)
159 (test_log_priority_action, test_upstart_open): Initialise alloc-safe
160 variables to NULL and diverted return values to 0 to avoid gcc
161 warnings.
162 (test_start_action, test_stop_action, test_restart_action):
163 Replace sigsetjmp/siglongjmp with a call to _exit() in the handler
164 * util/tests/test_sysv.c (test_change_runlevel): Initialise alloc-safe
165 variables to NULL to avoid gcc warnings
166
Scott James Remnante5cadae2009-07-09 12:02:06 +0100167 * util/man/runlevel.7: Formatting fixes, and mention that rcS
168 runs rc-sysinit again.
169 * util/man/runlevel.8: s/utilities/tools/
170 * util/man/telinit.8: s/utilities/tools/
171 * util/man/shutdown.8: s/utilities/tools/
172 * util/man/reboot.8: s/utilities/programs/
173 * util/man/initctl.8: s/utility/tool/
174
Scott James Remnant60d91ea2009-07-09 12:01:53 +0100175 * init/job_class.h (JobClass): Drop the leader option; at the time
176 it seemed to make sense that Upstart would provide a "daemon"-like
177 environment, but it really doesn't in practice. Software should
178 feel safe to daemonise on its own, and I'd rather fix supervision
179 of those; freeing up Upstart jobs to run as new sessions by default
180 again. This is also the only real option that would change the
181 behaviour between 0.6 and 0.10 in an awkwardly compatible way.
182 * init/job_class.c (job_class_new): Remove leader initialisation
183 * init/tests/test_job_class.c (test_new): Drop the initialisation
184 check for leader
185 * init/parse_job.c (stanza_session): Drop the stanza
186 * init/tests/test_parse_job.c (test_stanza_session): Drop the
187 stanza test cases.
188 * init/job_process.c (job_process_spawn): Drop the double-fork.
189 This means we don't need to read the pid of our extra child either.
190 (job_process_error_read): we no longer need a fork error.
191 * init/job_process.h (JobProcessErrorType): Drop the fork error.
192 * init/tests/test_job_process.c (test_spawn): Replace the simple job
193 test case with the session leader test case, now that's the default.
194 (test_run, test_spawn, test_kill, test_handler): Remove all the
195 class->leader = TRUE from the tests, we only ever really tested
196 session leaders anyway since that's all the test suite could follow
197 * init/tests/test_job.c (test_change_goal, test_change_state):
198 Remove the leader flag from test jobs
199 * init/tests/test_event.c (test_pending, test_finished): Remove
200 the leader flag from test jobs.
201
Scott James Remnant1e812b52009-07-09 10:10:37 +0100202 * init/job_process.c (job_process_catch_runaway): Use a monotonic
203 clock, not the realtime clock, for respawn interval detection.
204 * init/tests/test_job_process.c (test_kill, test_handler): Use the
205 monotonic clock in test cases too
206 * init/Makefile.am (init_LDADD): Link with librt
207 * NEWS: Update.
208
Scott James Remnantfbff5df2009-07-09 09:43:17 +0100209 * util/utmp.c (utmp_write_runlevel): Don't write 'N' to utmp or
210 wtmp for the previous runlevel, this will force writing reboot
211 records if prevlevel='N'/0 since read_runlevel will always return
212 'N' in that case.
213 * util/tests/test_utmp.c (test_write_runlevel): Add test case for
214 passing 'N' and having it treated as zero
215 (test_read_runlevel): Add a couple of test cases for the problems
216 we found last night where shutdown and corrupt utmp records result
217 in the wrong data being returned.
218 * util/tests/test_sysv.c (test_change_runlevel): Add a test case
219 for switching from sysinit to the first runlevel
220
Scott James Remnant8e354982009-07-09 09:36:52 +0100221 * init/conf.h,
222 * init/control.h,
223 * init/event.h,
224 * init/job_class.h: Variable declarations in header files need to
225 be prefixed with "extern", the NIH_BEGIN_EXTERN stuff only applies
226 to C++.
227
Scott James Remnant5619fdc2009-07-09 00:57:10 +0100228 * util/reboot.c: Reboot can't write the shutdown time before
229 calling shutdown, otherwise shutdown won't be able to get the
230 current runlevel anymore.
231 * util/man/reboot.8: Update, we don't write the shutdown time
232 before calling shutdown - it's up to the shutdown scripts to
233 call reboot -w before remounting the root filesystem.
234
Scott James Remnant9c95b102009-07-09 00:39:55 +0100235 * util/tests/test_utmp.c (test_get_runlevel): Replace test case
236 with one that expects 'N' rather than fall-through.
237 * util/tests/test_sysv.c (test_change_runlevel): Expect N when
238 there is no previous runlevel
239
Scott James Remnanta849b0a2009-07-09 00:36:46 +0100240 * util/utmp.c (utmp_read_runlevel): Also catch a zero runlevel from
241 utmp, replacing with 'N' - these functions should never return 0
242 * util/sysv.c (sysv_change_runlevel): Should set prevlevel to N
243 when we don't find one
244
Scott James Remnant5091edc2009-07-09 00:34:53 +0100245 * util/utmp.c (utmp_read_runlevel): Catch a negative runlevel from
246 corrupt utmp data, convert to 'N'
247 (utmp_get_runlevel): Return N when RUNLEVEL is set but empty,
248 rather than falling through
249
Scott James Remnant98af00b2009-07-09 00:22:25 +0100250 * util/telinit.c: Catch a missing argument separately so we don't
251 output "(null)"
252
Scott James Remnantbf7399d2009-07-09 00:14:49 +0100253 * README: Update requirements.
254 * TODO: Update.
255
Scott James Remnant6e177852009-07-09 00:09:09 +0100256 * conf/rc-sysinit.conf: Fix typo.
257
Scott James Remnant63473d72009-07-08 21:03:50 +01002582009-07-08 Scott James Remnant <scott@netsplit.com>
259
Scott James Remnant5094d2e2009-07-08 23:04:13 +0100260 * conf/rc-sysinit.conf: Michael Biebl pointed out that by setting
261 the runlevel to "S" during sysinit, we end up with the runlevel
262 after boot being "S 2" - and that means scripts in rc2.d that
263 are also in rcS.d won't get started. The way we had it before
264 ("N 2") was correct. This happily fixes the one corner case our
265 reboot handling didn't cover - crashing in single user mode and
266 rebooting.
267
Scott James Remnantc80b09f2009-07-08 22:48:03 +0100268 * util/telinit.c: Fix missing ret = from kill
269
Scott James Remnantdf7d14a2009-07-08 22:46:26 +0100270 * conf/rc-sysinit.conf: Ignore -s/single if we're already coming
271 from single-user-mode.
272
Scott James Remnantc2ebba92009-07-08 22:43:49 +0100273 * util/telinit.c (options): Unignore the -t option
274 * NEWS: Update.
275
Scott James Remnant911cb2e2009-07-08 22:40:50 +0100276 * init/main.c (hup_handler): Also try and reconnect to the message
277 bus if we've lost the connection.
278
Scott James Remnant545bbe32009-07-08 22:05:59 +0100279 * init/conf.c (conf_source_reload_dir): Don't blacklist certain
280 patterns from the configuration directory, instead just filter
281 to whitelist.
282 (conf_dir_filter): Whitelist filter, only accept files ending
283 in .conf
284 (conf_reload_path): Strip .conf from the filename to generate
285 the job name.
286 (conf_file_filter): Add the extra is_dir argument.
287 * init/tests/test_conf.c (test_source_reload_job_dir)
288 (test_source_reload_conf_dir, test_source_reload_file)
289 (test_source_reload): Append .conf to all our filenames
290 * init/tests/test_control.c (test_reload_configuration): Append
291 .conf to filenames here too
292 * NEWS: Update.
293
Scott James Remnant63473d72009-07-08 21:03:50 +0100294 * init/job_process.c (job_process_run): Stop being stingy, the
295 post-stop script can have the stop environment too
296 * init/tests/test_job_process.c (test_run): Add a test case to
297 make sure it is.
298
Scott James Remnantd3a6ca72009-07-08 20:59:21 +01002992009-07-08 Michael Biebl <mbiebl@gmail.com>
300
301 * contrib/vim/syntax/upstart.vim: Upstart job syntax highlighting
302 * contrib/vim/ftdetect/upstart.vim: Use for the /etc/init directory
303 * contrib/Makefile.am: Include the vim syntax files in the
304 distribution
305 * configure.ac (AC_CONFIG_FILES): Create contrib/Makefile
306 * Makefile.am (SUBDIRS): Recurse into the contrib sub-directory
307
Scott James Remnant9f322cb2009-07-08 15:42:15 +01003082009-07-08 Scott James Remnant <scott@netsplit.com>
309
Scott James Remnant0a046c62009-07-08 20:55:15 +0100310 * conf/rc.conf: This doesn't need to be an instance job, Upstart
311 will do the right thing and stop the task before starting it again
312 with the new environment (I spent so much time on that, you'd think
313 I'd remember :p)
314
Scott James Remnantedb382a2009-07-08 20:43:16 +0100315 * conf/control-alt-delete.conf: Default job for Control-Alt-Delete
316 * conf/rc-sysinit.conf: Default job for system initialisation
317 * conf/rc.conf: A fully wacky instance job that runs the rc script
318 for runlevel changes
319 * conf/rcS.conf: And a job for single-user-mode, which calls back
320 to rc-sysinit
321 * conf/Makefile.am (dist_init_DATA): Install the default files
322 into the /etc/init directory
323 * configure.ac (AC_CONFIG_FILES): Create conf/Makefile
324 * Makefile.am (SUBDIRS): Recurse into the conf directory.
325
Scott James Remnant10a35f22009-07-08 20:05:46 +0100326 * util/initctl.c (upstart_open, start_action, stop_action)
327 (restart_action, status_action, list_action): Don't auto-start
328 the init daemon, it makes no sense.
329 (upstart_open): When not running from the test suite, and not as
330 root, it makes sense to default to using the system bus daemon.
331 * util/tests/test_initctl.c (test_upstart_open): Make sure that
332 auto-start is FALSE, not TRUE.
333 * NEWS: Update.
334
Scott James Remnant3b61f512009-07-08 19:59:00 +0100335 * util/Makefile.am (dist_man_MANS): Oops, had the wrong name for
336 the runlevel(7) manpage.
337
Scott James Remnantf24e55d2009-07-08 19:58:37 +0100338 * util/shutdown.c: Gets a bit of a redress, but not much of rewrite
339 since this is largely just compatibility madness.
340 (shutdown_now): Port to use sysv_change_runlevel()
341 (warning_message): Construct plural forms a little better.
342 (wall): use utmpx, rather than utmp
343 * util/man/shutdown.8: Minor tweaks and improvements
344 * NEWS: Update.
345
Scott James Remnant461578a2009-07-08 19:30:12 +0100346 * util/reboot.c: Following the pattern of the previous, remove much
347 of the reboot code, but in the process adding support for reboot
348 implying --force in runlevel 0 or 6, and writing the shutdown
349 wtmp record.
350 * util/man/reboot.8: Minor updates.
351 * NEWS: Update.
352
Scott James Remnant3aac7132009-07-08 19:02:56 +0100353 * util/telinit.c: Drop quite a bit of the code of telinit too,
354 just becoming a wrapper about sysv_change_runlevel() - also support
355 Qq/Uu by using kill()
356 * util/tests/test_telinit.c (test_env_option): Since we have an
357 env option, we should test it.
358 * util/man/telinit.8: Update the manual page.
359 * util/man/runlevel.8: Typo (/var/run/wtmp -> /var/log/wtmp)
360 * util/Makefile.am (TESTS): Run the new test
361 (test_telinit_SOURCES, test_telinit_CFLAGS)
362 (test_telinit_LDFLAGS, test_telinit_LDADD): Details for the
363 test suite binary
364 * NEWS: Update.
365
Scott James Remnantff87eaf2009-07-08 18:38:25 +0100366 * util/runlevel.c: Drop about 90% of the code, this just becomes
367 a wrapper around utmp_get_runlevel()
368 * util/man/runlevel.8: Update the runlevel manpage.
369 * util/man/runlevel.7: Also put together a manual page that
370 describes the runlevel event, as well as the implementation in
371 Upstart.
372 * util/Makefile.am (dist_man_MANS): Install the new manpage.
373 * NEWS: Update.
374
Scott James Remnant054c5c42009-07-08 17:07:14 +0100375 * util/Makefile.am (reboot_SOURCES, runlevel_SOURCES): Compile and
376 link the utmp handling source, depending on the header.
377 (reboot_LDADD, runlevel_LDADD): Drop dependency on libupstart
378 (shutdown_SOURCES, telinit_SOURCES): Compile and link both the
379 utmp handling and sysv compat source, depending on the headers
380 (nodist_shutdown_SOURCES, nodist_telinit_SOURCES): Also link in
381 the auto-generated bindings
382 (shutdown_LDADD, telinit_LDADD): Drop dependencies on libupstart,
383 replacing with dependencies on libnih-dbus and the D-Bus libs.
384 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD)
385 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD)
386 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Remove duplicate
387 entries mistakenly copied from compat/sysv
388
Scott James Remnantd5a366e2009-07-08 17:03:05 +0100389 * util/sysv.c (sysv_change_runlevel): Pretty much the core compat
390 function for System V, generate a runlevel event and store the
391 appropriate things in utmp and wtmp.
392 * util/sysv.h: Prototype.
393 * util/tests/test_sysv.c: Test cases for the new function.
394 * util/Makefile.am (TESTS): Run the sysv test cases
395 (test_sysv_SOURCES, nodist_test_sysv_SOURCES, test_sysv_LDFLAGS)
396 (test_sysv_LDADD): Details for the sysv test cases, which obviously
397 depend on the auto-generated bindings code.
398
Scott James Remnant27c0c762009-07-08 16:56:53 +0100399 * util/utmp.c (utmp_write_runlevel): Make sure that it's ok to
400 have no previous runlevel.
401 * util/tests/test_utmp.c (test_write_runlevel): Add no previous
402 runlevel test.
403
Scott James Remnant591ab472009-07-08 15:52:55 +0100404 * util/utmp.c (utmp_read_runlevel): Don't call utmpxname() if we
405 don't pass a utmp_file, letting glibc pick the default.
406 * util/tests/test_utmp.c (test_read_runlevel): Add a test case for
407 no filename.
408
Scott James Remnant98025662009-07-08 15:42:41 +0100409 * util/util.supp: utmpname leaks memory, so suppress it from valgrind
410
Scott James Remnant9f322cb2009-07-08 15:42:15 +0100411 * util/utmp.c: Set of functions for dealing with utmp and wtmp
412 (utmp_read_runlevel): Read the current runlevel from the file
413 (utmp_get_runlevel): Obtain the current runlevel from the
414 environment, or the file if not set
415 (utmp_write_runlevel): Write a runlevel change record, and also
416 deal with the reboot record if the utmp or wtmp files don't quite
417 match.
418 (utmp_write_shutdown): Write a shutdown time record
419 (utmp_entry, utmp_write, wtmp_write): utility functions for creating
420 and writing utmp and wtmp records.
421 * util/utmp.h: Prototypes for new functions.
422 * util/tests/test_utmp.c: Test cases.
423 * util/Makefile.am (test_utmp_SOURCES, test_utmp_LDFLAGS)
424 (test_utmp_LDADD): Details for utmp test cases
425 (tests): Move to the bottom of the file and make PHONY
426
Scott James Remnant07b32242009-07-07 10:49:43 +01004272009-07-07 Scott James Remnant <scott@netsplit.com>
428
429 * util/man/initctl.8: Improve the manpage.
430
Scott James Remnantcf2e8332009-07-06 20:32:07 +01004312009-07-06 Scott James Remnant <scott@netsplit.com>
432
433 * util/initctl.c: Rewrite from scratch, utilising the current
434 D-Bus API and auto-generated method functions for it.
435 * util/tests/test_initctl.c: Rewrite from scratch to test all
436 of the new methods.
437 * util/Makefile.am (test_initctl_CFLAGS): Include AM_CFLAGS
438 (install-data-hook, install-exec-hook): Install a symlink for
439 "restart" as well.
440 * NEWS: Update.
441
Scott James Remnantb95895c2009-07-03 12:35:48 +01004422009-07-03 Scott James Remnant <scott@netsplit.com>
443
Scott James Remnant54179122009-07-03 17:38:02 +0100444 * dbus/com.ubuntu.Upstart.Instance.xml (Start, Stop, Restart): add
445 wait arguments to the instance commands as well.
446 * init/job.c (job_start, job_stop, job_restart): Add wait arguments,
447 when TRUE the functions behave as before; when FALSE the methods
448 return after changing the goal and no blocked entries are created.
449 * init/job.h: Amend prototypes.
450 * init/tests/test_job.c (test_start, test_stop, test_restart):
451 Pass TRUE for wait and check for a blocking entry in existing tests,
452 add tests for passing FALSE and making sure that there's no blocking
453 but we still get the reply.
454
Scott James Remnantf2926f02009-07-03 17:28:21 +0100455 * dbus/com.ubuntu.Upstart.Job.xml (Start, Stop, Restart): Add wait
456 arguments to these too
457 * init/job_class.c (job_class_start, job_class_stop)
458 (job_class_restart): Add wait arguments, when TRUE the functions
459 behave as before; when FALSE the methods return after changing
460 the goal and no blocked entries are created.
461 * init/job_class.h: Amend prototypes.
462 * init/tests/test_job_class.c (test_start, test_stop, test_restart):
463 Pass TRUE for wait and check for a blocking entry in existing tests,
464 add tests for passing FALSE and making sure that there's no blocking
465 but we still get the reply.
466 (test_get_name, test_get_description, test_get_author)
467 (test_get_version): Add missing code to free the class on enomem
468
Scott James Remnantfb8242d2009-07-03 17:08:10 +0100469 * dbus/com.ubuntu.Upstart.xml (EmitEvent): Add wait argument
470 * init/control.c (control_emit_event): Add wait argument, when TRUE
471 this behaves as before; when FALSE the method returns after queuing
472 the event and no blocked entry is created for it.
473 * init/control.h: Amend prototype.
474 * init/tests/test_control.c (test_emit_event): Pass TRUE for wait
475 and check for a blocking entry in existing tests, add a test for
476 passing FALSE and making sure that there's no blocking but we
477 still get the reply.
478
Scott James Remnantb9f5ee82009-07-03 16:03:25 +0100479 * dbus/com.ubuntu.Upstart.Instance.xml: Add a "processes" property
480 to obtain the list of current job processes, both their type and
481 their pid.
482 * init/job.c (job_get_processes): Implement the new property accessor
483 * init/job.h: Add prototype
484 * init/tests/test_job.c (test_get_processes): Add test cases for
485 returning process arrays.
486 (test_get_name, test_get_goal, test_get_state): Add missing free
487 for job class.
488
Scott James Remnantde5a1662009-07-03 12:51:34 +0100489 * init/tests/test_control.c (test_emit_event): Directly acess
490 the number from an NihDBusError
491
Scott James Remnantb95895c2009-07-03 12:35:48 +0100492 * dbus/com.ubuntu.Upstart.xml: Add a "version" property to obtain
493 the version of the init daemon, and a "log_priority" property to
494 get and set the daemon's log priority.
495 * init/control.c (control_get_version, control_get_log_priority)
496 (control_set_log_priority): Methods to support the new properties
497 * init/control.h: Prototypes.
498 * init/tests/test_control.c (test_get_version)
499 (test_get_log_priority, test_set_log_priority): Add tests for the
500 property accessor functions.
501
Scott James Remnant02606132009-07-02 18:31:25 +01005022009-07-02 Scott James Remnant <scott@netsplit.com>
503
Scott James Remnant0cbb06c2009-07-02 18:46:41 +0100504 * dbus/Upstart.conf: Need to adjust the security configuration
505 * dbus/upstart.h: And the constants as well.
506
Scott James Remnant02bdd772009-07-02 18:41:52 +0100507 * dbus/com.ubuntu.Upstart.xml,
508 * dbus/com.ubuntu.Upstart.Job.xml,
509 * dbus/com.ubuntu.Upstart.Instance.xml: Now we don't hardcode the
510 interface name anywhere, we can version it properly.
511 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
512 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
513 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update default interface
514 names.
515 * util/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
516 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
517 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update here too.
518
Scott James Remnant02606132009-07-02 18:31:25 +0100519 * dbus/Makefile.am (EXTRA_DIST): Make sure we distribute it
520 * dbus/upstart.h: Add a header file with the usual D-Bus constants.
521 * init/control.h: Drop CONTROL_ROOT, replace with DBUS_PATH_UPSTART
522 * init/control.c (control_server_open, control_bus_open)
523 (control_register_all): Replace CONTROL_* constants with the new ones
524 (control_get_job_by_name): Use DBUS_INTERFACE_UPSTART when constructing
525 error names.
526 * init/job_class.c (job_class_new, job_class_register)
527 (job_class_unregister): Construct paths using DBUS_PATH_UPSTART
528 (job_class_get_instance)
529 (job_class_get_instance_by_name, job_class_start)
530 (job_class_stop, job_class_restart): Use DBUS_INTERFACE_UPSTART to
531 construct error names
532 * init/job.c (job_new): Construct path using DBUS_PATH_UPSTART
533 (job_finished, job_start, job_stop, job_restart): Use
534 DBUS_INTERFACE_UPSTART to construct error names.
535 * init/event.c (event_finished): Use DBUS_INTERFACE_UPSTART to
536 construct error name.
537 * init/tests/test_control.c (test_server_open): Don't hardcode
538 the address, extract the abstract path from the constant.
539 (test_server_connect, test_bus_open, test_emit_event): Don't
540 harcode addresses, paths or interfaces - use the constants
541 * init/tests/test_job_class.c (test_consider, test_reconsider)
542 (test_register, test_unregister, test_start, test_stop)
543 (test_restart, test_get_instance, test_get_instance_by_name):
544 Use the constants instead of harcoding.
545 (test_new): Derive the expected path from the constant
546 * init/tests/test_job.c (test_new): Derive the paths from the
547 constant, check for jobs by that interface constant.
548 (test_change_state): Use DBUS_INTERFACE_UPSTART_JOB
549 (test_start, test_stop, test_restart): Use DBUS_INTERFACE_UPSTART_INSTANCE,
550 and generate errors from DBUS_INTERFACE_UPSTART
551
552 * dbus/com.ubuntu.Upstart.xml,
553 * dbus/com.ubuntu.Upstart.Job.xml,
554 * dbus/com.ubuntu.Upstart.Instance.xml: Remove the empty symbol
555 annotation for the interfaces.
556 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
557 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
558 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Define the default
559 interface and build-time instead.
560 * util/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
561 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
562 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Likewise for util
563
Scott James Remnantdcf67712009-06-30 13:20:25 +01005642009-06-30 Scott James Remnant <scott@netsplit.com>
565
566 * dbus/Upstart.conf: It doesn't make much sense to restrict getting
567 the values of properties, or looking up jobs or interfaces, so make
568 these public.
569
Scott James Remnantb3338202009-06-23 01:02:58 +01005702009-06-23 Scott James Remnant <scott@netsplit.com>
571
Scott James Remnant047b94f2009-06-23 13:45:12 +0100572 * Makefile.am (SUBDIRS): Add util to the list of sub-directories
573 again.
574 * configure.ac (AC_CONFIG_FILES): Generate util/Makefile
575 * util/Makefile.am (AM_CFLAGS): Append D-Bus CFLAGS
576 (AM_CPPFLAGS): Make sure the build directory is also in the quoted
577 include path
578 (nodist_initctl_SOURCES): Build and link the generated D-Bus
579 bindings, but don't distribute them
580 (initctl_LDADD): Drop the libupstart dependency, instead put
581 libnih-dbus and DBUS_LIBS in there.
582 (com_ubuntu_Upstart_OUTPUTS, com_ubuntu_Upstart_XML)
583 ($(com_ubuntu_Upstart_OUTPUTS)): Auto-generate D-Bus binding code
584 to proxy the manager object
585 (com_ubuntu_Upstart_Job_OUTPUTS, com_ubuntu_Upstart_Job_XML)
586 ($(com_ubuntu_Upstart_Job_OUTPUTS)): Auto-generate D-Bus binding
587 code to proxy job class objects
588 (com_ubuntu_Upstart_Instance_OUTPUTS)
589 (com_ubuntu_Upstart_Instance_XML)
590 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Auto-generate D-Bus
591 binding code to proxy job instance objects
592 (BUILT_SOURCES, CLEANFILES): Built sources have to come first
593 and be cleaned up
594 (test_initctl_LDADD): Tests need to be linked to libnih-dbus
595 and the D-Bus libraries, as well as the auto-generated output
596 * init/Makefile.am (EXTRA_DIST): Drop the EXTRA_DIST for the
597 sources, already handled since they're in a different directory
598
Scott James Remnant0c0c5a52009-06-23 10:29:35 +0100599 * COPYING: Change licence to version 2 of the GNU GPL.
600 All files have been updated to reflect this.
601
Scott James Remnant854fda22009-06-23 01:21:55 +0100602 * init/paths.h (CONFFILE): Add new macro
603 * init/Makefile.am (AM_CPPFLAGS): Add CONFFILE definition
604 (install-data-local): No need to make conf.d or jobs.d
605 * init/main.c: Only parse CONFFILE (/etc/init.conf) as a
606 configuration file source and CONFDIR (/etc/init) as a job
607 configuration source.
608
Scott James Remnantb3338202009-06-23 01:02:58 +0100609 * configure.ac: Bump version to 0.6.0
610 * NEWS: Copy in news from 0.5.3; that release doesn't appear in
611 this ChangeLog since it was made on a separate branch. Begin
612 new release.
613
Scott James Remnanta25cc902009-06-18 18:44:15 +01006142009-06-18 Casey Dahlin <cdahlin@redhat.com>
615
616 * util/man/initctl.8: Fix formatting of SYNOPSIS
617
Scott James Remnant11a21582009-06-18 11:29:39 +01006182009-06-18 Scott James Remnant <scott@netsplit.com>
619
620 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
621 dbus/com.ubuntu.Upstart.Instance.xml: Add a comment to these files
622 to clarify that you may communicate and interact with Upstart
623 through these interfaces without restriction. It also makes sense
624 that these files be copied into software that does so to turn into
625 their own bindings, so use the FSF permissive licence for them.
626
Scott James Remnant2ec8b042009-06-17 16:49:13 +01006272009-06-17 Scott James Remnant <scott@netsplit.com>
628
Scott James Remnantebbbb0d2009-06-17 19:03:24 +0100629 * configure.ac: Bump version to 0.5.3
630
Scott James Remnant4ef6e282009-06-17 19:02:13 +0100631 * NEWS: Copy in news from 0.5.2; that release doesn't appear in
632 this ChangeLog since it was made on a separate branch.
633
Scott James Remnantfff115a2009-06-17 18:47:22 +0100634 * NEWS: Include 0.3.10 release, which happened from a separate branch.
635
Scott James Remnante22f81e2009-06-17 18:28:24 +0100636 * init/parse_job.c (stanza_kill, stanza_respawn, stanza_nice)
637 (stanza_oom): Check errno after using strtol() to avoid overflows.
638 (stanza_normal, stanza_umask, stanza_limit): Also check with
639 strtoul() too
640 * init/tests/test_parse_job.c (test_stanza_kill)
641 (test_stanza_respawn): Add test cases for the two that don't
642 check for overflow already.
643 (test_stanza_limit): Add test for the too large case where we don't
644 already cope.
645
Scott James Remnant180b5442009-06-17 17:52:18 +0100646 * dbus/Upstart.conf: Allow root to obtain properties
647
Scott James Remnant6684a9a2009-06-17 17:49:58 +0100648 * dbus/com.ubuntu.Upstart.Instance.xml: Add name, goal and state
649 properties to the instance
650 * init/job.c (job_get_name, job_get_goal, job_get_state): Add methods
651 to return the property values
652 * init/job.h: Add prototypes.
653 * init/tests/test_job.c (test_get_name, test_get_goal)
654 (test_get_state): Test cases.
655
Scott James Remnant6f49af02009-06-17 17:41:09 +0100656 * dbus/com.ubuntu.Upstart.Job.xml: Add name, description, author
657 and version properties to the job
658 * init/job_class.c (job_class_get_name)
659 (job_class_get_description, job_class_get_author)
660 (job_class_get_version): Add methods to return the property values.
661 * init/job_class.h: Add prototypes
662
Scott James Remnantd9bbe972009-06-17 17:09:49 +0100663 * init/job_process.c (job_process_error_abort): Don't abort() from
664 a child process, it confuses people; just exit with an interesting
665 error code (which we ignore anyway).
666
Scott James Remnant2ec8b042009-06-17 16:49:13 +0100667 * dbus/Upstart.conf: Update the D-Bus configuration based on newer
668 D-Bus recommended practice with a proper deny-by-default D-Bus,
669 making sure to not use send_interface without send_destination.
670 Allow introspection as well.
671
Scott James Remnant25c96942009-06-17 16:41:34 +01006722009-06-17 Jeff Oliver <Jeffrey.Oliver@panasonic.aero>
673
674 * init/job_process.c (job_process_spawn): Only attempt to set
675 the OOM adjustment if set in the class, avoiding issue where /proc
676 is not mounted for the first job.
677
Scott James Remnanta5efa6c2009-06-17 14:30:45 +01006782009-06-17 Scott James Remnant <scott@netsplit.com>
679
Scott James Remnant1b91df42009-06-17 16:24:11 +0100680 * init/tests/test_job_process.c (test_handler): Add test cases for a
681 respawning job failing while it's post-start or pre-stop processes
682 are still running while making sure that it still respawns afterwards.
683 * init/job_process.c (job_process_terminated): To fix it, check for
684 a running post-start or pre-stop process before checking for a the
685 respawn. That's not enough because then we won't respawn when the
686 existing process finishes, so use the goal as a hint.
687 * init/job.c (job_next_state): Use that hint goal here, remembering
688 to set the goal back to JOB_START afterwards.
689 (job_change_goal): Nothing to do in the respawn case
690 (job_goal_name, job_goal_from_name): Add the new values
691 * init/job.h (job_goal): Add the respawn goal
692 * init/tests/test_job.c (test_next_state): Add tests for the respawn
693 goal
694 (test_goal_name, test_goal_from_name): Tests for the new values
695
Scott James Remnantf7271672009-06-17 14:59:38 +0100696 * configure.ac (AC_CONFIG_FILES): dbus goes before init just in case
697 we ever do anything to them later
698
Scott James Remnant0a8bd922009-06-17 14:37:23 +0100699 * init/job_class.c (job_class_register, job_class_unregister): Update
700 name of signal functions that we call.
701 (job_class_interfaces): No need to declare this separately
702 * init/job.c (job_register, job_change_state): Update name of signal
703 functions.
704 (job_interfaces): Drop, it comes from the generated header now
705 * init/control.c (manager_interfaces): Drop, comes from the header
706 as control_interfaces
707 (control_register_all): Change array name
708 * init/tests/test_job_class.c,
709 * init/tests/test_job.c,
710 * init/tests/test_control.c,
711 * init/tests/test_blocked.c: Rename conn member of NihDBusMessage
712 to connection
713
Scott James Remnanta5efa6c2009-06-17 14:30:45 +0100714 * dbus/com.ubuntu.Upstart.xml,
715 * dbus/com.ubuntu.Upstart.Job.xml,
716 * dbus/com.ubuntu.Upstart.Instance.xml: Use annotation to mark the
717 methods as async, rather than a namespaced attribute. Omit the
718 interface symbol.
719 * init/Makefile.am (AM_CPPFLAGS): Add builddir to the quoted includes
720 (init_SOURCES): Don't distribute the auto-generated outputs
721 ($(com_ubuntu_Upstart_OUTPUTS))
722 ($(com_ubuntu_Upstart_Job_OUTPUTS))
723 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Generate using the new
724 binary tool.
725 (BUILT_SOURCES): Remind myself why these are BUILT_SOURCES
726 (MAINTAINERCLEANFILES): Change to ordinary CLEANFILES
727 (EXTRA_DIST): outputs aren't distributed
728
Scott James Remnant75123022009-05-22 13:27:56 +02007292009-05-22 Scott James Remnant <scott@netsplit.com>
730
Scott James Remnant5c102eb2009-05-22 15:18:30 +0200731 * init/tests/test_conf.c: Remove nih/inotify.h include
732
Scott James Remnant75123022009-05-22 13:27:56 +0200733 * COPYING: Change licence from GPL-2+ to GPL-3 only.
734
Scott James Remnanta6a82532009-05-17 14:43:54 +01007352009-05-17 Scott James Remnant <scott@netsplit.com>
736
737 * init/tests/test_job.c,
738 * init/tests/test_job_class.c,
739 * init/tests/test_control.c: Include nih-dbus/errors.h
740
Scott James Remnantdbd3b152009-05-09 16:30:35 +01007412009-05-09 Scott James Remnant <scott@netsplit.com>
742
Scott James Remnant3306e262009-05-13 11:49:51 +0100743 * init/init.supp: setenv on tls/i686/cmov
744
Scott James Remnant0ff734e2009-05-09 16:56:08 +0100745 * init/job_class.c (job_class_get_instance, job_class_start)
746 (job_class_stop, job_class_restart): Clean up the code by using
747 nih_error_steal()
748
Scott James Remnant7f590ac2009-05-09 16:52:54 +0100749 * init/conf.c (conf_source_reload_file, conf_source_reload_dir):
750 Steal the error that we stash instead of getting it, otherwise we'll
751 fail if another one occurs.
752
Scott James Remnant3d7483b2009-05-09 16:36:03 +0100753 * init/conf.c (conf_reload_path): Simply return, no need to re-raise
754 the error.
755 * init/job_class.c (job_class_get_instance, job_class_start)
756 (job_class_stop, job_class_restart): If not ENOMEM, we need to
757 re-raise the error as a D-Bus one, that means we now have to free
758 the old error first (saving the msssage)
759 * init/job_process.c (job_process_error_read): Replace call to
760 nih_error_raise_again() with nih_error_raise_error()
761
Scott James Remnantdbd3b152009-05-09 16:30:35 +0100762 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
763 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
764 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Use the Python variant
765 of nih-dbus-tool for now
766
Scott James Remnantddee7aa2009-03-27 14:28:51 +00007672009-03-27 Scott James Remnant <scott@netsplit.com>
768
Scott James Remnant58278d62009-03-27 15:22:07 +0000769 * init/tests/test_process.c (test_from_name): Cast -1 to ProcessType
770 * init/tests/test_job_process.c (test_kill, test_handler): Cast -1
771 to ProcessType
772 * init/tests/test_job.c (test_new, test_change_state): Cast -1
773 to ProcessType
774 (test_goal_from_name): Cast -1 to JobGoal
775 (test_state_from_name): Cast -1 to JobState
776 * init/tests/test_control.c (test_bus_open): Add braces
777
Scott James Remnant58f873a2009-03-27 15:22:00 +0000778 * init/Makefile.am (tests): Add rule to build test cases
779 * util/Makefile.am (tests): Likewise
780
Scott James Remnant267e61c2009-03-27 15:16:06 +0000781 * init/job.c (job_interfaces): Put static first
782 (job_emit_event): Cast -1 to ProcessType
783 (job_emit_event): Cast -1 to ProcessType
784 * init/job_class.c (job_class_interfaces): Put static first.
785 * init/job_process.c (job_process_kill_timer): Cast -1 to ProcessType
786 * init/control.c (manager_interfaces): Put static first
787
Scott James Remnantddee7aa2009-03-27 14:28:51 +0000788 * init/Makefile.am (AM_CPPFLAGS): Use -iquote$(srcdir) instead of -I
789 since we only need it to pick those paths up.
790 * util/Makefile.am (AM_CPPFLAGS): Likewise.
791
Scott James Remnant0ad2d9a2009-02-20 22:08:20 +00007922009-02-20 Scott James Remnant <scott@netsplit.com>
793
Scott James Remnant7d59ed22009-02-20 22:28:03 +0000794 * util/initctl.c (handle_job_instance_end, handle_job_process)
795 (handle_job_status_end, handle_event),
796 * util/shutdown.c (main): No need for new_* temporary variable when
797 looping over nih_realloc with NIH_MUST.
798
Scott James Remnantc5d3e1b2009-02-20 22:22:48 +0000799 * util/initctl.c (job_info_output, output_name, handle_job_list)
800 (handle_job_instance, handle_job_instance_end)
801 (handle_job_status, handle_job_process, handle_job_status_end)
802 (handle_event, env_option),
803 * util/telinit.c (main),
804 * util/shutdown.c (main, shutdown_now, timer_callback, wall):
805
Scott James Remnant56954112009-02-20 22:18:57 +0000806 * init/event.c (event_init, event_pending_handle_jobs, event_finished),
807 * init/event_operator.c (event_operator_events),
808 * init/job.c (job_emit_event, job_name),
809 * init/job_class.c (job_class_init, job_class_start)
810 (job_class_stop, job_class_restart),
811 * init/job_process.c (job_process_run, job_process_error_read)
812 (job_process_kill),
813 * init/conf.c (conf_init, conf_source_reload_file)
814 (conf_reload_path),
815 * init/control.c (control_init, control_server_connect)
816 (control_bus_open): Set variable outside of NIH_MUST macro.
817
Scott James Remnant69132b72009-02-20 22:10:06 +0000818 * init/event.c (event_pending_handle_jobs): Set variable outside
819 of NIH_SHOULD macro.
820
Scott James Remnant0ad2d9a2009-02-20 22:08:20 +0000821 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
822 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
823 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Update expected path
824 of nih-dbus-tool
825
826 * configure.ac: Create nih-dbus-tool Makefile
827 * Makefile.am (SUBDIRS): Build in nih-dbus-tool
828
Scott James Remnantda7d2d42009-01-29 01:55:15 +00008292009-01-29 Scott James Remnant <scott@netsplit.com>
830
Scott James Remnant619905b2009-01-29 06:23:08 +0000831 * configure.ac: Bump version to 0.5.2
832 * NEWS: Begin 0.5.2
833
834 * NEWS: Copy in news from 0.5.1; that release doesn't appear in
835 this ChangeLog since it was made on a separate branch.
836
Scott James Remnant593c8ea2009-01-29 05:29:17 +0000837 * init/tests/test_blocked.c (test_new),
838 * init/tests/test_control.c (test_get_job_by_name)
839 (test_get_all_jobs, test_emit_event),
840 * init/tests/test_event.c (test_finished),
841 * init/tests/test_job.c (test_change_state),
842 * init/tests/test_job_class.c (test_get_instance)
843 (test_get_instance_by_name, test_get_all_instances): Continue the
844 battle with the gcc optimiser which declares variables first used
845 inside TEST_ALLOC_FAIL as used uninitialized.
846
Scott James Remnant88abb652009-01-29 04:23:21 +0000847 * init/parse_job.c (parse_exec, parse_script, stanza_instance)
848 (stanza_description, stanza_author, stanza_version)
849 (stanza_start, stanza_stop, stanza_chroot, stanza_chdir):
850 Unreference members when replacing them instead of freeing; not
851 strictly necessary but the style is the thing.
852
Scott James Remnant57a64d32009-01-29 04:21:07 +0000853 * init/job_process.c (job_process_terminated): Unreference the
854 kill timer instead of freeing
855
Scott James Remnantd3df7ee2009-01-29 04:20:42 +0000856 * init/job_class.c (job_class_get_instance): Use nih_local for
857 instance environment and name
858 (job_class_start, job_class_stop, job_class_restart):
859 Unreference job environment instead of freeing
860
Scott James Remnant636d37f2009-01-29 04:18:35 +0000861 * init/job.c (job_change_state, job_start, job_stop, job_restart):
862 Unreference job environment instead of freeing
863 (job_name): Discard job name in case a reference was taken.
864
Scott James Remnant248b40e2009-01-29 04:16:14 +0000865 * init/event.c (event_pending_handle_jobs): Unreference the job
866 environment instead of freeing
867
Scott James Remnant06d95a12009-01-29 04:15:05 +0000868 * init/environ.c (environ_add): should unreference the old environment
869 string in case anyone took a ref elsewhere
870 (environ_set): use nih_local for str
871 (environ_expand_until): Should set *str to NULL if we free it,
872 just in case.
873
Scott James Remnantd3667ed2009-01-29 04:11:24 +0000874 * init/conf.c (conf_source_reload): File should be unreferenced,
875 not freed.
876 (conf_source_reload_file): Use nih_local for dpath
877 (conf_delete_handler): Watch and file should be unreferenced,
878 not freed.
879 (conf_reload_path): File should be unreferenced, not freed;
880 use nih_local for file buffer
881
Scott James Remnant750c0b12009-01-29 02:24:21 +0000882 * init/blocked.c (blocked_new),
883 * init/conf.c (conf_source_new, conf_file_new),
884 * init/event.c (event_new),
885 * init/event_operator.c (event_operator_new),
886 * init/job.c (job_new),
887 * init/job_class.c (job_class_new): No need to cast function
888 argument to nih_alloc_set_destructor()
889
Scott James Remnant85ef5352009-01-29 02:15:34 +0000890 * init/tests/test_job_process.c (test_handler): We can't just
891 assume that our child is sitting at the signal otherwise we might
892 end up sending the CONT signal before it's even stopped. Use
893 waitid() to wait for the child to stop first.
894
Scott James Remnant79bd8612009-01-29 02:02:36 +0000895 * init/init.supp: More expressions for environment memory which
896 valgrind can't deal with
897
Scott James Remnantda7d2d42009-01-29 01:55:15 +0000898 * init/conf.c (conf_source_reload): The ConfFile destructor has
899 side-effects that involve the iteration of the sources and their
900 files, so we can't simply call it while iterating because of the
901 cursor. Move the sources into a deleted list first, and delete
902 them from there.
903 * init/conf.h: Fix prototype.
904 * init/tests/test_conf.c (test_source_reload_job_dir): Test pointers
905 with TEST_EQ_P not TEST_EQ
906
Scott James Remnant57982222009-01-28 01:22:31 +00009072009-01-28 Scott James Remnant <scott@netsplit.com>
908
Scott James Remnant75fb8382009-01-29 00:01:08 +0000909 * init/job_class.c (job_class_start): We can't create the blocked
910 until we know we're going to block, otherwise we could ref and unref
911 the message (freeing it). Wait until the job is created, which
912 means we can't fail to create the blocked item (we'll already have
913 announced the new instance).
914 (job_class_stop, job_class_restart): For consistency, don't fail
915 if OOM when making blocked.
916
Scott James Remnant78a9bb02009-01-28 23:42:24 +0000917 * init/tests/test_job.c (test_new): Initialise a bunch of subsystems
918 outside of TEST_ALLOC_FAIL
919
Scott James Remnant10cb7012009-01-28 23:39:29 +0000920 * init/environ.c (environ_add): We can't allocate nih_local with
921 a context, it won't be freed; so don't, but then remember to
922 reference it when we do just use it.
923
Scott James Remnant6edea722009-01-28 23:32:32 +0000924 * init/event.c (event_pending_handle_jobs): Must reset the start_on
925 operator in case of error.
926
Scott James Remnant64b9b7a2009-01-28 22:00:12 +0000927 * init/job_process.c (job_process_kill_timer): Oops, move the
928 assert that we have a process pid to after we know which process
929 we have.
930 * init/tests/test_job_process.c (test_run): Initialise the
931 error context and NihIo outside of TEST_ALLOC_FAIL
932 (test_kill): Initialise timers and the event system.
933 * init/init.supp: Reference from the jobs hash to the bins is
934 still reachable, obviously; as is the string inside job_name()
935 either way it is allocated
936
Scott James Remnant5eac8f12009-01-28 21:33:13 +0000937 * init/tests/test_parse_job.c (test_parse_job): Initialise the
938 error context outside of TEST_ALLOC_FAIL
939
Scott James Remnant514f1d02009-01-28 21:32:16 +0000940 * init/init.supp: Update suppressions for new nih_alloc()
941
Scott James Remnant4f1e0b72009-01-28 08:30:50 +0000942 * init/job_process.c (job_process_run): Had the shell variable
943 setting round the wrong way, now it should be ok.
944
Scott James Remnant01830df2009-01-28 08:30:23 +0000945 * init/tests/test_blocked.c (test_new): in the case of allocation
946 failure, the message should not be referenced; which we test by
947 trying to discard it and seeing whether that works.
948
Scott James Remnant44f60952009-01-28 04:04:15 +0000949 * init/job.c (job_emit_event): event_new() only references the
950 environment now, so use nih_local to make sure we clean it up
951 if that doesn't happen
952
Scott James Remnant885879b2009-01-28 04:01:55 +0000953 * init/job.h (Job): Add kill_process member
954 * init/job.c (job_new): Initialise to -1
955 * init/job_process.c (job_process_kill): Store the process to be
956 killed in the kill_process member for the timer, since we can't
957 pass two sets of data. Assert that it's not set to anything, this
958 all needs fixing, obviously.
959 (job_process_kill_timer): Take the job as the data argument,
960 eliminating the need for nih_alloc_parent(). Sanity check the job
961 and reset kill_timer and kill_process when done.
962 (job_process_terminated): Clear the kill_process field too.
963 * init/tests/test_job.c (test_new): Check it's -1
964 (test_change_state): Check kill_process is set to PROCESS_MAIN
965 when active, or -1 when not.
966 * init/tests/test_job_process.c (test_kill): Make sure the
967 kill_process member is set and cleared.
968 (test_handler): Set the kill_process member for the timer and make
969 sure it's cleared when appropriate.
970
Scott James Remnant50643372009-01-28 03:49:56 +0000971 * init/job_class.c (job_class_start, job_class_stop)
972 (job_class_restart): Use nih_local to eliminate nih_alloc_reparent,
973 and to clean up some of the code too.
974
Scott James Remnant041e7cd2009-01-28 03:41:47 +0000975 * init/job_class.c: Update documentation to match new nih_alloc()
976
Scott James Remnantda7839b2009-01-28 03:40:23 +0000977 * init/parse_job.c (parse_on_operator, parse_on_collect):
978 Use an nih_ref/nih_unref pair instead of nih_alloc_reparent; this
979 is not ideal, but then this code is rather messy and leaves a lot
980 of allocated data attached to the object on the assumption that
981 it will be thrown away.
982
Scott James Remnantee5b4202009-01-28 03:34:42 +0000983 * init/event_operator.c: Update documentation to match new nih_alloc()
984 (event_operator_match): Use nih_local on expanded value.
985 (event_operator_environment): Make evlist nih_local, it will be
986 referenced by the environment array on success
987
Scott James Remnantad9468a2009-01-28 03:27:51 +0000988 * init/event_operator.c (event_operator_new): Reference the
989 event instead of reparenting it.
990
Scott James Remnantcf14eeb2009-01-28 03:26:36 +0000991 * init/event.c: Update documentation to match new nih_alloc()
992 (event_finished): Use nih_local to tidy up a slight bit.
993
Scott James Remnantdec386b2009-01-28 03:24:22 +0000994 * init/event.c (event_new): Reference the event, don't reparent
995 (event_pending_handle_jobs): Use nih_local for environment array
996 and for the job name, damn I love this thing. Reference the array
997 into the job to avoid freeing.
998
Scott James Remnant5c540052009-01-28 03:17:04 +0000999 * init/parse_job.c (parse_job): Update documentation to match
1000 new nih_alloc()
1001 (parse_process, parse_on_operator, stanza_start, stanza_stop)
1002 (stanza_expect, stanza_kill, stanza_respawn, stanza_normal)
1003 (stanza_session, stanza_console, stanza_nice, stanza_umask)
1004 (stanza_oom, stanza_limit): Use nih_local for all the temporary
1005 arguments where we can.
1006
Scott James Remnant1bff7d62009-01-28 03:00:00 +00001007 * init/parse_job.c (parse_on_operand, stanza_env, stanza_export)
1008 (stanza_emits): Make temporary string variables use nih_local,
1009 this gives us a massive code clean-up and makes nih_str_array_addp
1010 safe to take a reference.
1011
Scott James Remnantc54150c2009-01-28 02:50:06 +00001012 * init/job_process.c (job_process_run): Make argv, env, script and
1013 cmd all use nih_local, this cleans up the code a little and makes
1014 nih_str_array_addp safe to take a reference.
1015
Scott James Remnantc4c2af92009-01-28 02:45:04 +00001016 * init/environ.c: Update documentation to match new nih_alloc()
1017
Scott James Remnant07a93482009-01-28 02:30:00 +00001018 * init/tests/test_job_process.c (test_run): Check that trailing
1019 newlines are ignored when running a script (can verify r1025 is
1020 fixed with gdb)
1021
Scott James Remnantbfc98512009-01-28 02:13:23 +00001022 * init/tests/test_environ.c (test_expand): Add a test case for the
1023 bug fixed in r1027, the implicit case of the gap in the environment
1024 string being the same size as the value replacing it.
1025
Scott James Remnant23b59822009-01-28 02:09:12 +00001026 * init/environ.c (environ_add): Use nih_local for new_str, making
1027 the code paths a little simpler and ensuring we pass something that
1028 can be referenced to nih_str_array_addp()
1029
Scott James Remnant4d34eb22009-01-28 02:07:32 +00001030 * init/tests/test_event.c (test_new): Make sure that env is an
1031 orphan with TEST_ALLOC_ORPHAN.
1032 * init/tests/test_event_operator.c (test_operator_new): Make sure
1033 that env is an orphan with TEST_ALLOC_ORPHAN.
1034 (test_operator_copy): Drop pointless NULL parent check.
1035
Scott James Remnantf6becd42009-01-28 02:02:06 +00001036 * init/tests/test_control.c: Include limits.h
1037
Scott James Remnant754a8752009-01-28 02:00:35 +00001038 * init/blocked.c (blocked_new): Take a reference to the message,
1039 otherwise it will be freed; we free the Blocked structure when we're
1040 done, so will automatically unref the message.
1041 * init/tests/test_blocked.c (test_new): Add tests to make sure the
1042 reference is taken.
1043 * init/tests/test_job.c (test_start, test_stop, test_restart):
1044 Make sure the message is referenced when an error is not returned
1045 but not referenced when one is.
1046 * init/tests/test_job_class.c (test_start, test_stop)
1047 (test_restart): Make sure the message is referenced when an error
1048 is not returned but not referenced when one is.
1049 * init/tests/test_control.c (test_emit_event): Make sure that
1050 the message is referenced.
1051
Scott James Remnant4cccfff2009-01-28 01:35:25 +00001052 * init/tests/test_blocked.c: Change nih/dbus.h include to
1053 nih-dbus/dbus_message.h
1054 * init/tests/test_control.c: Change nih/dbus.h include to error,
1055 connection and object; include D-Bus test macros.
1056 * init/tests/test_job.c: Change nih/dbus.h include to error, message
1057 and object; include D-Bus test macros
1058 * init/tests/test_job_class.c: Change nih/dbus.h include to error,
1059 message and object; include D-Bus test macros
1060
Scott James Remnant8269cac2009-01-28 01:31:02 +00001061 * init/job_class.h: Change nih/dbus.h include to
1062 nih-dbus/dbus_message.h and include the actual D-Bus header
1063 * init/job_class.c: Change nih/dbus.h include to error, message,
1064 object and util.
1065
Scott James Remnant1e78bc22009-01-28 01:30:56 +00001066 * init/job.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1067 and include the actual D-Bus header
1068 * init/job.c: Change nih/dbus.h include to error, message, object
1069 and util.
1070
Scott James Remnante8c03862009-01-28 01:25:44 +00001071 * init/control.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1072 and include the actual D-Bus header
1073 * init/control.c: Change nih/dbus.h include to error, connection,
1074 message and object includes.
1075
Scott James Remnant57982222009-01-28 01:22:31 +00001076 * init/blocked.h: Change nih/dbus.h include to nih-dbus/dbus_message.h
1077 * init/blocked.c: Change nih/dbus.h include to nih-dbus/dbus_message.h
1078
Scott James Remnant961ad212009-01-27 00:54:13 +000010792009-01-27 Scott James Remnant <scott@netsplit.com>
1080
1081 * init/Makefile.am: Update paths to libnih-dbus dependencies.
1082
Scott James Remnant2e8760b2009-01-26 01:15:21 +000010832009-01-26 Scott James Remnant <scott@netsplit.com>
1084
Scott James Remnant9b25c8d2009-01-26 15:35:51 +00001085 * configure.ac (AC_CONFIG_FILES): Add nih-dbus sub-directory
1086 * Makefile.am (SUBDIRS): Add nih-dbus sub-directory
1087
Scott James Remnantfcb81e62009-01-26 15:26:29 +00001088 * configure.ac: Bump copyright to 2009
1089
Scott James Remnant32804e82009-01-26 15:25:57 +00001090 * configure.ac: Matching libnih, we now mandate libtool 2.2.x
1091 * HACKING: Update dependency requirement to 2.2.4
1092
Scott James Remnantfc2b4f42009-01-26 01:18:12 +00001093 * init/init.supp: Adjust suppression for glibc 2.8
1094
Scott James Remnant4b2dcc62009-01-26 01:17:59 +00001095 * init/tests/test_event.c (test_finished): Remove erroneous test
1096 of free'd memory.
1097
Scott James Remnante32ab4f2009-01-26 01:17:21 +00001098 * configure.ac: Bump version to 0.5.1
1099
Scott James Remnantde22f422009-01-26 01:16:17 +00001100 * init/tests/test_event_operator.c (test_operator_handle): Add a
1101 test for duplicate events when already matched.
1102 * init/event_operator.c (event_operator_handle): Skip if already
1103 matched.
1104
Scott James Remnant2e8760b2009-01-26 01:15:21 +00001105 * README: Update features and requirements.
1106 * NEWS: Copy in news from 0.5.0; that release doesn't appear in
1107 this ChangeLog since it was made on a separate branch.
1108
Scott James Remnante4bbac02009-01-26 01:12:16 +000011092009-01-26 Casey Dahlin <cdahlin@redhat.com>
1110
1111 * init/environ.c (environ_expand_until): Handle the implicit case
1112 of the gap in the string being the same size of the value.
Scott James Remnant571b0702009-01-26 01:05:50 +00001113
1114 * init/job_process.c (job_process_handler): Handle the case of a
1115 child being continued by a signal, otherwise we'll assert.
Scott James Remnant07b2bc72009-01-26 01:03:35 +00001116
1117 * init/job_process.c (job_process_run): Double-check that the
1118 newline(s) we see are at the end of the script before stripping,
1119 since we can fall through if the newline is mid-script but /dev/fd
1120 isn't mounted.
1121
Scott James Remnantfd8a0432008-07-05 17:30:04 +010011222008-07-05 Scott James Remnant <scott@netsplit.com>
1123
1124 * TODO: Update.
1125
Scott James Remnantdd8abca2008-07-01 19:36:44 +010011262008-07-01 Scott James Remnant <scott@netsplit.com>
1127
1128 * init/Makefile.am ($(com_ubuntu_Upstart_OUTPUTS)):
1129 ($(com_ubuntu_Upstart_Job_OUTPUTS)):
1130 ($(com_ubuntu_Upstart_Instance_OUTPUTS)): Must be newer than the
1131 source for the dbus tool, and ensure the dbus tool is built
1132
Scott James Remnant55f3c7c2008-06-30 17:37:27 +010011332008-06-30 Scott James Remnant <scott@netsplit.com>
1134
1135 * init/Makefile.am: Update along with libnih so that we leave the
1136 D-Bus bindings in the dist tarball, meaning Python is no longer a
1137 build-dependency.
1138
Scott James Remnantce2b3b22008-06-11 08:21:35 +010011392008-06-11 Scott James Remnant <scott@netsplit.com>
1140
Scott James Remnant9a140952008-06-11 08:22:03 +01001141 * Makefile.am (SUBDIRS): List dbus before init in case we need to
1142 generate anything in that directory later on.
1143
Scott James Remnantce2b3b22008-06-11 08:21:35 +01001144 * Makefile.am (SUBDIRS): List po last so that update-po is run after
1145 generating any sources.
1146
Scott James Remnant3fb48382008-06-08 02:03:40 +010011472008-06-08 Scott James Remnant <scott@netsplit.com>
1148
Scott James Remnant94d75a12008-06-08 04:08:56 +01001149 * init/Makefile.am (EXTRA_DIST): Ship the built sources, don't
1150 clean them.
1151 (maintainer-clean-local): Well, not unless maintainer-clean anyway
1152
1153 * init/job.c, init/job_class.c: Add missing errno.h include
1154
Scott James Remnantb40e4dd2008-06-08 03:26:36 +01001155 * dbus/com.ubuntu.Upstart.Job.xml (GetInstance): Add method to get
1156 an instance name in the same basic manner as start and stop would,
1157 though this one's synchronous.
1158 * init/job_class.c (job_class_get_instance): Implementing by copying
1159 the relevant bit of Stop.
1160 * init/job_class.h: Add prototype.
1161 * init/tests/test_job_class.c (test_get_instance): Add tests.
1162 * TODO: Continue to document the C&P madness.
1163
Scott James Remnant39a8a0c2008-06-08 03:08:55 +01001164 * init/conf.c (conf_reload_path): Read file directly into memory,
1165 not using mmap.
1166
Scott James Remnant6591fef2008-06-08 03:08:39 +01001167 * compat/sysv/reboot.c, compat/sysv/runlevel.c, compat/sysv/shutdown.c,
1168 * compat/sysv/telinit.c: Move into the util directory; we're going
1169 to support limited SysV-a-like commands without full compatibility
1170 which is what we always did, and I'm not going to worry about adding
1171 others.
1172 * compat/sysv/man/reboot.8, compat/sysv/runlevel.8,
1173 * compat/sysv/man/shutdown.8, compat/sysv/telinit.8: Move as well.
1174 * compat/sysv/Makefile.am, util/Makefile.am: Merge.
1175 * configure.ac: Remove the (commented out) compat/sysv and logd
1176 Remove the --enable-compat option.
1177 * Makefile.am (SUBDIRS): Remove (commented out) compat/sysv and logd
1178
Scott James Remnant3e205a42008-06-08 02:13:33 +01001179 * logd/Makefile.am, logd/main.c, logd/man/logd.8, logd/jobs.d/logd.in:
1180 Consign logd to oblivion. We haven't supported it for ages, it has
1181 non-working issues, and there's got to be a better way to do this.
1182
Scott James Remnantd25ffae2008-06-08 02:12:10 +01001183 * TODO: Update.
1184
Scott James Remnantb3a1e7b2008-06-08 02:09:31 +01001185 * init/job.c (job_change_goal): Adjust the documentation. After
1186 careful thought, there's no way this can return after freeing the
1187 job, since it'll either block on an event, a process or do nothing.
1188
Scott James Remnant1d0a1e72008-06-08 02:05:49 +01001189 * init/job.c (job_start, job_stop, job_restart): Clear the start
1190 and stop environment, shouldn't necessarily make a difference, but
1191 it pays to be consistent.
1192
Scott James Remnant3fb48382008-06-08 02:03:40 +01001193 * dbus/com.ubuntu.Upstart.Job.xml (Start, Stop, Restart): Add methods
1194 to control jobs, all take an environment array and both Start and
1195 Restart return an instance path so properties, etc. can be obtained
1196 afterwards.
1197 * init/job_class.c (job_class_start, job_class_stop)
1198 (job_class_restart): Add the code for the top halves of the methods
1199 * init/job_class.h: Add prototypes for the new methods.
1200 * init/job.c (job_finished): And the bottom halves go here.
1201 * init/tests/test_job_class.c (test_start, test_stop)
1202 (test_restart): Add test cases for the methods.
1203 * init/blocked.h (blocked_type): Add enums for the new methods.
1204 * init/blocked.c (blocked_new): Handle the new methods here.
1205 * init/tests/test_blocked.c (test_new): Add add tests for handling.
1206
Scott James Remnantb7673b02008-06-07 01:28:39 +010012072008-06-07 Scott James Remnant <scott@netsplit.com>
1208
Scott James Remnanta4d83142008-06-07 22:59:56 +01001209 * init/job_process.c (job_process_terminated): Don't check the goal
1210 to see whether the main process was allowed to terminate, check the
1211 state. A termination is only not a failure if we're on the KILLED
1212 state (ie. we killed it), otherwise it can still be a failure even
1213 if it was going to stop anyway.
1214 * init/tests/test_job_process.c (test_handler): Add a test case.
1215
Scott James Remnante8762cb2008-06-07 21:11:20 +01001216 * init/control.c (control_emit_event): Use environ_all_valid here(),
1217 also reorder the blocking stuff to be less strange, it's ok to free
1218 environment.
1219 * init/tests/test_control.c (test_emit_event): The event array should
1220 be a child of message, which means it doesn't matter if the function
1221 we call frees it.
1222
Scott James Remnanta5e8e942008-06-07 21:06:56 +01001223 * init/environ.c (environ_all_valid): Add a validation function for
1224 external input.
1225 * init/environ.h: Add prototype.
1226 * init/tests/test_environ.c (test_all_valid): Test function.
1227
Scott James Remnant1a129922008-06-07 20:56:13 +01001228 * init/environ.c: Note that we can call this in a loop with OOM,
1229 since the resulting table will always be the same.
1230
Scott James Remnant44978b62008-06-07 20:54:49 +01001231 * init/event_operator.c (event_operator_environment): Use
1232 environ_append(), and while we're at it, there's no reason this should
1233 use NIH_MUST.
1234 * init/event_operator.h: Adjust prototype.
1235 * init/tests/test_event_operator.c (test_operator_environment): Allow
1236 for failure.
1237 * init/event.c (event_pending_handle_jobs): Call with NIH_MUST,
1238 which is actually safe.
1239
Scott James Remnanta175f3b2008-06-07 20:20:11 +01001240 * init/job_class.c (job_class_environment): Use environ_append()
1241
Scott James Remnant90b6f3f2008-06-07 20:17:29 +01001242 * init/environ.c (environ_append): There are multiple cases where we
1243 append one environment table onto another, so we should have a
1244 function to do that.
1245 * init/environ.h: Prototype for it.
1246 * init/tests/test_environ.c (test_append): Test the new function.
1247
Scott James Remnantfd364982008-06-07 03:40:29 +01001248 * init/job_process.c (job_process_run): Invert the logic; we nearly
1249 always want to pass the script with /dev/fd/NNN. The only times we
1250 don't are if it doesn't exist, or if we're dealing with a single-line
1251 shell script.
1252 * init/tests/test_job_process.c (test_run): Update test cases to
1253 only expect an argv-execution for single-line scripts.
1254
Scott James Remnant345fc022008-06-07 01:40:32 +01001255 * init/job.c (job_restart): Wrote the blocking bit slightly weirdly
1256 without neededing to, so leave it as it should be.
1257
Scott James Remnante22f7a22008-06-07 01:36:43 +01001258 * TODO: Update.
1259
Scott James Remnantb7673b02008-06-07 01:28:39 +01001260 * dbus/com.ubuntu.Upstart.Instance.xml (Start, Stop, Restart): Add
1261 simple instance control methods, these only change the goal of an
1262 existing instance - thus cannot pass environment.
1263 * init/job.c (job_start, job_stop, job_restart): Add methods, which
1264 look spookily similar to each other, except for the subtle yet
1265 important differences.
1266 (job_finished): Implement bottom halves.
1267 * init/job.h: Add prototypes.
1268 * init/tests/test_job.c (test_start, test_stop, test_restart): Add
1269 tests for the new methods.
1270 * init/blocked.h (blocked_type): Add enums for methods.
1271 * init/blocked.c (blocked_new): Handle methods here too
1272 * init/tests/test_blocked.c (test_new): Add tests for them.
1273
Scott James Remnantd0258e02008-06-06 02:09:38 +010012742008-06-06 Scott James Remnant <scott@netsplit.com>
1275
Scott James Remnant088f59a2008-06-06 23:00:35 +01001276 * init/blocked.h (blocked_type): Having a single message type won't
1277 work for the job cases, so expand to have many.
1278 * init/blocked.c (blocked_new): We'll just have to list them all here.
1279 * init/control.c (control_emit_event): Happily we create them
1280 individually anyway.
1281 * init/event.c (event_finished): And since we have to handle them
1282 individually, it'll actually protect us replying to the wrong one.
1283
Scott James Remnanta78145a2008-06-06 03:57:54 +01001284 * init/tests/test_conf.c (test_source_reload): Clean up the temporary
1285 directory.
1286 * init/tests/test_control.c (test_reload_configuration): That goes
1287 for this one too.
1288
Scott James Remnant6921caa2008-06-06 03:52:15 +01001289 * init/tests/test_control.c (my_connect_handler): Use TEST_DBUS_MESSAGE
1290 instead of a pop/read/write loop.
1291 (test_emit_event): Renamed TEST_DBUS_CONN to TEST_DBUS_OPEN.
1292 * init/tests/test_job.c (test_new, test_register)
1293 (test_change_state): Use TEST_DBUS_OPEN and TEST_DBUS_CLOSE to setup
1294 and tear down D-Bus connections and TEST_DBUS_MESSAGE instead of
1295 a loop.
1296 * init/tests/test_job_class.c (test_consider, test_reconsider)
1297 (test_register, test_unregister): Likewise.
1298
Scott James Remnantdf8435e2008-06-06 03:39:17 +01001299 * init/control.c (control_get_job_by_name): Sanity check the name
1300 of a job in the same way; we don't need to sanity check the instance
1301 name because "" is valid (and the default for singletons).
1302 * init/tests/test_control.c (test_get_job_by_name): Test.
1303
Scott James Remnantb36155b2008-06-06 03:34:16 +01001304 * dbus/com.ubuntu.Upstart.xml (EmitEvent): Add an asynchronous
1305 method to emit an event, providing the name and accompanying
1306 environment. No return value, it either works or you get an
1307 error.
1308 * init/control.c (control_emit_event): Implement top half of the
1309 method, blocking the message in the event.
1310 * init/control.h: Add prototype.
1311 * init/event.c (event_finished): Implement the bottom half which
1312 sends the reply or error, these are actually tested along with
1313 the top for sanity reasons.
1314 * init/tests/test_control.c (test_emit_event): Test the various
1315 ways the method may be used and abused; the async nature means
1316 we actually need a real D-Bus server to do this.
1317 * TODO: Update.
1318
Scott James Remnantd0258e02008-06-06 02:09:38 +01001319 * init/event.c (event_new): There's no reason this shouldn't be
1320 allowed to return insufficient memory, so do so.
1321 (event_finished): Wrap call.
1322 * init/tests/test_event.c (test_new): Add alloc failed test.
1323 * init/job.c (job_emit_event): Must create the event.
1324 * init/main.c (main, cad_handler, kbd_handler, pwr_handler): Wrap
1325 with NIH_MUST
1326
Scott James Remnant01735c02008-06-05 00:38:56 +010013272008-06-05 Scott James Remnant <scott@netsplit.com>
1328
Scott James Remnant02ee2002008-06-05 22:07:43 +01001329 * TODO: Update.
1330
Scott James Remnantad4afe22008-06-05 22:05:21 +01001331 * init/job.c (job_unblock): Rename to job_finished, since this
1332 does not behave like event_unblock but more like event_finished
1333 (job_change_state, job_failed): Change name in call.
1334 * init/job.h: Update prototype.
1335 * init/tests/test_job.c (test_unblock): Rename to test_finished
1336 * init/event.c (event_pending_handle_jobs): Update calls here.
1337
Scott James Remnant81e74e02008-06-05 22:00:56 +01001338 * init/job.h (Job): Rename blocked to blocker to match event, since
1339 it has the same use as event->blockers except it's a toggle
1340 * init/job.c (job_new, job_change_state): Rename where used
1341 * init/event.c (event_finished): Rename here also since its reset
1342 * init/tests/test_job.c, init/tests/test_job_process.c,
1343 * init/tests/test_event.c: Rename in test cases too.
1344
Scott James Remnant4ff5c7c2008-06-05 21:57:44 +01001345 * init/job.c (job_emit_event): Add a Blocked record to the event's
1346 blocking list for the starting and stopping events.
1347 * init/tests/test_job.c (test_emit_event): Add tests for the record
1348 being added to the list with the right details.
1349 (test_change_goal): Make sure that a Blocked record is added
1350 (test_change_state): Make sure that Blocked records are added
1351 * init/tests/test_job_process.c (test_handler): Also make sure
1352 that Blocked records are added.
1353
Scott James Remnant2ef01a92008-06-05 21:31:25 +01001354 * init/event.c (event_finished): Clear jobs referenced in the
1355 blocking list, rather than iterating the entire jobs hash.
1356 (event_finished_handle_jobs): Drop this function.
1357 * init/tests/test_event.c (test_finished, test_finished_handle_jobs):
1358 Merge tests again and test using both the blocking list and job's
1359 blocked member.
1360
Scott James Remnantdb7e92b2008-06-05 21:15:54 +01001361 * init/event.h (event): Add blocking member.
1362 * init/event.c (event_new): Initialising blocking list.
1363 * init/tests/test_event.c (test_new): Make sure it's initialised
1364 to an empty list.
1365
Scott James Remnant9e919ba2008-06-05 21:01:42 +01001366 * init/tests/test_job_process.c (test_handler): Update tests to use
1367 Blocked.
1368
Scott James Remnantea489282008-06-05 20:52:45 +01001369 * init/event.c (event_pending_handle_jobs): Collect environment
1370 and events independantly, which means we don't have to worry about
1371 the list contents or freeing them up in case of error.
1372 * init/event_operator.c (event_operator_events): Fix parent.
1373 * init/tests/test_event.c (test_pending_handle_jobs): Update tests.
1374 * init/init.supp: Update collect suppression.
1375
Scott James Remnant3aa31c82008-06-05 20:18:17 +01001376 * init/event_operator.c (event_operator_collect): Break in two.
1377 (event_operator_environment): Collect the environment from the event,
1378 appending the list of event names if necessary.
1379 (event_operator_events): Block events and pass them to the
1380 given list.
1381 * init/event_operator.h: Update prototypes.
1382 * init/tests/test_event_operator.c (test_operator_collect): Also
1383 split into two new functions
1384 (test_operator_environment, test_operator_events): Adjust
1385
Scott James Remnant56a1da62008-06-05 19:47:45 +01001386 * init/event_operator.c (event_operator_collect): Placed Blocked
1387 structures in the list, rather than ordinary entries; I strongly
1388 suspect that while it's nice to iterate the operator tree only once,
1389 this needs to be three functions really.
1390 * init/tests/test_event_operator.c (test_operator_collect): Update
1391 test suite.
1392
Scott James Remnantc33e1332008-06-05 19:33:17 +01001393 * init/job.h (Job): Make blocking a statically defined list.
1394 * init/job.c (job_new): Initialise rather than setting to NULL.
1395 (job_unblock): Assume that blocking members are Blocked structures
1396 and that the list itself is always iterable.
1397 * init/tests/test_job.c (test_new): Check the list is empty, rather
1398 than NULL.
1399 (test_change_state, test_failed, test_unblock): Change tests cases
1400 to expect blocking to always be present, and create members as Blocked
1401 structures.
1402
Scott James Remnantfa5ccfe2008-06-05 19:32:14 +01001403 * init/blocked.c (blocked_new): Set destructor (forgotten)
1404
Scott James Remnant5b2115f2008-06-05 19:31:58 +01001405 * init/init.supp: Add setenv, which has crept in
1406
Scott James Remnant0fb7dac2008-06-05 18:39:21 +01001407 * init/blocked.h: Header containing enum, struct and prototype.
1408 * init/blocked.c (blocked_new): Function to allocate the structure
1409 with the right details.
1410 * init/tests/test_blocked.c (test_new): Tests for the new function.
1411 * init/Makefile.am (init_SOURCES): Compile using blocked.c and header
1412 (TESTS): Build blocked test suite
1413 (test_process_LDADD, test_job_class_LDADD)
1414 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
1415 (test_event_operator_LDADD, test_parse_job_LDADD)
1416 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD):
1417 Link blocked.o to most test suites.
1418 (test_blocked_SOURCES, test_blocked_LDFLAGS, test_blocked_LDADD):
1419 Details for test suite.
1420
Scott James Remnantf3ef5112008-06-05 01:26:10 +01001421 * init/main.c: Also remove SIGTERM handling, we don't re-exec
1422 properly and this is a dangerous signal to use anyway.
1423 (term_handler): Drop function.
1424
Scott James Remnant6d271af2008-06-05 01:22:53 +01001425 * init/main.c: Remove handling for stop/cont; there's no reason
1426 a user should be able to pause the event queue.
1427 (stop_handler): Drop function.
1428 * init/event.c (event_poll): Remove paused handling.
1429
Scott James Remnant3d703792008-06-05 01:20:35 +01001430 * init/control.c: Fix doc string.
1431
Scott James Remnant8523ba72008-06-05 01:14:33 +01001432 * dbus/com.ubuntu.Upstart.xml (ReloadConfiguration): Add method
1433 that's effectively the same as the HUP signal.
1434 * init/control.c (control_reload_configuration): Unsurprisingly,
1435 the implementation is identical.
1436 * init/control.h: Add prototype.
1437 * init/tests/test_control.c (test_reload_configuration): Make sure
1438 the method works as expected.
1439 (test_get_job_by_name, test_get_all_jobs): Add missing free calls for
1440 message in cases of out of memory.
1441
Scott James Remnant01735c02008-06-05 00:38:56 +01001442 * dbus/com.ubuntu.Upstart.xml (JobAdded, JobRemoved): Add signals
1443 for when new jobs are added to the known list and when existing jobs
1444 are removed, this allows GUIs to always show an up-to-date list.
1445 * dbus/com.ubuntu.Upstart.Job.xml (InstanceAdded, InstanceRemoved):
1446 Also add matching signals for when instances are added to the list
1447 for a job and when they're removed again.
1448 * init/job_class.c (job_class_register): Emit the JobAdded signal
1449 for this job when registering if the new signal argument is TRUE;
1450 pass on the signal argument to job_register()
1451 (job_class_add): Emit signals when registering jobs with existing
1452 connections.
1453 (job_class_unregister): Emit signals when unregistering a job.
1454 * init/job.c (job_register): Likewise, emit the InstanceAdded signal
1455 for the job class if the new signal argument is TRUE.
1456 (job_new): Emit signals when registering instances with existing
1457 connections.
1458 (job_change_state): Emit the instance removed signal when destroying
1459 an inactive instance.
1460 * init/job_class.h, init/job.h: Add signal argument to prototypes
1461 * init/control.c (control_register_all): When registering job classes
1462 on a new connection, do not emit a signal since they will already
1463 exist at the point when the name appears on the bus or the connection
1464 is complete.
1465 * init/tests/test_control.c (test_bus_open): Add comment that we
1466 are testing for signal non-emission already with the fake server,
1467 since it was this test that actually made me realise we had to
1468 not emit them :p
1469 * init/tests/test_job_class.c (test_register): Test that the signal
1470 is emitted when signal is TRUE and not emitted when signal is FALSE
1471 (test_unregister): Test that the JobRemoved signal is emitted
1472 (test_get_instance_by_name, test_get_all_instances): Free message
1473 if allocation failed.
1474 (test_consider, test_reconsider): Test that the JobAdded and
1475 JobRemoved signals are emitted (or not) when appropriate.
1476 * init/tests/test_job.c (test_register): Make sure that the
1477 InstanceAdded signal is emitted when TRUE is passed, and not when
1478 FALSE is passed.
1479 (test_new): Make sure the InstanceAdded signal is emitted when the
1480 job is registered on the bus.
1481 (test_change_state): Make sure the InstanceRemoved signal is sent
1482 when deleting an instance.
1483
Scott James Remnantbd3504a2008-06-02 16:00:27 +010014842008-06-02 Scott James Remnant <scott@netsplit.com>
1485
Scott James Remnante49832c2008-06-02 16:12:22 +01001486 * init/tests/test_job.c (test_new, test_register): Also use a private
1487 dbus server to avoid session bus problems.
1488
Scott James Remnantf18c5ae2008-06-02 16:10:23 +01001489 * init/tests/test_job_class.c (test_consider, test_reconsider)
1490 (test_register, test_unregister): Use a private dbus server instead
1491 of connecting to the session bus, which might not be there.
1492
Scott James Remnant77446ca2008-06-02 16:05:28 +01001493 * init/tests/test_control.c (test_disconnected): Simplify using a
1494 private dbus server rather than faking one.
1495
Scott James Remnantbd3504a2008-06-02 16:00:27 +01001496 * init/tests/test_control.c (test_bus_close): Don't rely on being
1497 able to connect to the various buses, instead use a special private
1498 one.
1499
Scott James Remnant51980bc2008-06-01 19:22:11 +010015002008-06-01 Scott James Remnant <scott@netsplit.com>
1501
Scott James Remnant92f2cc42008-06-01 20:42:30 +01001502 * dbus/com.ubuntu.Upstart.Job.xml (GetAllInstances): And also add
1503 a similar method to return the object path of all instances of a
1504 particular job.
1505 * init/job_class.c (job_class_get_all_instances): Implement the
1506 method, pretty much the same as the other.
1507 * init/job_class.h: Add prototype.
1508 * init/control.c: Fix comment.
1509 * init/tests/test_control.c (test_get_all_jobs): Ensure that the
1510 individual paths are children of the array.
1511
Scott James Remnant30abe7c2008-06-01 20:31:09 +01001512 * dbus/com.ubuntu.Upstart.xml (GetAllJobs): Add method to return
1513 the object path of all known jobs.
1514 * init/control.c (control_get_all_jobs): Implement the method,
1515 somewhat simple happily.
1516 * init/control.h: Add prototype for the method.
1517 * init/tests/test_control.c (test_get_all_jobs): Test that the
1518 right data is returned.
1519
Scott James Remnante9876b72008-06-01 19:49:39 +01001520 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
1521 * dbus/com.ubuntu.Upstart.Instance.xml: Add libnih XML NS to the
1522 files so that we can tag methods as sync or async later.
1523
Scott James Remnant9c221382008-06-01 19:43:48 +01001524 * init/control.c (control_get_job_by_name): Remove const from
1525 return parameter.
1526 * init/control.h: Update prototype.
1527 * init/tests/test_control.c (test_get_job_by_name): Remove const
1528 from path type.
1529
Scott James Remnant8c69f7b2008-06-01 19:40:33 +01001530 * init/job_class.c (job_class_get_instance_by_name): Remove wrong
1531 const from parameter now that we've fixed the bindings generator.
1532 * init/job_class.h: Update prototype to match.
1533 * init/tests/test_job_class.c (test_get_instance_by_name): Change
1534 type of path to match.
1535
Scott James Remnant00c8b992008-06-01 19:27:04 +01001536 * HACKING (Dependencies): clarify that autoreconf and configure need
1537 to be run for libnih first.
1538
Scott James Remnant51980bc2008-06-01 19:22:11 +01001539 * init/Makefile.am (test_process_LDADD, test_job_class_LDADD)
1540 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
1541 (test_event_operator_LDADD, test_parse_job_LDADD)
1542 (test_parse_conf_LDADD, test_conf_LDADD, test_control_LDADD): Link
1543 the auto-generated D-Bus code in, otherwise the tests won't be
1544 complete.
1545
Scott James Remnant50677e02008-05-24 13:09:50 +020015462008-05-24 Scott James Remnant <scott@netsplit.com>
1547
1548 * HACKING: Changed branch location again, of both upstart and
1549 libnih.
1550
Scott James Remnant9a7282e2008-05-16 00:04:52 +020015512008-05-16 Scott James Remnant <scott@netsplit.com>
1552
1553 * init/job_class.c (job_class_consider, job_class_reconsider): Find
1554 the best class first and compare against the current class before
1555 acting, this avoids the re-register jump every time a job stops.
1556 (job_class_select): Rename to job_class_add() since this is takes
1557 a class and is the direct opposite to job_class_remove().
1558
Scott James Remnant88345b82008-05-15 23:58:05 +020015592008-05-15 Scott James Remnant <scott@netsplit.com>
1560
1561 * init/event.c (event_new): We can't rely on the event poll function
1562 being the last in the main loop, it's often the first, so after
1563 adding an event to the queue ensure the loop is iterated at least
1564 once so that the event poll occurs for it.
1565
Scott James Remnanta645a992008-05-09 00:15:49 +010015662008-05-09 Scott James Remnant <scott@netsplit.com>
1567
Scott James Remnant6308bb12008-05-09 03:05:47 +01001568 * TODO (Anytime): Update.
1569
Scott James Remnant54ef7512008-05-09 03:04:49 +01001570 * dbus/com.ubuntu.Upstart.Instance.xml: format to match others
1571
Scott James Remnantb0ce81e2008-05-09 03:04:29 +01001572 * dbus/com.ubuntu.Upstart.Job.xml (GetInstanceByName): Add method
1573 * init/job_class.c (job_class_get_instance_by_name): Implementation.
1574 * init/job_class.h: Add prototype.
1575 * init/tests/test_job_class.c (test_get_instance_by_name): Tests
1576 for new method.
1577
Scott James Remnant6fa0b492008-05-09 02:58:41 +01001578 * init/job_class.h (JobClass): Make instances a hash table.
1579 * init/job_class.c (job_class_new): Initialise instances as a hash
1580 table now.
1581 (job_class_register): Iterate instances as hash table.
1582 (job_class_remove): Slightly odd construct needed to return FALSE
1583 if there's anything in the hash table.
1584 (job_class_unregister): Likewise to assert on no instances.
1585 * init/tests/test_job_class.c (test_new): Check that instances is
1586 now a hash table.
1587 * init/job.h (Job): Make name the first member.
1588 * init/job.c (job_new): Add to instances as hash table.
1589 (job_instance): Drop entirely, replaced by a hash lookup.
1590 * init/tests/test_job.c (test_instance): Drop.
1591 * init/job_process.c (job_process_find): Iterate instances as a
1592 hash table.
1593 * init/event.c (event_pending_handle_jobs)
1594 (event_finished_handle_jobs): Iterate instances as hash table.
1595 (event_pending_handle_jobs): Replace job_instance call with an
1596 ordinary hash lookup.
1597 * init/tests/test_event.c: Update to use hash table.
1598 * init/tests/test_conf.c: Update instances stealing for hash table
1599
Scott James Remnant27d71f12008-05-09 02:35:26 +01001600 * init/job_class.c (job_class_new): initialise instance to the
1601 empty string.
1602 * init/tests/test_job_class.c: Update job_new() calls.
1603 (test_new): Check instance against the empty string.
1604 * init/job.c (job_new): name may no longer be NULL.
1605 * init/tests/test_job.c: Update job_new() calls.
1606 (test_instance): Reset back to "" when done.
1607 * init/event.c (event_pending_handle_jobs): Always expand the
1608 name, since the class->instance is always non-NULL.
1609 * init/tests/test_event.c: Update job_new calls.
1610 * init/tests/test_conf.c: Update job_new calls.
1611 * init/tests/test_job_process.c: Update job_new calls.
1612
Scott James Remnant07bdd4c2008-05-09 02:26:15 +01001613 * init/job.c (job_new): Singleton jobs have a fixed name of "",
1614 rather than a NULL name, and a D-Bus name of "_".
1615 (job_instance): Which rather simplifies this function (in fact,
1616 it makes this function look like a common one).
1617 (job_emit_event): Always set INSTANCE variable.
1618 (job_name): Still distinguish in output, to avoid ugly "()" but
1619 check character rather than NULL.
1620 * init/tests/test_job.c (test_new): Check name is set to ""
1621 and path to ".../_"
1622 (test_change_state, test_emit_event): Update test cases to assume
1623 an empty INSTANCE variable
1624 (test_instance): Update to pass "" instead of NULL.
1625 * init/job_process.c (job_process_run): Always set UPSTART_INSTANCE
1626 * init/tests/test_job_process.c (test_run): Always assume an
1627 UPSTART_INSTANCE variable, it may just be empty.
1628 * init/tests/test_event.c (test_pending_handle_jobs): Expect
1629 the name to be set to the empty string.
1630
Scott James Remnanta1fb6862008-05-09 00:30:14 +01001631 * init/Makefile.am (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
1632 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
1633 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
1634 Drop setting of data-type, turns out it doesn't work anyway.
1635
Scott James Remnant31253ca2008-05-09 00:19:07 +01001636 * dbus/Upstart.conf: Add configuration file.
1637 * dbus/Makefile.am (dbussystemdir, dist_dbussystem_DATA): Install
1638 the configuration file into the right place.
1639
Scott James Remnanta645a992008-05-09 00:15:49 +01001640 * dbus/com.ubuntu.Upstart.xml (GetJobByName): Add method
1641 * init/control.c (control_get_job_by_name): Implementation.
1642 * init/control.h: Prototype.
1643 * init/tests/test_control.c (test_get_job_by_name): Test the
1644 method using a fake message.
1645
Scott James Remnant327c7df2008-05-08 10:18:27 +010016462008-05-08 Scott James Remnant <scott@netsplit.com>
1647
Scott James Remnant8eb8dd22008-05-08 23:35:31 +01001648 * dbus/com.ubuntu.Upstart.xml, dbus/com.ubuntu.Upstart.Job.xml,
1649 * dbus/com.ubuntu.Upstart.Instance.xml: Add DTDs.
1650
Scott James Remnant8877f442008-05-08 23:30:40 +01001651 * init/control.c (manager_interfaces): Export the general
1652 com.ubuntu.Upstart interface
1653 * init/job_class.c (job_class_interfaces): Export the
1654 com.ubuntu.Upstart.Job interface
1655 * init/job.c (job_interfaces): Export the
1656 com.ubuntu.Upstart.Instance interface
1657
Scott James Remnante1640612008-05-08 23:27:51 +01001658 * init/Makefile.am (BUILT_SOURCES)
1659 (com.ubuntu.Upstart.c com.ubuntu.Upstart.h)
1660 (com.ubuntu.Upstart.Job.c com.ubuntu.Upstart.Job.h)
1661 (com.ubuntu.Upstart.Instance.c com.ubuntu.Upstart.Instance.h):
1662 Generate C code and header files from the XML files which produce
1663 object bindings.
1664 (init_SOURCES): Link the built sources.
1665 (CLEANFILES): Clean them up afterwards
1666
Scott James Remnant08169c12008-05-08 23:14:22 +01001667 * dbus/com.ubuntu.Upstart.xml: Initially empty description for
1668 manager object interface(s).
1669 * dbus/com.ubuntu.Upstart.Job.xml: Initially empty description
1670 for job class object interface(s).
1671 * dbus/com.ubuntu.Upstart.Instance.xml: Initially empty
1672 description for job instance object interface(s).
1673 * dbus/Makefile.am: Distribute the three interface files,
1674 they're used as sources elsewhere.
1675 * configure.ac (AC_CONFIG_FILES): Generate dbus/Makefile
1676 * Makefile.am (SUBDIRS): Descend into the dbus sub-directory.
1677
Scott James Remnant0464dc12008-05-08 19:21:54 +01001678 * init/job_class.c (job_class_consider, job_class_reconsider):
1679 Separate out the actual meat of the functions, since it's largely
1680 duplicated between the two. This makes the difference between
1681 the two functions clearer, consider always stages an election
1682 no matter which is registered, reconsider only stages an election
1683 if the current class is registered.
1684 (job_class_select, job_class_remove): Functions containing the
1685 common code, which now also handle registering and unregistering
1686 the class with D-Bus. Here is the right place, not in new, since
1687 we only export the current best class of a given name.
1688 (job_class_register, job_class_unregister): Function to register
1689 a job and its instances, and to unregister a job (we assert that
1690 there must be no instances for us to do this).
1691 * init/job_class.h: Add prototypes.
1692 * init/tests/test_job_class.c (test_consider, test_reconsider):
1693 Check that D-Bus registration and unregistration happens as
1694 expected.
1695 (test_register, test_unregister): test on their own.
1696 * init/job.c (job_new): Register instances with D-Bus, since
1697 instances can only ever exist for active classes, all instances
1698 are always registered on the bus.
1699 (job_register): Function to register an instance on the bus.
1700 * init/job.h: Add prototype.
1701 * init/tests/test_job.c (test_new): Test creating a job with an
1702 active d-bus connection, which should have it registered.
1703 (test_register): Test registration on its own.
1704 * init/control.c (control_register_all): Make this always succeed,
1705 and register existing jobs on the new connection.
1706 (control_server_connect, control_bus_open): registration is
1707 always successful.
1708 * init/tests/test_control.c (test_server_connect, test_bus_open):
1709 Test with existing jobs when we get a connection or create the
1710 bus connection, ensure that the jobs and instances are registered.
1711
Scott James Remnant327c7df2008-05-08 10:18:27 +01001712 * init/tests/test_job.c (test_change_state): Check for a bug where
1713 a job with multiple instances will be freed when one instance is
1714 deleted rather than the last instance.
1715 * init/job.c (job_change_state): Add debugging messages when we
1716 destroy a job that's no longer the current one or an instance
1717 that's no longer active; also ensure that we never destroy a job
1718 that's the current one.
1719 * init/event.c (event_pending_handle_jobs): Add a debugging message
1720 when we create a new instance of a job.
1721 * init/conf.c (conf_file_destroy): Add a debugging message when
1722 we destroy a job that's no longer the current one.
1723
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +010017242008-05-07 Scott James Remnant <scott@netsplit.com>
1725
Scott James Remnant1ba7f7a2008-05-07 23:52:11 +01001726 * init/control.c (control_server_open, control_server_close)
1727 (control_server_connect): Create and manage a listening d-bus server
1728 that is used for private direct connections to Upstart for when the
1729 d-bus daemon is not available. Each new connection has the same
1730 objects as the d-bus system bus, they only differ in their method.
1731 (control_conns, control_init): Cache the open connections, including
1732 the bus daemon and any private connections; we'll iterate this list
1733 when sending signals.
1734 (control_bus_open): Store connection in the list, don't worry about
1735 setting close-on-exec, we check that by test case and rely on d-bus
1736 to do it.
1737 (control_bus_disconnected): Rename to control_disconnected
1738 (control_disconnected): Work for system bus and private connections,
1739 remove from the connections list.
1740 * init/control.h: Add prototypes, remove global definition of bus
1741 name to just being private again.
1742 * init/tests/test_control.c (test_server_open, test_server_close)
1743 (test_server_connect): Test the new functions.
1744 (test_bus_open): add check for list entry
1745 (test_bus_disconnected): rename to test_disconnected
1746 * init/main.c: Open the listening server, warning if we're unable
1747 to do so (but we won't treat it as a hard error since there's the
1748 d-bus daemon as the default anyway).
1749 * init/init.supp: suppress the fact that the control connections
1750 list stays around.
1751
Scott James Remnant8e0fe4d2008-05-07 23:48:04 +01001752 * init/job_process.c (job_process_run): Use NIH_ZERO instead of
1753 NIH_MUST and == 0
1754
Scott James Remnant5635e072008-05-06 23:22:58 +010017552008-05-06 Scott James Remnant <scott@netsplit.com>
1756
Scott James Remnantd1799d22008-05-06 23:34:56 +01001757 * init/environ.c (environ_expand_until): Odd gcc optimiser warning,
1758 it reckons arg_start and end may be used uninitialised, but I don't
1759 see how they can be.
1760
Scott James Remnant5635e072008-05-06 23:22:58 +01001761 * init/main.c (main): Warn if we can't set the root directory.
1762 * init/job_process.c (job_process_spawn)
1763 (job_process_error_abort): loop on the return of write()
1764 * init/tests/test_job_process.c (child, main): assert getcwd() works
1765 (test_handler): initialise list and entry for gcc's blind spot.
1766 (test_run): initialise ret for gcc's blind spot
1767 * init/tests/test_job.c (test_name): jump through hoops for gcc
1768 (test_change_state): list and entry.
1769 * init/tests/test_event.c (test_finished_handle_jobs, test_finished)
1770 (test_pending_handle_jobs, test_poll, test_pending): initialise to
1771 NULL and buy gcc glasses
1772 * init/tests/test_event_operator.c (test_operator_collect): another
1773 NULL to make gcc happy.
1774
Scott James Remnant70a8c8a2008-05-01 01:06:22 +010017752008-05-01 Scott James Remnant <scott@netsplit.com>
1776
Scott James Remnant75f6fae2008-05-01 01:39:27 +01001777 * TODO: Update.
1778
Scott James Remnant8d68b132008-05-01 01:21:07 +01001779 * init/init.supp: Suppress a few test case artefacts caused by
1780 valgrind hating reachable memory at exec() time.
1781
Scott James Remnant41f44aa2008-05-01 01:20:33 +01001782 * init/tests/test_job_process.c: Fix a few cases where we were
1783 still dup'ing the name argument to job_new().
1784 * init/tests/test_parse_job.c: Include missing signal.h
1785
Scott James Remnant70a8c8a2008-05-01 01:06:22 +01001786 * init/event.c (event_pending_handle_jobs)
1787 (event_finished_handle_jobs): Land the old job event handling
1788 functions here as static functions, right now they're immense but
1789 we'll actually move much of the code back out again as we go.
1790 * init/tests/test_event.c (test_pending_handle_jobs)
1791 (test_finished_handle_jobs): Also land the test cases in renamed
1792 and somewhat restructued functions, since we now have to do the
1793 testing through event_poll().
1794 (test_poll, test_pending, test_finished): It never hurts to improve
1795 test cases while you're in there.
1796
Scott James Remnantb98ac992008-04-30 00:03:00 +010017972008-04-30 Scott James Remnant <scott@netsplit.com>
1798
Scott James Remnant63fd5c72008-04-30 21:34:31 +01001799 * init/job.c (job_change_state): Change calls to job_process_run
1800 and job_process_kill.
1801 * init/main.c: Change to job_process_handler
1802
Scott James Remnantf2d78e62008-04-30 21:33:38 +01001803 * init/job_process.c, init/job_process.h: Land the code from job.c
1804 and defs from job.h that deal specifically with a job's processes,
1805 rename the functions to job_process_*() in the process.
1806 * init/tests/test_job_process.c: And land the test cases as well.
1807
Scott James Remnanted255912008-04-30 21:09:48 +01001808 * init/job.c: Strip of everything not related to creation and finding
1809 of instances and the core state machine; process stuff will move to
1810 job_process.c and event handling to event.c, class (nee config) stuff
1811 is already moved to job_class.c
1812 (job_new): Don't reparent the name, it doesn't help anything, just
1813 take a copy.
1814 (job_name, job_failed, job_unblock, job_emit_event): Make extern since
1815 we need to use these outside or just want to test them.
1816 * init/job.h: Clean out also.
1817 * init/tests/test_job.c: Also clean out.
1818 (test_name, test_failed, test_unblock, test_emit_event): Add test cases
1819 for newly extern functions.
1820
Scott James Remnant5d82d902008-04-30 00:03:29 +01001821 * init/main.c: Include events.h to get the ones we need.
1822
Scott James Remnantb98ac992008-04-30 00:03:00 +01001823 * init/control.c (control_job_config_path, control_job_path)
1824 (control_path_append): Drop these functions (replaced by the more
1825 generic nih_dbus_path() function)
1826 * init/control.h: Make CONTROL_ROOT public, and drop other prototypes.
1827 * init/tests/test_control.c (test_job_config_path)
1828 (test_job_path): Drop tests.
1829
Scott James Remnant07336532008-04-29 19:45:51 +010018302008-04-29 Scott James Remnant <scott@netsplit.com>
1831
Scott James Remnante1725e82008-04-29 23:59:51 +01001832 * init/event.c, init/event.h, init/tests/test_event.c: Strip out the
1833 event operator code and events list.
1834
Scott James Remnant6f02f542008-04-29 23:59:12 +01001835 * init/job_class.c, init/job_class.h: We only need the event operator
1836 code here now.
1837
Scott James Remnantddbbaa62008-04-29 23:58:36 +01001838 * init/events.h, init/event_operator.c, init/event_operator.h,
1839 init/tests/test_event_operator.c: Separate out the event operator
1840 code and the list of events into separate source files.
1841 * init/Makefile.am (init_SOURCES): Build and link event operator code
1842 and use the lists of events.
1843 (TESTS): Build and run the event operator test suite.
1844 (test_event_operator_SOURCES, test_event_operator_LDFLAGS)
1845 (test_event_operator_LDADD): Details for the event operator test
1846 suite.
1847 (test_process_LDADD, test_job_class_LDADD)
1848 (test_job_process_LDADD, test_job_LDADD, test_event_LDADD)
1849 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
1850 (test_control_LDADD): Link the event operator code.
1851
Scott James Remnantf2f69d02008-04-29 23:38:23 +01001852 * init/job_class.c, init/main.c: Correct includes and some function
1853 names.
1854
Scott James Remnant9de968e2008-04-29 23:37:25 +01001855 * init/process.c, init/process.h, init/tests/test_process.c: Land
1856 original Process code (used by job class and similar).
1857
Scott James Remnant8092e792008-04-29 23:36:16 +01001858 * init/process.c, init/process.h, init/tests/test_process.c: Break
1859 into two pieces, one part becomes job_process which requires both
1860 job information and process information, the other becomes system
1861 which requires no job information.
1862 * init/errors.h: Update error name.
1863 * init/Makefile.am (init_SOURCES): Build and link job process code
1864 and header along with system code and header.
1865 (TESTS): Build and run job process and system test suites.
1866 (test_job_process_SOURCES, test_job_process_LDFLAGS)
1867 (test_job_process_LDADD): Details for job process test suite.
1868 (test_system_SOURCES, test_system_LDFLAGS, test_system_LDADD):
1869 Details for system test suite.
1870 (test_process_LDADD, test_job_class_LDADD, test_job_LDADD)
1871 (test_event_LDADD, test_parse_job_LDADD, test_parse_conf_LDADD)
1872 (test_conf_LDADD, test_control_LDADD): Link job process and system
1873 code.
1874
Scott James Remnant783a79d2008-04-29 20:00:52 +01001875 * init/parse_conf.c: Remove parse_job include.
1876
Scott James Remnantc2791dd2008-04-29 19:59:41 +01001877 * init/init.supp: Update leak check for class init; remove
1878 valgrind workaround since it's gone away with the change of that
1879 function.
1880
Scott James Remnant710c5152008-04-29 19:58:44 +01001881 * init/conf.h (ConfFile): Change type of job member, but leave name.
1882 Add prototype for new function.
1883 * init/conf.c (conf_reload_path): Somewhat simplify the case of
1884 having parsed a job, we only need to call job_class_consider() now
1885 to have it dealt with.
1886 (conf_file_destroy): Likewise after removing the ConfFile from the
1887 source (so it won't get considered) and marking the job class as
1888 deleted, we only need to call job_class_reconsider() and check the
1889 return value to see whether we've been replaced.
1890 (conf_select_job): In return we provide the function to decide which
1891 of the available job sources is the best one.
1892 * init/tests/test_conf.c: Update types in tests.
1893 (test_select_job): Test the new function.
1894
Scott James Remnant11168f32008-04-29 19:46:03 +01001895 * init/parse_job.h: Update to include job_class.h and update prototype
1896 to return JobClass, we'll keep the name though since we'll never
1897 parse jobs and otherwise things get annoying.
1898 * init/parse_job.c: Update to work on job classes.
1899 * init/tests/test_parse_job.c: Update to match.
1900
Scott James Remnant07336532008-04-29 19:45:51 +01001901 * init/job_class.h (JobClass): Factor out old JobConfig object into
1902 a new JobClass object with the same properties, but in its own source
1903 file.
1904 (ExpectType): Rename old JobExpect to this to match other enums.
1905 (ConsoleType): Move along with the object that uses it.
1906 * init/job_class.c (job_class_init, job_class_new)
1907 (job_class_environment): Bring along methods that only operate on
1908 a JobClass, cleaning them up in the process.
1909 (job_class_consider, job_class_reconsider): Replace job_config_replace
1910 with these two functions that may be used for a new job class and
1911 when discarding or finishing with an old one respectively.
1912 * init/tests/test_job_class.c: Tests for the functions.
1913 * init/Makefile.am (init_SOURCES): Build and link job class source
1914 and header.
1915 (TESTS): Build and run job class test suite.
1916 (test_job_class_SOURCES, test_job_class_LDFLAGS)
1917 (test_job_class_LDADD): Details for job class test suite.
1918 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
1919 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD)
1920 (test_control_LDADD): Link job class code to other tests too.
1921
Scott James Remnantf92d4832008-04-28 20:32:35 +010019222008-04-28 Scott James Remnant <scott@netsplit.com>
1923
Scott James Remnantbee70f52008-04-28 22:09:23 +01001924 * init/control.c (control_job_config_path, control_job_path): Add
1925 functions to generate D-Bus object paths for jobs and instances
1926 (control_path_append): and a static function used by both to append
1927 escaped path elements.
1928 * init/control.h: Add prototypes.
1929 * init/tests/test_control.c (test_job_config_path)
1930 (test_job_path): Add test cases for the new functions.
1931 * init/job.h (JobConfig, Job): Add path member to both structures.
1932 * init/job.c (job_config_new, job_new): Initialise the path members.
1933 * init/tests/test_job.c (test_config_new, test_new): Make sure
1934 the path members are initialised to something sensible.
1935 * init/init.supp: Valgrind whines, I do not know why.
1936
Scott James Remnantf92d4832008-04-28 20:32:35 +01001937 * init/control.c (control_bus_open): Call out to register objects
1938 on the new bus connection.
1939 (control_register_all): Start off by registering the connection
1940 manager object, no methods/signals for now.
1941 * init/tests/test_control.c (test_bus_open): Make sure the manager
1942 object is registered.
1943
Scott James Remnant00c71a02008-04-27 23:04:17 +010019442008-04-27 Scott James Remnant <scott@netsplit.com>
1945
Scott James Remnanta6cb3542008-04-27 23:10:55 +01001946 * init/tests/test_control.c (test_bus_open): Correct name of
1947 error macro.
1948
Scott James Remnant00c71a02008-04-27 23:04:17 +01001949 * init/job.c (job_emit_event): Make INSTANCE the second variable.
1950 * init/tests/test_job.c (test_next_state): Update tests.
1951
Scott James Remnant7fbefc12008-04-25 00:51:18 +010019522008-04-25 Scott James Remnant <scott@netsplit.com>
1953
1954 * init/tests/test_control.c (test_bus_open): Use D-bus macros for
1955 error strings instead of naming them by hand.
1956
Scott James Remnantaec48692008-04-22 07:44:48 +010019572008-04-22 Scott James Remnant <scott@netsplit.com>
1958
1959 * init/tests/test_control.c (test_bus_close): Add another missing
1960 call to dbus_shutdown.
1961
Scott James Remnant7e965822008-04-21 22:41:11 +010019622008-04-21 Scott James Remnant <scott@netsplit.com>
1963
1964 * init/tests/test_control.c (test_bus_open): Under valgrind we seem
1965 to get NoReply instead of Disconnected which is a wee bit odd.
1966 Add missing call
1967 (test_bus_disconnected): Add missing call to dbus_shutdown.
1968
Scott James Remnant30555d52008-04-19 11:52:04 +010019692008-04-19 Scott James Remnant <scott@netsplit.com>
1970
Scott James Remnantfbdd3cd2008-04-19 19:42:31 +01001971 * init/process.c: Add missing limits.h include
1972
Scott James Remnant15a1eea2008-04-19 16:47:32 +01001973 * init/job.h (JobConfig): Merge instance and instance_name; if
1974 instance is set, the job is multi-instance with the name derived
1975 from that; if unset the job is singleton. We will not support
1976 unlimited instances.
1977 * init/job.c (job_config_new): Initialise instance to NULL.
1978 (job_new): Assert that name is set for instance jobs.
1979 (job_instance): Alter to only deal with singleton and instance
1980 jobs, the unlimited instances case is gone.
1981 (job_handle_event): Use instance instead of instance_name
1982 * init/tests/test_job.c (test_config_new): Check instance is NULL
1983 (test_find_by_pid): Adjust the way instance jobs are made, which
1984 means we have to pass a name to job_config_new now.
1985 (test_instance): Adjust tests to remove unlmited-instance tests
1986 and pass name to job_config_new
1987 (test_change_state, test_run_process): Pass instance name to
1988 job_new as an allocated argument rather than waiting to set it
1989 until afterwards.
1990 (test_handle_event): Set instance instead of instance_name
1991 * init/parse_job.c (stanza_instance): Make the argument mandatory.
1992 * init/tests/test_parse_job.c (test_stanza_instance): Remove the
1993 checks for without argument, and make sure that without argument
1994 is an error.
1995
Scott James Remnantc75e8242008-04-19 13:01:43 +01001996 * init/parse_job.c (stanza_oom): Oops, forgot to free never arg.
1997
Scott James Remnant4e3365d2008-04-19 13:00:42 +01001998 * init/job.h (JobConfig): NihList is rather overkill for emits,
1999 which is static configuration; turn into a NULL-terminated array
2000 which'll make it easier to turn into a D-Bus property later.
2001 * init/job.c (job_config_new): Initialise to NULL now.
2002 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
2003 * init/parse_job.c (stanza_emits): Store in an array instead.
2004 * init/tests/test_parse_job.c (test_stanza_emits): Redo tests.
2005
Scott James Remnant264f7e92008-04-19 12:55:58 +01002006 * init/job.c (job_emit_event): Append exported variables to the
2007 job event without overwriting the builtins.
2008 * init/tests/test_job.c (test_change_state): Check that exported
2009 environment is added to the job events.
2010
Scott James Remnant4b7b9d72008-04-19 12:39:52 +01002011 * init/parse_job.c (stanza_export): Parse a new export stanza,
2012 which takes one or more environment variable names.
2013 * init/tests/test_parse_job.c (test_stanza_export): Test the new
2014 stanza.
2015
Scott James Remnant65da8662008-04-19 12:28:44 +01002016 * init/job.h (JobConfig): Add new export member.
2017 * init/job.c (job_config_new): Initialise to NULL.
2018 * init/tests/test_job.c (test_config_new): Make sure it's NULL.
2019
Scott James Remnantf2f53652008-04-19 12:15:47 +01002020 * init/environ.c (environ_add, environ_set): Add a replace argument
2021 which when FALSE does not replace existing entries in the environment
2022 table.
2023 * init/environ.h: Adjust prototypes.
2024 * init/tests/test_environ.c (test_add): Add tests for non-replacement
2025 mode, including corner cases.
2026 (test_set): Replace should be TRUE in this test.
2027 * init/event.c (event_operator_collect): Always replace existing
2028 environment members.
2029 * init/job.c (job_config_environment, job_run_process): Always replace
2030 existing environment members.
2031 (job_emit_event): Always replace existing environment members, and
2032 rework this function to get rid of the confusing gotos.
2033
Scott James Remnant30555d52008-04-19 11:52:04 +01002034 * init/tests/test_job.c (test_change_state): Add tests to make sure
2035 we include the INSTANCE variable in the event environment.
2036
Scott James Remnant9fab4e92008-04-18 13:19:06 +010020372008-04-18 Scott James Remnant <scott@netsplit.com>
2038
Scott James Remnantd8fe7022008-04-18 18:24:43 +01002039 * init/process.c (process_kill): Make sure we do send the signal to
2040 the process group; in practice this makes no difference, but it pays
2041 to be explicit in such things.
2042 * init/tests/test_process.c (test_kill): Add a test case for when
2043 the session leader is no more.
2044
Scott James Remnantac3d4ea2008-04-18 18:11:47 +01002045 * init/job.h (JobConfig): Another day, another obscure job config
2046 detail. This one is for adjusting how likely you are to be killed
2047 by the OOM Killer.
2048 * init/job.c (job_config_new): Set to zero by default.
2049 * init/tests/test_job.c (test_config_new): And make sure it is zero.
2050 * init/parse_job.c (stanza_oom): And it helps to have a function
2051 to set that one.
2052 * init/tests/test_parse_job.c (test_stanza_oom): Test it.
2053 * init/errors.h: And we need an error if its out of bounds.
2054 * init/conf.c (conf_reload_path): Which also needs to be caught.
2055 * init/process.c (process_spawn): Of course, we have to do something
2056 with the oom adjustment.
2057 (process_error_read): message for failure error.
2058 * init/process.h (processErrorType): And need an error if it fails
2059
Scott James Remnant7c1accf2008-04-18 13:32:01 +01002060 * init/main.c: Drop the legacy configuration directory, the format
2061 of jobs has changed sufficiently to not support it.
2062 * init/Makefile.am (AM_CPPFLAGS): Remove LEGACY_CONFDIR definition.
2063 (install-data-local): Don't create it, either.
2064
Scott James Remnantaaa59582008-04-18 13:30:05 +01002065 * init/enum.c, init/enum.h, init/tests/test_enum.c: Remove these
2066 source files, a hold-over from when we had them in a separate
2067 library and passed around the integer values.
2068 * init/job.c, init/job.h, init/tests/test_job.c: Restore in their
2069 proper place.
2070 * init/Makefile.am: Remove enum.* from build instructions.
2071
Scott James Remnantf8491442008-04-18 13:19:24 +01002072 * init/main.c: Attempt to connect to the system bus on startup,
2073 but don't expect it to work.
2074
Scott James Remnant9fab4e92008-04-18 13:19:06 +01002075 * init/control.c (control_bus_open, control_bus_disconnected)
2076 (control_bus_close): Functions to open a connection to the D-Bus
2077 system bus, clean up if disconnected or disconnect ourselves
2078 explicitly.
2079 * init/control.h: Prototypes.
2080 * init/tests/test_control.c (test_bus_open)
2081 (test_bus_disconnected, test_bus_close): Test the functions using
2082 a fake D-Bus system bus daemon.
2083 * init/errors.h: Add error for "name taken".
2084 * init/Makefile.am (init_SOURCES): Build and link control.c and
2085 control.h
2086 (TESTS): Build and run control test suite.
2087 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
2088 Details for control test suite.
2089 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2090 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
2091 Link control.o
2092
Scott James Remnantf8db5892008-04-16 14:39:59 +010020932008-04-16 Scott James Remnant <scott@netsplit.com>
2094
2095 * init/job.h (JobConfig): Add leader member.
2096 * init/job.c (job_config_new): Initialise leader to FALSE.
2097 * init/tests/test_job.c (test_config_new): Make sure leader is FALSE.
2098 (test_change_goal, test_change_state, test_run_process)
2099 (test_kill_process, test_child_handler, test_handle_event)
2100 (test_handle_event_finished): Jobs have to be leaders now to allow
2101 waitpid() to work in test cases.
2102 * init/parse_job.c (stanza_session): Parse "session leader" stanza
2103 to set to TRUE.
2104 * init/tests/test_parse_job.c (test_stanza_session): Test new
2105 stanza parsing.
2106 (test_stanza_console): Add missing "missing argument" test.
2107 * init/process.c (process_error_read): Deal with new fork error.
2108 (process_spawn): If we're not to be a session leader, fork again and
2109 write the pid back on the open socket.
2110 * init/process.h (ProcessErrorType): Introduce new fork error.
2111 * init/tests/test_process.c (test_spawn): Test that we can't start
2112 a non-session-leader and still have process details.
2113 (test_spawn, test_kill): Other jobs have to be leaders now to
2114 allow waitpid() to work.
2115 * init/tests/test_event.c (test_poll): Jobs have to be leaders now
2116 to allow waitpid() to work.
2117
Scott James Remnant048c79a2008-04-12 11:11:22 +010021182008-04-12 Scott James Remnant <scott@netsplit.com>
2119
Scott James Remnant477d9d42008-04-12 14:07:48 +01002120 * configure.ac (NIH_INIT): Require that libnih build D-Bus support,
2121 failing configure if we can't get it.
2122 * init/Makefile.am (AM_CFLAGS): Build with D-Bus CFLAGS,
2123 (init_LDADD, test_process_LDADD, test_job_LDADD, test_event_LDADD)
2124 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): and
2125 link with libnih-dbus.la and D-Bus LIBS.
2126 (init_LDFLAGS): No need for -static now since libnih will only exist
2127 statically anyway.
2128
Scott James Remnant2c0bd592008-04-12 12:31:49 +01002129 * init/main.c: Use a better name for kbdrequest
2130 * init/event.h (KBDREQUEST_EVENT): Rename event to keyboard-request
2131
Scott James Remnant4b56d6f2008-04-12 12:23:15 +01002132 * init/main.c: Drop the attempt to rescue a crashed system by
2133 carrying on with no state
2134 (crash_handler): After the child has core dumped, the parent will
2135 die and the kernel will panic. That's the best we can do, I think.
2136
Scott James Remnant6fd5acc2008-04-12 12:10:27 +01002137 * init/job.c (job_change_state): Don't generate the stalled event;
2138 there's nothing useful you can do with it other than start a root
2139 shell and that's just a security hole waiting to happen.
2140 (job_new): Don't increment the instances counter.
2141 * init/job.h: Remove extern for instances counter.
2142 * init/tests/test_job.c (test_new): Remove the check that the
2143 instance counter is incremented.
2144 (test_change_state): Remove the test for the stalled event.
2145 * init/event.h (STALLED): Remove stalled event definition,
2146 * TODO: Update.
2147
Scott James Remnant830370a2008-04-12 11:51:45 +01002148 * init/job.h (Job): And while we're at it, the instance name is
2149 guaranteed unique for a given job name, which is also guaranteed
2150 to be unique - so don't bother with job ids either, since they
2151 also get reused in bad cases.
2152 * init/job.c (job_next_id): Drop this function.
2153 (job_new): Don't assign an id anymore.
2154 (job_find_by_id): Drop this function.
2155 (job_run_process): Set UPSTART_INSTANCE to the instance name if set.
2156 (job_name): Function to create the string used in messages.
2157 (job_change_goal, job_change_state, job_run_process)
2158 (job_kill_process, job_kill_timer, job_child_handler)
2159 (job_process_terminated, job_process_trace_new)
2160 (job_process_trace_new_child, job_process_trace_signal)
2161 (job_process_trace_fork, job_process_trace_exec): Use the instance
2162 name in messages (if set) in place of the job id.
2163 * init/tests/test_job.c (test_new): Drop checks on the id field.
2164 (test_find_by_id): Drop test.
2165 (test_run_process): Check that UPSTART_INSTANCE is set only for
2166 named job instances, and contains the instance name.
2167 (test_change_state, test_run_process, test_child_handler): Remove
2168 id setting and update error message checks.
2169 * TODO: Update.
2170
Scott James Remnant048c79a2008-04-12 11:11:22 +01002171 * init/event.h (Event): We don't use the id field for anything;
2172 and it can't be guaranteed to be unique since it can wrap over
2173 and get reused. Drop it.
2174 * init/event.c (event_next_id): Drop this function.
2175 (event_new): Don't assign an id anymore.
2176 (event_find_by_id): Drop this function.
2177 * init/tests/test_event.c (test_new): Drop checks on the id field
2178 (test_find_by_id): Drop test.
2179 (test_poll): Drop id setting which was needless anyway.
2180
Scott James Remnant4dce7b32008-04-11 10:47:08 +010021812008-04-11 Scott James Remnant <scott@netsplit.com>
2182
Scott James Remnantf2874b82008-04-11 14:55:27 +01002183 * init/tests/test_job.c (test_child_handler): Add tests to make
2184 sure that respawn works for both services and tasks; the only
2185 difference we want for tasks is that zero is a normal exit code.
2186 * init/job.c (job_process_terminated): Status need not be non-zero
2187 if the job is not a task.
2188
Scott James Remnant2c1c57f2008-04-11 14:41:55 +01002189 Change the default job type from task to service, which will
2190 finally match people's expectations.
2191
2192 * init/job.h (JobConfig): Replace service member with task
2193 * init/job.c (job_config_new): Initialise task to FALSE
2194 (job_change_state): Unblock if not a task instead of if a service
2195 * init/tests/test_job.c (test_config_new): Make sure task is FALSE
2196 (test_change_state): Check service by default, task with flag;
2197 this also means we expect blockers to be cleared if we end up in
2198 running for the other checks
2199 (test_child_handler): Expect blockers to be cleared if we end up
2200 in running now that service is the default.
2201 * init/tests/test_event.c (test_poll): Test with a task since
2202 we want to remain blocked for longer.
2203 * init/parse_job.c (stanza_respawn): Don't set service to TRUE
2204 (stanza_service): Rename to stanza_task and set task flag instead
2205 * init/tests/test_parse_job.c (test_stanza_respawn): Remove checks
2206 for setting of service flag
2207 (test_stanza_service): Rename to test_stanza_task and test task
2208
Scott James Remnant4dce7b32008-04-11 10:47:08 +01002209 * init/job.c (job_init): Create hash using nih_hash_string_new()
2210 * init/conf.c (conf_source_new): Likewise.
2211
Scott James Remnantf8f19e92008-03-08 01:41:51 +000022122008-03-08 Scott James Remnant <scott@netsplit.com>
2213
Scott James Remnantb598eba2008-03-08 18:17:38 +00002214 * HACKING: Terminology changes: Bazaar-NG is now just Bazaar;
Scott James Remnantf6466b42008-04-11 10:38:04 +01002215 Malone is now just Launchpad's bug tracking system. Update bugs
Scott James Remnantb598eba2008-03-08 18:17:38 +00002216 URL to match modern form.
2217
Scott James Remnant76e3bc92008-03-08 16:12:12 +00002218 * init/enum.h (JobWaitType): Rename to JobExpect
2219 * init/job.h (JobConfig): Rename wait_for to expect
2220 * init/job.c (job_config_new, job_change_state, job_run_process)
2221 (job_process_stopped, job_process_trace_new_child): Rename wait_for
2222 to expect in all occurances.
2223 * init/tests/test_job.c: Likewise rename all occurances.
2224 * init/parse_job.c (stanza_wait): Rename to stanza_expect and drop
2225 the intermediate argument.
2226 * init/tests/test_parse_job.c (test_stanza_wait): Rename to
2227 test_stanza_expect and adjust tests to match new syntax.
2228 * init/tests/test_process.c (test_spawn): Remove set of wait_for.
2229
Scott James Remnantda695302008-03-08 01:50:56 +00002230 * doc/states.dot: Remove the state transition from starting to
2231 waiting ("emit_stopped" in the graph); we don't have a "respawning
2232 too fast" exit here anymore, so always go to stopping.
2233 * doc/states.png: Regenerate.
2234
Scott James Remnantf8f19e92008-03-08 01:41:51 +00002235 * TODO: Document the problems with overflowing ids and instance
2236 counter before I forget about them.
2237
Scott James Remnant7b6c16c2008-03-07 15:16:29 +000022382008-03-07 Scott James Remnant <scott@netsplit.com>
2239
Scott James Remnantd62ef892008-03-07 23:20:50 +00002240 * TODO: Update.
2241
Scott James Remnantdebbdc92008-03-07 23:20:34 +00002242 * init/job.h (JobConfig): Add instance_name member.
2243 (Job): Add name member.
2244 * init/job.c (job_config_new): Initialise instance name to NULL.
2245 (job_new): Accept the name as an argument, reparenting and stealing
2246 (job_handle_event): Expand the instance name and pass to job_new
2247 (job_instance): Accept a name and look that up in the list of current
2248 instances returning the instance if found.
2249 * init/tests/test_job.c: Add extra argument to all job_new calls
2250 (test_config_new): Make sure instance name is initialised to NULL.
2251 (test_handle_event): Make sure the job name is set from the instance,
2252 and make sure an existing instance is reused if we can.
2253 (test_instance): Make sure that the existing instance is returned.
2254 * init/parse_job.c (stanza_instance): Check for an optional argument
2255 and store it in the instance_name member if it exists, otherwise
2256 free and reset the instance_name member.
2257 * init/tests/test_parse_job.c (test_stanza_instance): Check the new
2258 argument is handled properly and stored in the right place.
2259 * init/tests/test_conf.c (test_source_reload_job_dir)
2260 (test_file_destroy): Add extra NULL to job_new
2261 * init/tests/test_event.c (test_poll): Add extra NULL to job_new
2262
Scott James Remnant6f857582008-03-07 21:32:53 +00002263 * init/event.c (event_operator_match): Accept an environment array
2264 and expand the operator value against it before attempting to match.
2265 (event_operator_handle): Also accept the environment array and pass
2266 through to calls to event_operator_match().
2267 * init/event.h: Update prototypes.
2268 * init/tests/test_event.c (test_operator_match): Add extra NULL
2269 argument to most tests, and add tests for known and unknown variable
2270 references.
2271 (test_operator_handle): Add extra NULL arguments to most tests, and
2272 add test for passing of environment through.
2273 (test_operator_reset): Add extra NULL argument to call.
2274 * init/job.c (job_handle_event): Pass the job environment for the
2275 stop event handling, but NULL for the start event.
2276 * init/tests/test_job.c (test_handle_event): Make sure that a stop
2277 operator is expanded from the job environment before being matched
2278 against the stop event.
2279
Scott James Remnant7d4ffbb2008-03-07 20:56:15 +00002280 * init/event.c, init/event.h, init/environ.c: Documentation tweaks.
2281
Scott James Remnantb605dfc2008-03-07 19:24:52 +00002282 * init/job.c (job_change_state): Remove the code to check for runaway
2283 jobs from here, we'll always let people explicitly start an instance.
2284 (job_process_terminated): Call job_catch_runaway when actually doing
2285 the respawn instead.
2286 * init/tests/test_job.c (test_change_state): Remove "too fast" checks,
2287 we're going to allow start/stop requests to restart jobs as much as
2288 they like since this is an external request.
2289 (test_handle_event, test_handle_event_finished): No need to remove
2290 a respawn limit with this behaviour.
2291 (test_child_handler): Instead check that the respawn counter is
2292 dealt with by the child handler.
2293
Scott James Remnant67e86ff2008-03-07 18:38:12 +00002294 * TODO: Update, I found a bug with the current model.
2295
Scott James Remnant7b6c16c2008-03-07 15:16:29 +00002296 * init/tests/test_environ.c (test_expand): Check that a string
2297 without an expansion still works ok.
2298
Scott James Remnant46ba8e92008-03-06 20:24:08 +000022992008-03-06 Scott James Remnant <scott@netsplit.com>
2300
2301 * init/event.c (event_operator_collect): Just use strcat functions.
2302
Scott James Remnanta8430552008-03-03 00:28:51 +000023032008-03-03 Scott James Remnant <scott@netsplit.com>
2304
Scott James Remnant7d2c9fb2008-03-03 17:29:13 +00002305 * init/environ.c (environ_valid): New function to check the validity
2306 of an environment variable name, should call before accepting any.
2307 (environ_expand_until): New function to expand variable references
2308 in a string using an environment table; supports a few common
2309 shell-like expressions.
2310 (environ_getn): Change to return the value of the string, not the
2311 entire environment string.
2312 * init/environ.h: Add prototypes.
2313 * init/errors.h: Add errors raised by new functions.
2314 * init/tests/test_environ.c (test_valid, test_expand): Add test
2315 cases for the new functions.
2316 (test_get, test_getn): Change test case to check for the variable
2317 value instead of returning the whole string.
2318
Scott James Remnant2c342d92008-03-03 10:52:29 +00002319 * TODO: Add thoughts on blocking commands.
2320
Scott James Remnant62f2d862008-03-03 02:13:19 +00002321 * TODO: Update.
2322
Scott James Remnant089298d2008-03-03 01:48:34 +00002323 * init/event.h (Event): Remove the refs member; we now never hold
2324 a reference to an event we're blocking since we always copy the
2325 environment out if we want to keep it.
2326 (EventOperator): Events are always blocked while we hold them,
2327 so drop the blocked member.
2328 (EventProgress): The done state is no longer needed, we can free
2329 in finished now.
2330 * init/event.c (event_ref, event_unref): Drop these functions.
2331 (event_new): Don't ininitialise the refs member since it's gone.
2332 (event_poll): Remove the done state since it's directly freed
2333 in event_finished again
2334 (event_finished): No done state, event is freed before return.
2335 (event_operator_new): No blocked member.
2336 (event_operator_copy): Always block the event after copying.
2337 (event_operator_destroy): Simply unblock.
2338 (event_operator_handle): Simply block the event on match.
2339 (event_operator_collect): Always block the copied event
2340 (event_operator_unblock): This function is no longer required, since
2341 it has an identical effect to reset.
2342 (event_operator_reset): Simply unblock the event.
2343 * init/tests/test_event.c (test_new): Drop the check for refs
2344 being initialised to zero.
2345 (test_ref, test_unref, test_operator_collect): Drop test for
2346 functions that have been dropped in the code.
2347 (test_operator_new): Drop the check for blocked being initialised
2348 to FALSE.
2349 (test_block, test_unblock, test_operator_destroy): Drop any references
2350 to the refs member.
2351 (test_operator_destroy): Actually fix the function to test things.
2352 (test_poll): Drop the check for remaining in the done state.
2353 (test_operator_new, test_operator_copy): Drop the checks for blocked.
2354 (test_operator_handle, test_operator_collect, test_opreator_reset):
2355 Drop references to refs and blocked.
2356 * init/job.c (job_unblock, job_handle_event): Drop the call to
2357 event_unref() since the next call was always event_unblock() and
2358 that's the one that we didn't delete.
2359 * init/tests/test_job.c (test_change_state, test_child_handler)
2360 (test_handle_event, test_handle_event_finished): Events don't
2361 have references anymore, so remove calls to reference, unreference
2362 and checks for the reference count - it's all done with blocks now.
2363 (test_new): Remove check that the operator is not blocked for a
2364 new job since there's no such thing now.
2365 (test_handle_event): Operators don't have a blocked member anymore,
2366 if there's an event, it's blocked.
2367
Scott James Remnant00ad0002008-03-03 01:15:39 +00002368 * init/job.c (job_change_state): Don't reference the event we're
2369 blocked on, we'll always know when it's finished.
2370 (job_handle_event_finished): Likewise no reason to unreference it.
2371 * init/tests/test_job.c (test_change_goal, test_child_handler)
2372 (test_handle_event, test_change_state)
2373 (test_handle_event_finished): Remove the expectation that the blocked
2374 event is referenced by the job.
2375 * init/tests/test_event.c (test_poll): Don't reference the event,
2376 since the job would not have.
2377
Scott James Remnant66fe4e22008-03-03 01:07:16 +00002378 * init/job.c (job_emit_event): Use environ_add/set for style
2379 reasons.
2380
Scott James Remnantd719fdc2008-03-03 00:52:52 +00002381 * init/job.c (job_handle_event): Reset the stop_on operator after
2382 processing the event, thus the expression needs to be completely
2383 reevaluated before the job can be stopped again by it. At last,
2384 correct behaviour!
2385 (job_change_state): No reason to reset the stop_on operator when
2386 starting since it's always reset after evaluating to TRUE now;
2387 likewise no reason to reset on re-entering running or waiting,
2388 job_unblock() is sufficient.
2389 (job_failed): No reason to iterate stop_on to set failed, it's
2390 empty - job_unblock() does what we want.
2391 * init/tests/test_job.c (test_handle_event): Check that the operator
2392 is actually reset and the event not referenced when handling from
2393 the event.
2394 (test_change_state, test_child_handler): Don't put anything in stop_on
2395 and thus don't expect anything to come out of it -- event environment
2396 is all done in stop_env and blocking done in blocking.
2397
Scott James Remnanta8430552008-03-03 00:28:51 +00002398 * init/job.c (job_handle_event): Collect the stop events and store
2399 them in the blocking list, unblocking any that were there before
2400 such as the start events.
2401 (job_change_state): Unblock blocking events when returning to running
2402 from pre-stop.
2403 * init/tests/test_job.c (test_handle_event): Make sure the stop
2404 events are collected and replace any previously blocking events.
2405 (test_change_state, test_child_handler): Test that stop events in
2406 the blocking list are kept and unblocked when necessary.
2407
Scott James Remnante4be2c52008-03-02 00:05:47 +000024082008-03-02 Scott James Remnant <scott@netsplit.com>
2409
Scott James Remnant8e402682008-03-02 23:45:31 +00002410 * init/job.c (job_change_state): Shouldn't emit the started event
2411 on pre-stop cancellation, and shouldn't unblock the job because
2412 it's a service.
Scott James Remnanta8430552008-03-03 00:28:51 +00002413
Scott James Remnant56ec5602008-03-02 22:42:21 +00002414 * init/job.c (job_change_state): Throw away the stop environment
2415 when starting and returning to running.
2416 * init/tests/test_job.c (test_change_state): Make sure the stop
2417 environment is actually thrown away.
2418
Scott James Remnant3a06f5c2008-03-02 22:30:17 +00002419 * init/job.c (job_run_process): Append the environment from the
2420 stop events if given the pre-stop process to run; do this before
2421 the special events so they can never be overriden.
2422 * init/tests/test_job.c (test_run_process): Check that the stop event
2423 environment is included for pre-stop and not for other jobs.
2424
Scott James Remnant562a4f12008-03-02 22:20:27 +00002425 * init/job.c (job_handle_event): Remove setting of UPSTART_JOB
2426 and UPSTART_JOB_ID, we set that when we run the process.
2427 * init/tests/test_job.c (test_handle_event): Don't check for
2428 UPSTART_JOB and UPSTART_JOB_ID since we no longer copy it in here.
2429
Scott James Remnant99c6e4a2008-03-02 22:18:14 +00002430 * init/job.c (job_run_process): Copy the environment to pass it to
2431 the job, appending the UPSTART_JOB and UPSTART_JOB_ID variables here;
2432 we never want to be able to match these, etc.
2433 * init/tests/test_job.c (test_run_process): Add tests to make sure
2434 that the environment is actually set in the processes we run.
2435
Scott James Remnant96986832008-03-02 21:52:50 +00002436 * init/job.h (Job): Add stop_env member to store environment from
2437 stop events for the stop script.
2438 * init/job.c (job_new): Initialise stop_env to NULL.
2439 (job_handle_event): Copy environment from the stop_on operator into
2440 the stop_env member.
2441 * init/tests/test_job.c (test_new): Check that stop_env is NULL.
2442 (test_handle_event): Add lots of tests to make sure that the
2443 environment is collected from the events and stored in stop_env
2444 properly, overwriting what was there already if necessary.
2445
Scott James Remnantf1755ad2008-03-02 20:42:00 +00002446 * init/init.supp (job-run-process-args): Add a suppression for the
2447 fact that job_run_process will leak its arguments to a new process
2448 assuming that it will call exec() or exit()
2449
Scott James Remnant5f68a522008-03-02 20:41:19 +00002450 * init/tests/test_job.c (test_child_handler): Remove bogus free tag
2451 of the list, which we don't use in this test (valgrind failure)
2452
Scott James Remnantdd6e9422008-03-02 20:40:45 +00002453 * init/job.h (Job): Remove the start_on member.
2454 * init/job.c (job_new): Don't initialise start_on since it's gone.
2455 (job_change_state): Drop call to unblock the start_on operator since
2456 the events are already unblocked by job_unblock.
2457 (job_failed): Drop setting of start_on events to failed since this
2458 is already done by job_unblock. This results in a slight change in
2459 behaviour, now when a job fails to start - the event or command will
2460 be immediately unblocked since there's no point waiting until it
2461 stops again - it was waiting for it to start.
2462 * init/tests/test_job.c (test_new): Remove start_on checks
2463 (test_change_state, test_child_handler, test_handle_event): Remove
2464 all references to start_on, instead relying on the blocking checks
2465 instead.
2466 * init/tests/test_event.c (test_poll): Remove solitary reference
2467 to job's start_on, this wasn't necessary anyway - we proved that it
2468 was the right event by affecting the job. Revert previous commit
2469 that temporarily increased the number of references, they should be
2470 one again now only the blocking list holds them.
2471
Scott James Remnant37305082008-03-02 20:08:07 +00002472 * init/job.h (job): Add blocking member, a list of events that we're
2473 blocking from finishing.
2474 * init/job.c (job_new): Initialise blocking member to NULL.
2475 (job_handle_event): Collect the list of events from the operator
2476 and store them in the job's blocking list (unblocking any existing
2477 first); if the job is already running, unblock unref and discard.
2478 (job_unblock): New function to deal with unblocking the events we're
2479 holding onto and resetting the blocking list; this will be extended
2480 later to also unblock any command.
2481 (job_change_state): Unblock events in running for services and in
2482 waiting for everything.
2483 (job_failed): Unblock events and mark them as failed.
2484 * init/tests/test_job.c (test_new): Check that it's initialised to NULL
2485 (test_handle_event): Extend the test cases to check the value of the
2486 blocking list, and to make sure that the previous blocking list is
2487 overwritten when necessary.
2488 (test_change_state, test_child_handler): Extend test cases so that
2489 wherever we're had a blocked event in start_on, we also have that in
2490 the blocking list.
2491 * init/tests/test_event.c (test_poll): Temporarily increase the
2492 expected number of references/blockers to the event in the poll
2493 test.
2494
Scott James Remnanteec6b102008-03-02 12:24:22 +00002495 * init/job.h (Job): Add start_env member, this stores the environment
2496 to use when starting the event so it doesn't overwrite the current
2497 environment of a restarting job.
2498 * init/job.c (job_handle_event): Do the heavy lifting of starting a
2499 new job instance here; construct the environment from the built-ins
2500 and configured, append that collected from the start events, locate
2501 or create a new instance, add the job name and id then copy into
2502 the new start_env member before starting the job. At some point
2503 this will probably all become a function since it'll be similar for
2504 the control functions.
2505 (job_change_state): Copy the start_env member into the env member
2506 when in the starting state; thus the job environment remains the same
2507 until restarted.
2508 (job_new): Remove code to initialise the environment, we now do that
2509 when actually starting the instance.
2510 * init/tests/test_job.c (test_handle_event): Add test cases for
2511 starting the job, making sure that the environment is correctly
2512 copied into the right field and also checking what happens if it's
2513 already stopping or running.
2514 (test_change_state): Make sure that start_env is correctly copied
2515 over into env, overwriting what is there if non-NULL or keeping it
2516 if NULL.
2517 (test_new): Remove checks for environment setup, since we don't do
2518 that anymore here; replace with checking for NULL and restore the
2519 alloc fail tests.
2520 * TODO: Update.
2521
Scott James Remnant377f6162008-03-02 02:23:52 +00002522 * init/environ.c (environ_add): Allow it to accept NULL length, since
2523 we can't always keep that around.
2524
Scott James Remnantf83e4cf2008-03-02 01:33:06 +00002525 * init/process.c (process_spawn): Accept the environment list as
2526 a parameter, then finally we can change this function to take a
2527 JobConfig as the first argument.
2528 (process_error_read): Remove the associated error handler.
2529 * init/process.h: Change prototype.
2530 (ProcessErrorType): Remove error enum for environment.
2531 * init/tests/test_process.c (test_spawn): Update calls in test to
2532 just pass in an environment array (direct testing).
2533 * init/job.c (job_run_process): Pass configuration and environment
2534 to process_spawn.
2535
Scott James Remnantaf44bfe2008-03-02 01:22:29 +00002536 * init/process.c (process_spawn): Take the environment directly out
2537 the job structure, rather than recreating it.
2538 (process_environment): Drop function, absorbed elsewhere.
2539 * init/process.h: Remove prototype.
2540 * init/tests/test_process.c (test_spawn): Set the job_id variable
2541 before calling job_new and set config->start_on instead of
2542 job->start_on so that job_new can pick up both.
2543 (test_environment): Remove test cases.
2544
Scott James Remnant01c0ba72008-03-02 01:16:10 +00002545 * init/job.h (Job): finally gains env pointer of its own.
2546 * init/job.c (job_new): Initialise the environment, moving the last
2547 of the code from process_environment -- this is only temporary
2548 though in the interests of refactoring, it'll move out of here again
2549 soon enough.
2550 * init/tests/test_job.c (test_new): Make sure that the environment is
2551 set in a manner which tests the overriding of things by other things;
2552 we have to temporarily comment out the alloc fail stuff though :-(
2553
Scott James Remnant61b11fc2008-03-02 01:16:03 +00002554 * init/event.c (event_operator_collect): Make list the last argument
2555 for consistency with future functions.
2556 * init/event.h: Update prototype.
2557 * init/tests/test_event.c (test_operator_collect): Swap arguments.
2558 * init/process.c (process_environment): Update.
2559
Scott James Remnanta6ce1292008-03-02 00:24:08 +00002560 * init/job.c (job_config_environment): Function to generate an
2561 environment table from a JobConfig, code largely moved from process.c
2562 * init/job.h: Add protoyype.
2563 (JOB_DEFAULT_ENVIRONMENT): List of environment variables to always
2564 copy from the environment (moved from process.h)
2565 * init/tests/test_job.c (test_config_environment): Add test case,
2566 again largely copied from test_process.c
2567 * init/process.c (process_environment): Call job_config_environment
2568 instead of the code moved out.
2569 * init/process.h (PROCESS_ENVIRONMENT): Move to job.h
2570 * TODO: Update.
2571
Scott James Remnante4be2c52008-03-02 00:05:47 +00002572 * TODO: Update.
2573
Scott James Remnantec8ea0e2008-03-01 17:58:15 +000025742008-03-01 Scott James Remnant <scott@netsplit.com>
2575
Scott James Remnant9fd25422008-03-01 23:56:31 +00002576 * init/event.c (event_operator_collect): Create a mega-function to
2577 iterate an EventOperator tree (filtering out those bits that aren't
2578 TRUE) and collect the events, adding them to a linked list, adding
2579 their environment to a table and making a string list for another
2580 environment variable. Fundamentally this function marshals data
2581 out of the Event subsystem into the right format for the Job subsystem.
2582 * init/event.h: Add prototype.
2583 * init/tests/test_event.c (test_operator_collect): Tests for the
2584 collector function; some bits may seem similar to test_process.c
2585 * init/process.c (process_environment): Use event_operator_collect
2586 to gather the environment, instead of its own code (which pretty
2587 much got pasted into event_operator_collect anyway). Force everything
2588 else to allocate matching the caller.
2589 * init/tests/test_process.c (test_spawn, test_environment): Had
2590 forgotten to set the value of the intermediate AND operator to TRUE,
2591 necessary now.
2592
Scott James Remnant8e695502008-03-01 21:34:12 +00002593 * init/process.c (process_environment_add): Move and rename this
2594 function, since it's not really process associated
2595 (process_environment): Change to use environ_add or environ_setf
2596 instead.
2597 * init/process.h: Remove prototype.
2598 * init/environ.c (environ_add): New name/location of
2599 process_environment_add, modified to not take a copy of the string
2600 (environ_set): Wrapper for the above for common dealing with
2601 environment we want to set from a format string.
2602 (environ_get, environ_getn, environ_lookup): Functions to get an
2603 environment variable entry; largely cripped from event.c but
2604 bug-fixed at the same time.
2605 * init/environ.h: Function prototypes.
2606 * init/event.c (event_operator_match): Change to use environ_lookup
2607 * init/tests/test_process.c (test_environment_add): Move the tests.
2608 * init/tests/test_environ.c: Test suite for environment handling
2609 * init/Makefile.am (init_SOURCES): Build environ.c and environ.h
2610 (TESTS): Build environment test suite
2611 (test_environ_SOURCES, test_environ_LDFLAGS, test_environ_LDADD):
2612 Details for environment test suite
2613 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
2614 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD):
2615 Link environ.o to other test suites
2616
Scott James Remnantec8ea0e2008-03-01 17:58:15 +00002617 * init/job.c (job_new): Increment the number of instances.
2618 (job_instance): Simplify the function, it now only returns the
2619 existing instance or NULL. This makes it easier to extend when
2620 we have env-limited instances later on.
2621 (job_handle_event): If job_instance returns NULL, create
2622 a new instance with job_new() and always reset the operator afterwards.
2623 * init/tests/test_job.c (test_new): Check that the instances variable
2624 is incremented when a new job is created.
2625 (test_instance): Change to check that it returns NULL when there is
2626 no active instance, or for multi-instance jobs, instead of creating
2627 a new one itself.
2628 (test_config_replace, test_find_by_pid)
2629 (test_find_by_id, test_change_goal, test_change_state)
2630 (test_next_state, test_run_process, test_kill_process)
2631 (test_child_handler, test_handle_event)
2632 (test_handle_event_finished): Call job_new to create a new instance
2633 from a config, instead of job_instance.
2634
2635 * init/tests/test_conf.c (test_source_reload_job_dir)
2636 (test_file_destroy): Call job_new to create a new instance from a
2637 config, instead of job_instance.
2638 * init/tests/test_event.c (test_poll): Call job_new to create a new
2639 instance from a config, instead of job_instance.
2640 * init/tests/test_process.c (test_spawn, test_environment): Call
2641 job_new to create a new instance from a config, instead of job_instance
2642
Scott James Remnant9f468de2008-02-29 16:17:17 +000026432008-02-29 Scott James Remnant <scott@netsplit.com>
2644
Scott James Remnant680d2fd2008-02-29 17:41:38 +00002645 * configure.ac: Compare the evaluated $sbindir against the common
2646 things we put in PATH, if it doesn't match, define EXTRA_PATH to
2647 contain it.
2648 * init/paths.h: Append EXTRA_PATH to PATH if defined.
2649
Scott James Remnant9f468de2008-02-29 16:17:17 +00002650 * init/Makefile.am (AM_CPPFLAGS): Replace TELINIT definition with
2651 SBINDIR, pointing at the common directory.
2652 * compat/sysv/Makefile.am (AM_CPPFLAGS): Replace SHUTDOWN definition
2653 with SBINDIR, pointing at the common directory.
2654 * init/paths.h (TELINIT): Redefine to be SBINDIR with "/telinit"
2655 on the end; define SBINDIR if necessary.
2656 * compat/sysv/reboot.c (SHUTDOWN): Redefine to be SBINDIR with
2657 "/shutdown" on the end; define SBINDIR if necessary.
2658
Scott James Remnantc3c78b02008-02-22 14:55:12 +000026592008-02-22 Scott James Remnant <scott@netsplit.com>
2660
Scott James Remnant72da2fe2008-02-22 20:10:53 +00002661 * init/event.c (event_operator_match): Rewrite to match both
2662 positionally and by name.
2663 * init/tests/test_event.c (test_operator_match): Update tests to
2664 check the new behaviour works.
2665
Scott James Remnantff48a242008-02-22 15:46:30 +00002666 * init/parse_job.c (parse_on_operand): Add arguments to env list
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00002667 rather than args; sanity check afterwards to ensure that positional
2668 doesn't follow name-based -- when parsing the job is the right place
2669 to catch this.
Scott James Remnantff48a242008-02-22 15:46:30 +00002670 * init/tests/test_parse_job.c (test_stanza_start)
2671 (test_stanza_stop): Change args to env when checking operators.
Scott James Remnant7e96c7b2008-02-22 17:23:18 +00002672 Check that arguments may be quoted in manners that we expect to be
2673 sane. Check that positional arguments cannot follow name-based ones.
2674 * init/errors.h: Add new error.
2675 * init/conf.c (conf_reload_path): Treat expected variable as a
2676 permanent error.
Scott James Remnantff48a242008-02-22 15:46:30 +00002677
Scott James Remnantd816fbd2008-02-22 15:13:07 +00002678 * init/tests/test_process.c (test_spawn, test_environment):
2679 Update event_new() calls to remove extra argument.
2680
Scott James Remnant36eea462008-02-22 15:11:05 +00002681 * init/main.c (main, cad_handler, kbd_handler, pwr_handler):
2682 Update event_new() calls to remove extra argument.
2683
Scott James Remnantc398d782008-02-22 15:07:54 +00002684 * init/job.c (job_change_state): Update event_new () call.
2685 (job_emit_event): Update to put failure information in environment.
2686 * init/tests/test_job.c (test_new, test_instance)
2687 (test_child_handler, test_handle_event)
2688 (test_handle_event_finished): Remove extra argument to event_new,
2689 rename args to env in operator where necessary.
2690 (test_change_state): Update to check emitted event by full environment.
2691
Scott James Remnant53cb0012008-02-22 14:55:53 +00002692 * init/event.h (Event): Remove args member.
2693 (EventOperator): Rename args member to env.
2694 Update prototypes to match.
2695 * init/event.c (event_new): Remove args member.
2696 (event_finished): Remove copying of args member to failed event.
2697 (event_operator_new): Rename args member to env.
2698 (event_operator_copy): Rename args copying to env.
2699 (event_operator_match): ??
2700 * init/tests/test_event.c (test_new): Update test to remove args.
2701 (test_operator_new): Update test to rename args to env.
2702 (test_operator_copy): Update test to rename args to env.
2703 (test_operator_match): ???
2704
Scott James Remnantc3c78b02008-02-22 14:55:12 +00002705 * TODO: Update with job atomicity notes.
2706
Scott James Remnantc488ddb2008-02-20 16:35:24 +000027072008-02-20 Scott James Remnant <scott@netsplit.com>
2708
Scott James Remnant37fb28a2008-02-20 16:38:01 +00002709 * init/job.c: Switch around job_find_by_pid and job_find_by_id
2710 * init/job.h: Likewise.
2711
Scott James Remnantc488ddb2008-02-20 16:35:24 +00002712 * init/job.h: Update prototypes to match variable names in the
2713 code.
2714
Scott James Remnant676c9052008-02-17 16:08:40 +000027152008-02-17 Scott James Remnant <scott@netsplit.com>
2716
Scott James Remnant742d4662008-02-17 18:29:26 +00002717 * init/process.c (process_kill): Change to accept a JobConfig rather
2718 than a Job, since in theory this should only ever need that in a
2719 future where we can specify a kill signal (right now it's not used
2720 for anything!)
2721 * init/process.h: Update prototype.
2722 * init/tests/test_process.c (test_kill): Update test cases.
2723 * init/job.c (job_kill_process, job_kill_timer): Pass in JobConfig
2724 instead of Job.
2725
Scott James Remnantd37dd062008-02-17 18:25:51 +00002726 * init/process.c (process_spawn): Accept trace as an argument instead
2727 of using a random piece of job state to determine whether to trace
2728 or not.
2729 * init/process.h: Update prototype.
2730 * init/tests/test_process.c (test_spawn): Update tests to pass in
2731 via argument whether to trace the job or not.
2732 * init/job.c (job_run_process): Pass in the trace variable rather
2733 than relying on it working it out for itself; this means we don't
2734 need to set the state until after, therefore don't need to reset it.
2735
Scott James Remnant6b1c7ee2008-02-17 18:00:33 +00002736 * AUTHORS, logd/jobs.d/logd.in: Update e-mail addresses.
2737
Scott James Remnant676c9052008-02-17 16:08:40 +00002738 * README: Update kernel recommendation to 2.6.24, since that's
2739 the oldest version that the test suite will complete under.
2740
Scott James Remnanta3239f62008-01-17 03:34:27 +000027412008-01-17 Scott James Remnant <scott@netsplit.com>
2742
Scott James Remnant85a96502008-01-17 03:38:44 +00002743 * TODO: Update.
2744
Scott James Remnantdc4162b2008-01-17 03:37:02 +00002745 * init/job.c (job_run_process): Don't append the list of event
2746 names, they can be found in $UPSTART_EVENTS now. This is better
2747 since it's consistent for exec and script.
2748 * init/tests/test_job.c (test_run_process): Drop test case.
2749
Scott James Remnanta3239f62008-01-17 03:34:27 +00002750 * init/process.c (process_environment): Function to build an
2751 environment table for a job containing built-in variables, those
2752 from the configuration, events and finally the upstart job ones.
2753 (process_environment_add): Helper function for the above that
2754 handles adding a variable to the array; dealing with fetching the
2755 value from init's environment if necessary.
2756 (process_setup_environment): This function now gets dropped in
2757 favour of the new ones.
2758 (process_spawn): Call the new process_environment() function and set
2759 the environ variable directly.
2760 * init/process.h (PROCESS_ENVIRONMENT): Define built-in environment
2761 variables that are always copied from our own environment.
2762 Add prototypes.
2763 * init/tests/test_process.c (test_environment): Check that the
2764 environment is built correctly and that each bit overrides the
2765 right other bit.
2766 (test_environment_add): Check that the array is built correctly.
2767 (test_spawn): Adjust order and values of expected environment
2768 to match what's now set.
2769
Scott James Remnant5c87e6e2008-01-16 00:27:22 +000027702008-01-16 Scott James Remnant <scott@netsplit.com>
2771
Scott James Remnantb150df62008-01-16 03:14:16 +00002772 * init/job.c (job_failed): Separate the logic that marks the job
2773 and its associated events as failed into its own function, since
2774 it's a large enough amount of code that we were otherwise duplicating
2775 everywhere else (and in a few places, failing to mark the events as
2776 failed as well).
2777 (job_change_state, job_process_terminated): Call job_failed instead
2778 of doing it ourselves.
2779 (job_emit_event): De-nest the logic and fix so that we don't add
2780 environment to the failed respawn event.
2781 * init/tests/test_job.c (test_change_state): Add checks on whether
2782 the event was marked as failed or not.
2783
Scott James Remnant340083b2008-01-16 02:06:51 +00002784 * TODO: Update.
2785
Scott James Remnant30bc02b2008-01-16 01:49:20 +00002786 * configure.ac (AC_COPYRIGHT): Update copyright to 2008.
2787
Scott James Remnant4ff4a7d2008-01-16 01:47:20 +00002788 * TODO: Update.
2789
Scott James Remnant75e801a2008-01-16 00:44:17 +00002790 * init/tests/test_job.c (test_child_handler): Don't run the signal
2791 and ptrace tests while in valgrind, sometimes signals (specifically
2792 SIGCONT after SIGSTOP) don't behave right and we kinda need that
2793 reliability.
2794
Scott James Remnant798284f2008-01-16 00:31:23 +00002795 * init/tests/test_job.c (test_child_handler): After adding extra
2796 processes, make sure we clean up again so each test is roughly
2797 independant. Fix the final test case to not rely on previous
2798 setup and work on its own.
2799
Scott James Remnant0cfd4e72008-01-16 00:30:26 +00002800 * init/tests/test_job.c (test_change_state): Remove useless check
2801 of job->start_on from a killed/post-stop check (noticed while
2802 writing the other).
2803
Scott James Remnant5c87e6e2008-01-16 00:27:22 +00002804 * init/job.c (job_change_state): Check the return value of
2805 job_run_process() and if particular processes fail, change the
2806 goal to stop and push the job into the next state; setting the job
2807 as failed along the way.
2808 (job_emit_event): If the exit_status is -1 then it means the job
2809 failed to spawn, so don't place EXIT_SIGNAL or EXIT_STATUS in the
2810 event environment.
2811 * init/tests/test_job.c (test_change_state): Check what happens when
2812 each process type fails, make sure that the job is stopped for
2813 pre-start, spawned and post-stop and the failure is ignored for
2814 post-start and pre-stop.
2815
Scott James Remnantfa733382008-01-15 15:33:27 +000028162008-01-15 Scott James Remnant <scott@netsplit.com>
2817
Scott James Remnant9f62a8e2008-01-15 19:22:36 +00002818 * init/main.c: Selectively compile out certain pieces when make is
2819 run with CPPFLAGS=-DDEBUG, giving us a build that'll happily run from
2820 a user terminal.
2821 * init/event.h: Change the startup event to "debug" when built like
2822 that, so we don't accidentally do bad things.
2823
Scott James Remnantb53527f2008-01-15 19:15:29 +00002824 * init/job.c (job_run_process): Catch PROCESS_ERROR and abort the
2825 attempt to run the process, returning a non-temporary error condition.
2826 * init/tests/test_job.c (test_run_process): Add test case for
2827 attempting to spawn a file that doesn't exist.
2828
Scott James Remnant85a2a0e2008-01-15 19:09:23 +00002829 * init/process.c (process_error_read): Avoid the word process, since
2830 it's likely included in the higher error message.
2831
Scott James Remnantfaa898c2008-01-15 19:05:04 +00002832 * init/process.c (process_spawn): Call process_error_abort() on any
2833 error condition.
2834 * init/tests/test_process.c (test_spawn): Add a test case for failing
2835 to spawn a process and receiving ProcessError correctly; fix other
2836 cases to ensure they return a pid.
2837
Scott James Remnantc7211972008-01-15 18:55:59 +00002838 * init/errors.h: Add PROCESS_ERROR to the enum, but not to the string
2839 list since there's no specific defined string for this one.
2840 * init/process.h (ProcessError): Structure that builds on NihError
2841 to add additional information for a process error.
2842 (ProcessErrorType): enum of different process error types.
2843 * init/process.c (process_spawn): After forking read the error in
2844 the parent, returning if we raise one.
2845 Ensure we close the pipe if the fork fails.
2846 Re-order so that we set the environment, umask and priority after the
2847 resource limits (which should apply to them).
2848 (process_error_abort): New function to immediately abort with an
2849 error, writing it on the pipe first.
2850 (process_error_read): Counterpart function to read the error from
2851 the pipe and raise it, with appropriate error messages.
2852
Scott James Remnant66738782008-01-15 17:01:19 +00002853 * init/process.c (process_spawn): Create a pipe to use for
2854 communication with the child, ensuring its closed before the parent
2855 returns and ensuring that the writing end is close-on-exec in the
2856 child.
2857
Scott James Remnant2e23f6b2008-01-15 16:38:28 +00002858 * init/job.c (job_run_process): Change to return a value indicating
2859 whether there's been a non-temporary error (always returns zero so
2860 far).
2861 * init/job.h: Update prototype.
2862 * init/tests/test_job.c (test_run_process): Check that job_run_process
2863 always returns zero.
2864
Scott James Remnant5dee92e2008-01-15 16:30:23 +00002865 * init/job.c (job_change_goal): Document in which states this function
2866 has unexpected side-effects such as freeing the job, since we do
2867 attempt to call it from within job_change_state().
2868
Scott James Remnantfa733382008-01-15 15:33:27 +00002869 * init/process.c (process_setup_limits): Integrate this function back
2870 into process_spawn() since there's no reason for it to be separate.
2871 (process_setup_console): Alter this function so it closes the original
2872 console descriptors, opens the new ones and can reset them to if
2873 required -- in particular, this no longer takes a Job parameter.
2874 (process_spawn): Use the new process_setup_console function and
2875 integrate code from process_setup_limits().
2876 * init/process.h: Update function prototype.
2877 * init/main.c (main): Use the new process_setup_console() argument
2878 form. Move syslog opening to the end of the function, rather than
2879 where it is now where it could be at risk of being closed again
2880 immediately. Change the root directory in case we're run in some
2881 weird way.
2882 (reset_console): Remove function since the code is now in
2883 process_setup_console()
2884 * init/enum.h (console_type): Remove CONSOLE_LOGGED and make the
2885 CONSOLE_NONE constant be zero.
2886 * init/parse_job.c (stanza_console): Drop parsing of "logged"
2887 * init/tests/test_parse_job.c (test_stanza_console): Drop testing
2888 of "logged" parsing.
2889
Scott James Remnantde581cc2008-01-14 21:35:53 +000028902008-01-14 Scott James Remnant <scott@netsplit.com>
2891
2892 * HACKING: Correct bzr URLs to trunk.
2893
Scott James Remnant20d3a1c2007-12-15 14:52:33 +000028942007-12-15 Scott James Remnant <scott@netsplit.com>
2895
Scott James Remnantcc6810d2007-12-15 15:39:02 +00002896 * init/process.c (process_spawn): Fix some documentation strings.
2897
Scott James Remnant206c97a2007-12-15 14:55:51 +00002898 * init/process.c (process_kill): Move to beneath the process setup
2899 functions.
2900 * init/process.h: Adjust ordering here too.
2901
Scott James Remnant20d3a1c2007-12-15 14:52:33 +00002902 * init/process.c (process_spawn): Group console closing and setup
2903 together, becoming the session and process group leader first.
2904
Scott James Remnant6f1e41f2007-12-07 00:32:21 +000029052007-12-07 Scott James Remnant <scott@netsplit.com>
2906
Scott James Remnante4178252007-12-07 13:35:45 +00002907 * init/process.c (process_spawn): Drop the debug message since
2908 it's always repeated by the caller.
2909 * init/job.c (job_run_process): Drop the word Active which is a
2910 hold-over from when we had different process states.
2911
Scott James Remnant64c8c772007-12-07 10:20:13 +00002912 * TODO: Update.
2913
Scott James Remnant0f688672007-12-07 10:17:25 +00002914 * init/job.c (job_child_handler): Add code to handle the trapped
2915 signal and ptrace event cases, distinguishing between a trapped
2916 signal and process stopped after exec or fork using our trace
2917 state member. Call out to other functions to do the work.
2918 (job_process_trace_new): Called after the first exec to set the
2919 ptrace options, update the trace state and allow the process to
2920 continue without delivering the signal. Also called after the
2921 fork to do the same.
2922 (job_process_trace_new_child): Called after a fork for the new child;
2923 increments the fork counter and if it goes over the number we want,
2924 detaches from the process and allows it to move to running. Otherwise
2925 calls job_process_trace_new() instead.
2926 (job_process_trace_signal): Called when a signal is trapped, simply
2927 delivers it to the process unchanged.
2928 (job_process_trace_fork): Called before a fork for the parent, obtains
2929 the new child process id from the event, updating the job structure,
2930 and detaches from the parent which we're no longer interested in.
2931 (job_process_trace_exec): Called after an exec other than the first,
2932 assumed to be the end of forking so detaches from the process and
2933 allows it to move to running.
2934 * init/tests/test_job.c (test_child_handler): Add test cases for
2935 the various ptrace states.
2936
Scott James Remnante3c10ae2007-12-07 09:18:38 +00002937 * init/job.c (job_run_process): Set process trace state to new for
2938 the main job if we need to wait for the daemon or fork; otherwise
2939 reset the state.
2940 * init/tests/test_job.c (test_run_process): Add test cases to make
2941 sure the trace state is set right and picked up by process_spawn.
2942
Scott James Remnant3525ffd2007-12-07 09:04:10 +00002943 * init/process.c (process_spawn): Set a ptrace before execing the
2944 binary if the trace state is TRACE_NEW, set by the caller.
2945 * init/tests/test_process.c (test_spawn): Make sure that a job is
2946 ptraced if set up properly.
2947 (child): Add a simple case that just exits immediately for testing
2948 the above.
2949
Scott James Remnantd431eea2007-12-07 09:01:58 +00002950 * init/job.h (Job): Add new trace_forks member to keep count of how
2951 many forks we've seen and trace_state member to track whether we've
2952 just started the trace or just forked.
2953 * init/enum.h (TraceState): Add enumeration to keep track of ptrace
2954 state to differentiate between a signal and an event.
2955 * init/job.c (job_new): Initialise new members.
2956 * init/tests/test_job.c (test_new): Check new members are initialised
2957
Scott James Remnant319c7f92007-12-07 08:57:48 +00002958 * init/enum.h (JobWaitType): Add new daemon and fork wait types.
2959 * init/parse_job.c (stanza_wait): Add parsing for daemon and fork.
2960 * init/tests/test_parse_job.c (test_stanza_wait): Add tests too.
2961
Scott James Remnant58d23f52007-12-07 00:42:50 +00002962 * init/job.h (JobConfig): Remove daemon and pid members.
2963 (Job): Remove pid_timer member.
2964 (JOB_DEFAULT_PID_TIMEOUT): Remove this constant.
2965 * init/job.c (job_config_new, job_new): Remove initialisation of
2966 removed members.
2967 (job_change_state): Stay in spawned unless we're not waiting for
2968 anything -- remove the daemon flag.
2969 * init/tests/test_job.c (test_config_new, test_new): Remove checks
2970 for initialisation of removed members.
2971 (test_change_state): Remove daemon flag stays in spawned check since
2972 the daemon flag has gone.
2973 * init/parse_job.c (stanza_daemon, stanza_pid): Remove these
2974 functions since they have no members to set.
2975 * init/tests/test_parse_job.c (test_stanza_daemon, test_stanza_pid):
2976 Remove the tests for the now non-existant functions.
2977
Scott James Remnant6f1e41f2007-12-07 00:32:21 +00002978 * init/process.c (process_spawn): raise the system error before
2979 calling another syscall, in case we overwrite errno.
2980
Scott James Remnant5fdadda2007-12-06 11:09:00 +000029812007-12-06 Scott James Remnant <scott@netsplit.com>
2982
Scott James Remnant5ebc6c62007-12-06 16:01:13 +00002983 * init/job.c (job_child_handler): Implement a combined child event
2984 handler to replace the multiple separate ones. This handler deals
2985 with adding appropriate messages to the log and decoding any state
2986 information before calling specific action functions.
2987 (job_child_reaper): Remove, moving the bulk of the code into new
2988 (job_process_terminated): function that handles it cleanly.
2989 (job_child_minder): Remove, moving the bulk of the code into new
2990 (job_process_stopped): function that's a lot cleaner.
2991 * init/job.h: Update prototypes.
2992 * init/tests/test_job.c (test_child_reaper, test_child_minder):
2993 Combine unit tests from both functions into single new
2994 (test_child_handler): function.
2995 * init/main.c (main): Call the combined function on child events
2996 instead of separate ones.
2997
Scott James Remnant5fdadda2007-12-06 11:09:00 +00002998 * init/job.c (job_child_minder): Add informational message and
2999 improve style and documentation.
3000
Scott James Remnantab882c22007-12-02 18:17:09 +000030012007-12-02 Scott James Remnant <scott@netsplit.com>
3002
3003 * init/enum.h (JobWaitType): Introduce a new enum that specifies
3004 how to transition the job from spawned to running; either we don't
3005 wait, or we wait for it to emit the stopped signal.
3006 * init/job.h (JobConfig): Add the wait_for member.
3007 Add protoype for job_child_minder.
3008 * init/job.c (job_config_new): Initialise to JOB_WAIT_NONE.
3009 (job_child_minder): New function to catch when a process is stopped
3010 by a signal, and move it to the next state when it does so.
3011 * init/tests/test_job.c (test_config_new): Check the initialisation
3012 of wait_for to JOB_WAIT_NONE.
3013 (test_child_minder): Tests for the new function.
3014 (test_change_state): Copy the daemon test case to refer to waiter.
3015 * init/main.c (main): Call job_child_minder whenever the job is
3016 stopped by a signal
3017 * init/parse_job.c (stanza_wait): Parse a new "wait" stanza that
3018 specifies what to wait for before leaving the spawned state.
3019 * init/tests/test_parse_job.c (test_stanza_wait): Check the new
3020 stanza.
3021
Scott James Remnant4bef98a2007-11-30 01:28:28 +000030222007-11-29 Scott James Remnant <scott@netsplit.com>
3023
3024 * init/tests/test_job.c (test_change_state): Add a few sets to NULL
3025 so gcc is happy.
3026
Scott James Remnant0eade492007-11-15 05:48:07 +000030272007-11-15 Scott James Remnant <scott@netsplit.com>
3028
3029 * init/job.c (job_child_reaper): Update argument names and types
3030 to match new NihChildHandler pattern; switch on event instead,
3031 which can now have three values not two (it always could, this was
3032 a bug) to output warning and assume that status is always non-zero
3033 if killed so no need to check that separately.
3034 * init/job.h: Update prototype.
3035 * init/tests/test_job.c (test_child_reaper): Update calls to
3036 job_child_reaper to pass an NihChildEvents member instead of FALSE
3037 or TRUE for killed.
3038 * init/main.c: Adjust call to nih_child_add_watch to indicate which
3039 events we want to pass to the reaper; we don't use NIH_CHILD_ALL
3040 since we're going to add ptrace stuff to a different function.
3041
Scott James Remnant5c408432007-11-07 21:42:25 -050030422007-11-07 Scott James Remnant <scott@netsplit.com>
3043
3044 * init/main.c (main): Tidy up.
3045
Scott James Remnantbc9b6712007-11-04 01:49:04 -040030462007-11-04 Scott James Remnant <scott@netsplit.com>
3047
3048 Complete the simplification of job config; rather than try and
3049 precompute job replacements, keeping them all in the same hash table
3050 and chaining them together, we just work it out when it's actually
3051 necessary based on what's in the conf_sources list.
3052
3053 * init/job.h (JobConfig): Remove the replacement and replacement_for
3054 members and put a deleted member in instead.
3055 * init/job.c (job_config_new): Initialise deleted to FALSE; don't
3056 replace the job into the hash table, since we only want the current
3057 one in there now.
3058 (job_config_find_by_name): Now that there is only ever one job
3059 config in the hash table, we don't need any special function and
3060 can just use nih_hash_lookup directly, so drop this function.
3061 (job_config_should_replace): Rename to job_config_replace
3062 (job_config_replace): Rework, it now checks to see whether there
3063 are instances, and if not removes the job from the hash table
3064 before selecting a new one (which might be the same job).
3065 * init/tests/test_job.c (test_config_new): Update test to check
3066 deleted starts off as FALSE and that the job isn't in the hash.
3067 (test_config_find_by_name): Drop.
3068 (test_config_should_replace): Rename and rewrite to test replacement
3069 actually works as we expect.
3070 (test_change_state): Update tests for entering the waiting mode and
3071 replacing jobs.
3072 (test_find_by_pid, test_find_by_id, test_handle_event)
3073 (test_handle_event_finished): Add jobs to the hash table, otherwise
3074 we can't find them
3075 (test_child_reaper): Add job to the hash table, and also create a
3076 source for it since we end up with it in the waiting state so need
3077 to be able to keep it.
3078 * init/Makefile.am (test_process_LDADD, test_job_LDADD)
3079 (test_event_LDADD): Need the full .o file list now.
3080 * init/conf.c (conf_file_destroy): Rewrite to mark the job deleted,
3081 call job_config_replace if it's the current job and free it if
3082 it isn't the current job either before or after that call.
3083 (conf_reload_path): Handle job replacement here; look up the
3084 old job in the hash table, if it exists attempt a replacement
3085 otherwise add the new job to the hash table.
3086 * init/tests/test_conf.c (test_source_reload_job_dir)
3087 (test_source_reload_conf_dir, test_source_reload_file): Update
3088 tests to check job->deleted and use nih_hash_lookup to see whether
3089 it's the current job.
3090 (test_file_destroy): Write tests to check the common cases, we don't
3091 need to worry about the intermediate now since they can't happen.
3092 * init/parse_job.c (parse_job): Massively simplify, this only creates
3093 the config and parses it now.
3094 * init/tests/test_parse_job.c (test_parse_job): Remove the replacement
3095 checks.
3096 * init/tests/test_event.c (test_poll): Add configs to the hash
3097 table so they can be found.
3098 * TODO: Update.
3099
Scott James Remnant9fa1ce82007-11-03 02:06:54 -040031002007-11-03 Scott James Remnant <scott@netsplit.com>
3101
3102 * init/conf.h (ConfSource): Remove priority, we'll place these
3103 in a linked list and use that order instead.
3104 (ConfSourcePriority): Drop accordingly.
3105 (ConfItem): Drop this structure; permitting jobs and states to be
3106 defined inside larger conf files made things complicated for no
3107 benefit; move the item union into
3108 (ConfFile): here, instead of the items list.
3109 (ConfItemType): Drop accordingly.
3110 * init/conf.c (conf_init): Store sources in a linked list, instead
3111 of a hash table; no idea why it ever was.
3112 (conf_source_new): Drop priority argument and add to list not hash.
3113 (conf_file_new): Set data to NULL instead of initialising items,
3114 set destructor to conf_file_destroy.
3115 (conf_item_destroy): Rename to conf_file_destroy
3116 (conf_file_destroy): and adjust to refer to ConfItem instead,
3117 getting the item type through the source.
3118 (conf_item_new): Drop.
3119 (conf_reload): Iterate as linked list not hash table.
3120 (conf_reload_path): Simplify handling of old files and items a
3121 little, just look it up and always free if it exists before parsing
3122 the new file.
3123 (conf_file_get): No longer any need for this function.
3124 * init/tests/test_conf.c (test_file_get, test_item_new): Drop
3125 test functions for those that have been removed.
3126 (test_item_destroy): Rename to test_file_destroy.
3127 (test_source_new): Don't pass or check priority, or hash lookup.
3128 (test_file_new): Check data is set correctly.
3129 (test_source_reload_job_dir, test_source_reload_conf_dir)
3130 (test_source_reload_file): Update tests accordingly.
3131 * init/parse_conf.c (stanza_job): Drop the job stanza, jobs
3132 may only be defined in dedicated directories.
3133 * init/tests/test_parse_conf.c (test_parse_conf): Simply check to only
3134 make sure the file is parsed.
3135 (test_stanza_job): Drop function.
3136 * init/main.c: Update calls to conf_source_new.
3137 * init/init.supp: Update intermediate function in suppression.
3138
Scott James Remnantb4169fa2007-10-26 13:54:41 -040031392007-10-26 Scott James Remnant <scott@netsplit.com>
3140
3141 * init/process.c (process_spawn): Mask out all signals across the
3142 fork() rather than just SIGCHLD; reset the signal handlers to default
3143 before unmasking again. The original rationale was we needed to
3144 avoid SIGCHLD occurring before we'd stashed the pid, but that's no
3145 longer a problem; the new rationale is that we want to avoid the
3146 signal handlers running in the newly forked child.
3147
Scott James Remnantd29da6f2007-10-20 00:08:52 +010031482007-10-20 Scott James Remnant <scott@netsplit.com>
3149
Scott James Remnant333ad2d2007-10-20 15:30:29 +01003150 * init/job.c (job_init): The job's name is the first item in the
3151 structure again, so we can use nih_hash_string_key.
3152 (job_config_name): Drop this function, then.
3153
Scott James Remnanteda29582007-10-20 14:44:24 +01003154 * init/conf.h (ConfSourcePriority): Add a priority enum
3155 (ConfSource): Add priority member.
3156 * init/conf.c (conf_source_new): Take priority as an argument and
3157 set it in the structure.
3158 * init/tests/test_conf.c (test_source_new): Make sure priority
3159 is set from the argument.
3160 (test_file_new, test_file_get, test_item_new)
3161 (test_source_reload_job_dir, test_source_reload_conf_dir)
3162 (test_source_reload_file, test_source_reload, test_item_destroy):
3163 Pass in a priority when creating a ConfSource.
3164 * init/tests/test_parse_conf.c (test_parse_conf): Likewise.
3165 * init/main.c (main): Set relative priorities for the configuration
3166 directories.
3167
Scott James Remnant388621b2007-10-20 14:29:40 +01003168 * init/conf.h (conf_file, conf_item): Add source and file members
3169 respectively that point to the parent structure.
3170 * init/conf.c (conf_file_new, conf_item_new): Set the members.
3171 * init/tests/test_conf.c (test_file_new, test_file_get)
3172 (test_item_new): Make sure the new members are set properly.
3173
Scott James Remnant87145d62007-10-20 14:02:59 +01003174 * util/Makefile.am (install-data-hook, install-exec-hook): Apply
3175 transform to source and destination of both manpage and program
3176 symlinks.
3177 * compat/sysv/Makefile.am (install-data-hook, install-exec-hook):
3178 Likewise for the compatibility symlinks.
3179
Scott James Remnant9f093752007-10-20 02:16:39 +01003180 * TODO: Update.
3181
Scott James Remnant1518f6c2007-10-20 02:14:29 +01003182 * init/tests/test_process.c (test_spawn): Make the event a child
3183 of the operator so it doesn't get freed first.
3184
Scott James Remnant509f7912007-10-20 02:06:23 +01003185 * init/job.c (job_instance): Increment an instances counter each
3186 time we spawn an instance.
3187 (job_change_state): Decrement the instances counter again.
3188 (job_detect_stalled): Drop the main loop function, since we perform
3189 active detection of stall now.
3190 * init/job.h: Update header.
3191 * init/tests/test_job.c (test_change_state): Check that we get the
3192 stalled event for the last instance.
3193 (test_detect_stalled): Drop the test.
3194 * init/main.c: Remove job_detect_stalled from the main loop.
3195
Scott James Remnant0af43242007-10-20 01:16:04 +01003196 * init/event.c (event_operator_destroy): Destructor for an
3197 EventOperator that unblocks and unreferences the event first.
3198 (event_operator_new): Set the operator.
3199 (event_operator_copy): Remove error handling since it's unnecessary
3200 with the destructor in place.
3201 * init/event.h: Add prototype.
3202 * init/tests/test_event.c (test_operator_destroy): Make sure it
3203 works properly.
3204 (test_operator_copy): Don't unblock or unref events before freeing
3205 them, since that's now taken care of when it's referenced.
3206 * init/job.c (job_new): Remove unnecessary error handling.
3207 * init/tests/test_job.c (test_run_process): Reference the event
3208 when setting it, otherwise we'll assert when we try to free it.
3209 * TODO: Update.
3210
Scott James Remnant2be7d582007-10-20 00:43:19 +01003211 * init/job.c (job_new): Drop the parent argument for consistency.
3212 (job_instance): Update call to job_new.
3213 * init/job.h: Update prototype.
3214 * init/tests/test_job.c (test_new): Adjust call, check the parent
3215 and make sure that start_on and stop_on are copied over properly.
3216 * TODO: Update.
3217
Scott James Remnante548bc72007-10-20 00:29:39 +01003218 * init/conf.c (conf_file_get): Split out the allocation code from here
3219 (conf_file_new): into this new function.
3220 * init/conf.h: Add prototype.
3221 * init/tests/test_conf.c (test_file_new): New tests.
3222 * TODO: Update.
3223
Scott James Remnantd29da6f2007-10-20 00:08:52 +01003224 * init/job.c (job_change_state): Hardcode the next state when we
3225 catch a runaway job to be JOB_WAITING.
3226 (job_next_state): Change next state for JOB_STARTING when goal is
3227 JOB_STOP to be JOB_STOPPING for consistency with the others; otherwise
3228 if our goal is stopped during our starting event, we'll never emit
3229 a stopping event to match it.
3230 * init/tests/test_job.c (test_next_state): Update test case.
3231 * doc/states.dot: Adjust the state transitions.
3232 * doc/states.png: Regenerate.
3233 * TODO: Update.
3234
Scott James Remnant493f5cd2007-10-19 22:49:09 +010032352007-10-19 Scott James Remnant <scott@netsplit.com>
3236
3237 Dealing with instances has always been tricky since they're copies
3238 that exist in the hash table; this patch changes that so the job's
3239 configuration is separated from its state. The only difference
3240 between instance and non-instance jobs now is that non-instance
3241 jobs only ever have one entry in their instances list.
3242
3243 * init/job.h (Job): Separate out the members that come from the
3244 configuration into a new JobConfig structure which can be shared
3245 amongst all of the instances; this means we can drop instance_of.
3246 (JobConfig): Add instances list.
3247 (JobProcess): Remove pid member, replaced by pid list in Job.
3248 Update prototypes of functions to match.
3249 * init/job.c (job_new): Split off initialisation of configuration
3250 pieces into new job_config_new function leaving the state here;
3251 copy the start_on and stop_on members from JobConfig
3252 (job_copy): Drop this function, we don't need to copy jobs now.
3253 (job_name): Rename to job_config_name.
3254 (job_init): Set key function to job_config_name.
3255 (job_process_new): Drop initialisation of pid.
3256 (job_process_copy): Drop this function entirely, we don't need it.
3257 (job_find_by_name): Rename to job_config_find_by_name; massively
3258 simplify now we won't find instances or deleted jobs in the list.
3259 (job_should_replace): Rename to job_config_should_replace; simplify
3260 now that we can do a simple check to see whether a job exists or not
3261 (job_find_by_pid, job_find_by_id): Loop through the instances after
3262 looping through the hash table.
3263 (job_instance): Simplify, now all it needs to do is call job_new()
3264 if there isn't anything in the instances list, or it's multi-instance.
3265 (job_change_goal): Document that job should not be used on return.
3266 No need to check for instance jobs anymore. Place the job id in
3267 the output.
3268 (job_change_state): Document that job should not be used on return.
3269 Place the job id in the output. Check for information in the job's
3270 config. Merge the waiting and deleted states, so that a job instance
3271 is automatically deleted when it finishes.
3272 (job_next_state): Assert that we never call job_next_state when
3273 in JOB_WAITING since there's no possible next state. Check config
3274 for whether a main process exists.
3275 (job_emit_event): Obtain config-replaced pieces from the job's config
3276 (job_run_process): Obtain process information from the job's config
3277 but store the pid in the Job. Put job id in the output.
3278 (job_kill_process, job_kill_timer): We don't need to obtain the
3279 JobProcess just the pid from the job. Put job id in the output.
3280 (job_child_reaper): Put job id in the output. Check job config.
3281 (job_handle_event): Iterate job instances and process their stop_on
3282 operators, but process the start_on from the job configs.
3283 (job_handle_event_finished): Loop through the instances too.
3284 (job_detect_stalled): Check start_on from the config and just
3285 check whether there are any instances in the list.
3286 (job_free_deleted): No deleted state, so drop this function.
3287 * init/tests/test_job.c (test_new): Split into test_new and
3288 new test_config_new function. Create JobConfig object and spawn
3289 Job instances from that.
3290 (test_copy): Drop the tests.
3291 (test_process_new): Drop check of pid.
3292 (test_process_copy): Drop test.
3293 (test_find_by_name): Rename to test_config_find_by_name.
3294 (test_should_replace): Rename to test_config_should_replace.
3295 (test_instance): Create JobConfig object, and adjust tests to ensure
3296 that we always get a Job object.
3297 (test_find_by_pid, test_find_by_id, test_change_goal): Create
3298 JobConfig object and spawn Job instances from that.
3299 (test_change_state): Create JobConfig object and spawn Job
3300 instances from that. Adjust tests that previously checked for
3301 JOB_WAITING to check for job being freed. Drop checks for JOB_DELETED.
3302 (test_next_state): Create JobConfig object and spawn Job instances
3303 from that. Drop JOB_DELETED and JOB_WAITING checks.
3304 (test_run_process, test_kill_process, test_child_reaper)
3305 (test_handle_event, test_detect_stalled): Create JobConfig object
3306 and spawn Job instances from that.
3307 (test_free_deleted): Drop.
3308 * init/main.c: Don't add job_free_deleted to the main loop.
3309 * init/enum.h (JobState): Drop JOB_DELETED.
3310 * init/enum.c (job_state_name, job_state_from_name): Drop JOB_DELETED.
3311 * init/tests/test_enum.c (test_state_name, test_state_from_name):
3312 Drop tests that use the JOB_DELETED value.
3313 * init/process.c (process_spawn, process_setup_limits)
3314 (process_setup_environment, process_setup_console): Get details
3315 from the job config. Put job id in the output.
3316 * init/tests/test_process.c (test_spawn, test_kill): Create
3317 a JobConfig object and make Job instances from that.
3318 * init/tests/test_event.c (test_poll): Create a JobConfig object
3319 and make Job instances from that.
3320 (test_operator_copy): Set pointers to NULL to avoid gcc complaining.
3321 * init/conf.h (ConfItem): Make the type for a job be JobConfig.
3322 * init/conf.c (conf_item_destroy): Don't attempt to replace the
3323 new middle-man target, if it was due to be replaced it would have
3324 already been. If we can replace the config, ensure nothing points
3325 at it and then free it, rather than kicking state.
3326 * init/tests/test_conf.c (test_source_reload_job_dir)
3327 (test_source_reload_conf_dir, test_source_reload_file)
3328 (test_source_reload, test_item_destroy): Call job_config_new to
3329 create JobConfig objects, track when they are freed rather than
3330 marked in the deleted state. Create instances with job_instance,
3331 and fetch from the instances list. Expect the job to be freed
3332 with the item.
3333 * init/tests/test_parse_conf.c (test_parse_conf)
3334 (test_stanza_job): Change expected type from Job to JobConfig.
3335 * init/parse_job.c: Update prototypes of all functions to refer to
3336 JobConfig instead of Job.
3337 (parse_job): If the old job already has a replacement, remove the
3338 replacement from the hash table -- but don't free it because it's
3339 linked by a ConfItem -- this is temporary. Likewise for when we
3340 replace the old job.
3341 * init/parse_job.h: Update prototype.
3342 * init/tests/test_parse_job.c: Update all functions to use JobConfig
3343 instead of Job.
3344 (test_parse_job): Create an instance.
3345 * doc/states.dot: Remove the deleted state.
3346 * doc/states.png: Regenerate.
3347 * TODO: Update with notes from the conversion.
3348
Scott James Remnantf9ec8292007-10-16 00:08:33 +010033492007-10-16 Scott James Remnant <scott@netsplit.com>
3350
3351 Update to catch up with changes in libnih that make code a little
3352 bit easier to follow (we hope).
3353
3354 * init/tests/test_process.c (test_spawn, test_kill): Replace calls
3355 to nih_list_free() with nih_free()
3356 * init/event.c (event_poll): Replace nih_list_free with nih_free
3357 since the former function has gone from libnih.
3358 (event_new): Adjust setting of the destructor.
3359 (event_operator_new): Set destructor for the tree node.
3360 * init/tests/test_event.c (test_new, test_find_by_id, test_ref)
3361 (test_unref, test_block, test_unblock, test_poll)
3362 (test_operator_match): Replace nih_list_free with nih_free.
3363 (test_poll): Use TEST_FREE_TAG and TEST_FREE rather than abusing
3364 destructors.
3365 * init/job.c (job_new): Set destructor to nih_list_destroy.
3366 (job_copy, job_free_deleted): Use nih_free instead of nih_list_free
3367 * init/tests/test_job.c (test_new, test_copy, test_find_by_name)
3368 (test_find_by_pid, test_find_by_id, test_instance)
3369 (test_change_goal, test_change_state, test_next_state)
3370 (test_should_replace, test_run_process, test_kill_process)
3371 (test_child_reaper, test_handle_event)
3372 (test_handle_event_finished, test_detect_stalled)
3373 (test_free_deleted): Replace all uses of nih_list_free with nih_free
3374 (test_child_reaper, test_free_deleted): Replace destructor abuse
3375 with TEST_FREE, etc.
3376 * init/conf.c (conf_reload_path): Use nih_free instead of nih_list_free
3377 (conf_source_new, conf_file_get, conf_item_new): Set destructor
3378 (conf_source_reload, conf_delete_handler): Use nih_free not the
3379 custom conf_file_free() function.
3380 (conf_reload_path): Use nih_free not the custom conf_item_free()
3381 function.
3382 (conf_delete_handler): Use nih_free not nih_watch_free()
3383 (conf_source_free, conf_file_free): Drop these functions, since
3384 all the free chaining happens properly with destructors.
3385 (conf_item_free): Rename to conf_item_destroy and turn into destructor
3386 * init/conf.h: Update prototypes.
3387 * init/tests/test_conf.c (test_source_new, test_file_get)
3388 (test_item_new, test_source_reload_job_dir)
3389 (test_source_reload_conf_dir, test_source_reload_file)
3390 (test_item_free): Replace nih_list_free calls with nih_free
3391 (test_source_reload_job_dir, test_source_reload_conf_dir)
3392 (test_source_reload_file, test_source_reload, test_item_free): Replace
3393 calls to conf_source_free with nih_free
3394 (test_source_free, test_file_free): Drop functions.
3395 (test_item_free): Rename to test_item_destroy
3396 (test_item_new): Assign a job before freeing, otherwise the destroy
3397 function will foul up as it expects one.
3398 * init/parse_conf.c (stanza_job): Replace nih_list_free with nih_free
3399 * init/tests/test_parse_conf.c (test_parse_conf)
3400 (test_stanza_job): Replace conf_source_free() with nih_free()
3401 (test_parse_conf, test_stanza_job): Replace conf_item_free()
3402 with nih_free()
3403 * init/parse_job.c (parse_job, parse_on_paren, parse_on_collect):
3404 Replace nih_list_free with nih_free
3405 (parse_on): always cut out the stack head before returning (it won't
3406 be empty on error) otherwise we end up with a bunch of list entries
3407 pointing to it -- and it's way out of scope when we try and free them
3408 (parse_on_operator, parse_on_operand): Use the job as the context
3409 not the operator for consistency of freeing.
3410 * init/tests/test_parse_job.c: Replace all instances of nih_list_free
3411 with nih_free (too many functions to list).
3412
Scott James Remnant5d6466d2007-10-15 01:40:52 +010034132007-10-15 Scott James Remnant <scott@netsplit.com>
3414
Scott James Remnant3e32e082007-10-16 00:08:24 +01003415 Strip out all of the IPC code, removing it and consigning it to the
3416 great revision control history in the sky. We're going to switch
3417 from home-brew to D-BUS. so all this is somewhat obsolete. Rather
3418 than maintain this while we carry on developing, we'll strip it out
3419 now and put the D-BUS code in ater once the rest of the core changes
3420 are done (otherwise we'd just be dragging those through maintenance
3421 too).
3422
3423 * Makefile.am (SUBDIRS): Remove the upstart sub-directory entirely;
3424 comment out util, compat/sysv & logd since we'll fix them up later
3425 * configure.ac (AC_CONFIG_FILES): Remove from here too.
3426 * upstart/enum.c, upstart/enum.h, upstart/tests/test_enum.c: Move
3427 these files into the init/ sub-directory; strictly speaking we'll
3428 probably need to share them again later in some way, but for now
3429 they can live with the rest of the daemon code.
3430 * upstart/: Delete.
3431 * init/Makefile.am (init_SOURCES): Remove control.c, control.h,
3432 notify.c and notify.h; add enum.c and enum.h
3433 (TESTS): Remove test_control and test_notify; add test_enum
3434 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD)
3435 (test_notify_SOURCES, test_notify_LDADD): Remove.
3436 (test_enum_SOURCES, test_enum_LDFLAGS, test_enum_LDADD): Add details
3437 (init_LDADD): Remove libupstart
3438 (test_process_LDADD, test_job_LDADD, test_event_LDADD)
3439 (test_parse_job_LDADD, test_parse_conf_LDADD, test_conf_LDADD): Remove
3440 libupstart, control.o and notify.o; add enum.o
3441 * init/control.c, init/control.h, init/tests/test_control.c: Delete
3442 * init/notify.c, init/notify.h, init/tests/test_notify.c: Delete
3443 * init/enum.c, init/job.c, init/job.h: Update include path for enum.h
3444 * init/parse_job.c: Remove unnecessary enum.h include
3445 * init/tests/test_enum.c: Update to reflect where it is.
3446 * init/main.c (main): Drop control socket opening.
3447 * init/tests/test_job.c: Remove unnecessary control.h include
3448 * init/event.c (event_pending, event_finished): Remove calls to
3449 notify_event and notify_event_finished
3450 * init/job.c (job_change_goal, job_change_state): Remove calls
3451 to notify_job.
3452 * init/tests/test_parse_conf.c: Remove calls to notify_init
3453 * init/tests/test_parse_job.c: Remove calls to notify_init
3454 * init/tests/test_event.c (test_poll): Strip out the part of the
3455 test that checks processes are notified.
3456 (check_event, check_event_finished): Remove.
3457
Scott James Remnanta86d3982007-10-15 17:55:09 +01003458 * configure.ac: Bump Autoconf dependency to 2.61 to match libnih
3459 * HACKING: Bump dependency in docs too.
3460
Scott James Remnant5d6466d2007-10-15 01:40:52 +01003461 * NEWS: Copy in news from 0.3.9; that release doesn't appear in
3462 this ChangeLog since it was made on a separate branch by backporting
3463 bug fixes made here.
3464 * configure.ac: Bump version to 0.5.0, which is where development
3465 is heading for.
3466
Scott James Remnant56d2d822007-10-12 18:06:21 +010034672007-10-12 Scott James Remnant <scott@netsplit.com>
3468
3469 * HACKING: Change URL for libnih.
3470
Scott James Remnant0c3bef32007-10-08 13:20:56 +010034712007-10-08 Scott James Remnant <scott@netsplit.com>
3472
Scott James Remnante16d32c2007-10-08 13:37:44 +01003473 * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.16.1 since this
3474 version of gettext is needed for compatibility with Automake 1.10
3475 * HACKING: Bump version in the docs too.
3476
Scott James Remnante6478362007-10-08 13:21:51 +01003477 * compat/sysv/Makefile.am: Only create symlinks if COMPAT_SYSV is
3478 enabled, otherwise we leave dangling ones.
3479
Scott James Remnant0c3bef32007-10-08 13:20:56 +01003480 * Makefile.am (ACLOCAL_AMFLAGS): Specify that aclocal install
3481 ordinarily system-wide macros into m4 (libtool.m4, specifically).
3482 This makes it easier for packagers to modify autoconfery since
3483 aclocal is no longer a destructive event.
3484 * configure.ac (AM_INIT_AUTOMAKE): Increase Automake requirement to
3485 1.10 to ensure we have aclocal --instal
3486 * HACKING: Increase Automake version in the docs.
3487
Scott James Remnant52ada042007-09-21 15:59:12 +010034882007-09-21 Scott James Remnant <scott@netsplit.com>
3489
3490 * init/job.c (job_detect_stalled, job_free_deleted): Call job_init()
3491 on entry, since we don't have a Job pointer passed to us, we need
3492 to make sure we don't dereference a potentially NULL list.
3493
Scott James Remnant65e21ac2007-06-22 12:48:14 +010034942007-06-22 Scott James Remnant <scott@netsplit.com>
3495
Scott James Remnant1e2e0b32007-06-22 16:59:29 +01003496 * TODO: Update.
3497
Scott James Remnant3a807ca2007-06-22 16:53:35 +01003498 * init/job.h: Update prototype of job_change_goal.
3499 (Job): Remove cause member.
3500 * init/job.c (job_change_goal): Drop additional argument since cause
3501 is no longer used.
3502 (job_change_state, job_child_reaper, job_handle_event): Only pass
3503 two arguments to job_change_goal.
3504 * init/control.c (control_job_start, control_job_stop): Only pass
3505 two argumenst to job_change_goal.
3506 * init/tests/test_job.c (test_change_goal, test_change_state): Only
3507 pass two arguments to job_change_goal.
3508
Scott James Remnant134e0592007-06-22 16:51:02 +01003509 * init/job.c (job_new): Drop setting of cause.
3510 (job_change_cause): Drop this function entirely.
3511 (job_change_goal, job_change_state): Drop calls to job_change_cause
3512 (job_change_state, job_child_reaper): Don't pass job->cause to
3513 job_change_goal calls.
3514
3515 * init/tests/test_job.c: Remove all tests that checked the value of
3516 job->cause, since that variable is going away.
3517 (test_change_goal): Remove the specific tests that checked whether
3518 cause was updated or not.
3519
Scott James Remnant108152d2007-06-22 16:43:07 +01003520 * init/job.c (job_run_process): Replace the arguments from the event
3521 with a list of event names.
3522 * init/tests/test_job.c (test_run_process): Update test case to
3523 supply arguments from the list of events.
3524
Scott James Remnantbc683992007-06-22 16:37:10 +01003525 * init/process.c (process_setup_environment): Drop the UPSTART_EVENT
3526 environment variable; it doesn't make sense when you can have multiple
3527 events.
3528 (process_setup_environment): Put all variables from the job's start
3529 events into the job's environment; replacing the UPSTART_EVENT variable
3530
Scott James Remnant47f5a762007-06-22 15:57:26 +01003531 * init/job.c (job_change_cause): Don't notify the job event
3532 subscribers when changing the cause.
3533 * init/notify.c (notify_job_finished): Instead notify them when
3534 the job reaches a rest state.
3535
Scott James Remnantfed4f262007-06-22 15:50:51 +01003536 * init/notify.c (notify_job): Call notify_job_event regardless,
3537 since this now looks over the start_on and stop_on fields.
3538 (notify_job_event): Rewrite to iterate over start_on and stop_on,
3539 and notifying for each cause event found.
3540 (notify_job_event_caused): Static function that is the guts of the
3541 above function.
3542 * init/tests/test_notify.c (test_job, test_job_event): Modify tests
3543 to refer exclusively to the start_on/stop_on expressions rather than
3544 the cause.
3545
Scott James Remnante379ab92007-06-22 15:35:42 +01003546 * init/job.c (job_change_cause): Only notify the job event and
3547 update the cause member, we don't need to ref or block it anymore
3548 since that's handled by start_on and stop_on.
3549 * init/tests/test_job.c (test_change_goal): Drop checks on cause
3550 being referenced and blocked.
3551 (test_change_state, test_child_reaper, test_handle_event): Update
3552 test cases to not reference ->cause, and not count any references
3553 or blockers towards it.
3554 * init/tests/test_event.c (test_poll): Update expected reference
3555 and block counts for events handled by jobs.
3556
Scott James Remnant06218642007-06-22 15:15:56 +01003557 * init/tests/test_process.c (test_kill): Make sure that all processes
3558 in the process group are killed, rather than just the lone one.
3559 * init/process.c (process_kill): Send the signal to all processes
3560 in the same process group as the pid.
3561 * init/tests/test_job.c (test_change_state, test_kill_process):
3562 After spawning a child, call setpgid() to put it in its own process
3563 group otherwise we could end up TERMing ourselves.
3564
Scott James Remnante84eb012007-06-22 13:42:14 +01003565 * init/tests/test_job.c (test_child_reaper): Update test cases to
3566 include checking of the start_on and stop_on expression trees.
3567 * init/job.c (job_child_reaper): Mark all blocked events in the
3568 start_on and stop_on trees as failed; since these are copies of
3569 the cause event, we can drop that setting already.
3570
Scott James Remnant65e21ac2007-06-22 12:48:14 +01003571 * TODO: Update again, still thinking about the atomicity of event
3572 expressions.
3573
Scott James Remnante332fa92007-06-21 15:35:53 +010035742007-06-21 Scott James Remnant <scott@netsplit.com>
3575
Scott James Remnantb4556392007-06-21 18:38:20 +01003576 * init/tests/test_job.c (test_change_state): Include tests on a job's
3577 start_on and stop_on event expression trees, and make sure that events
3578 are unblocked and unreferenced at the appropriate moments.
3579 * init/job.c (job_change_state): Unblock the events that started the
3580 job in running (if a service), and reset when we reach waiting (leave
3581 referenced otherwise so the environment is always present).
3582 Unblock and unreference the events that stopped the job in
3583 starting (for restarting), running (if coming from pre-stop) and
3584 waiting.
3585
Scott James Remnant7e198e42007-06-21 17:02:12 +01003586 * init/tests/test_job.c (test_handle_event): Rewrite tests using
3587 event expressions, and make sure events are referenced and blocked
3588 correctly matching how jobs are affected. Include tests for correct
3589 instance behaviour.
3590 (test_instance): Make sure that instances copy across the expression
3591 state, and reset the parent.
3592 * init/job.c (job_instance): After spawning a new instance, reset
3593 the start_on expression of the master job.
3594
Scott James Remnant625c8d02007-06-21 16:28:43 +01003595 * init/event.c (event_operator_copy): Change to making the parent
3596 of copies nodes be the actual tree parent, rather than the top
3597 parent; otherwise you can't free an entire tree in one go.
3598 * init/tests/test_event.c (test_operator_copy): Check parents of
3599 copied nodes.
3600 * init/tests/test_job.c (test_copy): Update parent checks here too.
3601
Scott James Remnante332fa92007-06-21 15:35:53 +01003602 * init/tests/test_job.c (test_copy): Make sure that the job copy
3603 references and blocks the event; and in the event of failure, doesn't
3604 * init/job.c (job_copy): Reset the start_on and stop_on expressions
3605 in the event of failure.
3606
Scott James Remnante7b6cd62007-06-20 22:17:09 +010036072007-06-20 Scott James Remnant <scott@netsplit.com>
3608
Scott James Remnant9b1d5202007-06-20 23:26:37 +01003609 * TODO: Update.
3610
Scott James Remnantce628ca2007-06-20 23:25:02 +01003611 * init/parse_job.c (parse_on): New generic parsing function to deal
3612 with event expressions, including operators, parentheses, etc.
3613 (parse_on_operator): Function called by parse_on() to deal with an
3614 operator or operand.
3615 (parse_on_paren): Function called by parse_on() to deal with a
3616 parenthesis.
3617 (parse_on_operand): Function called by parse_on_operator() to deal
3618 with a non-operator token.
3619 (parse_on_collect): Function called by all of the above to collect
3620 the operators on the stack and deposit them into the output box,
3621 either for collection by a later operator or for returning from
3622 parse_on().
3623 (stanza_start, stanza_stop): Call the new parse_on() function to
3624 deal with "start on" and "stop on", storing it in the appropriate
3625 part of the job.
3626 * init/tests/test_parse_job.c (test_parse_job): Replace list empty
3627 checks for start_events/stop_events with NULL checks on the new
3628 start_on/stop_on members.
3629 (test_stanza_start, test_stanza_stop): Test new stanza code.
3630
3631 * init/errors.h (PARSE_EXPECTED_EVENT, PARSE_EXPECTED_OPERATOR)
3632 (PARSE_MISMATCHED_PARENS): Add numerics and strings for the errors
3633 that can be generated by parsing an event expression.
3634 * init/conf.c (conf_reload_path): Handle the new errors properly,
3635 including the line number where they occurred.
3636 * logd/jobs.d/logd.in: Update "stop on" to work with the new parser.
3637
Scott James Remnant404f99c2007-06-20 22:18:39 +01003638 * init/parse_job.c (stanza_emits): Each entry in the emits list
3639 is now an NihListEntry with the event name as the string data
3640 pointer, rather than an EventInfo structure (since that structure
3641 is gone).
3642 * init/tests/test_parse_job.c (test_stanza_emits): Update test
3643 case to check for NihListEntry structures.
3644
Scott James Remnante7b6cd62007-06-20 22:17:09 +01003645 * init/parse_job.c: Where the stanza function parses an argument and
3646 can possibly reject it, save the position and line number and do not
3647 return that unless we're happy with the argument. This ensures errors
3648 are raised pointing *at* the argument, rather than past it.
3649 * init/tests/test_parse_job.c: Fix several test case errors where
3650 the buffer was built incorrectly. Pedantically check pos and lineno
3651 after successful parsing, and after errors, to make sure they are
3652 where they should be.
3653
Scott James Remnant77e9d342007-06-18 12:59:22 +010036542007-06-18 Scott James Remnant <scott@netsplit.com>
3655
Scott James Remnantc8ca88e2007-06-18 15:18:02 +01003656 * init/job.h (Job): Replace the start_events and stop_events NihLists
3657 with start_on and stop_on EventOperators.
3658 * init/job.c (job_new): Drop list initialising, and instead just set
3659 the new start_on/stop_on members to NULL.
3660 (job_copy): Copy the entire event operator tree to the new job,
3661 including references and blockers. emits has changed to a list of
3662 NihListEntry with embedded strings, so copy them that way.
3663 (job_run_process): Drop "->info."
3664 (job_handle_event): Instead of iterating the events lists, call
3665 event_operator_handle and check the return value and top node value.
3666 (job_detect_stalled): Modify to iterate the start_on tree.
3667 * init/tests/test_job.c (test_change_state, test_detect_stalled):
3668 Drop references to "->info." since we can get the variables directly.
3669 (test_new): Check that start_on and stop_on are NULL.
3670 (test_copy): Adjust tests of copying start_on and stop_on trees as
3671 well as the emits list.
3672 (test_handle_event, test_handle_event_finished)
3673 (test_detect_stalled): Change references from start_events to start_on,
3674 stop_events to stop_on and construct using EventOperators instead.
3675 (test_handle_event): Update number of blockers now that the event
3676 expressions themselves will block the event.
3677 * init/tests/test_event.c (test_poll): Update number of blockers since
3678 both the events and cause will block it for now; also change
3679 start_events and stop_events to start_on and stop_on respectively.
3680
Scott James Remnant210d6fa2007-06-18 15:12:29 +01003681 * init/event.c (event_operator_copy): Copy the children nodes as well.
3682 * init/tests/test_event.c (test_operator_copy): Test copying
3683 with children nodes.
3684
Scott James Remnant77e7a382007-06-18 14:10:39 +01003685 * init/tests/test_control.c (test_event_emit): Drop "->info."
3686
Scott James Remnant5b27f0b2007-06-18 14:09:49 +01003687 * init/notify.c (notify_event, notify_event_finished): Drop
3688 "->info." from event references.
3689
Scott James Remnant61b7ae82007-06-18 14:05:00 +01003690 * init/process.c (process_setup_environment): Drop "->info." from
3691 cause references
3692 * init/tests/test_process.c (test_spawn): Likewise.
3693
Scott James Remnant77e9d342007-06-18 12:59:22 +01003694 * init/event.h (Event): Directly include the name, args and env
3695 fields rather than using an interim structure; this makes more sense
3696 since we use them differently than a match does.
3697 (EventOperatorType, EventOperator): New structure to build event
3698 expression trees that combine a match with "or" and "and" boolean
3699 operators; solve some problems by holding the reference and blocker
3700 on the matched event inside this structure directly and provide
3701 methods to unblock and reset them.
3702 (EventInfo): Drop this structure completely now that it is unused.
3703 * init/event.c (event_info_new): Rename this structure to
3704 event_operator_new() and initialise the new fields properly.
3705 (event_info_copy): Likewise rename to event_operator_copy and deal
3706 with copying event references and blockers over to the new structure,
3707 since the state is useful to copy.
3708 (event_match): Rename to event_operator_match and switch the arguments
3709 around since it makes slightly more sense that way.
3710 (event_operator_update): Function to update the value of an EVENT_OR
3711 or EVENT_AND operator based on the value of the two children.
3712 (event_operator_handle): Function to iterate an entire expression
3713 tree looking for a given event, and update the values of other
3714 operators if matched.
3715 (event_operator_unblock): Function to iterate an expression tree
3716 and release any events we're blocking.
3717 (event_operator_reset): Function to iterate an expression tree,
3718 unreferencing any events and resetting all values back to FALSE.
3719 (event_new, event_pending, event_finished): Update references to
3720 the Event structure to discard the intermediate "->info."
3721 * init/tests/test_event.c (test_info_new): Rename to
3722 test_operator_new() and test various features of the function added
3723 in the converstion.
3724 (test_info_copy): Likewise rename to test_operator_copy() and add a
3725 few more tests, especially that blockers and references are copied.
3726 (test_match): Rename to test_operator_match() and adjust argument
3727 order to match the change.
3728 (test_new) Call event_init() to avoid a valgrind error and update
3729 references to drop "->info."
3730 (test_poll): Use EventOperators in the job to test event polling,
3731 rather than the old structures.
3732 (test_operator_update, test_operator_handle, test_operator_unblock)
3733 (test_operator_reset): Test behaviour of the new functions.
3734
Scott James Remnantf050aa62007-06-13 12:37:16 +010037352007-06-13 Scott James Remnant <scott@netsplit.com>
3736
3737 * TODO: Update utmp/wtmp thoughts.
3738
Scott James Remnantf9aec8c2007-06-12 12:18:15 +010037392007-06-12 Scott James Remnant <scott@netsplit.com>
3740
Scott James Remnantdd9249d2007-06-12 15:30:19 +01003741 * init/paths.h: Remove extra /, oops.
3742 * init/Makefile.am (install-data-local): Make destination
3743 configuration directories as part of "make install".
3744 (AM_CPPFLAGS): Define LEGACY_CONFDIR to be $(sysconfdir)/event.d
3745 * logd/Makefile.am (jobs.d/logd): Replace mkdir_p with MKDIR_P
3746 * init/main.c: Use macro to pick up /etc/event.d so it can be moved
3747 by configure
3748
Scott James Remnantdc6b5e42007-06-12 14:57:14 +01003749 * TODO: Update.
3750
Scott James Remnant0b3171a2007-06-12 14:55:58 +01003751 * init/Makefile.am (AM_CPPFLAGS): Define CONFDIR to be
3752 $(sysconfdir)/init, replacing the old CFG_DIR definition.
3753 * init/paths.h (CFG_DIR): Replace with CONFDIR definition,
3754 and set the default to /etc/init
3755 * init/main.c: Load configuration from /etc/init/init.conf,
3756 /etc/init/conf.d and /etc/init/jobs.d; retain loading from /etc/event.d
3757 for the time being.
3758 * init/man/init.8: Change reference to directory.
3759 * logd/Makefile.am: Replace references of eventdir with jobsdir,
3760 and event.d with jobs.d
3761 * logd/event.d: Rename to logd/jobs.d
3762
Scott James Remnant2b8a5052007-06-12 14:49:16 +01003763 * init/conf.c (conf_reload): Ignore ENOENT, it's not interesting
3764 in the general case.
3765
Scott James Remnant018e3562007-06-12 14:47:42 +01003766 * init/tests/test_conf.c (test_source_reload): Test the general
3767 reload function.
3768
Scott James Remnant0ca92cb2007-06-12 14:37:09 +01003769 * init/tests/test_conf.c (test_source_free): s/unlink/rmdir/
3770 (test_source_reload_file): Test that configuration files work, and
3771 are parsed with anything alongside ignored automatically.
3772 * init/conf.c (conf_file_filter): As well as not filtering out the
3773 source path itself, we also need to not filter out the path we're
3774 watching which is different in the case of files; we need to know
3775 about it because we handle its removal.
3776 (conf_delete_handler): Compare the path deleted against the path
3777 we're watching, rather than the source path, since this means the
3778 watch needs to be freed.
3779
Scott James Remnantf9aec8c2007-06-12 12:18:15 +01003780 * compat/sysv/shutdown.c: Use nih pidfile functions since they're
3781 more reliable than doing it ourselves.
3782
Scott James Remnant11b08b52007-06-11 12:00:40 +010037832007-06-11 Scott James Remnant <scott@netsplit.com>
3784
Scott James Remnant7e6d3a92007-06-11 18:37:44 +01003785 * init/conf.c (conf_reload_path): Call parse_conf for mixed files
3786 and directories. Make a correction to the old_items code, was
3787 passing the wrong arguments to nih_list_add; the effect we wanted
3788 was that we add the old items head into the list, and remove the
3789 existing head (what we did was add the first item to the old_items
3790 list and then cut the rest out).
3791 * init/tests/test_conf.c (test_source_reload_dir): Rename to
3792 test_source_reload_job_dir, since that's what this does.
3793 (test_source_reload_conf_dir): Add another function that tests
3794 directories of mixed configuration.
3795
Scott James Remnantc12704a2007-06-11 17:17:22 +01003796 * init/parse_conf.c (parse_conf): Parse a configuration file that
3797 defines jobs by name.
3798 (stanza_job): Job stanza, slightly trickier than it would appear to
3799 need to be, to parse the block in-place and keep pos/lineno
3800 consistent.
3801 * init/parse_conf.h: Prototype for external function.
3802 * init/tests/test_parse_conf.c: Test suite for mixed configuration
3803 parsing.
3804 * init/Makefile.am (init_SOURCES): Build and link parse_conf.c and
3805 parse_conf.h
3806 (TESTS): Build and run parse_conf tests
3807 (test_parse_conf_SOURCES, test_parse_conf_LDFLAGS)
3808 (test_parse_conf_LDADD): Details for parse_conf test suite.
3809 (test_conf_LDADD): Add parse_conf.o and conf.o since this calls
3810 them now.
3811
Scott James Remnantc14ec862007-06-11 16:47:34 +01003812 * init/conf.c (conf_source_reload, conf_source_reload)
3813 (conf_reload_path): Add some debugging messages.
3814
Scott James Remnant142a3222007-06-11 16:22:33 +01003815 * init/conf.c (conf_source_new): Add missing call to conf_init()
3816
Scott James Remnant11b08b52007-06-11 12:00:40 +01003817 * init/conf.c (conf_item_new): Drop source parameter, since it's
3818 unused in the function and makes it harder to call this when we
3819 only have one data pointer.
3820 (conf_reload_path): Drop source from conf_item_new() call.
3821 * init/conf.h: Update prototype.
3822 * init/tests/test_conf.c (test_item_new, test_item_free)
3823 (test_file_free): Drop source parameter from calls.
3824
Scott James Remnant56760be2007-06-10 14:23:53 +010038252007-06-10 Scott James Remnant <scott@netsplit.com>
3826
Scott James Remnant7ba2cf62007-06-10 22:20:38 +01003827 * init/main.c (main): Add a handler for the SIGHUP signal
3828 (hup_handler): Handler for SIGHUP, just calls conf_reload().
3829
Scott James Remnant54b2a952007-06-10 22:15:24 +01003830 * init/main.c (main): Read the configuration again.
3831
Scott James Remnantd9619482007-06-10 22:11:42 +01003832 * TODO: Update.
3833
Scott James Remnant4b324142007-06-10 22:08:40 +01003834 * init/tests/test_conf.c (test_source_reload_dir): Reset the priority
3835 and clean up consumed inotify instances.
3836 (test_source_free, test_file_free, test_item_free): Test the free
3837 functions on their own, paying special attention to conf_item_free()
3838 even though this really duplicates other tests.
3839
Scott James Remnant4561b262007-06-10 21:43:52 +01003840 * init/conf.c (conf_reload_path): In the case where we fail to map
3841 the file into memory, we still need to purge all the items that
3842 previously existed.
3843 * init/tests/test_conf.c (test_source_reload): Rename to
3844 test_source_reload_dir, so that we can keep this and the file
3845 tests separate to make it easier to deal with.
3846 (test_source_reload_dir): Add tests for physical and parse errors
3847 when re-loading jobs with and without inotify, and for inotify-based
3848 modification handling of jobs.
3849
Scott James Remnantde27a552007-06-10 21:17:55 +01003850 * init/tests/test_conf.c (test_source_reload): Add test for walk
3851 of non-existant directory with and without inotify; also test for
3852 what happens when the top-level directory is deleted, again with
3853 and without inotify.
3854 * init/conf.c (conf_delete_handler): Handle the case of the top-level
3855 directory being deleted by freeing the watch (so next time we asked
3856 to reload, we can restore it).
3857
Scott James Remnant4ee170f2007-06-10 20:58:09 +01003858 * init/tests/test_conf.c (test_source_reload): Add a test for
3859 deletion of a running job.
3860
Scott James Remnantcf52ef72007-06-10 20:55:41 +01003861 * init/conf.c (conf_item_free): Fix this up; when deleting an item
3862 from a source, we first mark it for deletion unless it's already
3863 marked for replacement. Then if it's the replacement for something
3864 else, we mark that to be replaced by whatever we're being replaced
3865 by (so there are no references to us) and change that state if
3866 necessary. Finally we replace our own item and free the record
3867 before returning.
3868 * init/tests/test_conf.c (test_source_reload): Check that we handle
3869 the cases of modiciation of a running job, modification of a
3870 replacement of a running job and deletion of a replacement for a
3871 running job.
3872
Scott James Remnanta77229e2007-06-10 20:52:55 +01003873 * init/parse_job.c (parse_job): Instead of freeing the previous
3874 replacement, which could leave invalid references to it, mark it
3875 for deletion and change the state.
3876 * init/tests/test_parse_job.c (test_parse_job): Adjust the test so
3877 that we hold a reference to the replacement job and make sure that
3878 the state is changed to deleted, rather than checking for a destructor
3879 being called on it.
3880
Scott James Remnantf1de26c2007-06-10 20:43:16 +01003881 * init/init.supp (conf-init): Add valgrind suppression for the
3882 configuration sources hash table.
3883
Scott James Remnant11a1cf22007-06-10 17:38:06 +01003884 * init/conf.c (conf_item_free): Don't overwrite any previous
3885 replacement, only mark us for deletion if we wouldn't otherwise
3886 be replaced. Add some commented possible code for testing.
3887 * init/tests/test_conf.c (test_source_reload): Test replacement of
3888 jobs works properly; test modification with direct write and with
3889 atomic rename replace; test deletion.
3890
Scott James Remnantfa38c532007-06-10 16:49:13 +01003891 * init/conf.c (conf_reload_path): It turns out that the flag trick
3892 doesn't work for items since we often reparse them within the same
3893 file tag (it works with files because they're atomic and reparsed).
3894 Store the old items in a different list instead.
3895 (conf_source_free): We need to be careful about freeing sources,
3896 so have a function to do it properly.
3897 (conf_item_new): Since the flag member isn't useful, don't bother
3898 setting it.
3899 * init/conf.h: Add conf_source_free prototype.
3900 (ConfFile): Remove flag member.
3901 * init/tests/test_conf.c (test_source_reload): Add test for inotify
3902 create detection.
3903
Scott James Remnant79b9bde2007-06-10 15:43:18 +01003904 * init/conf.c (conf_file_delete): Rename to conf_file_free and match
3905 the pattern of those kinds of functions.
3906 (conf_item_delete): Likewise rename to conf_item_free and match the
3907 pattern of these kinds of functions.
3908 * init/conf.h: Add prototypes.
3909
Scott James Remnantdb56d502007-06-10 15:37:28 +01003910 * init/conf.c (conf_reload_path): Fix bug with job name generation.
3911 Allow non-parsing errors to be returned from the function.
3912 (conf_item_delete): Drop all replacement management code, we'll put
3913 this back through testing.
3914 * init/tests/test_conf.c (test_source_reload): Test reloading adds
3915 the right inotify watch and parses the files, also check that loading
3916 without inotify and mandatory reloading work.
3917
Scott James Remnant56760be2007-06-10 14:23:53 +01003918 * init/conf.c (conf_source_reload): Move the item deletion detection
3919 code from this function, where it would only happen on a mandatory
3920 reload
3921 (conf_reload_path): to this function, where it will happen every time
3922 the file is parsed; which is actually what we want.
3923
Scott James Remnantac1f0682007-06-08 16:04:50 +010039242007-06-08 Scott James Remnant <scott@netsplit.com>
3925
3926 * init/conf.h (ConfItem): Drop the name and replace it with a type.
3927 (ConfItemType): Enum for different types of configuration items
3928 (ConfFile): Change items from a hash table to a list.
3929 * init/conf.c (conf_file_get): Initialise the items member as a list.
3930 (conf_item_set): Rename to conf_item_new again.
3931 (conf_item_new): Allocates a new ConfItem and adds it to the file's
3932 list, we won't reuse items anymore since it doesn't really make sense.
3933 (conf_source_reload): Adjust clean-up code now that items is a list.
3934 (conf_reload_path): Work out the name of jobs found by filename,
3935 allocate a new item for them and parse the job into it. Perform
3936 handling of errors by outputting a warning.
3937 (conf_item_delete): Takes both source and file so we can make
3938 intelligent decisions.
3939 (conf_file_delete): Takes a source and passes it to conf_item_delete
3940 (conf_delete_handler): Pass both source and file to conf_file_delet
Scott James Remnantac1f0682007-06-08 16:04:50 +01003941 * init/tests/test_conf.c (test_file_get): Check that the items
3942 list is empty; rather than the hash being unallocated.
3943 (test_item_set): Rename back to test_item_new and only allocate a
3944 single item which should get added to the list.
3945
Scott James Remnant3c063422007-06-06 13:25:15 +010039462007-06-06 Scott James Remnant <scott@netsplit.com>
3947
Scott James Remnanta940d5c2007-06-06 15:45:26 +01003948 * init/parse_job.c (stanza_respawn): Permit the word "unlimited",
3949 raise a specific error for illegal limit and illegal interval.
3950 (stanza_pid, stanza_kill, stanza_normal, stanza_umask)
3951 (stanza_nice, stanza_limit): Raise specific errors rather than
3952 a generic "illegal value" error.
3953 * init/tests/test_parse_job.c (test_stanza_respawn): Check that
3954 we can use "unlimited", also check for new error return.
3955 (test_stanza_pid, test_stanza_kill, test_stanza_normal)
3956 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Check
3957 for new specific errors.
3958 * init/errors.h: Replace CFG_ILLEGAL_VALUE with a series of parse
3959 errors.
3960
Scott James Remnantd516e3a2007-06-06 13:37:45 +01003961 * init/conf.c: Comments.
3962
Scott James Remnantf5ade4a2007-06-06 13:36:24 +01003963 * init/conf.c (conf_item_set): Call out to conf_item_delete() to
3964 handle unsetting of an item's data.
3965 (conf_source_reload): Add code to deal with mandatory reloading,
3966 calls conf_file_delete() and/or conf_item_delete() as appropriate.
3967 (conf_delete_handler): Call conf_file_delete() on the ConfFile that
3968 we find.
3969 (conf_file_delete): Function to delete all items in a file.
3970 (conf_item_delete): Placeholder function to delete an item.
3971
Scott James Remnant3c063422007-06-06 13:25:15 +01003972 * init/conf.c (conf_file_new): Rename to conf_file_get; in practice
3973 we never just want to allocate one of these, we always want to
3974 return the existing entry if it exists.
3975 (conf_item_new): Rename to conf_item_set; again in practice we always
3976 want to update an existing item. This function will grow the "deal
3977 with replacement" stuff.
3978 (conf_reload): Start putting in place the code that will allow
3979 mandatory reloads, as well as initial setup. This function iterates
3980 over the sources and deals with errors.
3981 (conf_source_reload): Function to reload an individual source, calls
3982 out to one of the following two functions and will eventually perform
3983 the deleted items scan.
3984 (conf_source_reload_file): Set up a watch on a file, and reload it.
3985 (conf_source_reload_dir): Set up a watch on a directory and reload it.
3986 (conf_file_filter): Filter for watching parent directory of files.
3987 (conf_create_modify_handler): File creation and modification handler.
3988 (conf_delete_handler): File deletion handler.
3989 (conf_file_visitor): Tree walk handler.
3990 (conf_reload_path): Function that deals with files themselves,
3991 currently just sorts out the ConfFile structure and maps the file
3992 into memory.
3993 * init/conf.h: Add new prototypes, update existing ones.
3994 * init/tests/test_conf.c (test_file_new): Rename to test_file_get,
3995 also test repeated calls when already in the table.
3996 (test_item_new): Rename to test_item_set, also test repeated calls
3997 when already in the table.
3998 (test_source_reload): Start of test for reloading sources.
3999
Scott James Remnant83826412007-06-05 16:52:12 +010040002007-06-05 Scott James Remnant <scott@netsplit.com>
4001
4002 * init/conf.c: Make a start on the new configuration management
4003 routines, which will allow finer-grained tracking of configuration
4004 and support mandatory reloading.
4005 (conf_source_new, conf_file_new, conf_item_new): Start off with the
4006 functions to allocate the tracking structures we need to use.
4007 * init/conf.h: Structures and prototypes
4008 * init/tests/test_conf.c: Test suite for allocation functions.
4009 * init/Makefile.am (init_SOURCES): Build and link conf.c and conf.h
4010 (TESTS): Run the conf test suite.
4011 (test_conf_SOURCES, test_conf_LDFLAGS, test_conf_LDADD): Details for
4012 the conf test suite.
4013
Scott James Remnant1f719242007-06-04 10:14:38 +010040142007-06-04 Scott James Remnant <scott@netsplit.com>
4015
Scott James Remnant758cd3a2007-06-04 11:49:02 +01004016 * init/parse_job.c (stanza_description, stanza_author, stanza_version)
4017 (stanza_chroot, stanza_chdir, stanza_pid): Instead of erroring when
4018 the string has already been allocated, free it and replace it with the
4019 new one. Attempting to forbid duplicates is just too inconsistent,
4020 especially for the integer ones which we compare against the default;
4021 using the last one allows us to be entirely consistent.
4022 (stanza_daemon, stanza_respawn, stanza_service, stanza_instance):
4023 Don't error if the flag is already set, just ignore it.
4024 (stanza_respawn, stanza_pid, stanza_kill, stanza_console)
4025 (stanza_umask, stanza_nice): Don't compare the current value against
4026 the default, just overwrite it!
4027 (parse_exec, parse_script): Free existing process command string
4028 before setting a new one over the top.
4029 (parse_process, stanza_exec, stanza_script, stanza_limit): Instead of
4030 erroring if the structure is already set and allocated, just don't
4031 allocate a new one and allow its members to be overwritten.
4032 * init/tests/test_parse_job.c (test_stanza_exec)
4033 (test_stanza_script, test_stanza_pre_start)
4034 (test_stanza_post_start, test_stanza_pre_stop)
4035 (test_stanza_post_stop, test_stanza_description)
4036 (test_stanza_author, test_stanza_version, test_stanza_daemon)
4037 (test_stanza_respawn, test_stanza_service, test_stanza_instance)
4038 (test_stanza_pid, test_stanza_kill, test_stanza_console)
4039 (test_stanza_umask, test_stanza_nice, test_stanza_limit)
4040 (test_stanza_chroot, test_stanza_chdir): Replace tests that check
4041 for an error in the case of duplicate stanzas with tests that make
4042 sure the last of the duplicates is used.
4043 * init/errors.h (CFG_DUPLICATE_VALUE, CFG_DUPLICATE_VALUE_STR): Drop
4044 this error, since we don't consider this a problem anymore.
4045
Scott James Remnant1f719242007-06-04 10:14:38 +01004046 * upstart/Makefile.am (libupstart_la_LIBADD): Add $(LTLIBINTL)
4047 * init/Makefile.am (init_LDADD): Reorder and add $(LTLIBINTL)
4048 * util/Makefile.am (initctl_LDADD): Reorder and add $(LTLIBINTL)
4049 * compat/sysv/Makefile.am (reboot_LDADD): Reorder and add $(LTLIBINTL)
4050 (runlevel_LDADD): add $(LTLIBINTL)
4051 (shutdown_LDADD): Reorder and add $(LTLIBINTL)
4052 (telinit_LDADD): Reorder and add $(LTLIBINTL)
4053 * logd/Makefile.am (logd_LDADD): Add $(LTLIBINTL)
4054
Scott James Remnante8b584e2007-06-03 19:08:38 +010040552007-06-03 Scott James Remnant <scott@netsplit.com>
4056
Scott James Remnant48a3a942007-06-03 19:21:34 +01004057 * init/tests/test_job.c (test_run_process): Add a test case for a
4058 crasher when the event has no arguments.
4059 * init/job.c (job_run_process): Fix the bug, we need to check the
4060 arguments before trying to append them.
4061
Scott James Remnante8b584e2007-06-03 19:08:38 +01004062 * init/cfgfile.c, init/cfgfile.h, init/tests/test_cfgfile.c: Rename
4063 to parse_job and strip out all functions except the parsing and stanza
4064 ones.
4065 * init/Makefile.am (init_SOURCES): Build and link parse_job.c and h
4066 (TESTS): Run the parse job test suite
4067 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
4068 Rename and update.
4069 * init/parse_job.c: Rename all cfg_stanza_*() functions to just
4070 stanza_*(), rename all cfg_parse_*() functions to just parse_*().
4071 (parse_job, parse_process, stanza_exec, stanza_script, stanza_start)
4072 (stanza_stop, stanza_emits, stanza_normal, stanza_env, stanza_limit):
4073 Don't use NIH_MUST, it's fine to be out of memory and we should fail
4074 in that case with a useful error. The user can always reload the
4075 config file.
4076 (cfg_read_job, cfg_watch_dir, cfg_job_name, cfg_create_modify_handler)
4077 (cfg_delete_handler, cfg_visitor): Drop these functions for now.
4078 * init/parse_job.h: Update so it just contains the one prototype.
4079 * init/tests/test_parse_job.c: Update all tests to pass a string
4080 to parse_job(), and check errors raised; rather than mucking around
4081 with file descriptors all of the time. Spend the effort while we're
4082 in here to run TEST_ALLOC_FAIL where we can.
4083 * init/main.c: Drop config file loading for now since it's missing.
4084
Scott James Remnanta482d9a2007-05-27 16:57:35 +010040852007-05-27 Scott James Remnant <scott@netsplit.com>
4086
Scott James Remnante7464fd2007-06-02 11:43:11 +01004087 * init/cfgfile.h (CFG_DIR): Drop this define, since it's in paths.h
4088 (CfgDirectory):
4089
Scott James Remnanta482d9a2007-05-27 16:57:35 +01004090 * init/cfgfile.c (cfg_read_job): Separate out the job-handling code
4091 into a new function that we could call from a stanza if we want
4092 later; this one now just maps the file into memory and deals with
4093 exceptions from the parsing.
4094 (cfg_parse_job): Function containing the seperated out code; parses
4095 a new job, marking it as a replacement for any existing job with the
4096 same name. Drop the warnings for using pid options without a daemon,
4097 since these are actually useful for other things later.
4098 * init/tests/test_cfgfile.c (test_read_job): Drop the check on
4099 unexpected daemon options, since we don't issue these warnings
4100 anymore.
4101
Scott James Remnant4fa7b872007-05-20 13:09:17 +010041022007-05-20 Scott James Remnant <scott@netsplit.com>
4103
Scott James Remnant2b4e0ed2007-05-20 14:00:06 +01004104 * init/event.c (event_match): Change to accept Event as the first
4105 argument and EventInfo as the second, making it obvious that this
4106 matches a received Event against known EventInfo rather than just
4107 comparing two info structs (since the order matters).
4108 * init/event.h: Update prototype.
4109 * init/tests/test_event.c (test_match): Update test accordingly.
4110 (test_poll): Fix typo.
4111 * init/job.c (job_handle_event): Pass in the event as the first
4112 argument to event_match, rather than its info.
4113 * TODO: Update.
4114
Scott James Remnant64b5f682007-05-20 13:14:51 +01004115 * init/job.c (job_emit_event): Return the event that we emit; don't
4116 bother tracking block status or setting blocked, leave that to the
4117 state loop so things are more obvious.
4118 (job_change_state): Set the blocked flag here for starting and stopping
4119 to the return value of job_emit_event().
4120
Scott James Remnant4fa7b872007-05-20 13:09:17 +01004121 * init/event.c (event_ref, event_unref): Reference counting of events
4122 so we don't free those we still need.
4123 (event_block, event_unblock): Blocker counting that replaces the
4124 previous jobs member.
4125 (event_new): Initialise refs and blockers fields.
4126 (event_emit_finished): Remove this function.
4127 (event_poll): Handle the new done state, and deal with the blockers
4128 and references counts; turns out that we can fall all the way through
4129 this switch if these are zero without needing to check again.
4130 (event_pending): Remove call to event_emit_finished, the event_poll()
4131 loop handles this case now.
4132 (event_finished): Set progress to done on the way out.
4133 * init/event.h (EventProgress): Add new done state
4134 (Event): Add refs and blockers members, replacing jobs
4135 * init/tests/test_event.c (test_new): Check refs and blockers are
4136 initialised to zero.
4137 (test_ref, test_unref, test_block, test_unblock): Check the ref
4138 counting function behaviours.
4139 (test_emit_finished): Drop this function since it's not used
4140 * init/job.c (job_change_cause): Reference and block the event,
4141 and unblock and unreference before changing.
4142 (job_emit_event): Reference the event that blocks the job from
4143 continuing.
4144 (job_handle_event_finished): Unreference the blocking event again.
4145 (job_change_state): Make sure that blocked has been cleared before
4146 allowing a state change.
4147 * init/tests/test_job.c: Change tests to use refs/blockers on the
4148 cause event when counting, and also to follow the status of blocked
4149 since that is now ref-counted as well.
4150
Scott James Remnantfea1e9c2007-05-18 15:42:25 +010041512007-05-18 Scott James Remnant <scott@netsplit.com>
4152
Scott James Remnant186ecdc2007-05-18 20:18:17 +01004153 * init/main.c (main, cad_handler, kbd_handler, pwr_handler): Use
4154 event_new rather than event_emit.
4155 * init/job.h (Job): Change type of cause and blocked to Event
4156 * init/job.c (job_change_goal, job_change_cause, job_emit_event)
4157 (job_handle_event, job_handle_event_finished): Update all references
4158 to EventEmission to use Event instead.
4159 (job_detect_stalled): Call event_new instead of event_emit
4160 (job_run_process): Use the info member of cause, not event member
4161 * init/tests/test_job.c (test_change_goal, test_change_state)
4162 (test_run_process, test_child_reaper, test_handle_event)
4163 (test_handle_event_finished): Update all references to EventEmission
4164 to use Event instead.
4165 (test_detect_stalled): Correct to use right structure types.
4166 * init/process.c (process_setup_environment): Use cause's info member,
4167 rather than event member.
4168 * init/tests/test_process.c (test_spawn): Update to use Event.
4169 * init/notify.h (NotifySubscription): Change member to event
4170 * init/notify.c (notify_subscribe_event)
4171 (notify_subscription_find, notify_job_event, notify_event)
4172 (notify_event_finished): Update functions to use event member and
4173 Event structures.
4174 * init/tests/test_notify.c (test_subscribe_event)
4175 (test_subscription_find, test_job, test_job_event, test_event)
4176 (test_event_finished): Update to use Event instead of EventEmission
4177 * init/control.c (control_event_emit): Update to use event_new.
4178 * init/tests/test_control.c (test_event_emit)
4179 (test_subscribe_events, test_unsubscribe_events): Update to use
4180 Event rather than EventEmission.
4181
4182 * init/event.h: Fix up a few references.
4183 * init/tests/test_event.c (test_new): Remove reference to emission.
4184
Scott James Remnant3a6b7f62007-05-18 19:54:45 +01004185 * init/event.h (EventEmission): Rename to Event, and rename event
4186 member to info.
4187 * init/event.c (event_emit_next_id): Rename to event_next_id
4188 (event_emit): Rename to event_new, and add standard parent argument.
4189 (event_emit_find_by_id): Rename to event_find_by_id
4190 (event_poll): Iterate over Events in the list
4191 (event_pending, event_finished): Operate on Event
4192 * init/tests/test_event.c (test_emit): Rename to test_new and
4193 adjust for names and arguments.
4194 (test_emit_find_by_id): Rename to test_find_by_id and adjust for
4195 names.
4196 (test_emit_finished, test_poll): Adjust names.
4197
Scott James Remnant23adaa42007-05-18 19:17:42 +01004198 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
4199 (cfg_stanza_emits): Convert to use EventInfo and event_info_*.
4200 * init/job.c (job_copy): Use EventInfo and event_info_copy.
4201 (job_handle_event, job_detect_stalled): Iterate EventInfo structures
4202 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop)
4203 (test_stanza_emits): Update to use EventInfo
4204 * init/tests/test_job.c (test_copy, test_handle_event)
4205 (test_handle_event_finished, test_detect_stalled): Update to use
4206 EventInfo and event_info_new
4207 * init/event.c (event_copy): Use nih_str_array_copy here, to make the
4208 code somewhat simpler.
4209 (event_finished): Copy the arguments and environment from the old
4210 event, rather than stealing and reparenting.
4211 * init/job.c (job_copy): Use nih_str_array_copy here too.
4212 (job_run_process): Use nih_str_array_append to add the arguments from
4213 the emission onto the command run.
4214
Scott James Remnantccf3ac22007-05-18 19:17:36 +01004215 * init/event.h (Event): Rename to EventInfo, since this structure
4216 representations information about an event, rather than an actual
4217 event in progress.
4218 * init/event.c (event_new): Rename to event_info_new, also now can
4219 take arguments and environment like event_emit() can.
4220 (event_copy): Rename to event_info_copy.
4221 * init/tests/test_event.c (test_new): Rename to test_info_new,
4222 update names in test and test being given args or env.
4223 (test_copy): Rename to test_info_copy and update names in test.
4224 (test_match, test_poll): Use EventInfo.
Scott James Remnant4a558b62007-05-18 18:41:12 +01004225
Scott James Remnantfea1e9c2007-05-18 15:42:25 +01004226 * TODO: Update.
4227
Scott James Remnantc043a8a2007-04-24 12:59:54 +010042282007-04-24 Scott James Remnant <scott@netsplit.com>
4229
4230 * configure.ac: Add AM_PROG_CC_C_O since we use per-target flags
4231 for one of the test cases.
4232
Scott James Remnant0495ff82007-03-16 17:18:00 +000042332007-03-16 Scott James Remnant <scott@netsplit.com>
4234
4235 * upstart/message.c (upstart_message_newv): Add va_end to match
4236 va_copy because the standard says so.
4237 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add
4238 va_end here as well.
4239
Scott James Remnant5b78ebf2007-03-13 17:04:16 +000042402007-03-13 Scott James Remnant <scott@netsplit.com>
4241
Scott James Remnantd03c53c2007-03-13 19:13:19 +00004242 * init/main.c: Wait until we've closed inherited standard file
4243 descriptors and opened the console instead before trying to open the
4244 control socket; otherwise we end up closing it by accident if we
4245 weren't opened with sufficient descriptors in the first place.
4246 Also wait until we've set up the logger before trying to parse the
4247 configuration. In fact both of these things need to be pretty low
4248 down the main() function.
4249
Scott James Remnantdde290e2007-03-13 18:52:30 +00004250 * init/tests/test_job.c (test_run_process): Skip /dev/fd test cases
4251 if that's not available.
4252
Scott James Remnant32844192007-03-13 18:47:54 +00004253 * init/tests/test_control.c (test_log_priority): Make sure we know
4254 that the message has been sent before calling the watcher.
4255
Scott James Remnanta951cec2007-03-13 18:39:13 +00004256 * init/cfgfile.c (cfg_watch_dir): We get ENOSYS for missing inotify
4257 support, not EOPNOTSUPP.
4258 * init/tests/test_cfgfile.c (test_watch_dir): Actually make the
4259 directory tree before testing for inotify, since we use the same
4260 tree there too.
4261
Scott James Remnant7f6ac152007-03-13 18:08:31 +00004262 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
4263 name can be used uninitialised.
4264 * init/tests/test_cfgfile.c (test_watch_dir): Correct an error where
4265 i wouldn't be initialised if we skipped the inotify tests.
4266
4267 * util/initctl.c (job_info_output): Restructure so gcc doesn't think
Scott James Remnant7e5d0062007-03-13 17:27:38 +00004268 * init/process.c (process_setup_environment): job id fits inside
4269 a %u now
4270
Scott James Remnant72301022007-03-13 17:27:09 +00004271 * upstart/message.h: Style; always refer to "unsigned int" as
4272 "unsigned int", and never "unsigned.
4273 * upstart/tests/test_message.c (my_handler): Catch a stray couple
4274 of "unsigned"s
4275
Scott James Remnant25a71542007-03-13 17:25:34 +00004276 * init/control.c (control_job_query, control_job_start)
4277 (control_job_stop): Change type of id argument to unsigned int,
4278 and call printf with %u to output it.
4279 * init/tests/test_control.c (check_job, check_job_instance)
4280 (check_job_instance_end, check_job_status__waiting)
4281 (check_job_status_end__waiting, check_job_status__starting)
4282 (check_job_status_end__starting, check_job_status__running)
4283 (check_job_status_end__running, check_job_status__pre_stop)
4284 (check_job_status_end__pre_stop, check_job_status__stopping)
4285 (check_job_status_end__stopping, check_job_status__deleted)
4286 (check_job_status_end__deleted, check_job_unknown)
4287 (check_job_invalid, check_job_unchanged, check_event): Change
4288 type of id arguments to unsigned int.
4289 (check_list): Change type of id to unsigned int.
4290 * init/tests/test_notify.c (check_job_status)
4291 (check_job_status_end, check_job_finished, check_event)
4292 (check_event_caused, check_event_finished): Change type of id
4293 arguments to unsigned int.
4294
Scott James Remnant4e7af0c2007-03-13 17:20:20 +00004295 * init/job.h (Job): Change the type of the id to unsigned int.
4296 * init/job.c (job_next_id): Change ids to be unsigned ints, and now
4297 we can just use %u in the nih_error call.
4298 (job_find_by_id): Change argument to be unsigned int
4299 * init/tests/test_job.c (test_find_by_id): Change id type to unsigned
4300 int.
4301 * init/event.h (Event): Change the type of the id to unsigned int.
4302 * init/event.c (event_emit_next_id): Change ids to be unsigned ints,
4303 and now we can just use %u in the nih_error call.
4304 (event_emit_find_by_id): Change argument to be unsigned int
4305 * init/tests/test_event.c (test_emit, test_emit_find_by_id)
4306 (check_event, check_event_finished): Change id type to unsigned int.
4307
Scott James Remnant8de2c532007-03-13 17:14:27 +00004308 * util/initctl.c (output_name): Use an unsigned int for the job id,
4309 which means we can use ordinary %u for the printf argument.
4310 (handle_job, handle_job_finished, handle_job_instance)
4311 (handle_job_instance_end, handle_job_status)
4312 (handle_job_status_end, handle_job_unknown, handle_job_invalid)
4313 (handle_job_unchanged, handle_event, handle_event_caused)
4314 (handle_event_finished): Change argument type of id from uint32_t
4315 to unsigned int.
4316 (job_info_output): Change output type of id from %zu to %u
4317
Scott James Remnant92406412007-03-13 17:10:40 +00004318 * upstart/message.c (upstart_message_handle): Use unsigned int for
4319 ids, rather than a fixed-width type.
4320 * upstart/tests/test_message.c (my_handler): Use unsigned int for
4321 the ids, and give "unsigned int" instead of "unsigned" to va_arg as
4322 a matter of style.
4323
Scott James Remnant5b78ebf2007-03-13 17:04:16 +00004324 * upstart/wire.c (upstart_push_int, upstart_pop_int): Send over the
4325 wire using a plain old integer type, instead of a fixed width type;
4326 there's no advantage to using the fixed-width type and we could hurt
4327 ourselves if we tried running on ILP64.
4328 (upstart_push_unsigned, upstart_pop_unsigned): Likewise use a plain
4329 unsigned int over the wire.
4330 (upstart_push_string, upstart_pop_string): Use an unsigned int for
4331 the length of the string, technically this means that we silently
4332 truncate any string that's greater than 4GB on 64-bit platforms;
4333 it's either that or make the test cases harder (we did this before
4334 anyway).
4335 (upstart_push_header, upstart_pop_header): Type is always an unsigned
4336 int (best conversion from an enum)
4337
Scott James Remnant57f02a72007-03-11 12:53:49 +000043382007-03-11 Scott James Remnant <scott@netsplit.com>
4339
Scott James Remnantfc7e60d2007-03-11 19:13:41 +00004340 * configure.ac: Bump version to 0.3.9
4341
Scott James Remnant7c862ed2007-03-11 19:13:24 +00004342 * NEWS: Update.
4343
Scott James Remnant2bc5c5e2007-03-11 19:01:57 +00004344 * util/man/initctl.8: Document the new commands.
4345
Scott James Remnantd055a9d2007-03-11 17:58:15 +00004346 * TODO: Update.
4347
Scott James Remnant19198252007-03-11 17:57:34 +00004348 * init/job.c (job_handle_event): Correct the function so we don't
4349 try and stop the master of an instance, and cause an assertion error.
4350
Scott James Remnantbea9e8d2007-03-11 17:41:58 +00004351 * util/initctl.c: Oops, correct function pointers in command table
4352
4353 * util/tests/test_initctl.c (test_version_action):
4354
Scott James Remnant509f8a62007-03-11 17:39:27 +00004355 * util/initctl.c (handle_version): Handle receipt of the version
4356 reply.
4357 (version_action): Send the version-query message to the server and
4358 expect one response.
4359 (log_priority_action): Parse the single argument into an NihLogLevel
4360 and send it to the server.
4361
Scott James Remnantae1927e2007-03-11 13:45:13 +00004362 * init/control.c (control_version_query, control_log_priority):
4363 Functions to handle the new messages from the server pov
4364 * init/tests/test_control.c (test_version_query)
4365 (test_log_priority): Test the new messages are handled properly.
4366 (check_version): Check the version string matches.
Scott James Remnantebeb2b62007-03-11 13:33:36 +00004367 * upstart/message.h: Add messages for querying the version of the
4368 init daemon and changing the log priority.
4369 * upstart/message.c (upstart_message_newv)
4370 (upstart_message_handle): Marshal the new messages.
4371 * upstart/tests/test_message.c (test_new, my_handler)
4372 (test_handle): Test the marshalling of the new messages,
4373
Scott James Remnant57312ad2007-03-11 12:55:32 +00004374 * upstart/libupstart.ver: Add enum functions to the global list.
4375
Scott James Remnant57f02a72007-03-11 12:53:49 +00004376 * util/initctl.c (start_action, stop_action): Imply --no-wait if
4377 we take the job id or name from an environment variable, since we'd
4378 end up waiting for ourselves otherwise
4379 * util/tests/test_initctl.c (test_start_action, test_stop_action):
4380 Update test cases to make sure no-wait is implied.
4381
Scott James Remnantcd84c312007-03-09 12:51:31 +000043822007-03-09 Scott James Remnant <scott@netsplit.com>
4383
Scott James Remnantb1c7eb22007-03-09 21:35:52 +00004384 * configure.ac: Bump version to 0.3.8
4385
Scott James Remnant79a3c9a2007-03-09 21:35:31 +00004386 * NEWS: Updated.
4387 * configure.ac: Increase version to 0.3.7
4388
Scott James Remnantcf8ede02007-03-09 19:56:07 +00004389 * init/tests/test_job.c (test_change_state): Add a test case for
4390 deleting the last instance of a replaced job.
4391 * init/job.c (job_change_state): When moving a instance of a job into
4392 the deleted state, check whether we should replace the job it's an
4393 instance of, and if so, change that job's state too.
4394 * TODO: Update.
4395
Scott James Remnant51881912007-03-09 18:15:58 +00004396 * util/initctl.c (handle_job_list): Always allocate current_list,
4397 since we need it to be the parent of pointers we attach to it.
4398 (handle_job_list_end): Always free the current list, only suppress
4399 output if there aren't any entries in it.
4400 (initctl_recv): Check the current_list pointer, no need for in_list
4401 (handle_job_instance, handle_job_instance_end, handle_job_status):
4402 Check current_list not in_list.
4403 * util/tests/test_initctl.c: Correct some memory leaks.
4404
Scott James Remnant46390a72007-03-09 17:38:35 +00004405 * init/process.c (process_setup_environment): Set the UPSTART_JOB_ID
4406 environment variable to the job's unique id.
4407 * init/tests/test_process.c (test_spawn): Make sure it's set.
4408
Scott James Remnant671c31c2007-03-09 17:34:34 +00004409 * util/man/initctl.8: Update the initctl manpage.
4410 * compat/sysv/man/reboot.8: Correct a minor grammar error.
4411 * compat/sysv/man/shutdown.8: Fix reference from runlevel to telinit.
4412
Scott James Remnantecf322c2007-03-09 16:58:48 +00004413 * README: Add a README that copies the text from the web page and
4414 adds some notes about recommended operating system versions.
4415
Scott James Remnant4f19cb92007-03-09 16:48:41 +00004416 * util/initctl.c: Completely rewrite initctl, top to bottom; handling
4417 of the new messages is done natively, meaning that the commands just
4418 vary the requests send and number of responses expected.
4419 * util/tests/test_initctl.c: Test all of the new code.
4420
Scott James Remnant06abbec2007-03-09 13:02:38 +00004421 * init/main.c: Improve restarting and rescuing a little; store the
4422 program path in a static variable so we can always access it, and
4423 use the exported loglevel to pass the same to the new process.
4424 * TODO: Update.
4425
Scott James Remnantcd84c312007-03-09 12:51:31 +00004426 * compat/sysv/shutdown.c: More error/fatal adjustments.
4427 * compat/sysv/telinit.c: More error/fatal adjustments.
4428
Scott James Remnantab1dd0d2007-03-08 12:29:02 +000044292007-03-08 Scott James Remnant <scott@netsplit.com>
4430
Scott James Remnant31421b72007-03-08 23:53:05 +00004431 * init/main.c (main, crash_handler): Promote deadly errors to nih_fatal
4432 * logd/main.c (main): Promote deadly errors to nih_fatal
4433 * compat/sysv/reboot.c (main): Promote deadly errors to nih_fatal
4434 * compat/sysv/shutdown.c (main, shutdown_now): Promote deadly errors
4435 to nih_fatal
4436 * compat/sysv/telinit.c (main): Promote deadly errors to nih_fatal
4437
Scott James Remnant12d741e2007-03-08 23:39:59 +00004438 * init/event.c (event_pending): The message that we're handling an
4439 event should be logged with --verbose.
4440
Scott James Remnant5cf17ea2007-03-08 15:42:32 +00004441 * init/cfgfile.c (cfg_parse_script): Remove the unnecessary check for
4442 a token inside a script block.
4443
Scott James Remnant3ee512d2007-03-08 14:30:21 +00004444 * TODO: Update.
4445
Scott James Remnant9435b8b2007-03-08 14:22:45 +00004446 * init/control.c (control_watch_jobs): Rename to control_subscribe_jobs
4447 and update to handle new event name.
4448 (control_unwatch_jobs): Rename to control_unsubscribe_jobs and update
4449 to handle the new event name.
4450 (control_watch_events): Rename to control_subscribe_events and update
4451 to handle the new event name.
4452 (control_unwatch_events): Rename to control_unsubscribe_events and
4453 update to handle the new event name.
4454 * init/tests/test_control.c (test_watch_jobs): Rename to
4455 test_subscribe_jobs and update to new event name.
4456 (test_unwatch_jobs): Rename to test_unsubscribe_jobs and update to
4457 new event name.
4458 (test_watch_events): Rename to test_subscribe_events and update to
4459 new event name.
4460 (test_unwatch_events): Rename to test_unsubscribe events and update
4461 to new event name.
4462
4463 * upstart/message.h: Rename the watch commands to subscribe/unsubscribe
4464 and regroup with new message numbers.
4465 * upstart/message.c (upstart_message_newv)
4466 (upstart_message_handle): Marshal the updated subscription messages.
4467 * upstart/tests/test_message.c (test_new, my_handler)
4468 (test_handle): Update tests to new names and numbers.
4469 * TODO: Update.
4470
Scott James Remnant47d4b8b2007-03-08 13:24:59 +00004471 * upstart/message.c (upstart_message_handle): Raise a the unknown
4472 message error if the type is unknown, rather than the invalid message
4473 error.
4474 * upstart/tests/test_message.c (test_handle): Correct test case.
4475
Scott James Remnant05345162007-03-08 12:37:09 +00004476 * init/job.c (job_change_state): Correct a problem here too, when
4477 moving from pre-stop to running, we don't want to emit a started event
4478 since we never emitted a stopping event and never killed the process
4479 anyway. We do need to notify the job as finished, since the process
4480 that tried to stop it will need to be told not to wait any longer.
4481 * init/tests/test_job.c (test_change_state): Add a test for pre-stop
4482 back to running.
4483
Scott James Remnantab1dd0d2007-03-08 12:29:02 +00004484 * doc/states.dot: Fix an error in the state diagram; when moving from
4485 starting back to waiting, due to a failed respawn, we need to emit
4486 the stopped event otherwise it will never happen.
4487 * doc/states.png: Update.
4488
Scott James Remnant609b24e2007-03-05 12:05:20 +000044892007-03-05 Scott James Remnant <scott@netsplit.com>
4490
Scott James Remnantfd5609b2007-03-05 20:48:06 +00004491 * upstart/message.c (upstart_message_new): Make this a wrapper around
4492 (upstart_message_newv): which has all the old code, but accepts a
4493 va_list instead of making its own.
4494 * upstart/message.h: Add prototype.
4495
Scott James Remnant502ea702007-03-05 20:47:18 +00004496 * init/main.c (crash_handler): Simply trying to leave a SEGV handler
4497 doesn't work so well, we end up repeating the problem instruction.
4498 We really can't resume from this point, and can't even jump elsewhere
4499 since our state is probably buggered up. Only thing for it is to
4500 re-exec ourselves with a clean state.
4501
Scott James Remnantb27ad2e2007-03-05 20:45:04 +00004502 * init/cfgfile.c (cfg_read_job, cfg_delete_handler): Don't try and
4503 free the magic (void *)-1 replacement (delete).
4504
Scott James Remnant4cd63672007-03-05 16:15:39 +00004505 * util/events.c, util/events.c, util/jobs.c, util/jobs.h: With the
4506 new message responses, that intermix event and job information freely,
4507 it no longer makes sense to distinguish between them. So fold these
4508 files back into the main initctl.c
4509 * util/initctl.h: Drop unused header.
4510 * util/Makefile.am (initctl_SOURCES): Update sources list.
4511 (TESTS): Change which tests we build
4512 (test_initctl_SOURCES, test_initctl_CFLAGS, test_initctl_LDFLAGS)
4513 (test_initctl_LDADD): Build the new combined test case binary, use
4514 an automake feature to rebuild initctl.c with -DTEST and a different
4515 .o file, and thus be able to define out main()
4516
4517 * util/tests/test_events.c, util/tests/test_jobs.c: Collapse the two
4518 test case files into one single
4519 * util/tests/test_initctl.c
4520
Scott James Remnant751245c2007-03-05 14:35:09 +00004521 * init/control.c (control_job_find): And implement the find function
4522 that returns a list of jobs matching an optional pattern.
4523 * init/tests/test_control.c: Make sure we do send all messages.
4524 (check_list): Complex function to check the responses to a job list
4525 (test_job_find): Test a couple of job lists.
4526 * init/tests/test_notify.c: Make sure we do send all messages.
4527
Scott James Remnant4ea9ddd2007-03-05 13:33:55 +00004528 * init/control.c (control_job_query): Implement the query message,
4529 this just needs to return the status or instance set.
4530 * init/tests/test_control.c (test_job_query): Test the query command.
4531 (check_job_status__deleted, check_job_status_end__deleted): Pair of
4532 functions to check we can query deleted jobs directly.
4533
Scott James Remnanteca04df2007-03-05 13:18:00 +00004534 * init/control.c (control_send_instance): Function to send an instance
4535 job, collating all of its instances together.
4536 * init/control.h: Update.
4537 * init/tests/test_control.c (test_send_instance): Check we receive
4538 the right messages.
4539 (check_job_instance, check_job_instance_end): Pair of functions to
4540 check the instance messages.
4541
Scott James Remnantd62b9042007-03-05 13:04:02 +00004542 * upstart/message.h: Add new UPSTART_JOB_INSTANCE and
4543 UPSTART_JOB_INSTANCE_END messages which we'll use to communicate that
4544 a job is an instance, and group the instances of it together.
4545 * upstart/message.c (upstart_message_new, upstart_message_handle):
4546 Marshal the new instance messages.
4547 * upstart/tests/test_message.c (test_new, my_handler)
4548 (test_handle): Test the new message types.
4549
Scott James Remnant609b24e2007-03-05 12:05:20 +00004550 * upstart/message.h: Restore arguments to JOB_LIST, but rename to
4551 pattern since that's what it is.
4552 * upstart/message.c (upstart_message_handle): Restore arguments
4553 with updated name.
4554 * upstart/tests/test_message.c (test_new, my_handler)
4555 (test_handle): Restore tests for arguments, rename and make sure we
4556 include a wildcard.
4557
Scott James Remnantf1091d12007-03-04 01:09:16 +000045582007-03-04 Scott James Remnant <scott@netsplit.com>
4559
Scott James Remnantbfb31a12007-03-04 20:52:43 +00004560 * upstart/message.h: Drop arguments to JOB_LIST.
4561 * upstart/message.c (upstart_message_new, upstart_message_handle):
4562 Drop arguments to JOB_LIST.
4563 * upstart/tests/test_message.c (test_new, my_handler)
4564 (test_handle): Drop the arguments from the test.
4565
Scott James Remnant117e16c2007-03-04 20:17:25 +00004566 * init/control.c (control_job_start): Update to return INVALID for
4567 instances and replacements; add the forgotten UPSTART_JOB message.
4568 (control_job_stop): Update to return INVALID for replacements; add
4569 the forgotten UPSTART_JOB message. Deal with instance masters
4570 magically by iterating all instances and stopping those instead.
4571 * init/tests/test_control.c (check_job_deleted): Rename to
4572 check_job_invalid and check that message.
4573 (check_job): Function to check the job we've acted upon.
4574 (test_job_start): Check that we get the UPSTART_JOB message first,
4575 restore the check on deleted jobs causing an error and add checks
4576 that instance and replacement jobs also cause an error.
4577 (test_job_stop): Check that we get the UPSTART_JOB message first,
4578 restore the check on deleted jobs causing an error. Make sure
4579 instances are handled.
4580
Scott James Remnant510b8082007-03-04 19:54:56 +00004581 * upstart/message.h: More message changes; add a JOB_FIND message
4582 and replace UPSTART_JOB_DELETED with UPSTART_JOB_INVALID since there's
4583 a few more problem conditions.
4584 * upstart/message.c (upstart_message_new, upstart_message_handle):
4585 Marshal the new message and update names.
4586 * upstart/tests/test_message.c (test_new, my_handler)
4587 (test_handle): Update tests to check the new message and update the
4588 values and names of the existing ones.
4589
Scott James Remnanta7e3bf12007-03-04 19:39:32 +00004590 * init/job.h (Job): Remove the delete flag, add replacement and
4591 replacement_for pointers instead.
4592 * init/job.c (job_new): Initialise replacement and replacement_for
4593 pointers to NULL.
4594 (job_find_by_name): Update to return what job the one we found is
4595 a replacement for, and to skip DELETED jobs.
4596 (job_instance): Make it simply illegal to call this for deleted jobs,
4597 instances or replacements.
4598 (job_change_goal): Make it illegal to change the goal of a replacement
4599 job.
4600 (job_free_deleted): Remove the previous code to handle deleted instance
4601 masters, because it's now bogus.
4602 (job_should_replace): New function to determine whether a job is
4603 replaceable.
4604 * init/tests/test_job.c (test_new): Check pointers are set.
4605 (test_copy): Check that replacement and replacement_for are not
4606 copied, since their state of an individual job.
4607 (test_find_by_name): Update tests to make sure we ignore deleted jobs,
4608 instances and replacements.
4609 (test_instance): Remove test that will now cause an assertion,
4610 and no longer check delete is set.
4611 (test_change_goal): Remove test that will now cause an assertion.
4612 (test_free_deleted): Remove test cases for deleted masters.
4613 (test_should_replace): Test the new check function.
4614 (test_change_state): Make sure that we end up in deleted for instances
4615 and replaced jobs, and that replacements become the real job.
4616 * init/cfgfile.c (cfg_read_job): Update to handle replacement jobs;
4617 the old job's previous replacement is discarded, and set to the
4618 current job; and then if the job should be replaced, it's moved
4619 to deleted (which should promote the new job).
4620 (cfg_delete_handler): Handle deletion of a job in a similar manner,
4621 except we sent the replacement pointer to the special -1 value since
4622 we have no actual replacement.
4623 * init/tests/test_cfgfile.c (test_watch_dir): Update tests to make
4624 sure that deletion and modification are handled wrt replacement.
4625 (test_read_job): Make sure that reparsing an existing file is handled.
4626 * init/tests/test_control.c (test_job_start): Remove checks that
4627 delete gets set to true for instances.
4628 (test_job_stop, test_job_start): Temporarily comment out deleted
4629 job behaviour, since that's been somewhat changed.
4630
Scott James Remnantffcbc5f2007-03-04 17:34:38 +00004631 * upstart/message.h: We're not going to return JOB_LIST for JOB_STOP
4632 since that's just awkward for the client; just act on the master,
4633 and return JOB_UNCHANGED.
4634
Scott James Remnant78dce1d2007-03-04 17:04:28 +00004635 * init/notify.c (notify_job_status): Move this function to
4636 * init/control.c (control_send_job_status): here, since we need it for
4637 the new control responses.
4638 (control_job_query): New single function to list all jobs or a
4639 particular job.
4640 * init/control.h: Add prototype.
4641 * init/tests/test_control.c (test_error_handler): Simplify this a
4642 little to just sending a NO_OP message, since we can send an entire
4643 stream of messages and leave them in the queue.
4644 (check_job_status__stopping, check_job_process)
4645 (check_job_status_end__stopping): Trio of check functions for a job
4646 status that's stopping, with an active main process.
4647 (test_send_job_status): Test the now global status function.
4648 (check_job_status__starting, check_job_status_end__starting): Pair
4649 of check functions for a starting job with no process yet.
4650 (test_watch_jobs, test_unwatch_jobs): Update to expect the full new
4651 job status messages, with an optional process part as well.
4652 (check_event): Function to check an event.
4653 (test_watch_events): Minor update to use above function.
4654 (check_job_status__waiting, check_job_status_end__waiting): Pair of
4655 check functions for the first step in starting a job (goal change only)
4656 (check_job_unknown, check_job_deleted, check_job_unchanged): Trio
4657 of functions to check common error responses.
4658 (test_job_start): Update tests to newer behaviour.
4659 (check_job_status__running, check_job_status_end__running)
4660 (check_job_status__pre_stop, check_job_status_end__pre_stop): Checks
4661 for the states we go through when stopping a job.
4662 (test_job_stop): Update tests to newer behaviour.
4663 * init/notify.c (notify_job, notify_job_event, notify_job_finished):
4664 Update to call the newly exported function.
4665 * init/job.c: Make job_id and job_id_wrapped externally available.
4666 * init/job.h: Update.
4667 * init/event.c: Make emission_id and emission_id_wrapped externally
4668 available.
4669 * init/event.h: Update.
4670
Scott James Remnanta90e6422007-03-04 14:41:05 +00004671 * upstart/message.h: Rename UPSTART_JOB_INVALID to
4672 UPSTART_JOB_UNCHANGED, as it's not really invalid just a no-op
4673 * upstart/message.c (upstart_message_new, upstart_message_handle):
4674 Update the constant, fields are unchanged,
4675 * upstart/tests/test_message.c (test_new, my_handler)
4676 (test_handle): Rename constants/messages.
4677
Scott James Remnant82626a92007-03-04 14:37:12 +00004678 * upstart/message.h: Turns out we need extra errors to indicate that
4679 the job was deleted or already at that goal, otherwise the client
4680 would sit there waiting for the finished event.
4681 * upstart/message.c (upstart_message_new, upstart_message_handle):
4682 Marshal the new error messages.
4683 * upstart/tests/test_message.c (test_new, my_handler)
4684 (test_handle): Test the handling of the new messages.
4685
Scott James Remnantd39165c2007-03-04 14:27:41 +00004686 * init/tests/test_job.c (test_free_deleted): Found a bug; because
4687 master instances never change state, they never end up in the deleted
4688 state so are never reaped. Add some test cases for cleaning them up,
4689 but not while they have remaining instances.
4690 * init/job.c (job_free_deleted): Implement the bug fix.
4691
Scott James Remnantd3cbc562007-03-04 14:18:36 +00004692 * init/job.c (job_instance): Split out the instance spawning code
4693 into its own function, as we'll frequently need a pointer to the
4694 instance before we try and change the goal.
4695 (job_change_goal): Clean this function back up again, it no longer
4696 needs to return values and can assert that it's never called for
4697 deleted jobs or instance mastersr.
4698 (job_handle_event): Spawn an instance when we get a start event.
4699 * init/job.h: Update.
4700 * init/tests/test_job.c (test_instance): Check instance creation.
4701 (test_change_goal): Update tests now that it doesn't return a value
4702 again, and doesn't spawn instances itself.
4703 (test_handle_event): Make sure instances are spawned.
4704
Scott James Remnant5bcc62b2007-03-04 13:27:15 +00004705 * init/tests/test_event.c (test_poll): Needs a slight fix now that
4706 we generate more events than we check, and that subscriptions go
4707 away automatically.
4708
Scott James Remnantb844efb2007-03-04 13:00:06 +00004709 * init/notify.c (notify_job_status): Static function to handle
4710 sending the more complicated job status message series
4711 (notify_job): Call notify_job_status() to send the new-style message
4712 (notify_job_event): Send the new UPSTART_EVENT_CAUSED message with
4713 the emission id, then call notify_job_status() to send the new-style
4714 common status message.
4715 (notify_job_finished): New function to be called when we reach the
4716 job rest state, notifies and unsubscribes directly subscribed
4717 processes, and includes failed information.
4718 (notify_event_finished): Unsubscribe processes after sending the
4719 finished event, since the event has gone away. Also don't send
4720 this to processes subscribed to all events, since it's not useful
4721 for them.
4722 * init/notify.h: Add prototype.
4723 * init/tests/test_notify.c: Update all test cases and helper
4724 functions to the new message types.
4725 (test_job_finished): Check the new finished message is sent with
4726 a status message preceeding it.
4727 * init/job.c (job_change_state, job_change_state): Notify subscribed
4728 processes with notify_job_finished() when in the running (for service)
4729 or waiting states, just before we drop the cause.
4730
Scott James Remnant79c95ff2007-03-04 12:30:37 +00004731 * upstart/message.h: Add failed, failed_process and exit_status
4732 arguments to UPSTART_JOB_FINISHED.
4733 * upstart/message.c (upstart_message_new, upstart_message_handle):
4734 Marshal the new arguments.
4735 * upstart/tests/test_message.c (test_new, my_handler)
4736 (test_handle): Test the new arguments.
4737
Scott James Remnantf1091d12007-03-04 01:09:16 +00004738 * upstart/message.h: Update the message types, introducing a more
4739 structured job message set and replacing the UPSTART_EVENT_JOB_STATUS
4740 message with UPSTART_EVENT_CAUSED which will be immediately followed
4741 by an ordinary UPSTART_JOB_STATUS message.
4742 * upstart/message.c (upstart_message_new, upstart_message_handle):
4743 Marshal the new messages.
4744 * upstart/tests/test_message.c (test_new, my_handler)
4745 (test_handle): Test the new message types.
4746 * TODO: Update.
4747
Scott James Remnant15538792007-03-03 15:30:23 +000047482007-03-03 Scott James Remnant <scott@netsplit.com>
4749
Scott James Remnantcd157612007-03-03 17:09:09 +00004750 * TODO: Update.
4751
Scott James Remnant8568a062007-03-03 17:06:43 +00004752 * init/cfgfile.c (cfg_parse_exec, cfg_parse_script): Separate out
4753 the parsing of an exec or script stanza into separate functions,
4754 seeing as this is quite a common operation. This also means we
4755 just need to change them in one place now.
4756 (cfg_parse_process): Function to call either of the above depending
4757 on the next argument.
4758 (cfg_stanza_exec): Call cfg_parse_exec instead.
4759 (cfg_stanza_script): Call cfg_parse_script instead.
4760 (cfg_stanza_pre_start, cfg_stanza_post_start)
4761 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Call cfg_parse_process
4762 with the right arguments instead of doing by hand in each function.
4763
Scott James Remnant15538792007-03-03 15:30:23 +00004764 * init/event.c (event_emit_next_id): Split the id assigning code into
4765 a static inline function for easier modification.
4766 * init/job.c (job_next_id): Use the same style function here too.
4767
Scott James Remnant3d39c7d2007-03-02 10:50:14 +000047682007-03-02 Scott James Remnant <scott@netsplit.com>
4769
Scott James Remnant9c7a9112007-03-02 17:08:46 +00004770 * init/event.c (event_emit): Port the slightly more efficient in the
4771 early case code from job_new.
4772
Scott James Remnantb61f5932007-03-02 17:06:44 +00004773 * init/job.h (Job): Add a unique id to the job structure.
4774 * init/job.c (job_new): Assign an incrementing id to each new job
4775 allocated.
4776 (job_find_by_id): Locate a job by its unique id, sadly not very
4777 efficient in a hash table ;-)
4778 (job_name): New hash key function since name isn't the first entry
4779 anymore.
4780 (job_init): Change hash key function.
4781 * init/tests/test_job.c (test_find_by_id): Make sure we can find a
4782 job by its id.
4783
Scott James Remnant5e453162007-03-02 16:27:57 +00004784 * init/job.c (job_change_goal): Return the new instance in that
4785 circumstance, and clean up a little bit.
4786 * init/job.h: Update prototype.
4787 * init/tests/test_job.c (test_change_goal): Update tests.
4788
Scott James Remnant3caa9f42007-03-02 15:09:34 +00004789 * init/job.c (job_find_by_name): Skip jobs marked for deletion too.
4790 * init/tests/test_job.c (test_find_by_name): Update test case.
4791
Scott James Remnant0720acf2007-03-02 14:58:27 +00004792 * init/event.h, init/notify.h, upstart/message.h: Provide C-level names
4793 for enums, this makes the compiler generate things that gdb can get.
4794
Scott James Remnantf60ee622007-03-02 13:13:11 +00004795 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
4796 Change process argument to be a plain ProcessType, this means we
4797 know exactly which process we're trying to run or kill.
4798 (job_change_state): Update calls to job_run_process
4799 and job_kill_process
4800 * init/tests/test_job.c (test_run_process, test_kill_process): Update
4801 function calls to just pass a ProcessType in.
4802
Scott James Remnantdb61ca82007-03-02 13:02:42 +00004803 * upstart/enum.h: Rename JobAction to ProcessType.
4804 * upstart/enum.c (job_action_name): Rename to process_name.
4805 (job_action_from_name): Rename to process_from_name.
4806 * upstart/tests/test_enum.c (test_action_name, test_action_from_name):
4807 Rename and update to match.
4808 * init/job.c (job_new, job_copy, job_change_state)
4809 (job_next_state): Change JOB_*_ACTION constants to PROCESS_*.
4810 (job_find_by_pid): Change JobAction argument to ProcessType.
4811 (job_emit_event): Call process_name on the failed process.
4812 (job_child_reaper): Update to use ProcessType instead of JobAction.
4813 * init/job.h (Job): Change type of failed_process to ProcessType.
4814 * init/tests/test_job.c (test_find_by_pid): Update to use ProcessType
4815 instead of JobAction in tests.
4816 (test_new, test_copy, test_change_goal, test_change_state)
4817 (test_next_state, test_run_process, test_kill_process)
4818 (test_child_reaper, test_handle_event_finished): Change JOB_*_ACTION
4819 constants to PROCESS_*
4820 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
4821 (cfg_stanza_pre_start, cfg_stanza_post_start)
4822 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Change JOB_*_ACTION
4823 constants to PROCESS_*
4824 * init/tests/test_cfgfile.c (test_stanza_exec)
4825 (test_stanza_script, test_stanza_pre_start)
4826 (test_stanza_post_start, test_stanza_pre_stop)
4827 (test_stanza_post_stop, test_read_job, test_watch_dir): Change
4828 JOB_*_ACTION constants to PROCESS_*
4829 * init/tests/test_event.c (test_poll): Change JOB_*_ACTION constants
4830 to PROCESS_*
4831 * init/tests/test_control.c (test_job_start, test_job_stop): Change
4832 JOB_*_ACTION constants to PROCESS_*
4833
Scott James Remnant4a104b52007-03-02 12:21:45 +00004834 * init/cfgfile.c (cfg_watch_dir): Restore the prefix argument; pass
4835 as the data pointer to the inotify callbacks and visitor function.
4836 Change the return value to be the watch structure.
4837 (cfg_job_name): Add prefix argument and prepend to relative path.
4838 (cfg_create_modify_handler, cfg_delete_handler, cfg_visitor): Get
4839 the prefix for the job names from the data pointer and pass to
4840 cfg_job_name().
4841 * init/cfgfile.h: Update prototypes.
4842 * init/tests/test_cfgfile.c (test_watch_dir): Actually test the
4843 watch functions.
4844 * init/main.c (main): Pass NULL for the prefix for the global job
4845 directory, compare the return value against (void *)-1.
4846 * TODO: Update.
4847
Scott James Remnant002dcda2007-03-02 11:05:56 +00004848 * init/cfgfile.c (cfg_stanza_on): Drop the simple on stanza.
4849 * init/tests/test_cfgfile.c (test_stanza_on): Remove test case.
4850
Scott James Remnant3d39c7d2007-03-02 10:50:14 +00004851 * TODO: Update.
4852
Scott James Remnantbc1ebc02007-03-01 12:27:09 +000048532007-03-01 Scott James Remnant <scott@netsplit.com>
4854
Scott James Remnant75914fd2007-03-01 19:05:45 +00004855 * util/jobs.c (handle_job_status): Drop the process field from the
4856 output for now.
4857 * util/events.c (handle_event_job_status): Likewise
4858 * util/tests/test_jobs.c (test_start_action, test_list_action)
4859 (test_jobs_action): Drop pid from messages we simulate.
4860 * util/tests/test_events.c (test_emit_action): Likewise.
4861
Scott James Remnant0c68cc12007-03-01 18:53:23 +00004862 * upstart/message.c (upstart_message_new, upstart_message_handle):
4863 Remove the pid field from the job status and event job status
4864 messages.
4865 * upstart/message.h: Update description of job status and event
4866 job status message to remove the pid field.
4867 * upstart/tests/test_message.c (test_new, my_handler)
4868 (test_handle): Remove checks using the pid field.
4869
Scott James Remnantd134fe82007-03-01 18:46:53 +00004870 * init/control.c (control_job_start, control_job_stop)
4871 (control_job_query, control_job_list): Remove the pid field from
4872 the messages, it'll come back later when we get better message
4873 formats.
4874 * init/tests/test_control.c (check_job_status, check_job_waiting)
4875 (check_job_started, check_job_stopped): Remove checks on the process
4876 id, since that field is gone from the message.
4877 (test_job_stop): Use the pid field of the main process.
4878 (test_job_start): Initialise the main action process.
4879
Scott James Remnantdd1a6742007-03-01 18:42:42 +00004880 * init/notify.c (notify_job, notify_job_event): Remove the pid field
4881 from the message, it'll come back later when we get better message
4882 formats.
4883 * init/tests/test_notify.c (check_job_status)
4884 (check_event_job_status): Remove checks on the pid, since that field
4885 is no longer present.
4886
Scott James Remnante2ce6372007-03-01 18:37:53 +00004887 * init/job.c (job_process_copy): Use job_process_new here, oops.
4888
Scott James Remnant8ed70e42007-03-01 18:34:37 +00004889 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script)
4890 (cfg_stanza_pre_start, cfg_stanza_post_start)
4891 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Use job_process_new
4892 to allocate process structures and store in the process array.
4893 * init/tests/test_cfgfile.c (test_read_job, test_stanza_exec)
4894 (test_stanza_script, test_stanza_pre_start)
4895 (test_stanza_post_start, test_stanza_pre_stop)
4896 (test_stanza_post_stop): Update test cases to use process array
4897 member information.
4898
Scott James Remnant42479f92007-03-01 18:12:34 +00004899 * init/tests/test_event.c (test_poll): Update to use newer job process
4900 array and find the pid under there.
4901
Scott James Remnantc8f15ac2007-03-01 18:03:22 +00004902 * init/job.h (Job): Remove the pid and aux_pid fields; replace the
4903 individual JobProcess pointers with an array of them of a fixed
4904 minimum size; replace failed_state with failed_process.
4905 (JobProcess): add a pid field here, so now we can obtain the pid on
4906 an individual process/action basis rather than global.
4907 * init/job.c (job_process_new): Function to create a JobProcess
4908 structure, setting the initial values to FALSE/NULL/0.
4909 (job_process_copy): Function to copy a JobProcess.
4910 (job_new): Don't initialise the pid or aux_pid members, initialise
4911 the process array to a fixed initial size and set the members to NULL,
4912 initialise the failed_process member to -1.
4913 (job_copy): Update to use job_process_copy and copy the process array.
4914 (job_find_by_pid): Look through the process structures in the job's
4915 process array to find the pid, and optionally return which action it
4916 was.
4917 (job_change_state): Call job_kill_process in the JOB_KILLED state if
4918 we have a main process and that has a pid, pass in the main process.
4919 (job_next_state): Check the process id of the main process when
4920 deciding what the next state is for running.
4921 (job_run_process): Store the process id in the process structure
4922 (job_kill_process): Accept a process structure and use that to obtain
4923 the process id we need to send TERM too. Remove the code that forced
4924 a state change if kill() failed, since we will get a child signal
4925 anyway and should do it there.
4926 (job_kill_timer): Likewise, accept a process structure and don't
4927 forcibly change the state anymore.
4928 (job_child_reaper): Rewrite to switch based on the action that died,
4929 rather than the state we were in; assert that the state is what we
4930 expected.
4931 (job_emit_event): The argument to the failed event is now the action
4932 name, rather than the state name; an action of -1 indicates that
4933 respawn failed.
4934 * init/tests/test_job.c (test_process_new, test_process_copy): Make
4935 sure the structure is created and copied properly.
4936 (test_new, test_copy): Drop checks on the pid and aux_pid members,
4937 add checks for the process array and pid members of processes.
4938 (test_find_by_pid): Update test case to make sure we can find the pid
4939 of any process, returning the action index rather than the process
4940 pointer.
4941 (test_run_process, test_kill_process, test_change_goal)
4942 (test_change_state, test_next_state, test_child_reaper): Update test
4943 cases to use pid fields inside process structures rather than the
4944 pid or aux_pid members.
4945 (test_handle_event, test_handle_event_finished)
4946 (test_free_deleted): Update to avoid pid field checks.
4947
Scott James Remnant4652e3b2007-03-01 16:25:56 +00004948 * upstart/enum.h (JobAction): Enumeration of different actions.
4949 * upstart/enum.c (job_action_name, job_action_from_name): Enumeration
4950 to string conversion functions.
4951 * upstart/tests/test_enum.c (test_action_name)
4952 (test_action_from_name): Tests for the new functions.
4953
Scott James Remnantdc9d7902007-03-01 12:57:37 +00004954 * init/cfgfile.c (cfg_read_job): Instead of trying to copy over an
4955 old job's state and instances into the new one, mark the old job
4956 as deleted. This ensures we never end up applying a new post-stop
4957 script to a job started with an old pre-start script, etc. It also
4958 makes life so much simpler.
4959 * init/tests/test_cfgfile.c (test_read_job): Update tests to make
4960 sure the old job is marked for deletion, instead of freed.
4961 * TODO: Update.
4962
Scott James Remnant26a41cf2007-03-01 12:50:10 +00004963 * init/notify.c (notify_job): Split out notification to processes
4964 subscribed to the cause event into a new function
4965 (notify_job_event): We can call this when we change cause.
4966 * init/job.c (job_change_state): Notify anyone subscribed to the
4967 job after we've changed the state, rather than before, otherwise
4968 we won't know the new pids or anything.
4969 (job_change_cause): Call notify_job_event before changing the cause
4970 so that subscribers get a final status update.
4971 * init/tests/test_notify.c (test_job_event): Check the new function.
4972 * TODO: Update.
4973
Scott James Remnantbc1ebc02007-03-01 12:27:09 +00004974 * init/cfgfile.c (cfg_stanza_respawn): Remove the shortcut that
4975 lets you specify "respawn COMMAND". It was confusing as it hid
4976 the common "[when] exec"/"[when] script" syntax, made it non-obvious
4977 that "exec" and "respawn" were the same flag, etc.
4978 * init/tests/test_cfgfile.c (test_stanza_respawn): Update tests.
4979 (test_stanza_service): Fix test case to not use shortcut.
4980 * logd/event.d/logd.in: Update to not use respawn shortcut.
4981
Scott James Remnantb1f34052007-02-25 09:12:53 +000049822007-02-25 Scott James Remnant <scott@netsplit.com>
4983
Scott James Remnant43d8f092007-02-25 12:56:37 +00004984 * init/job.c (job_child_reaper): Shift the signal value into the
4985 higher byte to make it easier to detect, and not stamp over exit
4986 statuses between 128 and 255.
4987 (job_emit_event): Detect the signal stored in the new way.
4988 * init/cfgfile.c (cfg_stanza_normal): Store signal in the higher bytes.
4989 * init/tests/test_job.c (test_copy, test_change_state)
4990 (test_child_reaper): Update test cases.
4991 * init/tests/test_cfgfile.c (test_stanza_normal): Update test.
4992
Scott James Remnant8a77b5d2007-02-25 11:45:47 +00004993 * TODO: Update.
4994
Scott James Remnant2c950692007-02-25 09:13:38 +00004995 * init/event.h (PWRSTATUS_EVENT): Add new power-status-changed event.
4996 * init/main.c (pwd_handler): Handle the SIGPWR signal by generating
4997 the new event, leave it up to a job to parse the file and do
4998 whatever it likes.
4999
Scott James Remnantb1f34052007-02-25 09:12:53 +00005000 * TODO: Update.
5001
Scott James Remnant7e3ad172007-02-13 15:53:39 +000050022007-02-13 Scott James Remnant <scott@netsplit.com>
5003
5004 * upstart/tests/test_message.c (test_reader, test_handle_using)
5005 (test_handle); Usual fix for gcc optimiser thinking that fixed
5006 for loops might not be.
5007 * init/tests/test_job.c (test_run_process, test_kill_process):
5008 Likewise.
5009 * init/tests/test_notify.c (test_subscription_find): I still don't
5010 know what a type-punned pointer is, nor why dereferencing such a
5011 thing would break strict-aliasing rules.
5012 * init/tests/test_cfgfile.c (test_read_job): More type-punning.
5013 * util/tests/test_jobs.c (test_start_action): More for-loop action.
5014 * util/tests/test_events.c (test_emit_action): And again.
5015
Scott James Remnant5c89c502007-02-11 14:08:19 +000050162007-02-11 Scott James Remnant <scott@netsplit.com>
5017
Scott James Remnant17305e12007-02-11 18:20:19 +00005018 * init/job.c (job_change_goal): We need to be able to stop a running
5019 job without a process, because that's what a job-as-state is! The
5020 check was added because job_child_reaper calls job_change_goal and
5021 then job_change_state immediately after, we should fix that instead.
5022 (job_child_reaper): If we call job_change_goal while in the running
5023 state, it will call job_change_state for us; so check for that first
5024 and don't change the state!
5025 * init/tests/test_job.c (test_change_goal): Update the test to ensure
5026 that we can stop a job with no running process.
5027
Scott James Remnantddda5f92007-02-11 14:18:00 +00005028 * init/cfgfile.c (cfg_stanza_normalexit): normalexit is inconsistent,
5029 change to "normal exit"
5030 * init/tests/test_cfgfile.c (test_stanza_normalexit): Update.
5031
Scott James Remnant5c89c502007-02-11 14:08:19 +00005032 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop)
5033 (cfg_stanza_pre_start, cfg_stanza_post_start)
5034 (cfg_stanza_pre_stop, cfg_stanza_post_stop, cfg_stanza_respawn):
5035 We're not going to allow stanza keywords to be quoted, since this
5036 gives us an easy way to allow users to make something explicitly
5037 not a keyword.
5038
Scott James Remnant5dd50e32007-02-10 00:44:44 +000050392007-02-10 Scott James Remnant <scott@netsplit.com>
5040
Scott James Remnant9675c072007-02-10 21:36:48 +00005041 * configure.ac: Bump version to 0.3.6
5042
Scott James Remnant4e977172007-02-10 21:24:29 +00005043 * configure.ac: Increase version to 0.3.5
5044 * NEWS: Update.
5045 * TODO: Update.
5046
Scott James Remnanta2f0a542007-02-10 18:07:26 +00005047 * TODO: More notes.
5048
Scott James Remnant78456a52007-02-10 17:46:21 +00005049 * TODO: Note an issue with using JobProcess->pid
5050
Scott James Remnantd11d0fd2007-02-10 17:45:17 +00005051 * init/cfgfile.c (cfg_stanza_pre_start, cfg_stanza_post_start)
5052 (cfg_stanza_pre_stop, cfg_stanza_post_stop): Add a needed check
5053 for a token when parsing "exec". Correct line number we expect
5054 to see the duplicated value on. Correct expected error for missing
5055 argument from "Unexpected token" to "Expected token".
5056
5057 * init/tests/test_cfgfile.c (main): Actually invoke the tests for
5058 the scripts.
5059
Scott James Remnant2ebe37b2007-02-10 17:35:33 +00005060 * init/cfgfile.c (cfg_read_job): Correct type of lineno in error.
5061
Scott James Remnant178f3a62007-02-10 17:34:02 +00005062 * TOOD: Minor notify bug
5063
Scott James Remnante72695c2007-02-10 17:11:26 +00005064 * TODO: Big update.
5065
Scott James Remnant743c1c12007-02-10 16:49:17 +00005066 * init/tests/test_job.c (test_child_reaper): Make sure that we can
5067 reap post-start and pre-stop processes, and have only the aux_pid
5068 changed. Also make sure that if the running process dies while
5069 in these states, with or without an aux process, that we don't
5070 transition badly.
5071
Scott James Remnanta54bfd02007-02-10 14:33:32 +00005072 * init/job.c (job_find_by_pid): Check aux_pid as well.
5073 * init/tests/test_job.c (test_find_by_pid): Make sure we can find it.
5074
Scott James Remnant153e3b52007-02-10 14:15:47 +00005075 * init/job.h (Job): Add an auxiliary pid member.
5076 * init/job.c (job_new): Initialise the aux_pid member.
5077 (job_change_state): Run the post-start and pre-stop scripts when we
5078 enter the state with the same name (assuming they exist).
5079 (job_run_process): Store the pid in aux_pid when starting the
5080 post-start or pre-stop processes.
5081 * init/tests/test_job.c (test_change_state): Add tests for running
5082 the new post-start and pre-stop scripts; which get their process ids
5083 stored in aux_pid instead of pid.
5084 (test_new): Make sure the aux_pid member is initialised properly.
5085 (test_copy): Make sure the aux_pid member is not copied.
5086
5087 * TODO: Update.
5088
Scott James Remnantf415d8d2007-02-10 13:55:04 +00005089 * init/tests/test_job.c (test_change_state): Add a check for the
5090 daemon stanza holding the job in spawned; we snuck this in a while
5091 back and never tested it (there's no support to get it out of
5092 spawned yet).
5093
Scott James Remnante9332be2007-02-10 13:46:50 +00005094 * init/job.h (Job): Add new post_start and pre_stop scripts.
5095 * init/job.c (job_new): Initialise new scripts to NULL.
5096 (job_copy): Copy the information from the new scripts over as well.
5097 * init/tests/test_job.c (test_new): Check they're initialised.
5098 (test_copy): Check that the information is copied properly.
5099 * init/cfgfile.c (cfg_stanza_post_start, cfg_stanza_pre_stop): Add
5100 new script stanza functions for the additional two scripts that
5101 we want.
5102 * init/tests/test_cfgfile.c (test_stanza_post_start)
5103 (test_stanza_pre_stop): Add tests for the new stanzas.
5104
Scott James Remnant5dd50e32007-02-10 00:44:44 +00005105 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_script): Rewrite to
5106 allocate a JobProcess and parse the command or script into it.
5107 (cfg_read_job): Fix the long broken assumption that pid_file and
5108 pid_binary are required for respawn, when they're actually required
5109 for daemon.
5110 (cfg_stanza_start, cfg_stanza_stop): Remove script second-level.
5111 (cfg_stanza_respawn): Parse into the job's process.
5112 (cfg_stanza_pre_start, cfg_stanza_post_stop): New stanzas for the
5113 processes alone.
5114 * init/tests/test_cfgfile.c (test_read_job): Update a few test
5115 cases to match reality.
5116 (test_stanza_start, test_stanza_stop): Remove script-related checks.
5117
Scott James Remnante885d552007-02-09 00:01:46 +000051182007-02-09 Scott James Remnant <scott@netsplit.com>
5119
Scott James Remnant315a80a2007-02-09 22:50:00 +00005120 * init/tests/test_job.c (test_kill_process): Poll the event queue
5121 after each test to get rid of the allocated events and make valgrind
5122 happy.
5123 * init/tests/test_control.c (test_job_start, test_job_stop)
5124 (test_event_emit): Poll the event queue after each test to get rid
5125 of the allocated events, as they make valgrind complain.
5126 (test_event_emit): Free args and env when done.
5127
Scott James Remnant1ada0e22007-02-09 22:40:51 +00005128 * init/job.h (JobName): Drop obsolete structure
5129 (JobProcess): Add a new structure to represent a single process
5130 within the job, instead of using two variables to pick either the
5131 script or command.
5132 (Job): Change command and script to a single JobProcess called process;
5133 change start_script and stop_script to a JobProcess called pre_start
5134 and post_stop respectively.
5135 * init/job.c (job_new): Initialise new members to NULL.
5136 (job_copy): Copy the process structures across, including contents.
5137 (job_change_state): Call job_run_process passing in the structure;
5138 rather than fiddling with if statements.
5139 (job_run_script, job_run_command, job_run_process): Combine all of
5140 these three functions into a single new job_run_process function.
5141 * init/tests/test_job.c (test_new, test_copy, test_change_goal)
5142 (test_change_state, test_child_reaper)
5143 (test_handle_event_finished): Change to using JobProcess for when
5144 we need to construct a command.
5145 (test_run_script, test_run_command): Merge into single new
5146 (test_run_process) function.
5147 * init/tests/test_event.c (test_poll): Replace command with process.
5148 * init/tests/test_control.c (test_job_start): Change to using
5149 JobProcess to specify the command.
5150
Scott James Remnantc6740472007-02-09 21:16:28 +00005151 * init/main.c (main): Run job_free_deleted each time through the
5152 main loop.
5153
Scott James Remnantcb468602007-02-09 21:13:16 +00005154 * init/job.c (job_change_goal): Minor tweak to the logic; we may
5155 have just made the job an instance, that should still let us stop
5156 the one underneath.
5157
Scott James Remnant3fbdda72007-02-09 21:12:10 +00005158 * TODO: Update.
5159
Scott James Remnantdde96ff2007-02-09 21:10:45 +00005160 * util/jobs.c (do_job): Always expect a list of replies.
5161
Scott James Remnantf9409952007-02-09 21:02:18 +00005162 * init/control.c (control_job_status, control_job_stop)
5163 (control_job_query): Reply with information about all instances of
5164 the job.
5165 * init/tests/test_control.c (test_job_status, test_job_stop)
5166 (test_job_query): Make sure we get the list end even for a single job;
5167 and make sure we get details of all instances attached to the job.
5168
Scott James Remnant6cfc8ab2007-02-09 20:34:37 +00005169 * init/tests/test_job.c (test_change_goal): Check that starting
5170 an instance job actually starts a new instance of it.
5171
Scott James Remnant87c46472007-02-09 20:05:32 +00005172 * init/cfgfile.c (cfg_stanza_limit): Support the word "unlimited" in
5173 limit arguments for both the soft and hard values.
5174 * init/tests/test_cfgfile.c (test_stanza_limit): Make sure that we
5175 can make limits be unlimited.
5176
Scott James Remnant22ac92f2007-02-09 19:39:42 +00005177 * init/event.c (event_copy): Function to copy an event structure.
5178 * init/event.h: Add prototype.
5179 * init/tests/test_event.c (test_copy): Make sure we copy the event
5180 correctly, with or without arguments and/or environment.
5181 * init/job.c (job_copy): Function to copy a job structure, leaving
5182 the state as it is.
5183 * init/job.h: Add prototype.
5184 * init/tests/test_job.c (test_copy): Make sure that we copy the
5185 job details whether they are NULL or non-NULL, but don't copy the
5186 state.
5187 * init/init.supp: Update supression.
Scott James Remnant099ece22007-02-09 18:13:51 +00005188 * init/job.c (job_find_by_name): If we get a job that's an instance,
5189 return what it's an instance of.
5190 * init/tests/test_job.c (test_find_by_name): Restore accidentally
5191 deleted test function; test that we get the real job, not an instance.
5192
Scott James Remnant99e3ecc2007-02-09 18:08:45 +00005193 * init/job.c (job_new): instance_of is initialised to NULL.
5194 * init/job.h: Add a new instance_of pointer, pointing to the parent
5195 that we're an instance of.
5196 * init/tests/test_job.c (test_new): Check that.
5197 * init/tests/test_cfgfile.c (test_read_job): Make sure instance_of
5198 pointers are updated.
5199
Scott James Remnant4513fae2007-02-09 17:52:32 +00005200 * init/job.c (jobs): Store jobs in a hash table.
5201 (job_new): Add to hash table, not to a list.
5202 (job_handle_event, job_handle_event_finished, job_detect_stalled)
5203 (job_free_deleted): Iterate across the hash table, rather than list.
5204 (job_find_by_name): Use nih_hash_lookup, we keep this function because
5205 we'll add "is instance or not" smarts soon!
5206 (job_find_by_pid): Iterate across the entire hash table.
5207 * init/tests/test_job.c (test_find_by_name): Drop test since this
5208 function is now gone.
5209 (test_free_deleted): Can't assume things are in a line now.
5210 * init/control.c (control_job_list): Iterate the hash table.
5211
Scott James Remnant3f9624c2007-02-09 17:16:07 +00005212 * init/event.c: Don't hide the events list anymore
5213 * init/event.h: Publish it and the init function.
5214 * init/job.c: Don't hide the jobs list anymore.
5215 (job_list): Since we don't hide it, we can drop this.
5216 * init/job.h: Publish it and the init function.
5217 * init/notify.c: Don't hide the subscriptions list anymore.
5218 * init/notify.h: Publish it and the init function.
5219 * init/control.c (control_job_list): Iterate the job list directly
5220 * init/tests/test_control.c (test_event_emit): Use the events list
5221 available to us.
5222 * init/tests/test_event.c (test_poll): Call job_init directly and
5223 just use the events list available to us.
5224 * init/tests/test_job.c (test_new): Call job_init directly.
5225 (test_change_state): Use the events list available to us.
5226 * init/tests/test_notify.c (test_unsubscribe): Use the subscriptions
5227 list available to us.
5228
Scott James Remnant9709a8d2007-02-09 16:08:21 +00005229 * doc/states.dot: Add updated state graph.
5230 * doc/Makefile.am (EXTRA_DIST): Ship the states diagram.
5231 (states.png): Include rules to build the png, we'll put it in bzr
5232 anyway, but this is useful.
5233
Scott James Remnant92b01602007-02-09 15:46:55 +00005234 * init/cfgfile.c (cfg_delete_handler): Handle deleted jobs; mark
5235 the job as deleted, and if it's dormant, invoke a state change.
5236
Scott James Remnant9c0215a2007-02-09 15:42:20 +00005237 * upstart/enum.h: Add a new JOB_DELETED state.
5238 * upstart/enum.c (job_state_name, job_state_from_name): Add the new
5239 state to the string functions.
5240 * upstart/tests/test_enum.c (test_state_name)
5241 (test_state_from_name): Check the enum works.
5242 * init/job.c (job_change_goal): New decision; we can start a waiting
5243 job if it's marked delete (it might be a new instance) -- we'll use
5244 the new deleted state to decide that we shouldn't.
5245 (job_change_state): Once we reach waiting, if the job is to be deleted,
5246 move to the next state.
5247 (job_next_state): The next state for a waiting job if the goal is stop
5248 is deleted. We should never call job_next_state () for a deleted job.
5249 (job_free_deleted): Very simple function, just detects
5250 deleted jobs and frees them.
5251 * init/job.h: Add prototype for new function.
5252 * init/tests/test_job.c (test_change_goal): Update test to use new
5253 deleted state; and don't even change the goal.
5254 (test_change_state): Add a check to make sure we end up in deleted.
5255 (test_next_state): Make sure waiting goes to deleted.
5256 (test_free_deleted): Check the function.
5257
Scott James Remnant07dd5db2007-02-09 15:20:25 +00005258 * init/job.c (job_change_goal): Don't try and start a job if it's
5259 marked to be deleted and is just waiting for cleanup.
5260 * init/tests/test_job.c (test_change_state): Make sure that the cause
5261 is released when we reach waiting.
5262
Scott James Remnanta1ade132007-02-09 15:07:30 +00005263 * init/tests/test_cfgfile.c (test_read_job): Make sure that a deleted
5264 job gets resurrected.
5265
Scott James Remnant25873b52007-02-09 13:35:43 +00005266 * init/cfgfile.c (cfg_visitor): Correct number of arguments and call
5267 to cfg_job_name.
5268
Scott James Remnant3b5daf62007-02-09 13:31:01 +00005269 * TODO: Update.
5270
Scott James Remnant845c6cb2007-02-09 13:29:27 +00005271 * init/cfgfile.c (cfg_stanza_daemon): Don't allow arguments anymore.
5272 * init/tests/test_cfgfile.c (test_stanza_daemon): Update tests.
5273
Scott James Remnant1cdc1632007-02-09 13:26:09 +00005274 * init/job.c (job_handle_event_finished): Function to unblock all
5275 jobs blocked on a given event emission.
5276 (job_new, job_emit_event): Rename blocker to blocked; it's useful for
5277 testing for truth.
5278 * init/job.h: Add prototype, rename member.
5279 * init/tests/test_job.c (test_handle_event_finished): Test it.
5280 (test_new, test_change_state): Update name here too.
5281 * init/event.c (event_finished): Call job_handle_event_finished
5282 function to unblock jobs.
5283 * init/tests/test_event.c (test_poll): Make sure the job gets
5284 unblocked; a few other tests have to change since running event_poll
5285 always unblocks the job if nothing listens to it.
5286
Scott James Remnantba5ebb02007-02-09 04:46:39 +00005287 * init/job.c (job_child_reaper): Set failed back to FALSE if
5288 we're respawning, since we don't want to be failing.
5289 * init/tests/test_job.c (test_child_reaper): cause will be NULL.
5290 also free and poll events when done.
5291 (test_handle_event): pid can never be -1
5292 (test_change_state): poll events when done
5293
Scott James Remnantfd0cc552007-02-09 04:39:36 +00005294 * init/tests/test_job.c (test_child_reaper): Process will always
5295 be zero on return from reaper.
5296
Scott James Remnantef11ca42007-02-09 04:37:24 +00005297 * init/tests/test_job.c (test_child_reaper): Killed doesn't go past
5298 stopping; it goes to waiting, which will clear the cause.
5299
Scott James Remnanta5034982007-02-09 04:36:12 +00005300 * init/tests/test_job.c (test_child_reaper): Fill in values before
5301 we test against them.
5302
Scott James Remnantda1ae312007-02-09 04:35:33 +00005303 * init/tests/test_job.c (test_kill_process): Fix violated assertion
5304
Scott James Remnant011e4ae2007-02-09 04:35:00 +00005305 * init/tests/test_job.c (test_change_state): This should be failed
5306 because nothing cleared it.
5307
Scott James Remnant4f4ea832007-02-09 04:33:50 +00005308 * init/tests/test_job.c (test_change_state): Fix a couple of array
5309 index problems.
5310
Scott James Remnantaf9b63f2007-02-09 04:32:50 +00005311 * init/tests/test_job.c (test_change_state): Why set that which
5312 does not change?
5313
Scott James Remnantfcc51902007-02-09 04:30:43 +00005314 * init/tests/test_job.c (test_change_state): Add newline to test.
5315
Scott James Remnant5f936192007-02-09 04:29:54 +00005316 * init/job.c (job_emit_event): Add the job name as an argument;
5317 oops.
5318
Scott James Remnantf89b1612007-02-09 04:28:09 +00005319 * init/tests/test_control.c (test_job_stop): Need to kill the process
5320 ourselves, as we're blocked on an event.
5321 (test_job_query): Fix wrong value in test.
5322 (check_job_stopped, test_job_stop, test_unwatch_jobs): Change job
5323 name to match the test.
5324
Scott James Remnant7178e722007-02-09 04:22:04 +00005325 * init/job.c (job_change_state): Must only not enter some states
5326 with no process now; others like killed actually usually want one!
5327
Scott James Remnant851a05c2007-02-09 04:18:20 +00005328 * init/tests/test_cfgfile.c (test_read_job): Fix test case.
5329
Scott James Remnant6c088782007-02-09 04:13:43 +00005330 * init/tests/test_job.c (test_handle_event): Clean up tests.
5331 (test_detect_stalled): Clean up.
5332
Scott James Remnantbfcb6162007-02-09 04:08:53 +00005333 * init/job.c (job_child_reaper): Update the reaping of the child
5334 processes; there's a much larger state range for the main process
5335 now, so that needs to be taken into account.
5336 * init/tests/test_job.c (test_child_reaper): New test cases.
5337
Scott James Remnantd7ac93f2007-02-09 03:39:00 +00005338 * init/job.c (job_next_state): Encapsulate the slightly odd three
5339 exit states of running in this function, otherwise we'll end up
5340 special-casing it in places I'd rather not think about.
5341 (job_change_goal): Only change the state of a running job if it
5342 has a process.
5343 * init/tests/test_job.c (test_next_state): Add a test case for the
5344 dead running job
5345 (test_change_goal): Add test case for the dead running job
5346
Scott James Remnantd285b832007-02-09 02:49:06 +00005347 * init/tests/test_job.c (test_change_state): Add test cases for
5348 the forgotten stopping to killed transition.
5349
Scott James Remnant999fc9a2007-02-09 02:44:25 +00005350 * init/job.c (job_kill_process, job_kill_timer): Just check the pid
5351 and state, and no longer any need to notify jobs since we're just
5352 called from one state amongst many.
5353 (job_change_state): Skip over the killed state if there's no process.
5354 * init/tests/test_job.c (test_kill_process): Update test cases.
5355
Scott James Remnantad011612007-02-09 02:34:03 +00005356 * init/job.c (job_run_process): Simplify a little bit, no need to
5357 do the state assertions here, just make sure there's no already
5358 a process running.
5359 * init/tests/test_job.c (test_run_command, test_run_script): Run
5360 tests in the spawned state, since that's where we run the primary
5361 command or script. Drop check for process state since that's no
5362 longer set.
5363
Scott James Remnant8bd1b042007-02-09 02:27:40 +00005364 * init/job.c (job_change_state, job_next_state): Ok, here's the big
5365 one ... rewrite this to use the new state transitions. This has
5366 suddenly got a lot simpler and easier to read, this was definitely a
5367 good idea.
5368 (job_emit_event): Function to make emission of events easier.
5369 (job_failed_event): replaces this one which wasn't so easy.
5370 * init/tests/test_job.c (test_change_state): I can't say how much I
5371 wasn't looking forwards to rewriting these test cases; anyway, it's
5372 done now and I hope they're all right;
5373 (test_next_state): Make sure the state transitions are correct too.
5374
Scott James Remnant6aee3782007-02-09 00:45:29 +00005375 * init/job.h: Rename is_instance to delete and spawns_instance to
5376 just instance.
5377 * init/job.c (job_new): Update.
5378 * init/tests/test_job.c (test_new): Update.
5379 * init/cfgfile.c (cfg_stanza_instance): Update.
5380 * init/tests/test_cfgfile.c (test_stanza_instance): Update.
5381
Scott James Remnant535c6902007-02-09 00:43:03 +00005382 * init/event.h: Correct the event names.
5383
Scott James Remnante2edac92007-02-09 00:39:24 +00005384 * init/job.h: Add blocker event member.
5385 * init/job.c (job_new): Initialise it to NULL.
5386 * init/tests/test_job.c (test_new): Check it.
5387
Scott James Remnante885d552007-02-09 00:01:46 +00005388 * init/job.c (job_change_goal): Have a stab at this function with the
5389 new state machine; it gets somewhat simpler (until we introduce the
5390 second scripts), now we just induce things by a state change.
5391 * init/tests/test_job.c (test_change_goal): Made easier (for now)
5392 because we don't need to deal with processes and can just wait to
5393 be blocked on an event.
5394
Scott James Remnant9e13a242007-02-08 00:24:21 +000053952007-02-08 Scott James Remnant <scott@netsplit.com>
5396
Scott James Remnant5e469e42007-02-08 23:49:01 +00005397 * init/cfgfile.c (cfg_read_job): Drop check for useless respawn script
5398 (cfg_stanza_respawn): Drop handling of "respawn script"
5399 * init/tests/test_cfgfile.c (test_stanza_respawn): Drop the checks
5400 for "respawn script"
5401
Scott James Remnant4fdf7552007-02-08 23:45:34 +00005402 * init/job.h: Move things about a bit more; remove respawn_script
5403 since that state is going away.
5404 * init/job.c (job_new): Drop initialisation of process_state.
5405 * init/tests/test_job.c (test_new): Improve the tests.
5406
Scott James Remnant3856c632007-02-08 23:29:17 +00005407 * init/main.c (STATE_FD): Remove this define, not used anymore.
5408
Scott James Remnantbc281c32007-02-08 23:25:33 +00005409 * init/tests/test_event.c (test_poll): Update the event checking
5410 to match what's likely to happen.
5411
Scott James Remnant049b50f2007-02-08 23:23:29 +00005412 * init/event.h: Remove commented out bit.
5413
Scott James Remnant1abebfd2007-02-08 23:20:02 +00005414 * init/tests/test_notify.c (check_job_status, test_job): Correct
5415 state usage to match a possible state.
5416
Scott James Remnant64bc2a82007-02-08 22:59:46 +00005417 * init/control.c (control_job_start, control_job_stop)
5418 (control_job_query, control_job_list): Drop process state and
5419 description from the job status messages we send back.
5420 * init/tests/test_control.c (test_error_handler)
5421 (check_job_started, test_job_start, check_job_stopped)
5422 (check_job_stopping, test_job_query, check_job_starting)
5423 (test_job_list, test_watch_jobs, test_unwatch_jobs): Remove
5424 process_state and description, and update usage of job states.
5425
Scott James Remnantcb178f82007-02-08 22:47:42 +00005426 * init/notify.c (notify_job): Don't include process state or
5427 description in the job status message anymore.
5428 * init/tests/test_notify.c (check_job_status, test_job): Update tests
5429
Scott James Remnant79cd4bf2007-02-08 22:44:46 +00005430 * init/cfgfile.c (cfg_read_job): Drop the copying of the process_state
5431 member, since it doesn't exist anymore.
5432 * init/tests/test_cfgfile.c (test_read_job): Drop the check too.
5433
Scott James Remnant6f0ff592007-02-08 22:43:04 +00005434 * init/job.h (Job): Drop the process_state member.
5435
Scott James Remnant56a1fa82007-02-08 22:40:01 +00005436 * util/jobs.c (handle_job_status): Drop the process_state and
5437 description arguments; output a process id only if it's greater
5438 than zero.
5439 * util/tests/test_jobs.c (test_start_action, test_list_action)
5440 (test_jobs_action): Update tests to use newer states and arguments.
5441 * util/events.c (handle_event_job_status): Simplify in the same way
5442
Scott James Remnantac0c88b2007-02-08 22:31:00 +00005443 * upstart/message.h: Remove process_state and description from the
5444 job status event (we already had the foresight to not put them in
5445 the event job status event).
5446 * upstart/message.c (upstart_message_new, upstart_message_handle):
5447 Update handling of the messages to reduce the arguments.
5448 * upstart/tests/test_message.c (test_new, my_handler)
5449 (test_handle): Update the tests for the new job status message.
5450
Scott James Remnante76986a2007-02-08 22:21:22 +00005451 * upstart/enum.h (JobState): Change the job states to the new set
5452 of states that we've planned.
5453 (ProcessState): Drop process state entirely; this information is now
5454 contained in the single JobState field.
5455 * upstart/enum.c (job_state_name, job_state_from_name): Update
5456 strings to match the new state names.
5457 (process_state_name, process_state_from_name): Drop these functions.
5458 * upstart/tests/test_enum.c (test_state_name)
5459 (test_state_from_name): Update test cases to match new names.
5460 (test_process_state_name, test_process_state_from_name): Drop.
5461
Scott James Remnant08100e02007-02-08 17:57:21 +00005462 * init/main.c (main): Remove the logd hack for now.
5463 * init/job.c (job_new): Change the default console to none for now.
5464 * init/tests/test_job.c (test_new): Update test.
5465 * init/cfgfile.c (cfg_stanza_console): Can't guard against duplicates
5466 for a while.
5467 * init/tests/test_cfgfile.c (test_stanza_console): Comment out dup test
5468
Scott James Remnantf247adf2007-02-08 15:23:43 +00005469 * init/cfgfile.c (cfg_read_job): Remove the restriction that there
5470 must be either an 'exec' or 'script' for a job; jobs without either
5471 define states others can use.
5472 * init/tests/test_cfgfile.c (test_read_job): Convert the test to
5473 a "must work".
5474 * init/job.c (job_change_state): Remove restriction that we must
5475 have either a script or a command; having neither should just wedge
5476 the job at the running rest state. Note that there's no way to get
5477 it out yet, because we don't force that particular state change.
5478 * init/tests/test_job.c (test_change_state): Make sure that works.
5479
Scott James Remnant920d65b2007-02-08 13:49:53 +00005480 * init/job.c (job_change_cause): Put the knowledge about how to
5481 change the cause into a separate function, since it's slightly
5482 tricky.
5483 (job_change_goal, job_change_state): Set the cause using the above
5484 function.
5485
Scott James Remnanta3bcac12007-02-08 13:40:53 +00005486 * init/job.h (Job): Rename goal_event to cause, also shuffle things
5487 around so that the state is mostly together.
5488 * init/job.c, init/process.c, init/notify.c, init/cfgfile.c: Update
5489 references (and comments) to match the new name.
5490 * init/tests/test_job.c, init/tests/test_event.c,
5491 init/tests/test_process.c, init/tests/test_cfgfile.c,
5492 init/tests/test_notify.c: Likewise.
5493
Scott James Remnantef119832007-02-08 13:24:16 +00005494 * init/job.c (job_child_reaper): Don't change the goal event; the
5495 state changes will handle this.
5496 (job_change_goal): Only dereference/reference the goal event if we're
5497 actually changing it.
5498 * init/tests/test_job.c (test_change_state, test_child_reaper):
5499 Update tests to not assume that the goal event gets changed.
5500 (test_kill_process): Eliminate race condition.
5501
Scott James Remnant93376ef2007-02-08 12:53:53 +00005502 * init/job.c (job_child_reaper): Correct some problems with job and
5503 event failure; we now don't overwrite an existing failure record,
5504 and don't record failure if the main process failed and the goal was
5505 stop; since we likely caused it.
5506 * init/tests/test_job.c (test_child_reaper): More test cases.
5507
Scott James Remnantc3db81c2007-02-08 12:38:19 +00005508 * logd/event.d/logd.in: Stop on the new runlevel events, not the
5509 shutdown event.
5510
Scott James Remnante8d263c2007-02-08 03:20:30 +00005511 * compat/sysv/shutdown.c (shutdown_now): Emit an ordinary runlevel
5512 change event now; including the INIT_HALT environment variable
5513 * compat/sysv/man/shutdown.8: Update the manual
5514
Scott James Remnant52360ea2007-02-08 03:06:40 +00005515 * compat/sysv/telinit.c: Now just sends out a runlevel event with
5516 an argument giving the new runlevel.
5517 * compat/sysv/man/telinit.8: Update description of the command.
5518
Scott James Remnant8662bd02007-02-08 02:57:56 +00005519 * upstart/message.h: Remove the UPSTART_SHUTDOWN message.
5520 * upstart/message.c (upstart_message_new, upstart_message_handle):
5521 Remove handling for the shutdown message.
5522 * upstart/tests/test_message.c (test_new, test_handle): Remove
5523 tests against the shutdown message.
5524 * init/control.c (control_shutdown): Remove the shutdown command
5525 from the server.
5526 * init/tests/test_control.c (test_shutdown): Remove tests for it.
5527 * init/event.h: Remove the shutdown event.
5528 * util/initctl.c: Remove the shutdown command reference.
5529 * util/events.c (shutdown_action): Remove the command.
5530 * util/events.h: Update.
5531 * util/tests/test_events.c (test_shutdown_action): Remove tests.
5532
Scott James Remnant65906602007-02-08 02:51:39 +00005533 * init/job.c (job_detect_idle): Rename to job_detect_stalled
5534 (job_detect_stalled): Remove the idle state detection
5535 (job_set_idle_event): Idle event has been removed.
5536 * init/job.h: Update.
5537 * init/tests/test_job.c (test_detect_idle): Rename to
5538 (test_detect_stalled): and remove idle detection tests.
5539 * init/main.c (main): Replace job_detect_idle with job_detect_stalled
5540 * init/control.c (control_shutdown): Don't set the idle event.
5541 * init/tests/test_control.c (test_shutdown): Don't detect the idle
5542 event (and thus the second event)
5543
Scott James Remnantb0d99d52007-02-08 02:40:43 +00005544 * init/cfgfile.c (cfg_stanza_service): Parser for service stanza.
5545 * init/tests/test_cfgfile.c (test_stanza_service): Test the service
5546 stanza.
5547 (test_stanza_respawn): Check that respawn implies service.
5548 * TODO: Update.
5549
5550 * init/job.h (Job): Add a new service member.
5551 * init/job.c (job_new): Service starts off as false.
5552 (job_change_state): Check service instead of respawn.
5553 * init/tests/test_job.c (test_change_state): Check with service
5554 instead of respawn, since that's what we really mean.
5555
Scott James Remnante4ab75c2007-02-08 02:28:19 +00005556 * init/cfgfile.c (cfg_read_job): Copy a whole bunch more state
5557 into the newly parsed job.
5558 * init/job.c (job_run_process): Only output the first error.
5559 * init/tests/test_cfgfile.c (test_read_job): Make sure important
5560 things are copied.
5561 * TODO: Update.
5562
Scott James Remnantdb31c152007-02-08 02:05:38 +00005563 * init/main.c: Restore a much simplified version of the term
5564 handler that doesn't try and copy across any state.
5565
Scott James Remnant517f5552007-02-08 02:02:52 +00005566 * compat/sysv/telinit.c: Update call to event_emit; we'll revisit
5567 this shortly when we get rid of the shutdown event.
5568
Scott James Remnant1dc0de52007-02-08 01:57:34 +00005569 * util/events.c (handle_event): Add new id field (but ignore it)
5570 Functio
5571 (handle_event_job_status): New function to handle the new event.
5572 (handle_event_finished): Function to handle the end of the event.
5573 (emit_action): Send the newer event, and loop over replies until
5574 we get a finished one.
5575 * util/tests/test_events.c (test_emit_action): Update tests cases.
5576
Scott James Remnantd9520172007-02-08 01:18:24 +00005577 * init/control.c (control_event_emit): New function to handle the
5578 new-style emit message.
5579 * init/tests/test_control.c (test_event_emit): Make sure the new
5580 message function behaves.
5581
Scott James Remnantb3e539e2007-02-08 01:10:12 +00005582 * init/event.c, init/job.c, init/main.c, init/tests/test_event.c,
5583 init/tests/test_job.c: Completely drop the serialisation code, it's
5584 getting out of date and in the way.
5585
Scott James Remnant71b91fc2007-02-08 01:07:56 +00005586 * init/event.h: Remove compatibility macros.
5587 (EventEmission): Drop the callback function; it was too error prone
5588 to try and do it this way, and we only ever wanted to release a job
5589 anyway as control requests are better handled through the notify
5590 interface.
5591 (EventEmissionCb): Drop unused typedef.
5592 * init/event.c (event_emit): Drop callback argument.
5593 (event_finished): Don't call the callback
5594 * init/tests/test_event.c: Update to avoid callbacks.
5595 * init/job.c (job_change_state): Convert to using event_emit and
5596 EventEmission.
5597 (job_detect_idle): Drop extra arguments to event_emit.
5598 * init/main.c (main, cad_handler, kbd_handler): Drop extra arguments
5599 to event_emit.
5600 * init/control.c (control_shutdown): Use event_emit instead of
5601 event_queue.
5602 * init/tests/test_control.c (test_shutdown): Convert to using
5603 EventEmission.
5604 (test_watch_events, test_unwatch_events): Drop extra arguments to
5605 event_emit.
5606 * init/tests/test_notify.c (test_subscribe_event, test_job)
5607 (test_event, test_event_finished): Drop extra arguments to event_emit
5608 * init/tests/test_job.c (test_change_goal, test_change_state)
5609 (test_run_script, test_child_reaper, test_detect_idle): Drop
5610 extra arguments to event_emit.
5611 * init/tests/test_process.c (test_spawn): Drop extra arguments to
5612 event_emit.
5613
Scott James Remnantf082fc42007-02-08 00:50:11 +00005614 * TODO: Update.
5615
Scott James Remnant716f75c2007-02-08 00:49:40 +00005616 Rewrite the notification subsystem quite significantly; now we
5617 have individual functions to subscribe to different types of
5618 notification, and can even subscribe to individual jobs or events.
5619
5620 * init/notify.c (notify_subscribe_job, notify_subscribe_event)
5621 (notify_unsubscribe): New subscription and unsubscription functions
5622 that assume one record per subscription, not process.
5623 (notify_subscription_find): Function to find a subscription.
5624 (notify_job): Send a message to anything subscribed to the goal event
5625 as well.
5626 (notify_event): Use EventEmission and include the id in the event.
5627 (notify_event_finished): New function, sends a finished message and
5628 includes both the id and whether the event failed.
5629 * init/notify.h (NotifySubscribe): New notify structure that is
5630 once per subscription, rather than per-process; and allows
5631 subscription to individual jobs or events.
5632 * init/tests/test_notify.c (test_subscribe_job)
5633 (test_subscribe_event, test_unsubscribe): Test the new subscription
5634 functions, replacing the old
5635 (test_subscribe): tests.
5636 (test_subscription_find): Check finding works
5637 (check_event, test_event): Update to use emissions, and check that the
5638 id is correct.
5639 (test_event_finished): Check this one works too
5640 (check_event_job_status, test_job): Make sure processes subscribed
5641 via the goal event are notified too.
5642 * init/event.c (event_pending): Pass the emission directly.
5643 (event_finished): Notify subscribers that the event has finished.
5644 * init/control.c (control_error_handler): Call notify_unsubscribe
5645 (control_watch_jobs, control_unwatch_jobs, control_watch_events)
5646 (control_unwatch_events): Update to the new subscription API.
5647 * init/tests/test_control.c (test_error_handler): Use new API
5648 (test_watch_jobs, test_unwatch_jobs, test_watch_events)
5649 (test_unwatch_events): Also update these to the new API; use a
5650 destructor to make sure the subscription is freed.
5651
Scott James Remnant9e13a242007-02-08 00:24:21 +00005652 * init/tests/test_process.c: Don't use printf, use TEST_FUNCTION
5653
Scott James Remnante627ad42007-02-07 00:23:57 +000056542007-02-07 Scott James Remnant <scott@netsplit.com>
5655
Scott James Remnant459aee32007-02-07 22:44:08 +00005656 * upstart/message.h: Allocate new grouped event messages.
5657 * upstart/message.c (upstart_message_new, upstart_message_handle):
5658 Add support for the new grouped event messages.
5659 * upstart/tests/test_message.c (test_new, test_handle)
5660 (my_handler): Make sure the new messages are passed correctly.
5661
Scott James Remnant1d792152007-02-07 20:56:01 +00005662 * init/job.c (job_change_state): Clear the goal event whenever we
5663 reach the final rest state of a job (waiting for all jobs, running
5664 for services).
5665 * init/tests/test_job.c (test_change_state): Check that the goal
5666 event goes away at the right times.
5667 * TODO: Update.
5668
Scott James Remnantab17ab92007-02-07 20:38:01 +00005669 * init/tests/test_job.c (test_child_reaper): Make sure that the
5670 event is marked failed properly
5671
Scott James Remnant6d007b82007-02-07 20:21:54 +00005672 * init/job.c (job_start_event, job_stop_event): There's no reason
5673 for these to exist as seperate functions anymore, especially since
5674 we want to eventually have some kind of match table.
5675 (job_handle_event): Perform the iterations and match calls here
5676 instead, since we just call job_change_goal now.
5677 * init/job.h: Remove prototypes.
5678 * init/tests/test_job.c (test_start_event, test_stop_event): Fold into
5679 (test_handle_event): which now handles all the cases.
5680
Scott James Remnant269b7b92007-02-07 20:04:42 +00005681 * init/job.c (job_detect_idle): Call event_emit
5682 * init/main.c (main, cad_handler, kbd_handler): Call event_emit
5683 instead of event_queue.
5684 * init/tests/test_event.c (test_new): Call event_poll
5685 * init/tests/test_job.c (test_change_state, test_child_reaper)
5686 (test_detect_idle, test_change_state): Update to use newer event API.
5687 * TODO: Update.
5688
Scott James Remnant80eabbc2007-02-07 19:54:27 +00005689 * init/job.c (job_start, job_stop): Drop these functions; call
5690 job_change_goal instead (which is now public).
5691 (job_change_state, job_child_reaper): Call job_change_goal instead.
5692 * init/job.h: Update.
5693 * init/tests/test_job.c (test_start, test_stop): Merge into new
5694 (test_change_goal): function.
5695 * init/main.c (main): Call job_change_goal instead of job_start.
5696 * init/control.c (control_job_start, control_job_stop): Call
5697 job_change_goal instead.
5698
Scott James Remnant4522f4d2007-02-07 19:38:19 +00005699 * init/tests/test_job.c (test_new, test_change_state)
Scott James Remnant80eabbc2007-02-07 19:54:27 +00005700 (test_run_script, test_start, test_stop, test_start_event):
Scott James Remnant4522f4d2007-02-07 19:38:19 +00005701
5702 * init/job.h (Job): goal_event is now an EventEmission, and is
5703 a direct pointer to the one in the events queue, rather than a copy.
5704 * init/process.c (process_setup_environment): Reference the event
5705 name and environment through the goal event, not directly.
5706 * init/job.c (job_run_script): Reference the event name and
5707 environment through the goal event, not directly.
5708 (job_change_state, job_child_reaper): Replace direct setting of the
5709 job goal with a call to job_stop; the process state is always
5710 PROCESS_NONE in all three cases, so this is completely safe.
5711 (_job_start, _job_stop): Merge these two functions together into
5712 (job_change_goal): which behaves a lot more like job_change_state,
5713 except that it doesn't loop. This handles the changing of the
5714 emission.
5715 (job_start, job_start_event, job_stop, job_stop_event): Simplify
5716 these functions, now they just call job_change_goal passing in
5717 the emission pointer (or NULL).
5718
Scott James Remnantb1db7a32007-02-07 16:33:27 +00005719 * init/main.c, init/job.c, init/job.h, init/event.c, init/event.h,
5720 init/tests/test_job.c, init/tests/test_event.c: Remove state
5721 serialisation code for the time being; maintaining it is getting
5722 increasingly harder, and it introduces some major bugs. It will
5723 get rewritten shortly.
5724
Scott James Remnant4216cc82007-02-07 16:22:47 +00005725 * init/event.c (event_pending): Pass the emission directly to
5726 job_handle_event now.
5727 * init/job.c (job_handle_event, job_start_event, job_stop_event):
5728 Deal with event emissions rather than just plain events, the change
5729 so far doesn't do anything else other than take the structure change.
5730 * init/job.h: Change prototypes.
5731 * init/tests/test_job.c (test_start_event, test_stop_event)
5732 (test_handle_event): Update tests to use emissions.
5733
Scott James Remnantb2d06d42007-02-07 15:55:33 +00005734 * init/tests/test_event.c (test_read_state, test_write_state): Check
5735 the passing of the progress information.
5736 * init/event.c (event_read_state, event_write_state): Add progress
5737 field to the serialisation (oops).
5738
Scott James Remnantab132da2007-02-07 15:48:02 +00005739 * init/event.h: Add missing attribute for event_read_state.
5740 * init/cfgfile.h: Add missing attributes.
5741 * init/main.c (read_state): Don't discard return value.
5742 * TODO: Update.
5743
Scott James Remnantfcc9a0d2007-02-07 15:41:57 +00005744 * init/main.c (read_state): Handle the Emission keyword; also handle
5745 Event really being an EventEmission.
5746 * init/event.c (event_emit): Make the next emission id a static global
5747 (event_read_state, event_write_state): Serialise event emission
5748 structures, not plain events; also send over the last id we used so
5749 it appears seamless. This doesn't yet handle the callback/data bit
5750 of the serialisation, which turns out to be a little tricky ... oops
5751 * init/event.h: Update.
5752 * init/tests/test_event.c (test_read_state, test_write_state): Check
5753 that serialisation is done with EventEmissions instead, and all the
5754 fields are passed (except callback and data which are ... tricky).
5755
Scott James Remnanta39da0f2007-02-07 13:52:42 +00005756 * init/main.c (main): Call event_poll instead of event_queue_run.
5757
Scott James Remnante47588c2007-02-07 13:50:01 +00005758 * init/event.c (event_poll): Add the new function that replaces
5759 event_queue_run(); handles the new-style event emission structures
5760 in the list and only returns when there are no non-handling events.
5761 (event_pending, event_finished): Handling of particular event states
5762 during poll; split out for readability.
5763 (event_queue, event_queue_run): Drop these obsolete functions.
5764 (event_read_state): Force type from event_queue.
5765 * init/event.h: Add event_poll prototype; remove prototypes of old
5766 functions, replacing with #defines for now so things still compile.
5767 * init/tests/test_event.c (test_queue): Drop tests.
5768 (test_read_state, test_write_state): Force type from event_queue
5769 Change type we check size of.
5770 (test_poll): Pretty thoroughly test the new poll function.
5771 * init/job.c (job_change_state): Force type from event_queue
5772 * init/control.c (control_event_queue): Force type from event queue
5773 * init/tests/test_job.c (test_detect_idle): Force type from event_queue
5774 * init/tests/test_control.c (test_event_queue, test_shutdown):
5775 Force type from event_queue
5776
Scott James Remnant162c2b22007-02-07 11:32:04 +00005777 * init/event.c: Revert to a single list of events with an enum
5778 (event_emit): Set the progress to pending initially.
5779 (event_emit_find_by_id): Simplify now it just checks one list
5780 (event_emit_finished): Function for jobs to call once they've done
5781 with an event; just sets the progress to finished for the event
5782 queue to pick up.
5783 * init/tests/test_event.c (test_emit_finished): Check it.
5784
5785 * init/event.h: Add prototype.
5786 (EventProgress): Add new enum
5787 (EventEmission): And add progress member to this structure
5788 * init/tests/test_event.c (test_emit): Make sure the event is pending
5789
Scott James Remnantd379a602007-02-07 10:58:06 +00005790 * init/event.c (event_emit_find_by_id): Locate an event emission
5791 by its id in either the pending or handling queue.
5792 * init/event.h: Add prototype
5793 * init/tests/test_event.c (test_emit): Make sure that the emission
5794 id is unique each time.
5795 (test_emit_find_by_id): Test the function.
5796
Scott James Remnant7282c9a2007-02-07 03:14:08 +00005797 * init/event.c (event_emit): New function to replace event_queue();
5798 returns an EventEmission structure with the details filled in as
5799 given.
5800 * init/event.h: Add prototype.
5801
Scott James Remnant81cc7942007-02-07 02:54:25 +00005802 * init/event.c (event_init): Rename the single events queue to
5803 pending and add a new handling list.
5804
5805 * init/event.h (EventEmission, EventEmissionCb): Add a new emission
5806 structure that wraps an event, for use in the queue.
5807
Scott James Remnantd82109e2007-02-07 02:15:39 +00005808 * util/tests/test_events.c (test_events_action): Update test now
5809 that nih_message is more sensible.
5810 * util/tests/test_jobs.c (test_start_action, test_list_action)
5811 (test_jobs_action): Update test
5812
Scott James Remnante5d3f012007-02-07 01:59:57 +00005813 * util/events.c (emit_action): Actually pass the emit_env array
5814 * util/tests/test_events.c (test_emit_action): Make sure it does.
5815
5816 * util/initctl.c (main): Catch nih_command_parser() returning a
5817 negative value to indicate an internal error, and always exit 1.
5818
Scott James Remnant2cb93052007-02-07 01:49:43 +00005819 * util/events.c (handle_event): Build up multiple lines to describe
5820 the event, including its arguments and environment.
5821 * util/tests/test_events.c (test_events_action): Check the new output
5822 format is right.
5823
Scott James Remnant685644e2007-02-07 01:29:28 +00005824 * init/main.c (main): Take out inadvertantly leaked debugging code;
5825 sorry about that.
5826
Scott James Remnant5130e6d2007-02-07 01:18:38 +00005827 * init/job.c (job_child_reaper): Rewrite this to make the logic a
5828 little easier to follow, and support signals in normalexit. This
5829 also now applies to deciding whether the job failed, if it did, we
5830 store that information in the job so the stop and stopped events
5831 can get it.
5832 * init/tests/test_job.c (test_child_reaper): Add new test cases for
5833 the setting of the failed flags.
5834
Scott James Remnant18935fe2007-02-07 00:38:13 +00005835 * init/cfgfile.c (cfg_stanza_normalexit): Allow signal names in the
5836 arguments, which are added to the normalexit array or'd with 0x80
5837 * init/tests/test_cfgfile.c (test_stanza_normalexit): Check that we
5838 can now parse signal names correctly.
5839
Scott James Remnant326c2312007-02-07 00:31:18 +00005840 * init/job.c (job_failed_event): Change add to addp to fix leak.
5841
Scott James Remnante627ad42007-02-07 00:23:57 +00005842 * init/job.c (job_failed_event): Function to turn an event into one
5843 that includes all the necessary arguments and environment.
5844 (job_change_state): Call job_failed_event for the stop and stopped
5845 events (bit hacky at the moment, will improve later).
5846 * init/tests/test_job.c (test_change_state): Check that the failed
5847 events are generated properly.
5848
Scott James Remnant2b2b7d12007-02-06 00:07:28 +000058492007-02-06 Scott James Remnant <scott@netsplit.com>
5850
Scott James Remnant038ef4d2007-02-06 23:46:53 +00005851 * init/job.c (job_change_state): Reset the failed member when
5852 we enter the starting state.
5853 * init/tests/test_job.c (test_change_state): Make sure that the
5854 failed member is reset when we enter the starting state.
5855
Scott James Remnantbd7ad1a2007-02-06 23:43:59 +00005856 * init/job.h (Job): Add failed, failed_state and exit_status members.
5857 * init/job.c (job_new): Initialise new members.
5858
Scott James Remnantddbf1162007-02-06 23:40:30 +00005859 * init/job.c (job_child_reaper): Convert signals to names when
5860 outputting status messages.
5861 * init/tests/test_job.c (test_child_reaper): Check that the signal
5862 name gets converted over.
5863
Scott James Remnantf11b7dc2007-02-06 23:03:48 +00005864 * init/event.h (CTRLALTDEL_EVENT): Now we've broken the shared
5865 namespace of events and jobs, rename the control-alt-delete event
5866 back to control-alt-delete.
5867
Scott James Remnant0ef0d392007-02-06 23:00:28 +00005868 * init/job.c (job_change_state): Replace the events generated as
5869 part of the job state, named for the job and state, with new state
5870 events that have the job name as an argument.
5871 * init/event.h: Define new job event names.
5872 * init/tests/test_job.c (test_change_state): Make sure the new
5873 events are correct, with the job name as an argument.
5874
Scott James Remnant1416d052007-02-06 22:42:55 +00005875 * init/job.c (job_change_state): Remove the job event; this has
5876 been repeatedly proved to be confusing.
5877 * init/tests/test_job.c (test_change_state): Remove checks for the
5878 job event.
5879
Scott James Remnant08146b92007-02-06 20:45:38 +00005880 * util/events.c (emit_action): Pass in extra arguments.
5881 (env_option): Function to parse an option given an environment
5882 variable.
5883 * util/events.h: Add prototype.
5884 * util/tests/test_events.c (test_emit_action): Make sure that the
5885 emit action works with no arguments and with arguments.
5886 (test_events_action): Send back events with the right number of args.
5887 (test_env_option): Check the env option parser works.
5888 * util/initctl.c: Give shutdown its own command and options, give
5889 emit a new -e option.
Scott James Remnante8f3ef92007-02-06 20:20:33 +00005890
Scott James Remnant7f69c622007-02-06 20:16:50 +00005891 * util/events.c (shutdown_action): Split out from emit, seeing as
5892 these are going to be different from now on.
5893 * util/events.h: Add prototype.
5894 * util/tests/test_events.c (test_shutdown_action): Copy test cases.
5895
Scott James Remnantca2df742007-02-06 20:13:32 +00005896 * init/control.c (control_event_queue): Take the arguments and
5897 environment from the event queue request; and reparent into the
5898 event.
5899 * init/tests/test_control.c (test_event_queue): Check that arguments
5900 and environment are copied across properly.
5901
Scott James Remnanta30a25f2007-02-06 20:08:22 +00005902 * init/notify.c (notify_event): Pass in the arguments and environment
5903 for the event.
5904 * init/tests/test_notify.c (check_event): Check for event arguments
5905 and environment from the notify process.
5906 (test_event): Add arguments and environment to the event we test with
5907
Scott James Remnantce51bfb2007-02-06 20:04:05 +00005908 * upstart/tests/test_message.c (test_new, test_handle): Send
5909 arguments and environment with the UPSTART_EVENT_QUEUE and
5910 UPSTART_EVENT messages.
5911 * upstart/wire.c (upstart_pop_int, upstart_pop_unsigned): Shrink
5912 only once.
5913 (upstart_pop_string): Check the length is at least one first, as
5914 we may just have an 'S'.
5915
5916 * upstart/message.c (upstart_message_new, upstart_message_handle):
5917 The UPSTART_EVENT and UPSTART_EVENT_QUEUE messages gain new array
5918 arguments containing the arguments and environment for the event.
5919 * upstart/message.h: Document the new arguments.
5920
Scott James Remnantd1a65342007-02-06 19:25:38 +00005921 * util/tests/test_events.c, util/tests/test_jobs.c: Update the
5922 message format checks here too.
5923
Scott James Remnantfb45e432007-02-06 19:07:24 +00005924 * upstart/tests/test_wire.c (test_pop_pack): Free the array.
5925
Scott James Remnanta8882032007-02-06 19:06:44 +00005926 * upstart/tests/test_message.c (test_new, test_handle)
5927 (test_handle_using, test_reader): Update tests to include and
5928 expect new type markers between each field.
5929
Scott James Remnantf9663f02007-02-06 18:58:37 +00005930 * upstart/wire.c (upstart_push_int, upstart_push_unsigned):
5931 Take out silly asserts; it must have room!
5932
Scott James Remnantc874a942007-02-06 18:57:34 +00005933 * upstart/wire.c (upstart_push_string, upstart_pop_string): Rewrite
5934 to use a type like the rest of the functions; this removes the strange
5935 length restriction and allows us to make the pop function
5936 non-destructive.
5937 * upstart/tests/test_wire.c (test_push_string): Update.
5938 (test_pop_string): Update, adding in non-destructive, wrong type
5939 and insufficient space for type test cases.
5940 (test_push_array, test_pop_array): These needed updated too,
5941 changing the string format changed the array format.
5942 (test_push_pack, test_pop_pack): And obviously the pack format changed.
5943
Scott James Remnant9ed52092007-02-06 18:36:51 +00005944 * upstart/wire.c (upstart_pop_header): Make the function
5945 non-destructive in the face of errors.
5946 * upstart/tests/test_wire.c (test_pop_header): Make sure that
5947 invalid headers are non-destructive on error.
5948
Scott James Remnantdc4436f2007-02-06 18:33:27 +00005949 * upstart/tests/test_wire.c (test_pop_int, test_pop_unsigned):
5950 Make sure that insufficient space is non-destructive.
5951
Scott James Remnantafc5b8c2007-02-06 18:32:08 +00005952 * upstart/wire.c (upstart_push_int, upstart_pop_int)
5953 (upstart_push_unsigned, upstart_pop_unsigned): Convert to array-style
5954 type first format.
5955 (upstart_push_string, upstart_push_header): Write the length and
5956 type fields out by hand so they don't get an 'i' prefix.
5957 (upstart_pop_string, upstart_pop_header): Read the length and type
5958 fields by hand so they don't get an 'i' prefix.
5959 * upstart/tests/test_wire.c (test_push_int, test_pop_int)
5960 (test_push_unsigned, test_pop_unsigned): Update test cases to match.
5961 (test_push_pack, test_pop_pack): Pack format was changed too.
5962
Scott James Remnanta63d4862007-02-06 18:10:58 +00005963 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Add calls
5964 to push and pop array.
5965 * upstart/tests/test_wire.c (test_push_pack, test_pop_pack): Test
5966 support for arrays.
5967
Scott James Remnant5b6a2022007-02-06 18:00:49 +00005968 * upstart/wire.c (upstart_push_array, upstart_pop_array): Implement
5969 new array functions; note that these use a newer format that allows
5970 us to transmit NULL without needing to limit the size of the array.
5971 * upstart/wire.h: Add prototypes.
5972 * upstart/tests/test_wire.c (test_push_array, test_pop_array):
5973 Test the new array functions.
5974
Scott James Remnantf1d51112007-02-06 16:22:48 +00005975 * init/job.c (job_run_script): Build up the argument list, appending
5976 those from the goal event if one is set.
5977 (job_run_command): Use nih_str_array_add to build up the arguments,
5978 but don't append those from the goal event (use script).
5979 * init/tests/test_job.c (test_run_script): Make sure the arguments get
5980 passed to the running shell scripts.
5981
Scott James Remnant2efe5562007-02-06 15:51:19 +00005982 * init/job.c (job_run_script): Only use the /dev/fd trick if we can
5983 actually stat /dev/fd; also don't hardcode that path ...
5984 * init/paths.h (DEV_FD): Add here.
5985
Scott James Remnantefa8c7e2007-02-06 15:02:23 +00005986 * init/process.c (process_setup_environment): Copy environment
5987 variables from the goal event into the job's process.
5988 * init/tests/test_process.c (test_spawn): Make sure the environment
5989 reaches the job, but doesn't override that in the job already.
5990
5991 * init/tests/test_job.c (test_start_event):
5992
Scott James Remnant0071dd32007-02-06 14:57:37 +00005993 * init/job.c (job_start_event, job_stop_event): Copy the arguments
5994 and environment from the event into the goal event.
5995
Scott James Remnantb3d4dee2007-02-06 14:39:35 +00005996 * init/job.c (job_read_state, job_write_state): Read and write
5997 arguments and environment for goal event.
5998 * init/tests/test_job.c (test_read_state, test_write_state): Test
5999 with arguments and environment to the goal event.
6000
Scott James Remnant4bba9702007-02-06 14:28:10 +00006001 * init/event.c (event_read_state, event_write_state): Read and write
6002 the arguments and environment of the event.
6003 * init/tests/test_event.c (test_read_state, test_write_state): Make
6004 sure arguments and environment are correctly serialised.
6005
Scott James Remnant462e7172007-02-06 13:30:24 +00006006 * init/cfgfile.c (cfg_stanza_console): Fix a leak of the console
6007 argument in the case of duplicated options.
6008 (cfg_stanza_env): Drop the counting now nih_str_array_addp does it;
6009 and be sure to use that function.
6010 (cfg_stanza_umask): Fix leak of umask argument
6011 (cfg_stanza_nice): Fix leak of nice argument
6012 * init/tests/test_event.c (test_new): Call event_queue_run so init
6013 is called outside of a TEST_ALLOC_FAIL block.
6014
Scott James Remnantfd196342007-02-06 13:19:03 +00006015 * init/event.c (event_new): Start off with NULL args and env, to
6016 match job (saves a few bytes).
6017 (event_match): Watch for NULL arguments!
6018 * init/tests/test_event.c (test_new): Check for NULL not alloc'd
6019
Scott James Remnantfc9a76e2007-02-06 13:14:46 +00006020 * init/cfgfile.c (cfg_stanza_on, cfg_stanza_start)
6021 (cfg_stanza_stop): Parse arguments to the on stanza and store them
6022 directly in the event.
6023 * init/tests/test_cfgfile.c (test_stanza_on, test_stanza_start)
6024 (test_stanza_stop): Make sure arguments are parsed into the event.
6025
Scott James Remnant5dd1bc92007-02-06 12:57:50 +00006026 * init/event.c (event_new): Use nih_str_array_new.
6027 * init/cfgfile.c (cfg_stanza_env): Rewrite to use nih_str_array.
6028
Scott James Remnant4d0fc0f2007-02-06 11:34:41 +00006029 * init/job.c (job_run_script): Check the error returned from
6030 nih_io_reopen; don't just loop. We only ever expect ENOMEM (the
6031 other error, EBADF, is impossible).
6032
Scott James Remnanteb8cb142007-02-06 11:31:27 +00006033 * init/job.c (job_change_state): Reset the goal_event to NULL when
6034 we catch a run-away job (as it's not stopping for the same event
6035 it started with).
6036 (job_child_reaper): Reset the goal_event to NULL after setting the
6037 goal to STOP.
6038 * init/tests/test_job.c (test_change_state, test_child_reaper):
6039 Check that the goal event gets reset whenever the goal gets changed.
6040
Scott James Remnant62e22f42007-02-06 02:08:19 +00006041 * init/tests/test_event.c: Use TEST_ALLOC_FAIL
6042
Scott James Remnant93cd4d22007-02-06 02:07:45 +00006043 * init/event.c (event_match): Match arguments using fnmatch() and
6044 allow more arguments in event1 than event2 (but not the other way
6045 around).
6046 * init/tests/test_event.c (test_match): Check the new permitted
6047 combinations.
6048
Scott James Remnant34b7c712007-02-06 01:57:45 +00006049 * init/event.h (Event): Add args and env members to Event.
6050 * init/event.c (event_new): Initialise args and env members to
6051 zero-length arrays.
6052 * init/tests/test_event.c (test_new): Use TEST_ALLOC_FAIL and
6053 make sure args and env are both initialised to a list containing
6054 just NULL.
6055
Scott James Remnantb36c1962007-02-06 01:48:09 +00006056 * util/jobs.c (start_action): Get the UPSTART_JOB environment variable
6057 and use that if we don't have any arguments passed to us.
6058 (do_job): Code split from the above function that handles a named job
6059 * util/tests/test_jobs.c (test_start_action): Make sure UPSTART_JOB
6060 is picked up.
6061
Scott James Remnant2a0b0852007-02-06 01:35:56 +00006062 * init/process.h: Add necessary attributes.
6063
Scott James Remnant0b10d502007-02-06 01:28:01 +00006064 * init/process.c (process_setup_environment): Set the UPSTART_JOB
6065 environment variable from the job, and the UPSTART_EVENT environment
6066 variable from the job's goal_event member (if set).
6067 * init/tests/test_process.c (test_spawn): Make sure we get the
6068 environment in the job.
6069
Scott James Remnantafce5282007-02-06 01:22:54 +00006070 * init/job.h: Add attributes to job_new and job_read_state.
6071 * init/tests/test_job.c: Use CHECK_ALLOC_FAIL on the functions we
6072 didn't get around to touching while we were in here.
6073
Scott James Remnant1b9914d2007-02-06 01:01:11 +00006074 * init/job.c (job_start_event, job_stop_event): Set the goal_event
6075 member to a copy of the event we found.
6076 (job_read_state): Use event_new instead of trying to do it by hand.
6077 * init/tests/test_job.c (test_start_event, test_stop_event): Use
6078 CHECK_ALLOC_FAIL; and make sure the goal_event is set properly.
6079 (test_start, test_stop, test_write_new): Use event_new here too
6080
Scott James Remnant9e7d25c2007-02-06 00:42:41 +00006081 * init/job.c (job_write_state): Output a goal_event field containing
6082 the event name or nothing for NULL.
6083 (job_read_state): Parse the goal_event field
6084 * init/tests/test_job.c (test_write_state): Make sure the state is
6085 written out properly.
6086 (test_read_state): Make sure that the state is parsed correctly too.
6087
Scott James Remnant7aa22b62007-02-06 00:32:30 +00006088 * init/job.c (job_start, job_stop): Split all of the code except
6089 the goal_event setting into two new static functions that this calls
6090 (_job_start, _job_stop): New static functions
6091 (job_start_event, job_stop_event): Call _job_start and _job_stop
6092 instead of job_start and job_stop
6093
Scott James Remnante4111be2007-02-06 00:17:27 +00006094 * init/job.c (job_catch_runaway): Move this function up a bit.
6095
Scott James Remnant5761ef02007-02-06 00:15:51 +00006096 * init/job.c (job_start, job_stop): Clear the goal_event member,
6097 these functions are called for a manual start.
6098 * init/tests/test_job.c (test_start, test_stop): Make sure the
6099 goal_event member is freed and set to NULL.
6100
Scott James Remnant2b2b7d12007-02-06 00:07:28 +00006101 * init/job.h (Job): Add a new goal_event member
6102 * init/job.c (job_new): Initialise the goal_event member to NULL.
6103 * init/tests/test_job.c (test_new): Check with TEST_ALLOC_FAIL;
6104 also make sure goal_event is initialised to NULL.
6105
Scott James Remnant506ad092007-02-05 21:09:30 +000061062007-02-05 Scott James Remnant <scott@netsplit.com>
6107
Scott James Remnantee7e5552007-02-05 23:14:10 +00006108 * configure.ac: Bump version to 0.3.3
6109
Scott James Remnantcf64c482007-02-05 23:14:00 +00006110 * NEWS: Update.
6111
Scott James Remnant506ad092007-02-05 21:09:30 +00006112 * init/process.c (process_spawn): Exit with 255 so we don't clash
6113 with anything that uses 1 as a normal exit code. Note why we only
6114 close 0..2 (everything else is FD_CLOEXEC).
6115 * init/cfgfile.c (cfg_watch_dir): Mark the inotify watch descriptor
6116 as FD_CLOEXEC.
6117 * init/control.c (control_open): nih_io_set_cloexec can only ever
6118 return EINVAL, so no point checking it.
6119
Scott James Remnant0b74ff62007-02-04 00:43:20 +000061202007-02-04 Scott James Remnant <scott@netsplit.com>
6121
6122 * init/tests/test_control.c: Remove strange old code.
6123
Scott James Remnant9c44a422007-02-03 12:17:14 +000061242007-02-03 Scott James Remnant <scott@netsplit.com>
6125
Scott James Remnant7b618862007-02-03 23:41:33 +00006126 * init/control.c (control_open_sock, control_reopen)
6127 (control_close_handler): Drop these functions; unconnected datagram
6128 sockets don't close -- so why try dealing with it?
6129 (control_error_handler): Don't reopen the socket on error, just log
6130 it -- the socket should be fine, there's no remote end to be lost,
6131 after all.
6132 * init/tests/test_control.c (test_close_handler): Drop.
6133 (test_error_handler): Drop the reopen tests.
6134
Scott James Remnant88c1aac2007-02-03 23:26:36 +00006135 * init/tests/test_job.c (test_run_script): Control socket doesn't
6136 get unexpectedly opened anymore; so no need to close it.
6137
6138 * init/control.c (control_open): Remove the strange behaviour that
6139 this can be called to get the socket. Instead make control_io
6140 global; we're all adults after all.
6141 * init/tests/test_control.c (test_open): Remove the test for the
6142 silly behaviour.
6143 * init/notify.c (notify_job, notify_event): Use the control_io
6144 pointer directly, and just do nothing if we lost it somehow.
6145
Scott James Remnant2e204b72007-02-03 23:15:28 +00006146 * init/main.c (main): Being unable tp open the control socket, or
6147 parse the configuration, should be a fatal error; stop being so
6148 damned liberal! <g> Don't reset the signal state if we're
6149 being restarted, as this loses any pending signals -- be happy
6150 that our parent left them in a good state. Set SIGCHLD to the
6151 standard handler, otherwise we might lose this before we start
6152 the main loop (which does the same anyway).
6153 (term_handler): Rework so we don't need to close and open the
6154 control socket; instead we just close it in the child that's
6155 going to send the state, and notify the parent that it's safe to
6156 exec (which will cause it to be closed so the new init can open it).
6157
Scott James Remnant3af85462007-02-03 18:31:54 +00006158 * init/tests/test_control.c (test_open): Fix valgrind error
6159 * init/tests/test_notify.c (test_subscribe): Fix valgrind error
6160
Scott James Remnante443b9c2007-02-03 18:24:18 +00006161 * init/notify.c (notify_subscribe): Make safe against ENOMEM.
6162 * init/tests/test_notify.c (test_subscribe): Use TEST_ALLOC_FAIL
6163
Scott James Remnant4b601d12007-02-03 18:20:00 +00006164 * init/control.c: Add needed attributes; tidy up formatting.
6165 (control_open): Don't let ENOMEM fail opening the control socket.
6166 * init/control.h: Add needed attributes.
6167 * init/tests/test_control.c (test_open): Test for failed allocation.
6168 * init/main.c (term_handler): Make sure we catch failure to open
6169 the control socket again.
6170
Scott James Remnantd308b432007-02-03 17:36:41 +00006171 * TODO: Update
6172
Scott James Remnant272938f2007-02-03 17:35:11 +00006173 * init/cfgfile.c (cfg_watch_dir): Clean this up a bit; now we only
6174 output a warning if inotify failed for any reason other than not
6175 being supported AND walking worked.
6176
Scott James Remnantd78d00e2007-02-03 17:27:32 +00006177 * init/cfgfile.c (cfg_watch_dir): Update to even newer watch API;
6178 our create_handler is now always called if inotify is successful,
6179 so we just need to fall back to walking the directory when it
6180 isn't -- if inotify isn't supported, don't even bother complaining.
6181 (cfg_create_modify_handler): Check the stat of the file visited to
6182 make sure it's a regular file.
6183 (cfg_visitor): Check the stat of the file visited to make sure it's
6184 a regular file.
6185
Scott James Remnantbcbb1122007-02-03 17:11:21 +00006186 * init/cfgfile.c: Update include to upstart/enum.h
6187 * init/job.c: Update include to upstart/enum.h
6188 * init/job.h: Update include to upstart/enum.h
6189
Scott James Remnant801f9e12007-02-03 17:10:06 +00006190 * logd/main.c: Add attribute to open_logging
6191
Scott James Remnantcbd0cf82007-02-03 17:05:39 +00006192 * util/initctl.c: Split out the command functions into new files;
6193 * util/jobs.c: This gets the job-related commands
6194 * util/events.h: This gets the event-related commands
6195 * util/initctl.h, util/jobs.h, util/events.h: Headers
6196 * util/tests/test_jobs.c: Test suite for job-related commands.
6197 * util/tests/test_events.c: Test suite for event-related commands.
6198 * util/Makefile.am (initctl_SOURCES): Add new files.
6199 (TESTS): Build new test suites.
6200 (test_jobs_SOURCES, test_jobs_LDFLAGS, test_jobs_LDADD):
6201 Details for job-related commands test suite binary.
6202 (test_events_SOURCES, test_events_LDFLAGS, test_events_LDADD):
6203 Details for event-related commands test suite binary.
6204 * TODO: Remove item about splitting initctl now we've done it.
6205
Scott James Remnantadfcc3f2007-02-03 12:24:07 +00006206 * TODO: Big update; strip anything we have a spec for.
6207
Scott James Remnant1157bbf2007-02-03 12:17:55 +00006208 * upstart/message.c (upstart_message_handle): Make sure that if we
6209 fail to parse a message, we don't leave strings around in memory.
6210 * upstart/tests/test_message.c (test_open): Check that we get a
6211 raised EADDRINUSE if we try an open a socket twice.
6212 (test_handle): Add lots of checks for things like NULL names and
6213 incomplete messages; as well as the obvious unknown message.
6214 (test_reader): Make sure that errors while handling messages are
6215 dealt with by logging it.
6216
Scott James Remnant9c44a422007-02-03 12:17:14 +00006217 * upstart/job.c, upstart/job.h, upstart/tests/test_job.c: Rename to
6218 enum.c, enum.h and tests/test_enum.c; since this just includes enums
6219 and convert functions really.
6220 * upstart/Makefile.am: Update.
6221 * upstart/libupstart.h: Update include.
6222 * upstart/tests/test_message.c: Update include.
6223
Scott James Remnant1e57ab22007-02-01 16:51:28 +000062242007-02-01 Scott James Remnant <scott@netsplit.com>
6225
Scott James Remnant0f1d9b62007-02-01 18:20:00 +00006226 * logd/main.c (main): Ensure we error if daemonise fails.
6227
Scott James Remnant36911572007-02-01 18:18:27 +00006228 * compat/sysv/shutdown.c (main): Ensure that signals and timers
6229 are added, even if we run out of memory.
6230
Scott James Remnant9b705ee2007-02-01 17:34:39 +00006231 * upstart/tests/test_message.c: Change from assert to assert0
6232 * upstart/tests/test_wire.c: Change from assert to assert0
6233 * init/tests/test_notify.c: Change from assert to assert0
6234 * init/tests/test_control.c: nih_io_message_send should always return
6235 a value greater than zero.
6236
Scott James Remnant91c6eb72007-02-01 17:19:32 +00006237 * upstart/tests/test_wire.c: Change to use assert instead of NIH_ZERO;
6238 the rationale here is that in test cases we just want to fail, not
6239 try again repeatedly.
6240 * upstart/tests/test_message.c: Likewise.
6241
Scott James Remnant9caf2822007-02-01 17:04:34 +00006242 * init/tests/test_control.c: Use assert to ensure we get the expected
6243 return values of functions that raise errors.
6244 * init/tests/test_notify.c: Use assert to ensure we get the expected
6245 return values of functions that raise errors.
6246
Scott James Remnant1e57ab22007-02-01 16:51:28 +00006247 * init/cfgfile.c (cfg_watch_dir): Port to the new NihWatch API and
6248 use nih_dir_walk(). This also fixes the long-standing bug where we
6249 wouldn't watch the configuration directory if inotify was disabled.
6250 Drop both the parent and prefix members for now, until we clean this
6251 up later.
6252 (cfg_create_modify_handler): Wrap cfg_read_job after figuring out
6253 the job name.
6254 (cfg_job_name): Function to figure out the job name from a path.
6255 (cfg_visitor): Visitor function to handle initial parsing, figuring
6256 out the job name; otherwise identical to the standard handler.
6257 * init/cfgfile.h: Update prototype for cfg_watch_dir.
6258 * init/main.c (main): Update call to cfg_watch_dir.
6259
Scott James Remnantbfd712d2007-01-31 12:13:25 +000062602007-01-31 Scott James Remnant <scott@netsplit.com>
6261
6262 * upstart/tests/test_message.c: Use TEST_ALLOC_FAIL to make sure
6263 allocations are handled properly.
6264
Scott James Remnant44828472007-01-30 11:53:33 +000062652007-01-30 Scott James Remnant <scott@netsplit.com>
6266
Scott James Remnant2cc36542007-01-30 17:12:34 +00006267 * upstart/wire.c: Note that if any of the push functions fail, the
6268 entire buffer should be discarded.
6269 * upstart/tests/test_wire.c (test_push_int, test_push_unsigned)
6270 (test_push_string, test_push_header, test_push_pack): Us
6271 TEST_ALLOC_FAIL to ensure that failing to allocate memory is caught.
6272
Scott James Remnant1084c682007-01-30 15:17:41 +00006273 * upstart/tests/test_message.c (my_handler): Free the name and
6274 description after checking; they aren't otherwise.
6275
Scott James Remnantdc8b3292007-01-30 15:01:30 +00006276 * upstart/wire.c (upstart_push_packv, upstart_pop_packv): Consume
6277 a copy of the va_list, so these can be called multiple times on the
6278 same list without ill effect.
6279
Scott James Remnant92d87442007-01-30 15:01:21 +00006280 * upstart/message.h: Add warn_unused_result attributes to
6281 upstart_message_handle and upstart_message_handle_using as they raise
6282 errors.
6283
Scott James Remnant2de25012007-01-30 14:57:27 +00006284 * upstart/wire.c: push functions return negative values to indicate
6285 insufficient memory.
6286 * upstart/wire.h: Add warn_unused_result attributes to push functions
6287
Scott James Remnant4ccebcf2007-01-30 14:51:17 +00006288 * upstart/tests/test_message.c: Guard calls to nih_io_buffer_push and
6289 nih_io_message_add_control with NIH_ZERO to ensure they succeed.
6290 * upstart/tests/test_wire.c: Guard calls to nih_io_buffer_push
6291
Scott James Remnant44828472007-01-30 11:53:33 +00006292 * HACKING: Update from libnih with new Documentation,
6293 Function Attributes and Test Cases sections.
6294
Scott James Remnant16a286f2007-01-10 15:38:33 +000062952007-01-10 Scott James Remnant <scott@netsplit.com>
6296
Scott James Remnantde443012007-01-10 18:45:40 +00006297 * init/main.c (crash_handler): s/SEGV/SIGSEGV/
6298
Scott James Remnant505f9282007-01-10 18:44:38 +00006299 * init/main.c (main): Rename variable
6300
Scott James Remnant56a4d062007-01-10 17:33:39 +00006301 * TODO: Update.
6302
Scott James Remnant78626fb2007-01-10 16:48:10 +00006303 * init/main.c (main): Change the way we clear the arguments; by
6304 deleting just the final NULL terminator, we fool the kernel into
6305 only returning one argument in cmdline.
6306
Scott James Remnant16a286f2007-01-10 15:38:33 +00006307 * init/main.c (segv_handler): Rename to crash_handler and handle
6308 SIGABRT as well, so we can catch assertion errors. Of course, in
6309 theory, with our high test converage this should never happen in
6310 practice <chortle>
6311
Scott James Remnant39ec35b2007-01-09 08:16:01 +000063122007-01-09 Scott James Remnant <scott@netsplit.com>
6313
Scott James Remnant7f4db422007-01-09 20:51:08 +00006314 * init/main.c (main): Clear arguments so that upstart only ever
6315 appears as /sbin/init in ps, top, etc.
6316
Scott James Remnant8fd06de2007-01-09 20:38:27 +00006317 * TODO: Update.
6318
Scott James Remnant4d0481d2007-01-09 20:38:07 +00006319 * util/initctl.c: Add data pointer to functions and handle calls.
6320
Scott James Remnantbcf9e972007-01-09 20:34:47 +00006321 * init/control.c: Add data pointer to all functions.
6322 * init/tests/test_control.c: Pass data pointer to
6323 upstart_message_handle_using()
6324 * init/tests/test_notify.c: Pass data pointer to
6325 upstart_message_handle_using()
6326
Scott James Remnant6aa008c2007-01-09 20:26:44 +00006327 * upstart/message.c (upstart_message_handle)
6328 (upstart_message_handle_using): Add a data pointer argument to these
6329 functions and pass it to the handler.
6330 (upstart_message_reader): Pass the io structure's data pointer.
6331 * upstart/message.h (UpstartMessageHandler): Add a data pointer to
6332 the message handler.
6333 * upstart/tests/test_message.c (test_handle, test_handle_using):
6334 Pass a data pointer to the function call and check it's passed
6335 to the handler correctly.
6336 (test_reader): Check that the io data pointer gets passed.
6337
Scott James Remnantc7017d32007-01-09 18:44:58 +00006338 * init/tests/test_cfgfile.c (test_stanza_console, test_stanza_env)
6339 (test_stanza_umask, test_stanza_nice, test_stanza_limit): Finish off
6340 the newer style test cases.
6341
Scott James Remnante63ef802007-01-09 17:54:56 +00006342 * init/cfgfile.c (cfg_stanza_console, cfg_stanza_umask)
6343 (cfg_stanza_nice, cfg_stanza_limit, cfg_stanza_chroot)
6344 (cfg_stanza_chdir): Guard against duplicate uses of the stanzas.
6345 * init/tests/test_cfgfile.c (test_stanza_daemon)
6346 (test_stanza_respawn): Check that neither daemon or respawn override
6347 exec if they have no arguments.
6348 (test_stanza_script): Add missing function
6349 (test_stanza_chroot, test_stanza_chdir): Add tests for these simple
6350 stanzas.
6351
Scott James Remnant0cd393d2007-01-09 17:36:34 +00006352 * init/cfgfile.c: Change remaining uses of nih_error_raise and
6353 return to just nih_return_error.
6354
Scott James Remnantc352b632007-01-09 17:31:41 +00006355 * init/cfgfile.c (cfg_stanza_exec, cfg_stanza_daemon)
6356 (cfg_stanza_respawn, cfg_stanza_script): Disallow duplicates,
6357 both of command strings, scripts, limits and of just the flags.
6358 * init/tests/test_cfgfile.c (test_stanza_exec)
6359 (test_stanza_daemon, test_stanza_respawn, test_stanza_instance):
6360 Check the behaviour of these stanzas.
6361
Scott James Remnant94188d42007-01-09 16:43:58 +00006362 * init/cfgfile.c (cfg_stanza_start, cfg_stanza_stop): Disallow
6363 duplicate values for the script.
6364 * init/tests/test_cfgfile.c (test_stanza_start, test_stanza_stop):
6365 Test cases for those two functions.
6366
Scott James Remnant474a6ff2007-01-09 16:17:49 +00006367 * init/cfgfile.c (cfg_stanza_description, cfg_stanza_author)
6368 (cfg_stanza_version): Don't allow stanza to be duplicated anymore.
6369 * init/tests/test_cfgfile.c (test_stanza_description)
6370 (test_stanza_author, test_stanza_version): Test cases for these
6371 simple stanza; making sure duplication is not permitted.
6372 (test_stanza_on): Add a test case for this stanza too.
6373
Scott James Remnant49e8bb82007-01-09 15:57:59 +00006374 * init/cfgfile.c (cfg_stanza_kill): Guard against duplicate uses
6375 of the kill timeout stanza.
6376 * init/tests/test_cfgfile.c (test_stanza_kill): Test the complex
6377 kill stanza.
6378 (test_stanza_pid): Check duplicate usage results in an error.
6379
Scott James Remnant443ef2e2007-01-09 15:47:24 +00006380 * init/job.h (Job): Rename pidfile to pid_file and binary to pid_binary
6381 * init/job.c (job_new): Update names here too.
6382 * init/errors.h: Add a new "duplicate value" error.
6383 * init/cfgfile.c (cfg_read_job): Change name of variables, and catch
6384 the duplicate value error to add the line number.
6385 (cfg_stanza_pid): Change variable names, and clean this function up
6386 a little. Make it an error to use a stanza more than once.
6387 * init/tests/test_cfgfile.c (test_stanza_pid): Write a newer test
6388 case function for the pid stanza.
6389
Scott James Remnant34ff87d2007-01-09 09:00:30 +00006390 * init/cfgfile.c (cfg_stanza_normalexit): Use do/while instead of
6391 while, that we don't have to test has_token first as next_arg does
6392 that for us.
6393
Scott James Remnanta7354692007-01-09 08:56:02 +00006394 * init/cfgfile.c (cfg_stanza_normalexit): Change to peek at the next
6395 token to see whether it's missing or not, and then just fetch each
6396 next argument at a time. This is more efficient than parsing them
6397 all in one go, and also means we can report the error in the right
6398 place!
6399 * init/tests/test_cfgfile.c (test_stanza_normalexit): Since we've
6400 changed the function that parses the stanza, add a proper test case
6401 function for it, covering all the behaviours.
6402
Scott James Remnant92e7fda2007-01-09 08:40:13 +00006403 * init/job.c (job_new): Initialise the emits member to an empty list.
6404 * init/job.h (Job): Add the emits member as a list.
6405 * init/tests/test_job.c (test_new): Check the emits list starts off
6406 empty.
6407 * init/tests/test_cfgfile.c (test_stanza_emits): Test the new emits
6408 stanza; this function will also serve as a prototype for cleaning up
6409 the config tests.
6410
6411 * init/cfgfile.c (cfg_stanza_emits): Add function to parse the new
6412 emits stanza.
6413
Scott James Remnant39ec35b2007-01-09 08:16:01 +00006414 * init/cfgfile.c (cfg_stanza_depends): Remove the depends stanza
6415 from the configuration file. Dependency support has never been used,
6416 and is to be replaced by a more flexible event/state configuration
6417 and blocking on the starting/stopping events.
6418 * init/tests/test_cfgfile.c: Remove references and tests for the
6419 depends stanza.
6420 * init/job.h: Remove the depends list from the job structure.
6421 * init/job.c (job_new): No depends list to initialise.
6422 (job_change_state): No dependencies to release
6423 (job_start): No dependencies to iterate; this removes a particularly
6424 hairy and complex interaction between state changes. Remove the
6425 dependency event.
6426 (job_release_depends): Drop this function.
6427 * init/tests/test_job.c (test_start, test_stop): Massively simplify
6428 these tests cases now we don't have dependencies to worry about.
6429 (test_release_depends): Drop tests
6430
Scott James Remnantd4f5fb82007-01-08 23:25:23 +000064312007-01-08 Scott James Remnant <scott@netsplit.com>
6432
6433 * init/cfgfile.c: Rewrite using the nih_config API, rather than one
6434 huge function we now just have seperate handler functions for each
6435 stanza. We can also use more fine-grained parsing than slurping
6436 all args in and counting them.
6437 (cfg_read_job): Catch exceptions from the configuration parser and
6438 add the line number where the problem occurred to an output message.
6439 Parser errors are now fatal, and not ignored.
6440 * init/errors.h: Add a file containing errors raised within the init
6441 daemon codebase.
6442 * init/Makefile.am (init_SOURCES): Build with errors.h
6443 * init/tests/test_cfgfile.c: Update test cases now we don't expect
6444 a job to be returned if there's a parser error.
6445
6446 * TODO: Update
6447
Scott James Remnant66384202007-01-06 14:23:18 +000064482007-01-06 Scott James Remnant <scott@netsplit.com>
6449
Scott James Remnant4f968192007-01-06 20:31:13 +00006450 * logd/main.c (logging_reader): Fix inadvertent shadowing of the
6451 len parameter.
6452
Scott James Remnantda100272007-01-06 20:24:18 +00006453 * compat/sysv/telinit.c: Oops, nearly forgot to port this to send
6454 the messages in the new way.
6455 * compat/sysv/shutdown.c (shutdown_now): Likewise, port this too.
6456
Scott James Remnant83a86522007-01-06 19:55:38 +00006457 * TODO: Update.
6458
Scott James Remnant6e941882007-01-06 14:38:57 +00006459 * util/initctl.c (handle_job_status): Output the process argument,
6460 not the pid argument which contains the origin of the message.
6461
Scott James Remnant17d6dca2007-01-06 14:33:30 +00006462 * upstart/message.c (upstart_message_handle): Raise a new unknown
6463 message error if we don't have a handler and a new illegal message
6464 error if the source is illegal.
6465 * upstart/tests/test_message.c (test_handle): Adjust tests to check
6466 for the new errors that we raise.
6467 * upstart/errors.h: Define strings for new errors.
6468
Scott James Remnant66384202007-01-06 14:23:18 +00006469 * util/initctl.c: Yet another makeover for this little program,
6470 port it to the new message/control framework using handler functions
6471 and NihIoMessage. This starts to make each action function look
6472 very similar, so there's method to this madness.
6473
Scott James Remnantb4725d92007-01-05 13:10:21 +000064742007-01-05 Scott James Remnant <scott@netsplit.com>
6475
Scott James Remnant3d6bb792007-01-05 22:33:43 +00006476 * logd/main.c (main): Make sure that we add the SIGTERM handler.
6477
Scott James Remnantefbaafb2007-01-05 18:12:15 +00006478 * init/tests/test_job.c (test_run_script): This test case relies
6479 on there only being one file descriptor watch, which won't be true
6480 if the control socket has been opened because there's a message to
6481 go out. Make sure it's closed first.
6482
Scott James Remnantbe1941f2007-01-05 17:57:59 +00006483 * init/init.supp: Update supressions file now that control_init
6484 has been renamed to notify_init
6485
Scott James Remnant71cc4d82007-01-05 17:53:32 +00006486 * init/Makefile.am: Include notify.o from all tests.
6487 * init/job.c (job_change_state, job_kill_process, job_start)
6488 (job_stop): Use the new notify_job function name.
6489 * init/event.c (event_queue_run): Use the new notify_event function
6490 name.
6491
Scott James Remnantfea6cb62007-01-05 17:49:13 +00006492 * init/control.c (control_error_handler): Handle ECONNREFUSED now
6493 that the process id is available to us.
6494 * init/tests/test_control.c (test_error_handler): Make sure children
6495 going away is handled properly.
6496
Scott James Remnant3dfb2132007-01-05 17:44:48 +00006497 * upstart/message.c (upstart_message_new): Store the process id in
6498 the int_data message field.
6499 * upstart/tests/test_message.c (test_new): Check the int_data field
6500 is filled in.
6501
Scott James Remnant5d702952007-01-05 17:21:34 +00006502 * init/main.c (main): Guard against various things returning an error
6503 that we weren't catching.
6504
Scott James Remnant601a0e32007-01-05 17:06:31 +00006505 * init/tests/test_notify.c: Whitespace fix.
6506
Scott James Remnant15cd0862007-01-05 17:06:20 +00006507 * init/control.c (control_watch_jobs, control_unwatch_jobs)
6508 (control_watch_events, control_unwatch_events): Restore functionality
6509 to subscribe and unsubscribe from job and event notifications.
6510 * init/tests/test_control.c (test_watch_jobs, test_unwatch_jobs)
6511 (test_watch_events, test_unwatch_events): Check that the subscription
6512 and unsubscription messages work.
6513 * init/Makefile.am (test_control_LDADD): Link to notify.o
6514
6515 * init/control.c: Drop unused include of upstart/errors.h
6516
Scott James Remnant58cef572007-01-05 16:18:42 +00006517 * init/notify.c: Move functions that handle subscription and
6518 notification from control.c. Other than changing the names, we're
6519 keeping the API the same for now; expect it to change later when we
6520 add the ability to subscribe to individual jobs or events.
6521 (notify_init): initialise the subscriptions list; we don't have a
6522 separate send queue now that the control I/O is always asynchronous.
6523 * init/notify.h: Moved notification enum, structure and prototypes
6524 from control.h, changing the names so they match notify_* in the
6525 process.
6526 * init/Makefile.am (init_SOURCES): Build and link notify.c using
6527 notify.h
6528 (TESTS): Build the notify test suite binary.
6529 (test_notify_SOURCES, test_notify_LDFLAGS, test_notify_LDADD): Details
6530 for notify test suite binary.
6531 * init/tests/test_notify.c: Rewrite test cases in the manner of
6532 test_control.c so that we have one function for notify_job and
6533 one for notify_event, each of which contains the child process that
6534 receives the notification,
6535
Scott James Remnantb1679c62007-01-05 15:49:54 +00006536 * init/control.c (control_open): Allow this to be called to obtain
6537 the control socket, which means we can make it static.
6538 * init/tests/test_control.c (test_open): Check that it works.
6539
Scott James Remnantf7c6b062007-01-05 15:33:33 +00006540 * init/control.c, init/control.h, init/tests/test_control.c: Move
6541 functions that handle subscription and notification to new notify.c
6542 (control_init): Drop completely, no need to maintain a send queue now
6543 (control_open): Change to return an NihIo that uses the default
6544 control watcher, and our error handler. Split socket opening into
6545 (control_open_sock): which can be called from other functions.
6546 (control_close): Use nih_io_close() to close the socket and free the
6547 structure in one go.
6548 (control_reopen): Close the open control socket and open it again
6549 without destroying the NihIo structure, its queues or state.
6550 (control_close_handler): Handle the control socket going away
6551 (control_error_handler): Handle errors on the control socket,
6552 including the connection refused error that indicates a client went
6553 away.
6554 (control_handle): Split this into a miriad of small functions with
6555 a table to link them to the message type; this will make expanding
6556 each message handler much easier in future.
6557 * init/control.h: Update.
6558 * init/tests/test_control.c: Rewrite test cases to check the new
6559 handler functions; as a side-effect, this gets rid of the evil giant
6560 child/parent functions in favour of one test function per handler
6561 function.
6562
Scott James Remnantb4725d92007-01-05 13:10:21 +00006563 * upstart/message.c (upstart_message_handle_using): Wrapper function
6564 around upstart_message_handle that ensures all messages as passed to
6565 a single function.
6566 * upstart/message.h: Update.
6567 * upstart/tests/test_message.c (test_handle_using): Make sure it
6568 calls the single function.
6569
Scott James Remnantde3666f2007-01-04 23:00:07 +000065702007-01-04 Scott James Remnant <scott@netsplit.com>
6571
6572 * upstart/message.c (upstart_message_reader): Handle any errors
6573 that occurred while handling the message.
6574
Scott James Remnant92feed92007-01-02 15:27:47 +000065752007-01-02 Scott James Remnant <scott@netsplit.com>
6576
Scott James Remnant7833bbf2007-01-02 20:57:23 +00006577 * upstart/message.c (upstart_message_handle): Check that the name
6578 argument is never NULL.
6579 (upstart_message_reader): Simple message reader function that can
6580 be associated with an I/O watch and handles each message received.
6581 * upstart/message.h: Add prototype.
6582 * upstart/tests/test_message.c (test_reader): Test the reader function.
6583
Scott James Remnant0e3b5fe2007-01-02 18:39:03 +00006584 * upstart/control.c: Rename to upstart/message.c
6585 * upstart/control.h: Rename to upstart/message.h
6586 * upstart/tests/test_control.c: Rename to upstart/tests/test_message.c
6587 * upstart/libupstart.h: Update includes.
6588 * upstart/wire.c: Include message.h
6589 * upstart/wire.h: Update includes.
6590 * upstart/tests/test_wire.c: Update includes.
6591 * upstart/errors.h: Rename UPSTART_INVALID_MESSAGE to
6592 UPSTART_MESSAGE_INVALID so that it's prefixed.
6593 * upstart/Makefile.am (libupstart_la_SOURCES)
6594 (upstartinclude_HEADERS, TESTS): Update filenames.
6595
Scott James Remnant2ad9a042007-01-02 18:29:49 +00006596 * upstart/control.c (upstart_message_new): New function that
6597 creates an NihIoMessage directly from its arguments, which are a type
6598 followed by a variable number of args depending on that type.
6599 (upstart_message_handler): Function to find a handler function for
6600 a particular message type and origin process.
6601 (upstart_message_handle): New function that takes an NihIoMessage
6602 and invokes a handler function with a variable number of args
6603 depending on the message type.
6604 (upstart_send_msg, upstart_send_msg_to, upstart_recv_msg): Drop these
6605 functions, leave it up to the caller to decide whether to send and
6606 receive the messages synchronously or asynchronously; now that the
6607 capability is in nih_io_*.
6608 * upstart/control.h (UpstartMsgType): Rename to UpstartMessageType.
6609 (UpstartMessageHandler): Function with variable number of arguments
6610 that handles a message received.
6611 (UpstartMsg): Drop this structure entirely, we'll encode or decode
6612 the wire format directly from or into a function call, rather than
6613 use an intermediate structure to marshal it.
6614 (UpstartMessage): New structure to make a table that can be passed
6615 to upstart_message_handle to determine which handler should be called.
6616 * upstart/tests/test_control.c: Test new behaviour.
6617 * upstart/wire.c (upstart_push_header, upstart_pop_header): Change
6618 structure name for type parameter.
6619 * upstart/wire.h: Update.
6620 * upstart/tests/test_wire.c: Update.
6621
Scott James Remnant92feed92007-01-02 15:27:47 +00006622 * configure.ac (AC_COPYRIGHT): Update copyright to 2007.
6623
Scott James Remnant67546d12006-12-29 13:08:32 +000066242006-12-29 Scott James Remnant <scott@netsplit.com>
6625
6626 * upstart/wire.c (upstart_write_int, upstart_write_unsigned)
6627 (upstart_write_string, upstart_write_header, upstart_write_packv)
6628 (upstart_write_pack): Rename to *_push_*
6629 (upstart_read_int, upstart_read_unsigned, upstart_read_string)
6630 (upstart_read_header, upstart_read_packv, upstart_read_pack): Rename
6631 to *_pop_*.
6632 All of the above modified to modify an NihIoMessage structure,
6633 instead of trying to carry around buffers ourself.
6634 * upstart/wire.h: Update to match above.
6635 * upstart/tests/test_wire.c: Update all tests to match the above
6636 changes.
6637
Scott James Remnantd76e8e32006-12-21 18:34:31 +000066382006-12-21 Scott James Remnant <scott@netsplit.com>
6639
Scott James Remnantf922a982006-12-21 18:45:30 +00006640 * upstart/wire.c (upstart_read_packv, upstart_write_packv): Change
6641 nih_assert_notreached to nih_assert_not_reached.
6642
Scott James Remnantd76e8e32006-12-21 18:34:31 +00006643 * init/job.c (job_run_script): Open the NihIo structure in stream mode.
6644 * logd/main.c (logging_watcher): Open the NihIo structure in
6645 stream mode.
6646 (logging_reader): Need to pass the length of the size_t as a pointer
6647 so that it can be modified if less is read.
6648
Scott James Remnanta0385232006-12-17 15:21:39 +000066492006-12-17 Scott James Remnant <scott@netsplit.com>
6650
Scott James Remnant00cc6882006-12-17 19:54:36 +00006651 * upstart/wire.c (upstart_write_packv, upstart_write_pack)
6652 (upstart_read_packv, upstart_read_pack): Functions to write a pack
6653 of different variables to the stream, or read them from it
6654 * upstart/wire.h: Add prototypes.
6655 * upstart/tests/test_wire.c (test_write_pack, test_read_pack):
6656 Check we can read and write a pack of variables at once.
6657
Scott James Remnant518e1c12006-12-17 18:12:14 +00006658 * upstart/wire.c (upstart_write_header, upstart_read_header): Drop
6659 the version from the header, we'll just keep the protocol always
6660 backwards compatible.
6661 * upstart/wire.h: Update.
6662 * upstart/tests/test_wire.c (test_write_header, test_read_header):
6663 Check that everything works.
6664
Scott James Remnant64e378f2006-12-17 17:24:44 +00006665 * upstart/wire.c (upstart_write_string, upstart_read_string):
6666 Transmit the length as an unsigned, and use 0xffffffff to mean NULL
6667 instead of zero so we can still transmit the empty string.
6668 * upstart/wire.h: Update.
6669 * upstart/tests/test_wire.c (test_write_string, test_read_string):
6670 Tests for the functions to make sure the wire is at it should be.
6671
Scott James Remnantd6dde952006-12-17 17:00:56 +00006672 * upstart/wire.c (upstart_read_str, upstart_write_str): Rename to
6673 upstart_read_string and upstart_write_string.
6674 * upstart/wire.h: Update.
6675
Scott James Remnantc71ab3b2006-12-17 16:58:28 +00006676 * upstart/wire.c (upstart_write_unsigned, upstart_read_unsigned):
6677 Functions to send unsigned values over the wire, which we'll use
6678 to get a bit extra for the string lengths.
6679 * upstart/wire.h: Update.
6680 * upstart/tests/test_wire.c (test_write_unsigned)
6681 (test_read_unsigned): Test the new functions.
6682
Scott James Remnant0218e3a2006-12-17 16:39:33 +00006683 * upstart/wire.c (upstart_write_ints, upstart_read_ints): Drop
6684 these functions, we'll go with something far more generic and
6685 useful.
6686 * upstart/wire.h: Remove prototypes.
6687
Scott James Remnant9ee44302006-12-17 16:37:59 +00006688 * upstart/wire.c (upstart_write_int, upstart_read_int): Transmit
6689 integers as signed 32-bit values in network byte order.
6690 * upstart/tests/test_wire.c (test_write_int, test_read_int): Test
6691 the functions to make sure the wire is at it should be,
6692
Scott James Remnant5cef53e2006-12-17 15:41:13 +00006693 * upstart/control.c (upstart_read_int, upstart_write_int)
6694 (upstart_read_ints, upstart_write_ints, upstart_read_str)
6695 (upstart_write_str, upstart_read_header, upstart_write_header): Move
6696 functions to new wire.c file.
6697 * upstart/wire.c: Source file to hold wire protocol functions.
6698 * upstart/wire.h: Prototypes.
6699 * upstart/tests/test_wire.c: (empty) test suite.
6700 * upstart/libupstart.h: Include wire.h
6701 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link wire.c
6702 (upstartinclude_HEADERS): Install wire.h
6703 (TESTS): Build and run wire test suite.
6704 (test_wire_SOURCES, test_wire_LDFLAGS, test_wire_LDADD): Details for
6705 wire test suite binary.
6706
Scott James Remnanta0385232006-12-17 15:21:39 +00006707 * upstart/control.c (MAGIC): Change to "upstart\n", the final
6708 character was originally \0 and then was a " " for the 0.2 series.
6709 * upstart/tests/test_control.c (test_recv_msg): Change to match.
6710
Scott James Remnantfb9412a2006-12-15 18:03:22 +000067112006-12-15 Scott James Remnant <scott@netsplit.com>
6712
Scott James Remnant2e5fe2b2006-12-15 18:27:58 +00006713 * util/initctl.c, compat/sysv/telinit.c, compat/sysv/shutdown.c:
6714 Update all uses of the UpstartMsg structure to avoid the
6715 intermediate union that no longer exists.
6716
Scott James Remnantfb521462006-12-15 18:24:57 +00006717 * init/control.c, init/tests/test_control.c: Update all uses of
6718 the UpstartMsg structure to avoid the intermediate union that no
6719 longer exists.
6720
Scott James Remnant99b97662006-12-15 18:15:22 +00006721 * upstart/control.h: Combine all the previous message structures
6722 into just one that has all of the fields anyway.
6723 * upstart/control.c, upstart/tests/test_control.c: Update all uses of
6724 the UpstartMsg structure to avoid the intermediate union that no
6725 longer exists.
6726
Scott James Remnantd452ab12006-12-15 18:05:23 +00006727 * upstart/control.h (UPSTART_API_VERSION): Define API version macro
6728 to be public.
6729 * upstart/control.c (MSG_VERSION, upstart_send_msg_to): Replacing the
6730 previous MSG_VERSION macro here.
6731
Scott James Remnantfb9412a2006-12-15 18:03:22 +00006732 * upstart/control.c (upstart_read_int, upstart_write_int)
6733 (upstart_read_ints, upstart_write_ints, upstart_read_str)
6734 (upstart_write_str, upstart_read_header, upstart_write_header):
6735 New functions to replace the old "write a struct" protocol with
6736 something a little more regimented and supportable.
6737 (IOVEC_ADD, IOVEC_READ, WireHdr, WireJobPayload, WireJobStatusPayload)
6738 (WireEventPayload): Remove these structures, use the functions
6739 instead.
6740 (upstart_send_msg_to): Call write functions intead of using macros,
6741 this makes the code somewhat neater.
6742 (upstart_recv_msg): Call read functions instead of using macros,
6743 again making the code somewhat neater.
6744 * upstart/tests/test_control.c (test_recv_msg): Change wire
6745 tests to match new protocol, and thus actually work properly,
6746 previously these were endian sensitive.
6747
Scott James Remnant27ebd792006-12-14 11:37:14 +000067482006-12-14 Scott James Remnant <scott@netsplit.com>
6749
Scott James Remnant136dc6f2006-12-14 12:36:43 +00006750 * compat/sysv/shutdown.c (wall): Construct the wall message so that
6751 we don't put \r into a po file; for some reason, gettext hates that
6752 and bitches about it. Someone's confusing internationalisation with
6753 operating system portability, I expect.
6754
Scott James Remnantf334f842006-12-14 11:46:14 +00006755 * util/man/initctl.8: Drop reference to start(8), as that's just
6756 a symlink to initctl now.
6757
Scott James Remnant88847432006-12-14 11:44:36 +00006758 * init/man/init.8: Link to initctl.
6759
Scott James Remnantf6b237a2006-12-14 11:40:49 +00006760 * compat/sysv/reboot.c (main): Clear up help text a little.
6761
Scott James Remnant3b4b2272006-12-14 11:39:05 +00006762 * HACKING: Correct some typos.
6763
Scott James Remnant27ebd792006-12-14 11:37:14 +00006764 * configure.ac (AC_INIT): Correct bug reporting address.
6765
Scott James Remnant1d8763a2006-12-13 17:49:38 +000067662006-12-13 Scott James Remnant <scott@netsplit.com>
6767
Scott James Remnantecec0fe2006-12-13 21:55:28 +00006768 * configure.ac: Bump version to 0.3.2
6769
Scott James Remnantf642ffa2006-12-13 18:24:22 +00006770 * NEWS: Update.
6771
Scott James Remnant1d8763a2006-12-13 17:49:38 +00006772 * util/initctl.c (print_job_status): Drop the newline from the
6773 output.
6774
Scott James Remnant567cbdc2006-12-13 17:07:58 +000067752006-12-13 Alex Smith <alex@alex-smith.me.uk>
6776
6777 * util/initctl.c (print_job_status): Clean up initctl job status
6778 output, which was badly converted from printf to nih_message.
6779
Scott James Remnante2cf6392006-12-13 17:02:20 +000067802006-12-13 Scott James Remnant <scott@netsplit.com>
6781
6782 * compat/sysv/man/shutdown.8: Add missing documentation on the
6783 format of TIME by copying it from --help output.
6784
Scott James Remnantfec90562006-12-13 17:00:40 +000067852006-12-13 Alex Smith <alex@alex-smith.me.uk>
6786
6787 * init/process.c (process_setup_console): Actually send output to
6788 /dev/null instead of /dev/console, when CONSOLE_NONE.
6789
Scott James Remnantf233c9d2006-12-13 16:45:35 +000067902006-12-13 Scott James Remnant <scott@netsplit.com>
6791
Scott James Remnantfbf7a5c2006-12-13 16:54:42 +00006792 * Makefile.am (EXTRA_DIST): Distribute the nih ChangeLog as well.
6793
Scott James Remnantf233c9d2006-12-13 16:45:35 +00006794 * init/tests/test_job.c: Port to the new test framework.
6795 * init/job.c (job_set_idle_event): Fix a slight memory leak,
6796 repeated setting of the idle event never freed the previous one set.
6797
Scott James Remnant1abced42006-12-12 11:28:49 +000067982006-12-12 Scott James Remnant <scott@netsplit.com>
6799
Scott James Remnantfbad50c2006-12-12 18:47:43 +00006800 * init/tests/test_cfgfile.c: Port to the new test framework.
6801
Scott James Remnantef372232006-12-12 17:23:05 +00006802 * init/tests/test_control.c: Port to the new test framework.
6803 * init/init.supp: Suppress the list head allocated within control_init.
6804
Scott James Remnant2c2e01a2006-12-12 17:22:40 +00006805 * init/control.c (control_watcher): Need to save the pid when we
6806 get ECONNREFUSED, otherwise we lose it when we free the message.
6807
Scott James Remnant40f7d912006-12-12 15:31:35 +00006808 * init/tests/test_process.c: Port to the new test framework.
6809 * init/init.supp: Suppress the list head allocated within job_init.
6810
Scott James Remnantfc456592006-12-12 14:09:45 +00006811 * init/init.supp: Include a valgrind suppressions file.
6812 * init/Makefile.am (EXTRA_DIST): Distribute the suppressions file.
6813
Scott James Remnant96c9b072006-12-12 14:07:30 +00006814 * init/tests/test_event.c: Port to the new test framework.
6815
Scott James Remnant237c7f62006-12-12 13:49:19 +00006816 * logd/Makefile.am, util/Makefile.am, compat/sys/Makefile.am
6817 (AM_CPPFLAGS): Add -I$(srcdir), necessary for testing "programs"
6818 that don't have usual library path semantics.
6819
Scott James Remnant2a35ab92006-12-12 13:23:10 +00006820 * upstart/tests/test_control.c: Port to the new test framework.
6821 * upstart/control.c (upstart_free): Drop this function, while not
6822 exposing libnih is a valiant effort, it already slips out because
6823 of the error handling.
6824
Scott James Remnant905dd272006-12-12 12:38:34 +00006825 * upstart/tests/test_job.c: Add missing include.
6826
Scott James Remnante77567f2006-12-12 12:25:46 +00006827 * upstart/tests/test_job.c: Port to the new test framework.
6828 (test_process_state_name): Check that this returns NULL.
6829
Scott James Remnantb7983062006-12-12 11:34:49 +00006830 * HACKING: Update location of download directory. Document
6831 requirement that all code have test cases.
6832
Scott James Remnant0c577ce2006-12-12 11:31:13 +00006833 * logd/main.c (open_logging): Likewise.
6834
Scott James Remnantc654baf2006-12-12 11:30:44 +00006835 * init/control.c (control_open): No need to set ENOMEM, errno is
6836 always set anyway.
6837
Scott James Remnant1abced42006-12-12 11:28:49 +00006838 * configure.ac (AM_INIT_AUTOMAKE): Include nostdinc so we don't get
6839 Automake's broken default includes.
6840 * upstart/Makefile.am (DEFAULT_INCLUDES): Drop override now that
6841 we don't need it.
6842 (DEFS, INCLUDES): Replace these variables with the combined
6843 (AM_CPPFLAGS): variable that declares everything.
6844 * init/Makefile.am (DEFAULT_INCLUDES): Drop override now that
6845 we don't need it.
6846 (DEFS, INCLUDES): Replace these variables with the combined
6847 (AM_CPPFLAGS): variable that declares everything.
6848 * util/Makefile.am (DEFAULT_INCLUDES): Drop override now that
6849 we don't need it.
6850 (DEFS, INCLUDES): Replace these variables with the combined
6851 (AM_CPPFLAGS): variable that declares everything.
6852 * compat/sysv/Makefile.am (DEFAULT_INCLUDES): Drop override now that
6853 we don't need it.
6854 (DEFS, INCLUDES): Replace these variables with the combined
6855 (AM_CPPFLAGS): variable that declares everything.
6856 * logd/Makefile.am (DEFAULT_INCLUDES): Drop override now that
6857 we don't need it.
6858 (DEFS, INCLUDES): Replace these variables with the combined
6859 (AM_CPPFLAGS): variable that declares everything.
6860
Scott James Remnantacec3b22006-11-02 16:36:53 +000068612006-11-02 Scott James Remnant <scott@netsplit.com>
6862
6863 * util/initctl.c (start_action): Remove break calls which shouldn't
6864 be there.
6865
Scott James Remnantea806b72006-10-18 15:01:00 +010068662006-10-18 Sean E. Russell <ser@ser1.net>
6867
6868 * init/main.c: Include sys/time.h
6869 * init/cfgfile.c: Include sys/time.h and sys/resource.h
6870 * init/job.c: Include sys/time.h and sys/resource.h
6871
Scott James Remnant6702ac12006-10-17 18:55:24 +010068722006-10-17 Scott James Remnant <scott@netsplit.com>
6873
Scott James Remnantd5758f42006-10-17 19:21:25 +01006874 * configure.ac: Bump version to 0.3.1
6875
Scott James Remnantfd029da2006-10-17 19:21:07 +01006876 * NEWS: Update.
6877 * TODO: Update.
6878
Scott James Remnant9f67cb82006-10-17 19:12:28 +01006879 * configure.ac (AM_GNU_GETTEXT_VERSION): Quote version number.
6880
Scott James Remnant4ebe87f2006-10-17 19:04:40 +01006881 * logd/Makefile.am (event.d/logd): Make the event.d sub-directory
6882 in case we're building outside of the source tree.
6883
Scott James Remnant6702ac12006-10-17 18:55:24 +01006884 * compat/sysv/runlevel.c (store): Don't break strict-aliasing rules
6885 by avoiding dereferencing type-punned pointer. Answers on a
6886 postcard, please.
6887
Scott James Remnant7f133012006-10-13 12:00:34 +010068882006-10-13 Scott James Remnant <scott@netsplit.com>
6889
Scott James Remnantecbb2b52006-10-13 15:18:24 +01006890 * util/initctl.c (start_action, emit_action): Add missing \n
6891
Scott James Remnant48622982006-10-13 15:15:50 +01006892 * util/initctl.c: Rewrite using nih_command_parser.
6893 * util/man/initctl.8: Improve.
6894
6895 * util/start.c: Remove, replaced by initctl.
6896 * util/man/start.8: Remove, replaced by initctl.
6897 * util/Makefile.am (sbin_PROGRAMS): Drop start, now just a symlink
6898 to initctl.
6899 (dist_man_MANS): Drop start.8, now a symlink to initctl.8
6900 (install-exec-hook): Make symlinks to initctl, add start
6901 (install-data-hook): Make symlinks to initctl.8, add start.8
6902
Scott James Remnantb1d8a7d2006-10-13 13:57:31 +01006903 * initctl: Rename to util again, I don't want a separate directory
6904 for every single little tool; and we'll be shipping more than just
6905 initctl (e.g. a non-compat reboot).
6906 * configure.ac (AC_CONFIG_FILES): Make util/Makefile instead of
6907 initctl/Makefile.
6908 * Makefile.am (SUBDIRS): Descend into util, not initctl.
6909
Scott James Remnanta48b4fe2006-10-13 13:49:46 +01006910 * compat/sysv/reboot.c: Remove long options where they didn't exist
6911 before. Write help text.
6912 * compat/sysv/man/reboot.8: Update.
6913
Scott James Remnant462734c2006-10-13 13:36:00 +01006914 * init/main.c (main): Formatting.
6915 * logd/main.c (main): Formatting.
6916 * logd/man/logd.8: Formatting.
6917 * compat/sysv/runlevel.c (main): Formatting.
6918 * compat/sysv/telinit.c (main): Formatting.
6919 * compat/sysv/man/shutdown.8: Remove long options.
6920
Scott James Remnanteff01f12006-10-13 13:32:12 +01006921 * compat/sysv/shutdown.c: Remove -e/--event, it has no place in a
6922 compatibility tool. Get rid of long options that never existed
6923 before. Specify help text to describe the options.
6924 * compat/sysv/man/shutdown.8: Spruce up a bit.
6925
Scott James Remnant4a5cd212006-10-13 12:59:15 +01006926 * compat/sysv/telinit.c (main): Set help text to list the valid
6927 runlevels.
6928 * compat/sysv/man/telinit.8: Refine the notes to mention runlevel(8).
6929
Scott James Remnantf7819622006-10-13 12:54:43 +01006930 * compat/sysv/runlevel.c (main): Make the help text describe the
6931 options, rather than the behaviour.
Scott James Remnant4a5cd212006-10-13 12:59:15 +01006932 * compat/sysv/man/runlevel.8: Flesh out a little more.
Scott James Remnantf7819622006-10-13 12:54:43 +01006933
Scott James Remnant930e25a2006-10-13 12:28:05 +01006934 * configure.ac (AC_INIT): Change bug reporting address to the
6935 mailing list, since Launchpad doesn't accept random bugs without
6936 accounts and complicated control messages.
6937 * init/main.c, logd/main.c: Add a period to the synopsis.
6938
Scott James Remnanta6ed7eb2006-10-13 12:14:45 +01006939 * init/main.c (main): Set the synopsis, and direct people to look
6940 at telinit in the --help output.
6941 * init/man/init.8: Flesh this out a little more, still a lot of
6942 explaining to do about jobs and events, but we'll wait until we've
6943 changed that code before documentating the behaviour.
6944
Scott James Remnant7f133012006-10-13 12:00:34 +01006945 * logd/main.c (main): Correct help text to describe the options,
6946 rather than what the program does. As per standard style.
6947 Don't become a daemon until the logging socket is open, and make
6948 that exclusive with waiting for SIGCONT.
6949 * logd/man/logd.8: Write some more extensive documentation,
6950 including describing the startup interlock and the socket protocol.
6951 * TODO: Plan to get rid of the signal interlock from logd.
6952
Scott James Remnant8985dd32006-10-12 15:26:29 +010069532006-10-12 Scott James Remnant <scott@netsplit.com>
6954
6955 * configure.ac: Expand AC_GNU_SOURCE so we get _GNU_SOURCE and so
6956 that gettext doesn't complain.
6957 (AM_GNU_GETTEXT_VERSION): Increase to 0.15
6958 (AC_PREREQ): Increase to 2.60
6959 * HACKING: Update autoconf and gettext requirements.
6960
Scott James Remnantc16a9b42006-10-11 17:08:58 +010069612006-10-11 Scott James Remnant <scott@netsplit.com>
6962
Scott James Remnant74a11442006-10-11 17:58:56 +01006963 * init/control.c (control_init): Pass NULL to nih_list_new.
6964 Clarify list item types.
6965 * init/event.c (event_init): Pass NULL to nih_list_new.
6966 * init/job.c (job_init): Pass NULL to nih_list_new.
6967
Scott James Remnantc34c4be2006-10-11 17:56:34 +01006968 * init/main.c: Change nih_signal_add_callback to nih_signal_add_handler
6969 and NihSignalCb to NihSignalHandler.
6970
Scott James Remnant8b227402006-10-11 17:55:27 +01006971 * init/cfgfile.c, init/cfgfile.h, init/control.c, init/control.h,
6972 init/event.c, init/event.h, init/job.c, init/job.h, init/main.c,
6973 init/process.c: Clean up documentation strings and parent pointer
6974 types.
6975
Scott James Remnantd033c862006-10-11 17:41:22 +01006976 * compat/sysv/shutdown.c: Change nih_signal_add_callback to
6977 nih_signal_add_handler.
6978
Scott James Remnant1ee0f482006-10-11 17:40:41 +01006979 * compat/sysv/reboot.c: Set synopsis text depending on command
6980 used (probably should use nih_command_parser?)
6981 * compat/sysv/runlevel.c: Set synopsis and help text, and correct
6982 usage.
6983 * compat/sysv/shutdown.c: Set synopsis text.
6984 * compat/sysv/telinit.c: Set synopsis text.
6985
Scott James Remnant3b734642006-10-11 17:22:33 +01006986 * compat/sysv/runlevel.c, compat/sysv/shutdown.c: Clean up
6987 documentation strings.
6988
Scott James Remnantc6e4f002006-10-11 17:22:03 +01006989 * logd/main.c: Set synopsis and help text.
6990
Scott James Remnant5e31d742006-10-11 17:16:55 +01006991 * logd/main.c: Clean up documentation strings.
6992 Change nih_signal_add_callback to nih_signal_add_handler.
6993
Scott James Remnant48359382006-10-11 17:13:48 +01006994 * upstart/control.c, upstart/control.h, upstart/job.c: Clean up
6995 documentation strings and correct parent pointer type.
6996
Scott James Remnantc16a9b42006-10-11 17:08:58 +01006997 * HACKING: Detail function documentation requirement and format.
6998
Scott James Remnant59093a82006-10-10 13:09:58 +010069992006-10-10 Scott James Remnant <scott@netsplit.com>
7000
Scott James Remnant335947d2006-10-11 17:08:34 +01007001 * event.d/logd.in: Move to logd/event.d
7002 * event.d/Makefile.am: Remove
7003 * logd/Makefile.am: Create the logd job definition and install
7004 * Makefile.am (SUBDIRS): event.d directory has been removed.
7005 * configure.ac (AC_CONFIG_FILES): No longer make event.d/Makefile
7006
Scott James Remnant59093a82006-10-10 13:09:58 +01007007 * configure.ac: Check for --enable-compat, default to sysv if given
7008 or no compat if not given.
7009 * compat/sysv/Makefile.am: Don't build binaries or install manpages
7010 unless COMPAT_SYSV is defined.
7011
Scott James Remnant45150942006-10-06 16:36:27 +010070122006-10-06 Scott James Remnant <scott@netsplit.com>
7013
7014 * doc/upstart-logo.svg: Include the logo Alexandre designed.
7015 * doc/Makefile.am (EXTRA_DIST): Ship the logo in the tarball.
7016 * Makefile.am (SUBDIRS): Install under doc
7017 * configure.ac: Generate doc/Makefile
7018 * AUTHORS: Ensure he's credited fully.
7019
Scott James Remnant10b8c0e2006-09-27 21:27:38 +010070202006-09-27 Scott James Remnant <scott@netsplit.com>
7021
Scott James Remnant44052a32006-09-28 00:04:32 +01007022 * event.d/Makefile.am (do_subst): Eliminate duplicate /s
7023
Scott James Remnant5222c402006-09-27 22:48:48 +01007024 * man/init.8: Move to init/man
7025 * init/Makefile.am: Update to install man page.
7026 * man/logd.8: Move to logd/man
7027 * logd/Makefile.am: Update to install man page.
7028 * man/initctl.8, man/start.8: Move to initctl/man
7029 * initctl/Makefile.am: Update to install man pages.
7030 * man/reboot.8, man/runlevel.8, man/shutdown.8, man/telinit.8:
7031 Move to compat/sysv/man
7032 * compat/sysv/Makefile.am: Update to install man pages.
7033 * man/Makefile.am: Remove
7034 * configure.ac (AC_CONFIG_FILES): Remove man/Makefile
7035 * Makefile.am (SUBDIRS): Don't build in man
7036
Scott James Remnant545cb8c2006-09-27 21:32:49 +01007037 * util: Rename to initctl
7038 * configure.ac (AC_CONFIG_FILES): Update.
7039 * Makefile.am (SUBDIRS): Update.
7040
Scott James Remnant960c82d2006-09-27 21:30:42 +01007041 * util/reboot.c: Move to compat/sysv
7042 * util/shutdown.c: Move to compat/sysv
7043 * util/Makefile.am: Update.
7044 * compat/sysv/Makefile.am: Update.
7045
Scott James Remnant10b8c0e2006-09-27 21:27:38 +01007046 * configure.ac: Replace macros with single call to NIH_INIT.
7047 Bump version to 0.3.0 to begin new development cycle.
7048
Scott James Remnante5591992006-09-21 05:49:34 +010070492006-09-21 Scott James Remnant <scott@netsplit.com>
7050
7051 * logd/main.c: Revert the change that logged to the console, in
7052 practice this doesn't work so well. I want to get rid of logd
7053 in the long term, or at least just have it as a simple logging
7054 proxy, so giving it features seems wrong.
7055
Scott James Remnant9b58b842006-09-20 05:37:47 +010070562006-09-20 Scott James Remnant <scott@netsplit.com>
7057
Scott James Remnant97f08fa2006-09-20 06:34:12 +01007058 * configure.ac: Bump version to 0.2.8
7059 * NEWS: Updated.
7060
Scott James Remnante59c71e2006-09-20 06:14:32 +01007061 * logd/main.c (main): Check the kernel command-line for "quiet"
7062 (line_reader): Write to console unless silent or a daemon
7063
Scott James Remnant9b58b842006-09-20 05:37:47 +01007064 * man/Makefile.am (dist_man_MANS): Drop sulogin.8
7065 * man/sulogin.8: Drop, we don't include an sulogin
7066
Scott James Remnant0fafba42006-09-20 01:36:29 +010070672006-09-19 Michael Biebl <mbiebl@gmail.com>
7068
7069 * event.d/Makefile.am (logd): Drop $(srcdir)
7070 * init/Makefile.am (init_SOURCES): Distribute paths.h
7071
Scott James Remnant58f165f2006-09-18 19:43:07 +010070722006-09-18 Michael Biebl <mbiebl@gmail.com>
7073
7074 * configure.ac: Check for sys/inotify.h
7075
Scott James Remnante371cab2006-09-18 16:16:00 +010070762006-09-18 Scott James Remnant <scott@netsplit.com>
7077
7078 * util/shutdown.c (warning_message): Adjust method of constructing
7079 the message to not confuse poor translators who think \r and \n are
7080 the same thing!
7081
Scott James Remnantf2b1c052006-09-14 10:34:45 +010070822006-09-14 Scott James Remnant <scott@netsplit.com>
7083
Scott James Remnantb2e03d02006-09-14 11:20:13 +01007084 * init/job.c (job_change_state): Catch runaway respawns when we
7085 enter the running state, so we catch stop/start loops too.
7086 * init/tests/test_job.c (test_change_state): Update test.
7087
Scott James Remnantb7714f72006-09-14 11:07:38 +01007088 * event.d/logd: Rename to logd.in
7089 * event.d/logd.in: Replace /sbin with @sbindir@ so we can transform
7090 * event.d/Makefile.am: Generate logd from logd.in
7091
Scott James Remnant7e6bdb32006-09-14 10:57:03 +01007092 * util/reboot.c: Don't hardcode the location of /sbin/shutdown
7093 * util/Makefile.am (DEFS): Use autoconf to seed it
7094 * util/shutdown.c (sysvinit_shutdown): Don't hardcode the location
7095 of /dev/initctl
7096
Scott James Remnante0d0dd12006-09-14 10:51:05 +01007097 * init/paths.h: Create a new configuration file that can contain
7098 all of the path definitions, and in particular, allow them to be
7099 overidden elsewhere.
7100 * init/Makefile.am (DEFS): Override definitions of CFG_DIR and
7101 TELINIT using autoconf
7102 * init/main.c: Include paths.h. Don't hardcode location of telinit
7103 * init/job.c: Include paths.h
7104 * init/process.c: Include paths.h
7105 * init/process.h: Remove definitions from here.
7106
Scott James Remnantf2b1c052006-09-14 10:34:45 +01007107 * configure.ac: Bump version to 0.2.7
7108
Scott James Remnant0b8f23f2006-09-13 16:51:38 +010071092006-09-13 Scott James Remnant <scott@netsplit.com>
7110
Scott James Remnant948ab872006-09-14 10:34:34 +01007111 * NEWS: Updated.
7112
Scott James Remnant0b8f23f2006-09-13 16:51:38 +01007113 * TODO: More TODO.
7114
Scott James Remnant080dd8d2006-09-10 12:42:03 +010071152006-09-10 Scott James Remnant <scott@netsplit.com>
7116
7117 * util/reboot.c (main): Don't give -H with "halt".
7118
Scott James Remnantd7042862006-09-09 00:50:10 +010071192006-09-09 Scott James Remnant <scott@netsplit.com>
7120
Scott James Remnantedb97902006-09-09 05:48:42 +01007121 * configure.ac: Bump version to 0.2.6
7122
Scott James Remnant760237e2006-09-09 05:38:32 +01007123 * NEWS: Update.
7124 * TODO: Update.
7125
Scott James Remnant5e267a42006-09-09 05:21:28 +01007126 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
7127 the magic to be the package string.
7128 * upstart/tests/test_control.c (test_recv_msg): Update tests.
7129
Scott James Remnant17fec6e2006-09-09 05:05:42 +01007130 * util/initctl.c (main): Set the usage string.
7131 * util/shutdown.c (main): Set the usage string.
7132 * util/start.c (main): Set the usage string.
7133 * compat/sysv/runlevel.c (main): Set the usage string.
7134 * compat/sysv/telinit.c (main): Set the usage string.
7135
Scott James Remnantabede802006-09-09 05:01:45 +01007136 * man/Makefile.am: Use install-data-hook and $(man8dir)
7137 * util/Makefile.am: Also use install-exec-hook
7138
Scott James Remnantc6c20052006-09-09 04:58:11 +01007139 * Makefile.am (SUBDIRS): Install contents of the man directory
7140 * configure.ac (AC_CONFIG_FILES): Generate man/Makefile
7141 * man/Makefile.am: Install manpages in the appropriate places.
7142 * man/init.8, man/logd.8, man/initctl.8, man/reboot.8,
7143 * man/shutdown.8, man/start.8, man/sulogin.8, man/runlevel.8,
7144 * man/telinit.8: Include some basic manpages so we at least have
7145 some level of documentation.
7146
Scott James Remnant33e47112006-09-09 03:45:00 +01007147 * init/job.c (job_child_reaper): Don't check the exit status of
7148 a respawning job if the goal is to stop it.
7149
Scott James Remnant1889aa62006-09-09 03:41:53 +01007150 * compat/sysv/telinit.c (main): Generate events rather than
7151 starting and stopping jobs directly, the events are named
7152 "runlevel-X". 0, 1, 6 and s/S are shutdown events.
7153
Scott James Remnant515b2b92006-09-09 03:41:27 +01007154 * logd/main.c (main): Raise SIGSTOP before entering the main loop.
7155 * init/main.c (main): Interlock with logd.
7156
Scott James Remnant17eb9052006-09-09 03:41:04 +01007157 * event.d/logd: Should not be a console owner, but should stop
7158 on shutdown.
7159
Scott James Remnant34752262006-09-09 01:38:02 +01007160 * init/process.c (process_setup_console): Revert part of the previous
7161 change, should just output to /dev/null if we don't have logd.
7162
Scott James Remnante5533332006-09-09 01:36:07 +01007163 * configure.ac: Bump version to 0.2.5
7164
Scott James Remnantb4a1c2b2006-09-09 01:28:26 +01007165 * init/main.c (main): Start the logd job if it exists.
7166
7167 * init/process.c (process_setup_console): Ignore ECONNREFUSED as
7168 that just means that logd isn't around, handle errors by falling
7169 back to opening the console.
7170
Scott James Remnant9fb20d42006-09-09 01:22:03 +01007171 * init/process.c (process_setup_console): Implement handling for
7172 CONSOLE_LOGGED and generally clean up the other handling.
7173 * init/process.h: Update.
7174 * init/main.c (main): Pass NULL for the job to setup console.
7175 * TODO: Update.
7176
Scott James Remnantd7042862006-09-09 00:50:10 +01007177 * logd/main.c: Implement the logging daemon, it accepts connections
7178 on a unix stream socket with the abstract name
7179 "/com/ubuntu/upstart/logd", expects the length of the name and the
7180 name to follow; then sequences of lines which are logged to
7181 /var/log/boot, or memory until that file can be opened.
7182
Scott James Remnant527b9452006-09-08 17:15:07 +010071832006-09-08 Scott James Remnant <scott@netsplit.com>
7184
Scott James Remnantcb655e72006-09-08 17:49:20 +01007185 * util/shutdown.c (event_setter): Change the event names to
7186 distinguish between "shutdown -h" and "shutdown -h -H".
7187
Scott James Remnant90732d32006-09-08 17:33:19 +01007188 * init/job.c (job_handle_event): Allow jobs to react to their own
7189 events, this is how we'll do respawn eventually.
7190 * init/tests/test_job.c (test_handle_event): Remove test.
7191
Scott James Remnantbb3cc3f2006-09-08 17:17:47 +01007192 * init/main.c (cad_handler, kbd_handler): Generate the new event
7193 names.
7194 * init/event.h (CTRLALTDEL_EVENT, KBDREQUEST_EVENT): Add definitions
7195 of these event names, change the ctrlaltdel event to just that.
7196
Scott James Remnant527b9452006-09-08 17:15:07 +01007197 * logd/main.c (main): Add the code to daemonise, etc.
7198
Scott James Remnanta17917d2006-09-07 00:18:28 +010071992006-09-07 Scott James Remnant <scott@netsplit.com>
7200
Scott James Remnant214ebe82006-09-07 21:48:55 +01007201 * TODO: Long discussion today on #upstart, many improvements to the
7202 job and event model that make it more elegant.
7203 * AUTHORS: Include a list of thanks.
7204
Scott James Remnantb8280072006-09-07 03:19:00 +01007205 * util/shutdown.c (shutdown_now): If we get ECONNREFUSED when we
7206 try and send the shutdown event to init, it probably means we're
7207 still in sysvinit. So try that instead.
7208 (sysvinit_shutdown): Function to send a hand-crafted runlevel
7209 change message across /dev/initctl.
7210
Scott James Remnantae969062006-09-07 00:43:57 +01007211 * util/initctl.c (main): Add a shutdown command that takes an
7212 arbitrary event name to be issued after "shutdown". You'll
7213 nearly always want the /sbin/shutdown tool instead.
7214
Scott James Remnant987bcc42006-09-07 00:38:24 +01007215 * init/job.c (job_detect_idle): Only generate the stalled event
7216 if at least one job handles it in its start_events list.
7217 * init/tests/test_job.c (test_detect_idle): Make sure that works.
7218
Scott James Remnantea204d42006-09-07 00:30:53 +01007219 * init/event.h (STARTUP_EVENT, SHUTDOWN_EVENT, STALLED_EVENT):
7220 Macros to define the standard event names.
7221 * init/main.c (main): Use STARTUP_EVENT macro instead of "startup"
7222 * init/control.c (control_handle): Use SHUTDOWN_EVENT macro
7223 instead of "shutdown".
7224 * init/job.c (job_detect_idle): Use STALLED_EVENT macro instead
7225 of "stalled".
7226
Scott James Remnant84607df2006-09-07 00:27:22 +01007227 * init/job.c (job_detect_idle): Add some log messages for when we
7228 detect the idle or stalled states.
7229 (job_kill_process, job_kill_timer): Increase log verbosity.
7230 * init/event.c (event_queue_run): Log which events we're handling
7231 if --debug is given.
7232
Scott James Remnanta17917d2006-09-07 00:18:28 +01007233 * compat/sysv/telinit.c (main): Send a shutdown command when
7234 requesting to enter runlevel 0 or runlevel 6, likewise for
7235 runlevel 1, s or S which all run "rc1" not "rcS".
7236 * init/main.c (main): When called directory (pid != 1) try and
7237 run telinit before complaining that we're not init. Make sure
7238 errors aren't lost.
7239
Scott James Remnantf5c376c2006-09-04 16:25:04 +010072402006-09-04 Johan Kiviniemi <johan@kiviniemi.name>
Scott James Remnantedcae302006-09-04 07:06:23 +01007241
Scott James Remnantf5c376c2006-09-04 16:25:04 +01007242 * upstart/control.c (upstart_addr): Replace use of __builtin_offsetof
7243 with offsetof.
7244 * upstart/tests/test_control.c (test_recv_msg): Likewise.
7245
72462006-09-04 Scott James Remnant <scott@netsplit.com>
7247
Scott James Remnantedcae302006-09-04 07:06:23 +01007248 * util/shutdown.c (main): Exit normally after sending the warning
7249 message if -k is given.
7250
Scott James Remnante94bd202006-09-01 00:48:36 +010072512006-09-01 Scott James Remnant <scott@netsplit.com>
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01007252
Scott James Remnant294cde72006-09-01 19:58:35 +01007253 * configure.ac: Bump version to 0.2.2
7254
Scott James Remnant7663bfb2006-09-01 19:58:19 +01007255 * NEWS: Update.
7256 * configure.ac: Bump version to 0.2.1
7257
Scott James Remnant67982142006-09-01 19:47:39 +01007258 * init/process.c (process_setup_console): Ensure that the console
7259 is always initialised to at least /dev/null
7260 * init/job.c (job_change_state): Initialise event to NULL.
7261 * init/event.c (event_read_state): Don't mask initialisation of
7262 other variable.
7263 * init/cfgfile.c (cfg_job_stanza, cfg_parse_script, cfg_next_token):
7264 Print lineno using %zi not %d
7265 * compat/sysv/runlevel.c (store): Cast pointer type of timeval.
7266
Scott James Remnant097b2a92006-09-01 19:30:37 +01007267 * init/main.c: Move the kernel headers include beneath the C
7268 library ones, so that compilation doesn't fail on !i386.
7269 * util/reboot.c: Likewise.
7270
Scott James Remnant28fcc922006-09-01 04:15:57 +01007271 * init/main.c (term_handler): Close the control connection if we
7272 re-exec init, otherwise it won't be able to bind. Drop debugging.
7273
Scott James Remnant6f464962006-09-01 04:10:20 +01007274 * init/main.c (term_handler): It always helps if we dup2 the
7275 right file descriptor.
7276
Scott James Remnant1db88042006-09-01 03:14:19 +01007277 * init/main.c: Use the TERM signal instead of USR1, as old init
7278 used that for something else. Also rather than passing across
7279 file descriptor numbers, use a fixed descriptor and just pass
7280 "--restart". When we get that option we need to unmask signals
7281 otherwise we sit there looking like a lemon.
7282
Scott James Remnante7a73262006-09-01 02:32:27 +01007283 * init/job.c (job_change_state): Don't free the event unless we
7284 generate one.
7285
Scott James Remnant12dd7252006-09-01 02:27:04 +01007286 * NEWS: Update.
7287
Scott James Remnant694172a2006-09-01 02:26:45 +01007288 * init/cfgfile.c (cfg_watcher): Ignore any file with '.' or '~'
7289
Scott James Remnantc6e63dd2006-09-01 02:16:43 +01007290 * TODO: Update.
7291
Scott James Remnant3401ab72006-09-01 02:14:47 +01007292 * init/main.c (main): Parse command-line arguments, specifically
7293 look for --state-fd which we'll use for reexec. Don't do a couple
7294 of things if we're passed this.
7295 (read_state): Parse the line-buffered state.
7296 * init/job.c (job_read_state, job_write_state): Job state
7297 serialisation so that we can re-exec ourselves.
7298 * init/job.h: Update.
7299 * init/tests/test_job.c: Test the serialisation.
7300 * init/event.c (event_read_state, event_write_state): And similar
7301 functions for serialising the event queue.
7302 * init/event.h: Update.
7303 * init/tests/test_event.c: Test the serialisation.
7304 * init/cfgfile.c (cfg_read_job): Fix a bug, need to subtract current
7305 time to get due time.
7306
Scott James Remnante94bd202006-09-01 00:48:36 +01007307 * upstart/job.c (job_goal_from_name, job_state_from_name)
7308 (process_state_from_name): Add opposite numbers that convert a
7309 string back into an enumeration.
7310 * upstart/job.h: Update.
7311 * upstart/tests/test_job.c: Test the new functions.
7312
73132006-08-31 Scott James Remnant <scott@netsplit.com>
Scott James Remnant694172a2006-09-01 02:26:45 +01007314
Scott James Remnantb7260a72006-08-31 22:08:56 +01007315 * init/job.h (Job): Add respawn_limit, respawn_interval,
7316 respawn_count and respawn_time members so that we can keep track of
7317 runaway processes.
7318 * init/job.c (job_catch_runaway): Increment the respawn_count
7319 within respawn_interval, or reset it if we go over.
7320 (job_new): Initialise respawn_limit and respawn_interval to sensible
7321 defaults.
7322 * init/tests/test_job.c (test_new): Check the defaults are set.
7323 (test_change_state): Check the respawning code works.
7324 * init/cfgfile.c (cfg_job_stanza): Parse the "respawn limit" stanza.
7325 * init/tests/test_cfgfile.c (test_read_job): Test the new stanza.
7326
Scott James Remnantff0d26a2006-08-31 20:49:43 +01007327 * init/process.c (process_setup_console): Remove the console reset
7328 code, it tends to just crash X and seems to do nothing interesting.
7329 * init/main.c (reset_console): Instead put it here and just do it
7330 on startup.
7331
Scott James Remnant25b263a2006-08-31 18:59:02 +01007332 * configure.ac: Bump version to 0.2.0
7333
Scott James Remnant4b61be92006-08-31 17:08:44 +01007334 * util/Makefile.am (install-exec-local): Create symbolic links,
7335 not hard links.
7336
Scott James Remnantaf1404f2006-08-31 16:04:16 +01007337 * init/main.c: Can't catch STOP.
7338
Scott James Remnant242b50b2006-08-31 15:40:42 +01007339 * util/reboot.c: Pause init while shutting down or rebooting.
7340
Scott James Remnanteabb7802006-08-31 15:39:04 +01007341 * init/main.c (stop_handler): Catch STOP/TSTP and CONT.
7342 * init/event.c (event_queue_run): Don't run the event queue while
7343 paused.
7344 * init/job.c (job_detect_idle): Don't detect idle jobs while paused.
7345
Scott James Remnant1cd8d862006-08-31 15:17:16 +01007346 * util/reboot.c: if we get the -w argument ("only write to wtmp")
7347 we need to exit, and not behave as halt normally would.
7348
Scott James Remnantff63cf72006-08-31 04:39:34 +01007349 * compat/sysv/runlevel.c (main): Add missing newline.
7350 * compat/sysv/telinit.c (main): And here too.
7351
Scott James Remnant32de9222006-08-31 04:34:27 +01007352 * init/main.c (main): Check for idle after the startup event queue
7353 has been run, otherwise we may just sit there.
7354
Scott James Remnant13ffffe2006-08-31 04:33:39 +01007355 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install telinit
7356 (telinit_SOURCES, telinit_LDFLAGS, telinit_LDADD): Details for
7357 telinit binary.
7358 * compat/sysv/telinit.c: Trivial telinit program that just runs
7359 the appropriate rcX job.
7360 * compat/sysv/runlevel.c (main): Suggest help on illegal runlevel.
7361
Scott James Remnant40f09012006-08-31 04:21:49 +01007362 * util/Makefile.am: Tidy up.
7363
Scott James Remnant12473562006-08-31 04:21:05 +01007364 * configure.ac (AC_CONFIG_FILES): Create compat/sysv/Makefile
7365 * Makefile.am (SUBDIRS): Build things found in compat/sysv
7366 * compat/sysv/Makefile.am (sbin_PROGRAMS): Build and install runlevel
7367 (runlevel_SOURCES, runlevel_LDFLAGS, runlevel_LDADD): Details for
7368 runlevel binary.
7369 * compat/sysv/runlevel.c: Helper to store and retrieve the current
7370 "runlevel" from utmp/wtmp; as well as the reboot time.
7371
Scott James Remnantd909cca2006-08-31 04:20:14 +01007372 * init/main.c (main): Drop debugging set.
7373
Scott James Remnantcedd11a2006-08-31 02:59:29 +01007374 * init/job.c (job_change_state): As well as the job/state events,
7375 send the job event when a service is running or a task is stopping.
7376 * init/tests/test_job.c (test_change_state): Check the events get
7377 sent properly.
7378
Scott James Remnant44b684a2006-08-31 02:58:45 +01007379 * util/start.c: Write a simple utility to start, stop, or query
7380 the status of the named jobs.
7381 * util/Makefile.am (sbin_PROGRAMS): Build and install start
7382 (start_SOURCES, start_LDFLAGS, start_LDADD): Details for start
7383 (install-exec-local): Also install as stop and status.
7384 * util/reboot.c (main): Drop the debugging set.
7385
Scott James Remnantb8ed2d12006-08-31 02:15:48 +01007386 * init/cfgfile.c (cfg_job_stanza): Correct nih_alloc error.
7387
Scott James Remnanta6125ae2006-08-31 02:14:25 +01007388 * init/process.c (process_setup_environment): Guard memory alloc.
7389 * init/job.c (job_set_idle_event): Likewise.
7390 (job_change_state): And here too.
7391 (job_run_command): Likewise.
7392 * init/control.c (control_send): Likewise.
7393 * init/cfgfile.c: And throughout this file.
7394 * upstart/control.c (upstart_recv_msg): And once here too.
7395
Scott James Remnant0b358ab2006-08-31 02:07:32 +01007396 * upstart/control.h: Abolish the separate halt, reboot and poweroff
7397 messages and replace with a single shutdown message that takes
7398 an event name (for the idle event issued afterwards).
7399 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
7400 the new shutdown event type by just treating it as an event.
7401 * upstart/tests/test_control.c (test_messages): Update tests.
7402 * init/job.c (job_set_idle_event): Store a copy of the idle event
7403 name.
7404 * init/control.c (control_send): Copy the shutdown event name.
7405 (control_handle): Replace individual handling with the new
7406 single event.
7407 * init/tests/test_control.c (test_watcher): Update.
7408 * util/initctl.c: Drop handling for things that shutdown does now.
7409 * util/shutdown.c: Send the UPSTART_SHUTDOWN event and let the user
7410 specify anything they want, just give defaults.
7411
Scott James Remnantff5efb92006-08-31 01:45:19 +01007412 This is quite a big change and abolishes level events entirely,
7413 along with the event history. We now just treat events as a
7414 transient queue of strings that go past, may cause things to change,
7415 but are otherwise forgotten. This turns out to be much easier to
7416 understand and has no real loss of power.
7417
7418 * init/event.c: Vastly simplify; gone are the separate notions of
7419 edge and level events, instead we just treat them as one-shot
7420 things that go past and are forgotten about.
7421 * init/event.h (Event): Remove value member.
7422 Update prototypes.
7423 * init/tests/test_event.c: Update.
7424 * init/job.c (job_change_state): Change the event pattern to be
7425 one that includes the job name and a description of the transition
7426 instead of the new state.
7427 (job_detect_idle): Call event_queue rather than event_queue_edge.
7428 * init/tests/test_job.c: Update.
7429 * init/cfgfile.c (cfg_job_stanza): Drop "when" and "while".
7430 * init/tests/test_cfgfile.c (test_read_job): Drop mentions of
7431 "when" and "while".
7432 * init/control.c (control_send, control_handle): Drop cases for
7433 level events.
7434 (control_handle_event): Don't include a level in the event.
7435 * init/tests/test_control.c: Update
7436 * init/main.c: Call event_queue rather than event_queue_edge.
7437 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Change
7438 event handling so that only a name is read.
7439 * upstart/control.h: Remove value/level event structures.
7440 * upstart/tests/test_control.c (test_messages): Update.
7441 * upstart/job.c (process_state_name): Not used for events, adjust
7442 documentation so it doesn't lie.
7443 * util/initctl.c (main): Drop the set function, simplify trigger.
7444 * util/shutdown.c (shutdown_now): Call UPSTART_EVENT_QUEUE for
7445 shutdown into maintenance mode.
7446
Scott James Remnantfcbee2d2006-08-31 00:49:36 +01007447 * init/control.c (control_handle): Place a message in the syslog
7448 before halting, powering off or rebooting.
7449
Scott James Remnantd4cdaca2006-08-31 00:47:11 +01007450 * util/shutdown.c: Adjust so that the warning message is sent out
7451 if shutdown is immediate, and when it actually happens. Include
7452 the hostname as wall does.
7453
Scott James Remnant255c5f22006-08-30 16:05:01 +010074542006-08-30 Scott James Remnant <scott@netsplit.com>
7455
Scott James Remnant5be55662006-08-30 19:13:25 +01007456 * TODO: Update.
7457
Scott James Remnant4a9245f2006-08-30 19:13:00 +01007458 * util/shutdown.c: Implement shutdown utility along the same lines
7459 as the sysvinit one, but with rather different code.
7460
Scott James Remnant2a71aaa2006-08-30 16:34:06 +01007461 * util/initctl.c (main): Call setuid on the effective user id so
7462 that we can be made setuid root and executable by a special group.
7463 * util/reboot.c (main): Likewise.
7464
Scott James Remnant70cc2292006-08-30 16:06:03 +01007465 * util/initctl.c (main): Check the effective rather than the real
7466 user id, if we're effectively root, that's good enough.
7467
Scott James Remnant255c5f22006-08-30 16:05:01 +01007468 * util/reboot.c: Implement reboot/halt/poweroff utility.
7469 * util/Makefile.am (sbin_PROGRAMS): Build and install reboot
7470 (reboot_SOURCES, reboot_LDFLAGS, reboot_LDADD): Details for reboot
7471 (install-exec-local): Create hardlinks to reboot for halt and poweroff.
7472
Scott James Remnantdc8877d2006-08-29 16:56:48 +010074732006-08-29 Scott James Remnant <scott@netsplit.com>
7474
7475 * init/main.c (main): Actually run the idle-detect function.
7476 * init/job.c (job_detect_idle): Interrupt the main loop, otherwise
7477 we may end up waiting for a signal before we process the event
7478 we just issued.
7479
Scott James Remnantf43bdf32006-08-27 18:20:29 +010074802006-08-27 Scott James Remnant <scott@netsplit.com>
7481
Scott James Remnant47158482006-08-27 22:37:10 +01007482 * util/shutdown.c: Template main function.
7483 * util/Makefile.am (sbin_PROGRAMS): Build and install the
7484 shutdown binary.
7485 (shutdown_SOURCES, shutdown_LDFLAGS, shutdown_LDADD): Details for
7486 the shutdown binary
7487
Scott James Remnant70a6ec62006-08-27 22:23:50 +01007488 * util/initctl.c (main): Add commands for halt, poweroff and reboot.
7489
Scott James Remnant0c7e72a2006-08-27 22:22:53 +01007490 * init/event.c (event_queue_run): Remove the parameters.
7491 * init/event.h: Update.
7492 * init/main.c (main): Update.
7493 * init/tests/test_control.c (test_watcher): Update.
7494 * init/tests/test_job.c (test_detect_idle): Update.
7495
Scott James Remnant96ae9e42006-08-27 22:15:34 +01007496 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Deal
7497 with halting, rebooting and powering off; or at least the appropriate
7498 messages.
7499 * upstart/control.h: Add control message structures for halting,
7500 powering off and rebooting the machine.
7501 * upstart/tests/test_control.c (test_messages): Run the tests.
7502 * init/control.c (control_handle): Add handling for halt, power off
7503 and reboot that issue the shutdown event and arrange for the halt,
7504 poweroff or reboot to be issued the next time the system is idle.
7505 * init/tests/test_control.c (test_watcher): Test the events.
7506
Scott James Remnant01a37082006-08-27 21:51:00 +01007507 * TODO: Update.
7508
Scott James Remnante02892b2006-08-27 21:49:44 +01007509 * init/job.c (job_detect_idle): Function to detect when the system is
7510 stalled or idle.
7511 * init/job.h: Update
7512 * init/tests/test_job.c (test_detect_idle): Test the new function.
7513
Scott James Remnant6a8508c2006-08-27 19:10:44 +01007514 * util/initctl.c (main): Handle the list command.
7515
Scott James Remnanta9476ad2006-08-27 19:07:23 +01007516 * TODO: Update.
7517
Scott James Remnant4da474d2006-08-27 19:06:35 +01007518 * upstart/control.c (WireJobStatusPayload): add description to the
7519 job status payload.
7520 (upstart_send_msg_to, upstart_recv_msg): Send and receieve the
7521 description over the wire.
7522 * upstart/control.h (UpstartJobStatusMsg): add a description field
7523 * upstart/tests/test_control.c: Update test cases.
7524 * init/control.c (control_handle): Include the job description in
7525 the message.
7526 (control_send): Copy the description when we put the message on
7527 the queue.
7528 (control_handle_job): Copy the description here too
7529 * init/tests/test_control.c: Update test cases.
7530
Scott James Remnant84f5e932006-08-27 18:49:25 +01007531 * init/job.c (job_list): Add a function to return the job list.
7532 * init/job.h: Update.
7533 * init/control.c (control_handle): Handle the JOB_LIST message
7534 by sending back a list of job status messages followed by the
7535 JOB_LIST_END message.
7536 * init/tests/test_control.c (test_watcher_child): Check the
7537 JOB_LIST message works properly.
7538
Scott James Remnantf4ad6d12006-08-27 18:40:01 +01007539 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Handle
7540 the JOB_LIST and JOB_LIST_END messages which have no payload.
7541 * upstart/control.h: Add enums and structures for job list messages.
7542 * upstart/tests/test_control.c (test_messages): Update tests.
7543
Scott James Remnantf4970812006-08-27 18:27:19 +01007544 * init/main.c (main): Check that we're both uid and process #1
7545
Scott James Remnantf43bdf32006-08-27 18:20:29 +01007546 * init/main.c (main): Stop handling SIGTERM, we never want people
7547 to kill init. Handle SIGINT and SIGWINCH through the ordinary
7548 handler and SIGSEGV through a direct handler.
7549 (segv_handler): Write a sensible core dump handler, we use a child
7550 to dump core while we carry on in the parent hopefully stepping over
7551 the bad instruction.
7552 (cad_handler): Generate the control-alt-delete event.
7553 (kbd_handler): Generate the kbdrequest event.
7554
Scott James Remnant33e64d02006-08-25 14:44:32 +020075552006-08-25 Scott James Remnant <scott@netsplit.com>
7556
Scott James Remnant21679252006-08-25 16:22:13 +02007557 * configure.ac: Bump version to 0.1.2
7558 * NEWS: Update.
7559
Scott James Remnantfef12b52006-08-25 16:16:45 +02007560 * TODO: Update.
7561
Scott James Remnant94d00982006-08-25 15:38:22 +02007562 * init/process.c (process_setup_environment): Inherit the PATH
7563 and TERM environment variables from the init process, so the
7564 console works properly.
7565 * init/process.h (PATH): Declare a default value for this variable
7566 * init/main.c (main): Set the value of PATH to the default.
7567 * init/tests/test_process.c (child): Update test case.
7568
Scott James Remnant33e64d02006-08-25 14:44:32 +02007569 * NEWS: Update.
7570 * configure.ac: Bump version to 0.1.1
7571
Scott James Remnant68ccc9e2006-08-24 00:10:41 +020075722006-08-24 Scott James Remnant <scott@netsplit.com>
7573
Scott James Remnant279d4352006-08-24 15:33:19 +02007574 * init/cfgfile.h (CFG_DIR): Change configuration directory to
7575 /etc/event.d -- it's not been used by anyone, but is similar to
7576 other directories that have which is a good precedent.
7577 * event.d/Makefile.am (eventdir, dist_event_DATA): Install files
7578 into the new directory name.
7579 * Makefile.am (SUBDIRS): Rename sub directory
7580 * configure.ac (AC_CONFIG_FILES): Rename generated Makefile
7581
Scott James Remnant937192c2006-08-24 02:57:50 +02007582 * init/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7583 directories so out of tree builds work.
7584 * logd/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7585 directories so out of tree builds work.
7586 * upstart/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7587 directories so out of tree builds work.
7588 (upstartinclude_HEADERS): Install errors.h
7589 * util/Makefile.am (DEFAULT_INCLUDES): Set to include the right
7590 directories so out of tree builds work.
7591
7592 * Makefile.am (SUBDIRS): Add m4 to the list
7593 * configure.ac (AC_CONFIG_FILES): Generate m4/Makefile
7594 * upstart/Makefile.am (upstartinclude_HEADERS): Add errors.h
7595
7596 * upstart/control.c (upstart_open):
7597
Scott James Remnante4c3d552006-08-24 02:34:01 +02007598 * init/control.c (control_open): Raise the error before
7599 performing other actions so errno is not lost.
Scott James Remnant73550092006-08-24 02:27:03 +02007600
Scott James Remnante4c3d552006-08-24 02:34:01 +02007601 * TODO: Update.o
Scott James Remnantf8b776b2006-08-24 00:36:15 +02007602 * init/cfgfile.c (cfg_next_token): Don't count quote characters
7603 unless we're actually planning to dequote the file, otherwise we
7604 end up allocating short.
7605
Scott James Remnant9e17fc02006-08-24 00:28:10 +02007606 * init/control.c (control_close): Free the io_watch using list_free
7607 in case a destructor has been set.
7608 * init/tests/test_control.c: Initialise the type of the message, and
7609 free job correctly.
7610
Scott James Remnant68ccc9e2006-08-24 00:10:41 +02007611 * upstart/tests/test_control.c: Fix overwrite of buffer.
7612 * init/tests/test_job.c: Clean up not-freed job.
7613
Scott James Remnantc961ce32006-08-23 19:46:29 +020076142006-08-23 Scott James Remnant <scott@netsplit.com>
7615
Scott James Remnant013e9722006-08-23 23:00:14 +02007616 * init/tests/test_event.c: free the entry allocated and initialise
7617 the return values.
7618
Scott James Remnantc961ce32006-08-23 19:46:29 +02007619 * init/cfgfile.c (cfg_skip_token): Drop this function; we'll
7620 make sure *pos is pointing at the start of the thing we want
7621 to parse, not the first token. Update the other functions
7622 accordingly.
7623 (cfg_read_job): Implement function to look over a job file and
7624 parse all of the stanzas that are found. Also sanity checks the
7625 job afterwards and deals with reloading existing jobs.
7626 (cfg_job_stanza): Function that parses an individual stanza,
7627 calling out to the other parse functions; this is the main config
7628 file parser!
7629 (cfg_parse_args, cfg_parse_command): Drop requirement that filename
7630 and lineno be passed, so we can be called to reparse arguments after
7631 we've already done so.
7632 (cfg_parse_script): Remove requirement that it be called at the
7633 start of the entire stanza, and instead at the start of the script.
7634 When hitting EOF, return the script so far, not NULL.
7635 (cfg_parse_args): Correct bug where we didn't check sufficient
7636 characters while skipping whitespace.
7637 (cfg_next_token): Correct bug where we didn't copy the character
7638 after a slash into the text, instead of just not copying the slash.
7639 Adjust line numbers to match the fact that it's zero based now.
7640 * init/cfgfile.h: Define prototype.
7641 * init/tests/test_cfgfile.c (test_read_job): Pretty thoroughly
7642 test the config file parser code.
7643
Scott James Remnant0c58ed02006-08-22 11:42:19 +020076442006-08-22 Scott James Remnant <scott@netsplit.com>
7645
Scott James Remnant214168f2006-08-22 18:52:51 +02007646 * init/cfgfile.c (cfg_tokenise): Rename to cfg_next_token.
7647 (cfg_skip_token): Code to skip whitespace, token and whitespace.
7648 (cfg_parse_args): Function to parse an argument list.
7649 (cfg_next_token): Extend to support the removal of quotes and
7650 slashes from the token.
7651
Scott James Remnant21590a22006-08-22 17:40:48 +02007652 * init/cfgfile.c (cfg_parse_script): Pass filename and lineno and
7653 increment the latter as we go.
7654 (cfg_script_end): Pass and increment lineno.
7655
Scott James Remnanteed2e8d2006-08-22 17:31:07 +02007656 * init/cfgfile.c: Correct a missing semi-colon in prototypes.
7657 (cfg_parse_command): Function to parse any stanza that requires
7658 a command and arguments list, e.g. exec/respawn/daemon. We don't
7659 want to require that the list be quoted, etc. and do want to allow
7660 it to be folded over lines.
7661 (cfg_tokenise): Function used by the above to tokenise the file,
7662 handling things like \, quoted strings and newlines, etc. Can be
7663 used both to determine the length of the token and to copy it.
7664
Scott James Remnantfcc98ad2006-08-22 12:28:19 +02007665 * init/cfgfile.c (cfg_read_script): Rename to cfg_parse_script.
7666
Scott James Remnantfd32dd32006-08-22 11:46:01 +02007667 * init/cfgfile.c (cfg_read_script): Function to parse a script
7668 fragment ("foo script\n....end script\n") from the job file, which
7669 is the most complex form we can find. Write it assuming the file is
7670 in a character array which may not be NULL terminated (ie. a mmap'd
7671 file).
7672 (cfg_script_end): Used by the above to detect the end of the
7673 fragment.
7674 * init/cfgfile.h: Empty header file.
7675 * init/Makefile.am (init_SOURCES): Build and link cfgfile.c
7676 using the cfgfile.h header
7677 (TESTS): Build and run the config file test cases.
7678 (test_cfgfile_SOURCES, test_cfgfile_LDFLAGS, test_cfgfile_LDADD):
7679 Details for config file test case binary.
7680
Scott James Remnant0c58ed02006-08-22 11:42:19 +02007681 * init/main.c (main): Remove the calls to the unfinished config
7682 file code.
7683
Scott James Remnant6ce44812006-08-21 08:46:32 +020076842006-08-21 Scott James Remnant <scott@netsplit.com>
7685
Scott James Remnant027dd7b2006-08-21 09:01:25 +02007686 * init/main.c: Add missing include for unistd.h
7687 * init/process.c (process_setup_console): Drop use of job.
7688 * util/initctl.c (main): Check that we're run as root.
7689
Scott James Remnant77e8db32006-08-21 08:47:50 +02007690 * init/main.c (main): Write the main function
7691
Scott James Remnant6ecceb82006-08-21 08:47:23 +02007692 * init/event.c (event_queue_cb): Rename to event_queue_run.
7693 * init/event.h: Update.
7694
Scott James Remnant6ce44812006-08-21 08:46:32 +02007695 * init/process.c (process_setup_console): Become an exported
7696 function that includes the code to reset a console.
7697
Scott James Remnant5befd932006-08-19 19:24:54 +010076982006-08-19 Scott James Remnant <scott@netsplit.com>
7699
Scott James Remnantcd39a7c2006-08-19 20:02:17 +01007700 * logd/main.c (main): Write the basic main function.
7701
Scott James Remnant3bcd15e2006-08-19 19:50:12 +01007702 * util/initctl.c (main): Fill in the details to give us a basic
7703 test client.
7704
Scott James Remnant3dc965c2006-08-19 19:25:23 +01007705 * TODO: Update.
7706
Scott James Remnant5befd932006-08-19 19:24:54 +01007707 * util/initctl.c (main): Provide the most basic main function.
7708 * util/Makefile.am (sbin_PROGRAMS): Build the initctl binary
7709 * Makefile.am (SUBDIRS): Build the utilities.
7710 * configure.ac (AC_CONFIG_FILES): Generate the util Makefile.
7711
Scott James Remnant1fe38a82006-08-18 17:06:25 +010077122006-08-18 Scott James Remnant <scott@netsplit.com>
7713
Scott James Remnantc2659612006-08-18 22:19:47 +01007714 * init/Makefile.am (test_job_LDADD): Remove the duplicate link.
7715
Scott James Remnantd5e07052006-08-18 20:39:30 +01007716 * TODO: Update.
7717
Scott James Remnanta060bb72006-08-18 20:16:55 +01007718 * init/job.c (job_handle_child): Rename to job_child_reaper.
7719 * init/job.h: Update.
7720 * init/tests/test_job.c: Update function names.
7721
Scott James Remnant829dc082006-08-18 20:10:02 +01007722 * init/control.c (control_cb): Rename to control_watcher
7723 * init/tests/test_control.c: Update function names.
7724
Scott James Remnantddc3e282006-08-18 18:49:50 +01007725 * TODO: Update.
7726
Scott James Remnantc2cac3f2006-08-18 17:17:57 +01007727 * Makefile.am (SUBDIRS): Install the rc.d files.
7728 * configure.ac (AC_CONFIG_FILES): Generate the rc.d Makefile.
7729 * rc.d/Makefile.am (rcdir): Define rcdir to be /etc/rc.d
7730 (dist_rc_DATA): Install the logd file into that directory.
7731 * rc.d/logd: Write a simple service definition for the log daemon,
7732 this saves us hardcoding any information about it into init; it'll
7733 just need to know the name.
7734
Scott James Remnant1fe38a82006-08-18 17:06:25 +01007735 * Makefile.am (SUBDIRS): Build the logd daemon
7736 * configure.ac (AC_CONFIG_FILES): Generate the logd Makefile.
7737 * logd/Makefile.am (sbin_PROGRAMS): Install the logd binary into
7738 the sbin directory by default.
7739 (logd_SOURCES): Build and link main.c
7740 * logd/main.c (main): Add basic main function for testing purposes.
7741
Scott James Remnantb9814432006-08-16 02:11:51 +010077422006-08-16 Scott James Remnant <scott@netsplit.com>
7743
Scott James Remnantc5da6fd2006-08-16 18:06:49 +01007744 * init/job.c (job_start): Ignore self-dependencies; over-document
7745 why the dependency event prodding has a surprise in its tail.
7746 (job_change_state): Move the job_release_depends call to here.
7747
Scott James Remnant133a7a32006-08-16 17:45:51 +01007748 * init/event.c (event_queue_cb): Add event consumer/dispatcher.
Scott James Remnant13e5dbf2006-08-16 17:48:01 +01007749 * init/event.h: Update.
Scott James Remnant133a7a32006-08-16 17:45:51 +01007750
Scott James Remnant3772bc62006-08-16 17:41:34 +01007751 * init/control.c (control_send): Make the event code clearer.
7752 (control_handle): Handle the changed event semantics.
7753 (control_handle_event): Issue the new event type.
7754 * init/tests/test_control.c: Update tests.
7755
Scott James Remnantcaee5b52006-08-16 17:32:12 +01007756 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Adjust
7757 marshal code to match.
7758 * upstart/control.h: Update all structures appropriately to the
7759 previous changes.
7760 * upstart/tests/test_control.c: Update.
7761
Scott James Remnant4d4389d2006-08-16 17:19:20 +01007762 * init/job.c (job_change_state): Change call to event_trigger_level
7763 to event_queue_level.
7764
Scott James Remnant51664d72006-08-16 17:17:58 +01007765 * init/event.c (event_trigger_edge, event_trigger_level): Place
7766 the event on the event_queue rather than directly triggering it.
7767 Rename to event_queue_edge and event_queue_level respectively.
7768 * init/event.h: Update.
7769 * init/tests/test_event.c: Update test cases.
7770
Scott James Remnant4ddc86e2006-08-16 16:17:48 +01007771 * init/job.c (job_handle_event): Add another sanity check, jobs
7772 should not be able to react to their own events; that's just silly.
7773 * init/tests/test_job.c (test_handle_event): Check that the new
7774 condition does the right thing.
7775
Scott James Remnant930f3e02006-08-16 16:13:03 +01007776 * init/job.c (job_change_state): Make it illegal for a job to exist
7777 without either a command or script or both. This is for sanity
7778 reasons, allowing no primary process makes no sense and can lead
7779 to event loops if someone is feeling nefarious.
7780 * init/tests/test_job.c (test_change_state): Drop test on behaviour
7781 we've just outlawed.
7782
Scott James Remnant7dd047e2006-08-16 13:43:50 +01007783 * init/job.c (job_start): Only announce the change if we're still
7784 in the waiting state, we could have moved on to running already.
7785
Scott James Remnantf9261ba2006-08-16 13:40:05 +01007786 * init/job.c (job_start): If holding the job, at least announce
7787 the goal change to subscribed clients.
7788
Scott James Remnant853cc772006-08-16 13:34:51 +01007789 * TODO: Update.
7790
Scott James Remnantfdb82592006-08-16 13:31:49 +01007791 * init/job.c (job_start): Check for dependencies before starting
7792 the process, if we have any that aren't running we stay in waiting
7793 until they are. Any that aren't even starting get poked with a
7794 dependency event to see whether that wakes them up.
7795 * init/tests/test_job.c (test_start): Test paths through new
7796 dependency code.
7797
Scott James Remnant278150a2006-08-16 12:56:34 +01007798 * init/job.c (job_run_process): Once we've got an active process
7799 in the running state, release our dependencies.
7800
Scott James Remnant6d4104d2006-08-16 12:50:39 +01007801 * init/job.c (job_release_depends): Function to release any waiting
7802 dependencies on the given job.
7803 * init/job.h: Update.
7804 * init/tests/test_job.c (test_release_depends): Test the behaviour
7805 of the function on its own.
7806
Scott James Remnant1da1dad2006-08-16 12:18:50 +01007807 * init/job.h (Job): Add depends list field
7808 (JobName): New structure to hold the name of a job.
7809 * init/job.c (job_new): Initialise the depends list.
7810 * init/tests/test_job.c (test_new): Make sure the depends list is
7811 initialised properly.
7812
Scott James Remnant37eee032006-08-16 12:10:49 +01007813 * init/job.c (job_next_state): Return JOB_STARTING if we're in
7814 JOB_WAITING and the goal is JOB_START. This is only called when
7815 there's some change, and I don't want to hard-code the goal there.
7816 (job_start): Don't hardcode JOB_STARTING, instead just use the next
7817 state.
7818 * init/tests/test_job.c (test_next_state): Adjust test case.
7819
Scott James Remnantc3d3ead2006-08-16 09:00:50 +01007820 * init/control.c (control_subscribe): Allow the current
7821 subscription to be found by passing NOTIFY_NONE.
7822 (control_handle): Don't remove an existing subscription to jobs,
7823 a GUI will probably want a permanent one to keep the status up to
7824 date.
7825
Scott James Remnantb9a568c2006-08-16 08:57:46 +01007826 * init/job.c (job_kill_process, job_kill_timer): Don't hardcode
7827 JOB_STOPPING here, instead move to the next logical state.
7828 (job_kill_process): Notify subscribed processes that we killed
7829 the job.
7830 (job_start, job_stop): Notify subscribed processes of a change of
7831 goal that doesn't result in an immediate state change.
7832
Scott James Remnant8dbc6012006-08-16 08:57:38 +01007833 * init/event.c (event_trigger_edge, event_trigger_level): Swap
7834 order so that events are announced before processed.
7835
Scott James Remnant28161252006-08-16 08:41:48 +01007836 * init/control.c (control_handle): Handle requests to watch and
7837 unwatch jobs and events.
7838 * init/tests/test_control.c (test_cb_child, test_cb): Check that
7839 subscriptions work.
7840
Scott James Remnantb6d55bf2006-08-16 08:24:16 +01007841 * init/tests/test_control.c (test_cb_child): Add a sleep to avoid
7842 a race that upsets gdb, have tried this with a STOP/CONT interlock
7843 but can't seem to find where the child should reach first.
7844
Scott James Remnant5612b232006-08-16 08:21:06 +01007845 * init/job.c (job_change_state): Notify the control handler.
7846 * init/event.c (event_trigger_edge, event_trigger_level): Pass
7847 event to the control handler.
7848 * init/tests/test_control.c (test_cb_child): Expect to receive
7849 job status events as well.
7850 * init/Makefile.am (test_event_LDADD, test_process_LDADD)
7851 (test_job_LDADD): Add control.o to the linkage.
7852
Scott James Remnant9e0626a2006-08-16 08:17:07 +01007853 * init/control.c (control_cb): Don't display an error for
7854 ECONNREFUSED, just remove any subscriptions.
7855 * init/tests/test_control.c (test_handle_job, test_handle_error):
7856 Clean up our subscriptions properly.
7857
Scott James Remnant3c465c82006-08-16 07:40:24 +01007858 * init/control.c (control_handle_job): Function to send out an
7859 UPSTART_JOB_STATUS message to subscribed processes whenever a
7860 job state changes.
7861 (control_handle_event): Function to send out an
7862 UPSTART_EVENT_TRIGGERED message to subscribed processes whenever
7863 an event is triggered.
7864 * init/control.h: Update.
7865 * init/tests/test_control.c (test_handle_job, test_handle_event):
7866 Check that the functions work properly.
7867
Scott James Remnant16dadc52006-08-16 07:27:40 +01007868 * init/control.c (control_handle): Handle messages that trigger
7869 edge and level events; subscribe the process to receive notification
7870 of job changes during the event.
7871 * init/tests/test_control.c (test_cb_child): Check that the messages
7872 are handled properly (without subscription check).
7873
Scott James Remnanta7ba72a2006-08-16 07:11:30 +01007874 * init/control.c (control_cb): Unsubscribe a process if it stops
7875 listening.
7876
Scott James Remnant2c9669c2006-08-16 07:10:05 +01007877 * init/control.c (control_send): Copy the pointers in the new
7878 event messages.
7879 * init/tests/test_control.c (test_send): Check the pointers are
7880 copied across correctly.
7881
Scott James Remnant15d61c62006-08-16 06:55:58 +01007882 * init/control.c (control_subscribe): Add function to handle
7883 processes that want to subscribe to changes.
7884 (control_init): Initialise the subscriptions list.
7885 * init/control.h: Add structures and prototypes.
7886 * init/tests/test_control.c (test_subscribe): Test the function.
7887
Scott James Remnant8692f762006-08-16 06:21:13 +01007888 * upstart/control.h (UpstartMsgType): add messages for triggering
7889 edge and level events, receiving the trigger for an event and for
7890 watching jobs and events.
7891 (UpstartEventTriggerEdgeMsg, UpstartEventTriggerLevelMsg)
7892 (UpstartEventTriggeredMsg, UpstartWatchJobsMsg)
7893 (UpstartUnwatchJobsMsg, UpstartWatchEventsMsg):
7894 (UpstartUnwatchEventsMsg): Add structures for the new messages.
7895 (UpstartMsg): And add them to the union.
7896 * upstart/control.c (WireEventPayload): The event messages can all
7897 share a wire payload type; the watch messages don't need any special
7898 payload.
7899 (upstart_send_msg_to): Add the payloads onto the wire.
7900 (upstart_recv_msg): And take the payloads back off the wire.
7901 * upstart/tests/test_control.c (test_messages): Test the new
7902 message types.
7903
Scott James Remnant8ed97eb2006-08-16 05:46:44 +01007904 * upstart/control.h (UpstartJobStatusMsg): add a process id.
7905 * upstart/control.c (WireJobStatusPayload): and here too.
7906 (upstart_send_msg_to): copy the process id onto the wire.
7907 (upstart_recv_msg): copy the process id from the wire.
7908 * init/control.c (control_handle): Fill in the pid from the job.
7909 * upstart/tests/test_control.c (test_messages): Check the pid gets
7910 passed across the wire properly.
7911
Scott James Remnant7d914312006-08-16 05:37:50 +01007912 * init/control.c (control_cb): Disable the poll for write once the
7913 send queue becomes empty.
7914
Scott James Remnant59707c22006-08-16 05:32:20 +01007915 * upstart/Makefile.am (libupstart_la_SOURCES): Correct ordering.
7916
Scott James Remnanta98c8b82006-08-16 05:32:02 +01007917 * init/control.c (control_handle): Add missing break.
7918
Scott James Remnantb5c7a302006-08-16 05:24:55 +01007919 * upstart/job.c (job_goal_name, process_state_name): For completeness
7920 add these two functions as well.
7921 * upstart/job.h: Update.
7922 * upstart/tests/test_job.c (test_goal_name)
7923 (test_process_state_name): Test the new functions.
7924
Scott James Remnant20b15ad2006-08-16 05:20:02 +01007925 * init/job.c (job_state_name): Move this utility function from here
7926 * upstart/job.c (job_state_name): to here so all clients can use
7927 it.
7928 * init/job.h: Update.
7929 * upstart/job.h: Update.
7930 * init/tests/test_job.c (test_state_name): Move the test case from here
7931 * upstart/tests/test_job.c: to here as well.
7932 * upstart/Makefile.am (libupstart_la_SOURCES): Build and link job.c
7933 (TESTS): Run the job test cases
7934 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for
7935 job test case binary.
7936 * init/Makefile.am (test_job_LDADD, test_process_LDADD)
7937 (test_event_LDADD): Link to libupstart.la
7938
Scott James Remnant7a5c6672006-08-16 05:01:13 +01007939 * init/control.c: Code to handle the server end of the control
7940 socket, a bit more complex than a client as we want to avoid
7941 blocking on malcious clients.
7942 * init/control.h: Prototypes.
7943 * init/tests/test_control.c: Test the control code.
7944 * init/Makefile.am (init_SOURCES): Build and link control.c
7945 using the control.h header
7946 (init_LDADD): Link to libupstart as well
7947 (TESTS): Build and run the control test suite.
7948 (test_control_SOURCES, test_control_LDFLAGS, test_control_LDADD):
7949 Details for control test suite binary.
7950
Scott James Remnantb7cbda52006-08-16 04:53:38 +01007951 * upstart/control.c: Add a way to disable the safety checks.
7952 * upstart/tests/test_control.c (test_free): Fix bad test case.
7953
Scott James Remnant71d4d842006-08-16 04:29:21 +01007954 * upstart/control.c (upstart_recv_msg): fixed bogus return type
7955 for recvmsg from size_t to ssize_t so we don't infiniloop on error.
7956
Scott James Remnant2bda3832006-08-16 03:41:10 +01007957 * upstart/control.c (upstart_send_msg_to, upstart_recv_msg): Avoid
7958 job_start as the short-cut for assigning name, as that might become
7959 a more complex message eventually. Use job_query instead.
7960
Scott James Remnantd154b952006-08-16 03:39:35 +01007961 * upstart/control.c (upstart_free): Add wrapper function around
7962 nih_free so we're a proper library and don't expose libnih too much
7963 (upstart_recv_msg): Stash the sender pid in an argument.
7964 * upstart/control.h: Update.
7965 * upstart/tests/test_control.c (test_recv_msg): Test pid is
7966 returned properly.
7967 (test_free): Test the nih_free wrapper.
7968
Scott James Remnantdc0eb442006-08-16 02:40:29 +01007969 * init/job.c (job_run_script): Document future FIXME.
7970
Scott James Remnant2f558532006-08-16 02:24:55 +01007971 * init/exent.h, init/job.h, init/process.h: Fix up headers.
7972
Scott James Remnant45aab692006-08-16 02:23:27 +01007973 * upstart/control.c, upstart/control.h, upstart/errors.h,
7974 upstart/job.h, upstart/libupstart.h: Fix up headers.
7975
Scott James Remnant8c16cc82006-08-16 02:13:40 +01007976 * upstart/control.c: Write the code to handle the control socket
7977 and communication over it; turns out this was possible to write so
7978 that both ends are handled in the same code.
7979 * upstart/control.h: Structures and prototypes.
7980 * upstart/tests/test_control.c: Test the new code.
7981
Scott James Remnant729d9222006-08-16 02:12:23 +01007982 * upstart/Makefile.am (libupstart_la_LIBADD): Link to libnih
7983
Scott James Remnantb9814432006-08-16 02:11:51 +01007984 * upstart/errors.h: Header file containing errors raised by
7985 libupstart.
7986 * upstart/libupstart.h: Include errors.h
7987
Scott James Remnant342451a2006-08-15 00:08:20 +010079882006-08-15 Scott James Remnant <scott@netsplit.com>
7989
Scott James Remnant0a8e3472006-08-15 23:54:14 +01007990 * init/event.h: Add missing attribute for event_new()
7991
Scott James Remnant6f128872006-08-15 23:54:05 +01007992 * init/job.h (JobGoal, JobState, ProcessState, ConsoleType): Move
7993 the enums from here
7994 * upstart/job.h: into here so that we can use them across the
7995 control socket.
7996
Scott James Remnante5831792006-08-15 21:46:21 +01007997 * Makefile.am (SUBDIRS): Build the libupstart library
7998 * configure.ac (AC_CONFIG_FILES): Generate upstart/Makefile
7999 * upstart/Makefile.am: Makefile for sub-directory
8000 * upstart/libupstart.ver: Linker version script.
8001 * upstart/libupstart.h: "Include everything" header file.
8002
Scott James Remnant26a8eec2006-08-15 05:46:27 +01008003 * TODO: Update.
8004
Scott James Remnant1f8619c2006-08-15 05:45:38 +01008005 * init/job.c (job_handle_child): Warn when processes are killed
8006 or exit with an abnormal status. Warn when respawning.
8007
Scott James Remnanteb5ad272006-08-15 05:43:05 +01008008 * init/job.c (job_handle_child): Respawn processes that were not
8009 supposed to have died.
8010 * init/tests/test_job.c (test_handle_child): Test the respawn code.
8011
Scott James Remnant77c926d2006-08-15 05:22:08 +01008012 * TODO: Update.
8013
Scott James Remnant429cd672006-08-15 05:09:51 +01008014 * init/event.c (event_trigger_edge, event_trigger_level): Call
8015 job_handle_event so that we actually do something useful.
8016 * init/Makefile.am (test_event_LDADD): Link to process.o and job.o
8017 now that event.c calls code from job.
8018
Scott James Remnant355e1b62006-08-15 05:07:24 +01008019 * init/job.c (job_start_event): Function to start a job if an event
8020 matches.
8021 (job_stop_event): Function to stop a job if an event matches.
8022 (job_handle_event): Iterate the job list and dispatch the given event,
8023 causing jobs to be stopped or started using the above two functions.
8024 * init/job.h: Update.
8025 * init/tests/test_job.c: Test the new functions.
8026
Scott James Remnant923400d2006-08-15 04:27:44 +01008027 * init/job.c (job_new): Initialise start_events and stop_events to
8028 an empty list.
8029 * init/job.h (Job): Add start_events and stop_events list heads.
8030 * init/tests/test_job.c (test_new): Check the lists are initialised
8031 correctly to the empty list.
8032
Scott James Remnant865534f2006-08-15 04:22:06 +01008033 * init/event.c (event_match): Function to check events for equality.
8034 * init/event.h: Update.
8035 * init/tests/test_event.c (test_match): Test function.
8036
Scott James Remnant97137a72006-08-15 04:07:08 +01008037 * init/job.c (job_change_state): Trigger the level event with the
8038 same name as the job, with the value taken from the state.
8039 * init/tests/test_job.c (test_change_state): Check the event
8040 gets set to the right values as we go.
8041 * init/Makefile.am (test_job_LDADD, test_process_LDADD): Link to
8042 event.o now that job.c uses code from there.
8043
Scott James Remnant3b35a522006-08-15 04:01:32 +01008044 * init/event.c (event_change_value): Rename event_set_value to this
8045 as we intended in the first place; makes it more consistent with job.
8046 Always change the value.
8047 (event_trigger_edge): Add a high-level function to trigger an edge
8048 event.
8049 (event_trigger_level): And another to trigger a level event with
8050 a given value, this inherits the "don't change it" functionality
8051 that was in event_set_value.
8052 * init/event.h: Update.
8053 * init/tests/test_event.c: Test new behaviours and functions.
8054
Scott James Remnant4fef0732006-08-15 01:45:02 +01008055 * init/event.c: Add simple code to keep track of events, whether
8056 they have been recorded or not and their current value if any.
8057 * init/event.h: Structures and prototypes.
8058 * init/tests/test_event.c: Test cases for event code.
8059 * init/Makefile.am (init_SOURCES): Build and link event.c using event.h
8060 (TESTS): Run the event test suite.
8061 (test_event_SOURCES, test_event_LDFLAGS, test_event_LDADD): Details
8062 for event test suite binary.
8063
Scott James Remnant38fc8ff2006-08-15 00:43:26 +01008064 * init/job.c (job_run_process, job_kill_process, job_kill_timer):
8065 Downgrade error messages to warning as they're not fatal.
8066 (job_change_state): Change info message to be more regular.
8067
Scott James Remnantf033fb02006-08-15 00:37:33 +01008068 * init/job.c (job_start): A very simple, but very necessary, function.
8069 Set the goal of the given job to JOB_START and kick it off.
8070 (job_stop): And its companion, cause a running job to be stopped.
8071 * init/job.h: Update.
8072 * init/tests/test_job.c: Test the functions.
8073
Scott James Remnant342451a2006-08-15 00:08:20 +01008074 * init/job.c (job_handle_child): Child handler to kick jobs into
8075 the next state when their process dies.
8076 * init/job.h: Update.
8077 * init/tests/test_job.c (test_handle_child): Test the handler
8078 directly by just invoking it with various job states.
8079
Scott James Remnant1c463b92006-08-14 14:46:17 +010080802006-08-14 Scott James Remnant <scott@netsplit.com>
8081
Scott James Remnant51c827d2006-08-14 23:06:00 +01008082 * init/tests/test_process.c (test_kill): Use select rather than
8083 poll for consistency with other test cases.
8084
Scott James Remnante6e4a732006-08-14 23:04:53 +01008085 * init/job.c (job_kill_process): Add function to send the active
8086 process of a job the TERM signal, and then set a timer to follow
8087 up with the KILL signal if the job doesn't get cleaned up in time.
8088 (job_kill_timer): Timer callback to send the KILL signal; this
8089 does the same job as the child handler and puts the job into the
8090 next state as there's no point waiting around now.
8091 * init/job.h: Update.
8092 * init/tests/test_job.c (test_kill_process): Test both functions
8093 in one test case (as one is just the bottom half of the other).
8094
Scott James Remnant6868f652006-08-14 21:42:45 +01008095 * init/tests/test_process.c (test_spawn): Use the right thing in
8096 the test case filename and unlink it to make sure.
8097
Scott James Remnant85df9422006-08-14 21:41:39 +01008098 * init/job.c (job_change_state): Write the principal state gate
8099 function, called once a state has been left to enter the given new
8100 state (which one should determine with job_next_state). Spawns
8101 the necessary processes or moves to the next appropriate state.
8102 * init/job.h: Update.
8103 * init/tests/test_job.c: Test the state changes.
8104
Scott James Remnantba44b8b2006-08-14 20:06:28 +01008105 * init/job.c (job_run_process): Internal function to call
8106 process_spawn and update the job structure.
8107 (job_run_command): Simple(ish) wrapper for the above to split
8108 a command by whitespace, or use a shell if it needs more complex
8109 argument processing.
8110 (job_run_script): More complex wrapper that uses a shell to execute
8111 verbatim script, either using -c or a /dev/fd/NN and feeding the
8112 shell down a pipe to it.
8113 * init/job.h: Update.
8114 * init/tests/test_job.c: Test the new functions.
8115
Scott James Remnant156f5482006-08-14 19:09:55 +01008116 * init/Makefile.am (init_SOURCES, TESTS): Reorder so that process.c,
8117 which is arguably lower level, comes first.
8118 (test_job_LDADD): Link the process code.
8119 (test_process_LDADD): Swap the order.
8120
Scott James Remnant00bcc932006-08-14 19:07:28 +01008121 * TODO: Update.
8122
Scott James Remnant1c463b92006-08-14 14:46:17 +01008123 * init/process.c (process_spawn): Correct typo (progress -> process),
8124 thanks Johan.
8125
Scott James Remnant43534ca2006-08-12 14:52:01 +010081262006-08-12 Scott James Remnant <scott@netsplit.com>
8127
Scott James Remnant3030cc22006-08-12 15:18:55 +01008128 * init/process.c (process_spawn): Correct formatting of function.
8129 * init/process.h (SHELL): Define the location of the shell, all in
8130 the spirit of not hard-coding stuff like this.
8131
Scott James Remnant43534ca2006-08-12 14:52:01 +01008132 * init/job.c (job_new): Initialise all structure members to zero
8133 as this doesn't happen automatically.
8134
Scott James Remnant60b03e32006-08-10 00:59:00 +010081352006-08-10 Scott James Remnant <scott@netsplit.com>
8136
8137 * init/job.h (job_state_name): Declare as a const function.
8138
Scott James Remnant143a8572006-08-09 17:37:00 +010081392006-08-09 Scott James Remnant <scott@netsplit.com>
8140
Scott James Remnantd945d2e2006-08-09 23:47:44 +01008141 * init/job.c (job_next_state): State transition logic; this uses
8142 our departure from the specification (the goal) so that the state
8143 can always be currently accurate rather than suggestive.
8144 (job_state_name): Cute function to convert enum into a name.
8145 * init/job.h: Update.
8146 * init/tests/test_job.c (test_next_state): Test the transitions.
8147 (test_state_name): And the return values.
8148
Scott James Remnant5fa15672006-08-09 23:23:17 +01008149 * TODO: Add file to keep track of things.
8150
Scott James Remnantdbc78612006-08-09 23:22:45 +01008151 * init/job.c: Include nih/macros.h and nih/list.h
8152 * init/process.c: Include order fixing, include nih/macros.h
8153 * init/tests/test_job.c: Include nih/macros.h and nih/list.h
8154 * init/tests/test_process.c: Include nih/list.h
8155
Scott James Remnant03853ed2006-08-09 23:11:59 +01008156 * init/job.c: Include order fixing.
8157 (job_find_by_name): Function to find a job by its (unique) name.
8158 (job_find_by_pid): Function to find a job by the pid of its process.
8159 * init/job.h: Update.
8160 * init/tests/test_job.c (test_find_by_name, test_find_by_pid): Test
8161 new functions.
8162
Scott James Remnant143a8572006-08-09 17:37:00 +01008163 * init/process.c (process_spawn): Spawn a process using the job
8164 details to set up the environment, etc.
8165 (process_setup_console): Set up the console according to the job.
8166 (process_setup_limits): Set up the limits according to the job.
8167 (process_setup_environment): Set up the environment according to
8168 the job.
8169 (process_kill): Simple function to send a kill signal or raise an
8170 error; mostly just a wrapper without any particular logic.
8171 * init/process.h: Prototypes and macros.
8172 * init/tests/test_process.c: Test cases.
8173 * init/Makefile.am (init_SOURCES): Build and link process.c and
8174 its header file.
8175 (TESTS): Run the process test suite.
8176 (test_process_SOURCES, test_process_LDFLAGS, test_process_LDADD):
8177 Details for process test sutie binary.
8178
Scott James Remnant29abda02006-08-08 15:01:24 +010081792006-08-08 Scott James Remnant <scott@netsplit.com>
8180
Scott James Remnant31ee2632006-08-08 15:06:02 +01008181 * init/job.c (job_new): nih_list_free is necessary.
8182 * init/tests/test_job.c (test_new): Free job when done.
8183
Scott James Remnant29abda02006-08-08 15:01:24 +01008184 * init/job.h: Header file to contain the definition of the Job
8185 structure and associated typedefs, etc.
8186 (JobGoal): In a divergence from the specification, we introduced a
8187 "goal" for a job which tells us which way round the state machine
8188 we're going (towards start, or towards stop).
8189 (JobState): Which means this always holds the current state, even
8190 if we're trying to get out of this state (ie. if we've sent the TERM
8191 signal to the running process, we're still in the running state until
8192 it's actually been reaped).
8193 (ProcessState): And in another divergence, we keep the state of the
8194 process so we know whether we need to force a state transition or
8195 can just expect one because something transient is happening.
8196 * init/job.c (job_new): Function to allocate a Job structure, set
8197 the pointers to NULL and other important members to sensible
8198 defaults.
8199 (job_init): Initialise the list of jobs.
8200 * init/tests/test_job.c: Test suite.
8201 * init/Makefile.am (init_SOURCES): Compile and link job.c using
8202 its header file.
8203 (TESTS): Run the job test suite.
8204 (test_job_SOURCES, test_job_LDFLAGS, test_job_LDADD): Details for the
8205 job test suite binary.
8206
Scott James Remnantb933bc92006-08-02 02:29:25 +010082072006-08-02 Scott James Remnant <scott@netsplit.com>
8208
Scott James Remnant6c7667a2006-08-02 02:43:12 +01008209 * configure.ac: Check for C99
8210
Scott James Remnantb933bc92006-08-02 02:29:25 +01008211 * HACKING: Document dependency on libnih.
8212
Scott James Remnanta780d6c2006-07-27 18:40:51 +010082132006-07-27 Scott James Remnant <scott@netsplit.com>
8214
8215 * init/Makefile.am (DEFS): Append to the default DEFS list, rather
8216 than overriding, otherwise we lose HAVE_CONFIG_H
8217
Scott James Remnantb6270dd2006-07-13 02:16:38 +010082182006-07-13 Scott James Remnant <scott@netsplit.com>
8219
Scott James Remnant1bb35142006-07-13 02:30:58 +01008220 * HACKING: Correct incorrect Bazaar URL.
8221
Scott James Remnantb6270dd2006-07-13 02:16:38 +01008222 * AUTHORS: Change e-mail address to ubuntu.com.
8223 * HACKING: Update Bazaar and Release URLS.
8224 * configure.ac (AC_COPYRIGHT): Change copyright to Canonical Ltd.
8225 (AC_INIT): Change bug submission address to Launchpad.
8226 * init/main.c: Update header to use Canonical copyright and
8227 credit me as author.
8228
Scott James Remnant50748842006-05-16 21:02:31 +010082292006-05-16 Scott James Remnant <scott@netsplit.com>
8230
8231 * init/main.c: Add the simplest template main.c
8232 * init/Makefile.am: Add template Makefile.am that builds init from
8233 main.c and links to libnih statically
8234 * configure.ac (AC_CONFIG_FILES): Configure nih and init subdirs.
8235 * Makefile.am (SUBDIRS): Recurse into nih and init subdirs.
8236
Scott James Remnant8a0cd072006-05-14 18:28:58 +010082372006-05-14 Scott James Remnant <scott@netsplit.com>
8238
8239 * ChangeLog: Initial project infrastructure created.