Merge lp:~jamesodhunt/upstart/bug-1096531 into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1426
Proposed branch: lp:~jamesodhunt/upstart/bug-1096531
Merge into: lp:upstart
Diff against target: 70 lines (+36/-3)
2 files modified
ChangeLog (+16/-0)
init/log.c (+20/-3)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/bug-1096531
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Upstart Reviewers Pending
Review via email: mp+143314@code.launchpad.net

Description of the change

* init/log.c:
  - log_clear_unflushed(): Correct remote_closed assertion to handle
    early-job-logging scenario where a job satisfies both of the
    following conditions:
    - ends before the log directory becomes writeable.
    - has spawned one or more processes that continue to run after the
      job itself has exited and which produce output before the log
      directory becomes writeable.
    (LP: #1096531).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Your future self will probably thank you for separating the nih_assert (foo && bar) into two asserts, so that you can easily see which condition failed. Otherwise, looks good to me, thanks.

review: Approve
lp:~jamesodhunt/upstart/bug-1096531 updated
1426. By James Hunt

* init/log.c:log_clear_unflushed(): Simplify asserts.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Having just returned from the future (which is by the way awesome - even my toothbrush runs Ubuntu! :-), I see the wisdom of your words and have thus split that condition into two separate asserts.

Thanks for reviewing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-01-08 10:27:17 +0000
3+++ ChangeLog 2013-01-21 16:28:21 +0000
4@@ -1,3 +1,19 @@
5+2013-01-21 James Hunt <james.hunt@ubuntu.com>
6+
7+ * init/log.c:log_clear_unflushed(): Simplify asserts.
8+
9+2013-01-15 James Hunt <james.hunt@ubuntu.com>
10+
11+ * init/log.c:
12+ - log_clear_unflushed(): Correct remote_closed assertion to handle
13+ early-job-logging scenario where a job satisfies both of the
14+ following conditions:
15+ - ends before the log directory becomes writeable.
16+ - has spawned one or more processes that continue to run after the
17+ job itself has exited and which produce output before the log
18+ directory becomes writeable.
19+ (LP: #1096531).
20+
21 2013-01-04 Dmitrijs Ledkovs <xnox@ubuntu.com>
22
23 * init/conf.c: add ability to apply override files from higher
24
25=== modified file 'init/log.c'
26--- init/log.c 2012-12-07 21:38:17 +0000
27+++ init/log.c 2013-01-21 16:28:21 +0000
28@@ -793,6 +793,11 @@
29 elem = (NihListEntry *)iter;
30 log = elem->data;
31
32+ /* To be added to this list, log should have been
33+ * detached from its parent job.
34+ */
35+ nih_assert (log->detached);
36+
37 /* We expect 'an' error (as otherwise why would the log be
38 * in this list?), but don't assert EROFS specifically
39 * as a precaution (since an attempt to flush the log at
40@@ -800,9 +805,20 @@
41 */
42 nih_assert (log->open_errno);
43
44- nih_assert (log->unflushed->len);
45- nih_assert (log->remote_closed);
46- nih_assert (log->detached);
47+ if (log->remote_closed) {
48+ /* Parent job has ended and unflushed data
49+ * exists.
50+ */
51+ nih_assert (log->unflushed->len);
52+ nih_assert (! log->io);
53+ } else {
54+ /* Parent job itself has ended, but job spawned one or
55+ * more processes that are still running and
56+ * which might still produce output (the error
57+ * handler has therefore not been called).
58+ */
59+ nih_assert (log->io);
60+ }
61
62 if (log_file_open (log) != 0)
63 return -1;
64@@ -810,6 +826,7 @@
65 if (log_file_write (log, NULL, 0) < 0)
66 return -1;
67
68+ /* This will handle any remaining unflushed log data */
69 nih_free (log);
70 }
71

Subscribers

People subscribed via source and target branches