James Hunt has proposed merging lp:~jamesodhunt/upstart/bug-1120660 into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~jamesodhunt/upstart/bug-1120660/+merge/147712

  * init/log.c: log_serialise(): Handle re-exec scenario where
    jobs producing output have finished but where log data cannot
    be persisted (for example where disk is full or log directory
    is inaccessible). (LP: #1120660)

-- 
https://code.launchpad.net/~jamesodhunt/upstart/bug-1120660/+merge/147712
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~jamesodhunt/upstart/bug-1120660 into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2013-02-08 16:55:25 +0000
+++ ChangeLog	2013-02-11 16:56:27 +0000
@@ -1,3 +1,10 @@
+2013-02-11  James Hunt  <[email protected]>
+
+	* init/log.c: log_serialise(): Handle re-exec scenario where
+	  jobs producing output have finished but where log data cannot
+	  be persisted (for example where disk is full or log directory
+	  is inaccessible). (LP: #1120660)
+
 2013-02-08  James Hunt  <[email protected]>
 
 	* init/job_process.c: job_process_run(): Copy parent environment if

=== modified file 'init/log.c'
--- init/log.c	2013-01-21 16:24:48 +0000
+++ init/log.c	2013-02-11 16:56:27 +0000
@@ -854,14 +854,8 @@
 	if (! json)
 		return NULL;
 
-	if (! log || (! log->io && log->unflushed && ! log->unflushed->len)) {
-		/* Create a "placeholder" log object for non-existent
-		 * log objects and for those that are no longer usable.
-		 */
-		if (! state_set_json_string_var (json, "path", NULL))
-			goto error;
-		return json;
-	}
+	if (! log || (! log->io && log->unflushed && ! log->unflushed->len))
+		goto placeholder;
 
 	/* Attempt to flush any cached data */
 	if (log->unflushed && log->unflushed->len) {
@@ -874,7 +868,12 @@
 			(void)log_file_write (log, NULL, 0);
 	}
 
-	nih_assert (log->io);
+	/* Job associated with log has ended. If we failed to write
+	 * unflushed data above, it will now be lost as we cannot
+	 * create a valid serialisation without an associated NihIo.
+	 */
+	if (! log->io)
+		goto placeholder;
 
 	if (! state_set_json_int_var_from_obj (json, log, fd))
 		goto error;
@@ -918,6 +917,14 @@
 
 	return json;
 
+placeholder:
+	/* Create a "placeholder" log object for non-existent
+	 * log objects and for those that are no longer usable.
+	 */
+	if (! state_set_json_string_var (json, "path", NULL))
+		goto error;
+	return json;
+
 error:
 	json_object_put (json);
 	return NULL;

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to